Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
feat: added author card to strats page
Browse files Browse the repository at this point in the history
  • Loading branch information
cecilia-sanare committed Nov 11, 2022
1 parent d5b60c1 commit 071d29f
Show file tree
Hide file tree
Showing 17 changed files with 470 additions and 12 deletions.
21 changes: 21 additions & 0 deletions __tests__/mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Author } from '../src/types/author';
import { Strat } from '../src/types/strat';

export function mockStrat(overrides?: Partial<Strat>): Strat {
return {
id: '1234',
name: 'Strats for Stratty things!',
author: mockAuthor(),
...overrides
};
}

export function mockAuthor(overrides?: Partial<Author>): Author {
return {
uid: 'marcy',
name: 'Marcy',
image: 'https://avatars.githubusercontent.com/u/9692284?v=4',
pronouns: ['she/her', 'they/them'],
...overrides
};
}
22 changes: 22 additions & 0 deletions __tests__/prebuilts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { mockAuthor } from './mocks';

export const authors = {
ceci: mockAuthor({
uid: 'ceci',
name: 'Ceci',
image: 'https://avatars.githubusercontent.com/u/9692284?v=4',
pronouns: ['she/hers', 'they/them']
}),
clover: mockAuthor({
uid: 'clover',
name: 'Clover',
image: 'https://i.imgur.com/WKXMkzY.png',
pronouns: ['she/her', 'they/them', 'he/him']
}),
mumu: mockAuthor({
uid: 'mumu',
name: 'Mumu',
image: 'https://i.imgur.com/I4bUHxt.png',
pronouns: ['they/them']
})
}
6 changes: 5 additions & 1 deletion next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
*/
const nextConfig = {
images: {
domains: ['cdn.discordapp.com']
domains: [
'cdn.discordapp.com',
'avatars.githubusercontent.com',
'i.imgur.com'
]
}
};

Expand Down
231 changes: 231 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/components/common/Avatar.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.avatar {
position: relative;
border-radius: 50%;
overflow: hidden;
aspect-ratio: 1/1;
min-width: 40px;
user-select: none;
}
12 changes: 6 additions & 6 deletions src/components/common/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export function Avatar({
src
}: AvatarProps): JSX.Element {
return (
<Image
className={styles.avatar}
width={40}
height={40}
src={src}
/>
<div className={styles.avatar}>
<Image
layout='fill'
src={src}
/>
</div>
)
}
30 changes: 30 additions & 0 deletions src/components/common/Pronouns.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { useReadOnlyCachedState } from '../hooks/use-cached-state';
import styles from './Avatar.module.scss';

export type PronounsProps = {
pronouns: string[];
}

export function Pronouns({
pronouns: externalPronouns
}: PronounsProps): JSX.Element {
const pronouns = useReadOnlyCachedState(() => {
let formattedPronouns: string[];
if (externalPronouns.length === 1) {
formattedPronouns = externalPronouns[0].split('/');
} else {
formattedPronouns = externalPronouns.reduce((output, pronoun) => {
output.push(pronoun.split('/')[0])
return output;
}, []);
}

return formattedPronouns.join(' / ');
}, [externalPronouns]);

return (
<div className={styles.pronouns}>
{pronouns}
</div>
)
}
9 changes: 9 additions & 0 deletions src/components/common/Typography.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.typography {
line-height: 1;
}

.h1 {
font-weight: normal;
margin: 0;
font-size: 50px;
}
Loading

0 comments on commit 071d29f

Please sign in to comment.