Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pronoun support #43

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added pronoun support
  • Loading branch information
F-iiral committed Nov 23, 2023
commit 2aadec5b71916255088cb5ba9ffee17a3830e6a6
2 changes: 2 additions & 0 deletions src/chat-api/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export interface UserDetails {
}
export interface UserProfile {
bio?: string;
pronouns?: string;
}

export async function getUserDetailsRequest(userId?: string) {
Expand Down Expand Up @@ -198,6 +199,7 @@ interface UpdateUserOptions {
password?: string;
newPassword?: string;
bio?: string | null;
pronouns?: string | null;
socketId?: string;
dmStatus?: number;
}
Expand Down
5 changes: 5 additions & 0 deletions src/components/profile-pane/ProfilePane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,11 @@ export default function ProfilePane() {
<span class={styles.username}>{user()!.username}</span>
<span class={styles.tag}>{`:${user()!.tag}`}</span>
</div>
<div>
<span class={styles.pronouns}>
{userDetails()?.profile.pronouns ? userDetails().profile.pronouns : 'Rather not say'}
</span>
</div>
<UserPresence
hideActivity
animate
Expand Down
5 changes: 5 additions & 0 deletions src/components/profile-pane/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
color: rgba(255, 255, 255, 0.6);
}

.pronouns {
color: rgba(255, 255, 255, 0.6);
font-size: 12px;
}

.bannerFloatingItems {
position: absolute;
display: flex;
Expand Down
47 changes: 45 additions & 2 deletions src/components/settings/AccountSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,25 @@ const bioBlockStyles = css`
}
`;

const pronounBlockStyles = css`
&& {
height: initial;
min-height: initial;
align-items: start;
flex-direction: column;
flex: 0;
padding-top: 15px;
align-items: stretch;
}
.inputContainer {
margin-left: 35px;
margin-top: 5px;
}
textarea {
height: 100px;
}
`

function EditProfilePage() {
const { account } = useStore();
const [userDetails, setUserDetails] = createSignal<UserDetails | null>(null);
Expand All @@ -348,6 +367,7 @@ function EditProfilePage() {

const defaultInput = () => ({
bio: userDetails()?.profile?.bio || '',
pronouns: userDetails()?.profile?.pronouns || '',
})

const [inputValues, updatedInputValues, setInputValue] = createUpdatedSignal(defaultInput);
Expand All @@ -365,10 +385,19 @@ function EditProfilePage() {
setError(null);
const values = updatedInputValues();
await updateUser({
bio: values.bio?.trim() || null
bio: values.bio?.trim() || null,
pronouns: values.pronouns?.trim() || null
})
.then(() => {
setUserDetails(() => ({ ...userDetails()!, profile: { bio: values.bio } }))
setUserDetails(() => (
{
...userDetails()!,
profile: {
bio: values.bio,
pronouns: values.pronouns
}
}
))
})
.catch(err => {
setError(err.message)
Expand All @@ -382,6 +411,20 @@ function EditProfilePage() {
<Text size={12} style={{ "margin-left": "38px", "margin-top": "5px" }}>({inputValues().bio.length} / 1000)</Text>
<Input class='inputContainer' type='textarea' value={inputValues().bio} onText={(v) => setInputValue('bio', v)} />
</SettingsBlock>

<SettingsBlock icon='face' label='Pronouns' class={pronounBlockStyles} description='Either select or use a custom one'>
<Text size={12} style={{ "margin-left": "38px", "margin-top": "5px" }}></Text>
<div style={{ "margin-left": "38px", "display": 'flex' }}>
<Button label="he/him" onClick={() => setInputValue('pronouns', 'he/him')} />
<Button label="she/her" onClick={() => setInputValue('pronouns', 'she/her')} />
<Button label="they/them" onClick={() => setInputValue('pronouns', 'they/them')} />
<Button label="Rather not say" onClick={() => setInputValue('pronouns', 'Rather not say')} />
</div>
<a></a>
<Text size={12} style={{ "margin-left": "38px", "margin-top": "5px" }}>({inputValues().pronouns.length} / 16)</Text>
<Input class='inputContainer' type='textarea' value={inputValues().pronouns} onText={(v) => setInputValue('pronouns', v)} />
</SettingsBlock>

<Show when={error()}><Text size={12} color="var(--alert-color)" style={{ "margin-top": "5px" }}>{error()}</Text></Show>
<Show when={Object.keys(updatedInputValues()).length}>
<Button iconName='save' label={requestStatus()} class={css`align-self: flex-end;`} onClick={onSaveButtonClicked} />
Expand Down