Skip to content

Commit a5b1d1a

Browse files
committed
Improve RelationshipStatus icon
1 parent ef7665c commit a5b1d1a

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed

web/components/filters/choices.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import {invert} from "lodash";
2+
import {FaHeart, FaUsers} from "react-icons/fa";
3+
import {FiUser} from "react-icons/fi";
4+
import {GiRing} from "react-icons/gi";
25

36
export const RELATIONSHIP_CHOICES = {
47
// Other: 'other',
@@ -8,13 +11,21 @@ export const RELATIONSHIP_CHOICES = {
811
};
912

1013
export const RELATIONSHIP_STATUS_CHOICES = {
11-
Single: 'single',
12-
Married: 'married',
13-
'Casual': 'casual',
14-
'Long-term': 'long_term',
15-
'Open': 'open',
14+
'Single': 'single',
15+
'Married': 'married',
16+
'In casual relationship': 'casual',
17+
'In long-term relationship': 'long_term',
18+
'In open relationship': 'open',
1619
};
1720

21+
export const RELATIONSHIP_ICONS = {
22+
single: FiUser,
23+
married: GiRing,
24+
casual: FaHeart,
25+
long_term: FaHeart,
26+
open: FaUsers,
27+
} as const;
28+
1829
export const ROMANTIC_CHOICES = {
1930
Monogamous: 'mono',
2031
Polyamorous: 'poly',
@@ -74,7 +85,7 @@ export const RELIGION_CHOICES = {
7485
'Other': 'other',
7586
}
7687

77-
export const LANGUAGE_CHOICES = {
88+
export const LANGUAGE_CHOICES = {
7889
'Akan': 'akan',
7990
'Amharic': 'amharic',
8091
'Arabic': 'arabic',

web/components/profile-about.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import clsx from 'clsx'
22
import {convertRace, convertRelationshipType, type RelationshipType,} from 'web/lib/util/convert-types'
33
import stringOrStringArrayToText from 'web/lib/util/string-or-string-array-to-text'
4-
import {ReactNode} from 'react'
4+
import React, {ReactNode} from 'react'
55
import {
66
INVERTED_DIET_CHOICES,
77
INVERTED_EDUCATION_CHOICES,
@@ -10,7 +10,8 @@ import {
1010
INVERTED_POLITICAL_CHOICES,
1111
INVERTED_RELATIONSHIP_STATUS_CHOICES,
1212
INVERTED_RELIGION_CHOICES,
13-
INVERTED_ROMANTIC_CHOICES
13+
INVERTED_ROMANTIC_CHOICES,
14+
RELATIONSHIP_ICONS
1415
} from 'web/components/filters/choices'
1516
import {BiSolidDrink} from 'react-icons/bi'
1617
import {BsPersonHeart, BsPersonVcard} from 'react-icons/bs'
@@ -30,7 +31,7 @@ import {UserActivity} from "common/user";
3031
import {ClockIcon} from "@heroicons/react/solid";
3132
import {MAX_INT, MIN_INT} from "common/constants";
3233
import {GiFruitBowl} from "react-icons/gi";
33-
import {FaBriefcase, FaHandsHelping, FaStar} from "react-icons/fa";
34+
import {FaBriefcase, FaHandsHelping, FaHeart, FaStar} from "react-icons/fa";
3435

3536
export function AboutRow(props: {
3637
icon: ReactNode
@@ -79,10 +80,7 @@ export default function ProfileAbout(props: {
7980
>
8081
<Seeking profile={profile}/>
8182
<RelationshipType profile={profile}/>
82-
<AboutRow
83-
icon={<BsPersonHeart className="h-5 w-5"/>}
84-
text={profile.relationship_status?.map(v => INVERTED_RELATIONSHIP_STATUS_CHOICES[v])}
85-
/>
83+
<RelationshipStatus profile={profile}/>
8684
<Education profile={profile}/>
8785
<Occupation profile={profile}/>
8886
<AboutRow
@@ -207,6 +205,20 @@ function RelationshipType(props: { profile: Profile }) {
207205
)
208206
}
209207

208+
function RelationshipStatus(props: { profile: Profile }) {
209+
const {profile} = props
210+
const relationship_status = profile.relationship_status ?? []
211+
if (relationship_status.length === 0) return
212+
const key = relationship_status[0] as keyof typeof RELATIONSHIP_ICONS
213+
const icon = RELATIONSHIP_ICONS[key] ?? FaHeart
214+
return (
215+
<AboutRow
216+
icon={icon ? React.createElement(icon, {className: 'h-5 w-5'}) : null}
217+
text={relationship_status?.map(v => INVERTED_RELATIONSHIP_STATUS_CHOICES[v])}
218+
/>
219+
)
220+
}
221+
210222
function Education(props: { profile: Profile }) {
211223
const {profile} = props
212224
const educationLevel = profile.education_level

0 commit comments

Comments
 (0)