-
Notifications
You must be signed in to change notification settings - Fork 1
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
[FE] Typography component #78
Merged
wiktoriasalamon
merged 9 commits into
develop
from
75-feature-my-space---employee-pov---ladder
Jul 3, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2af694c
feat: add Typography component
wiktoriasalamon b3486b7
feat: add element type to Typography props
wiktoriasalamon 1a79fdc
linter
wiktoriasalamon b6370ff
refactor: use typography for all copies in the app
wiktoriasalamon 79df2cd
linter
wiktoriasalamon 2c9cf2d
Merge branch 'develop' into 75-feature-my-space---employee-pov---ladder
wiktoriasalamon 7d5fb0e
refactor
wiktoriasalamon baa728f
linter
wiktoriasalamon d60cb57
Merge branch 'develop' into 75-feature-my-space---employee-pov---ladder
wiktoriasalamon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import { Typography } from '@app/components/common/Typography'; | ||
|
||
export default function Documentation() { | ||
return ( | ||
<div> | ||
<h1 className="mb-10 text-lg font-semibold leading-6 text-navy-900">Documentation</h1> | ||
<Typography className="mb-10" variant="body-l/semibold" as="h1"> | ||
Documentation | ||
</Typography> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import { Typography } from '@app/components/common/Typography'; | ||
|
||
export default function MySpace() { | ||
return ( | ||
<div> | ||
<h1 className="mb-10 text-lg font-semibold leading-6 text-navy-900">My Space</h1> | ||
<Typography className="mb-10" variant="body-l/semibold" as="h1"> | ||
My Space | ||
</Typography> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { redirect } from 'next/navigation'; | ||
import { routes } from '@app/constants'; | ||
|
||
export default function Home() { | ||
return ( | ||
<div className="z-10 w-full max-w-5xl items-center justify-between font-mono text-sm lg:flex">We shall see</div> | ||
); | ||
redirect(routes.mySpace.index); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import { Typography } from '@app/components/common/Typography'; | ||
|
||
export default function People() { | ||
return ( | ||
<div> | ||
<h1 className="mb-10 text-lg font-semibold leading-6 text-navy-900">People</h1> | ||
<Typography className="mb-10" variant="body-l/semibold" as="h1"> | ||
People | ||
</Typography> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import Link from 'next/link'; | ||
import { LadderCardInterface } from './LadderCard.interface'; | ||
import { routes } from '@app/constants'; | ||
import { Typography } from '@app/components/common/Typography'; | ||
|
||
export const LadderCard = ({ ladderName, ladderSlug }: LadderCardInterface) => ( | ||
<Link | ||
href={`${routes.library.index}/${ladderSlug}`} | ||
className="flex h-44 cursor-pointer items-center justify-center rounded-2xl border border-navy-200 bg-white hover:bg-navy-100" | ||
> | ||
<h2 className="text-l text-navy-900">{ladderName}</h2> | ||
<Typography as="h2" variant="body-l/semibold"> | ||
{ladderName} | ||
</Typography> | ||
</Link> | ||
); |
46 changes: 46 additions & 0 deletions
46
frontend/src/components/common/Typography/Typography.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
export interface TypographyProps { | ||
variant?: TypographyVariants; | ||
as?: TextElement; | ||
className?: string; | ||
} | ||
|
||
export type TypographyVariants = | ||
| 'hint/caps-medium' | ||
| 'hint/regular' | ||
| 'hint/medium' | ||
| 'hint/semibold' | ||
| 'hint/bold' | ||
| 'body-s/regular' | ||
| 'body-s/medium' | ||
| 'body-s/semibold' | ||
| 'body-s/bold' | ||
| 'body-m/regular' | ||
| 'body-m/medium' | ||
| 'body-m/semibold' | ||
| 'body-m/bold' | ||
| 'body-l/regular' | ||
| 'body-l/medium' | ||
| 'body-l/semibold' | ||
| 'body-l/bold' | ||
| 'head-s/regular' | ||
| 'head-s/medium' | ||
| 'head-s/semibold' | ||
| 'head-s/bold' | ||
| 'head-m/regular' | ||
| 'head-m/medium' | ||
| 'head-m/semibold' | ||
| 'head-m/bold' | ||
| 'head-l/regular' | ||
| 'head-l/medium' | ||
| 'head-l/semibold' | ||
| 'head-l/bold' | ||
| 'head-xl/regular' | ||
| 'head-xl/medium' | ||
| 'head-xl/semibold' | ||
| 'head-xl/bold' | ||
| 'head-2xl/regular' | ||
| 'head-2xl/medium' | ||
| 'head-2xl/semibold' | ||
| 'head-2xl/bold'; | ||
|
||
export type TextElement = 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, { PropsWithChildren } from 'react'; | ||
import { TypographyProps, TypographyVariants } from '@app/components/common/Typography/Typography.interface'; | ||
import { generateClassNames } from '@app/utils'; | ||
|
||
const variantsStyles: { | ||
[key in TypographyVariants]: string; | ||
} = { | ||
'hint/caps-medium': 'text-xs tracking-widest uppercase font-medium', | ||
'hint/regular': 'text-xs tracking-wider font-normal', | ||
'hint/medium': 'text-xs font-medium', | ||
'hint/semibold': 'text-xs font-semibold', | ||
'hint/bold': 'text-xs font-bold', | ||
'body-s/regular': 'text-sm tracking-wide font-normal', | ||
'body-s/medium': 'text-sm tracking-wider font-medium', | ||
'body-s/semibold': 'text-sm tracking-wider font-semibold', | ||
'body-s/bold': 'text-sm tracking-wide font-bold', | ||
'body-m/regular': 'text-base tracking-wider font-normal', | ||
'body-m/medium': 'text-base font-medium', | ||
'body-m/semibold': 'text-base font-semibold', | ||
'body-m/bold': 'text-base font-bold', | ||
'body-l/regular': 'text-lg font-normal', | ||
'body-l/medium': 'text-lg font-medium', | ||
'body-l/semibold': 'text-lg font-semibold', | ||
'body-l/bold': 'text-xl font-bold', | ||
'head-s/regular': 'text-xl font-normal', | ||
'head-s/medium': 'text-xl font-medium', | ||
'head-s/semibold': 'text-xl font-semibold', | ||
'head-s/bold': 'text-xl font-bold', | ||
'head-m/regular': 'text-2xl font-normal', | ||
'head-m/medium': 'text-2xl font-medium', | ||
'head-m/semibold': 'text-2xl font-semibold', | ||
'head-m/bold': 'text-2xl font-bold', | ||
'head-l/regular': 'text-3xl font-normal', | ||
'head-l/medium': 'text-3xl font-medium', | ||
'head-l/semibold': 'text-3xl font-semibold', | ||
'head-l/bold': 'text-3xl font-bold', | ||
'head-xl/regular': 'text-4xl font-normal', | ||
'head-xl/medium': 'text-4xl font-medium', | ||
'head-xl/semibold': 'text-4xl font-semibold', | ||
'head-xl/bold': 'text-4xl font-bold', | ||
'head-2xl/regular': 'text-5xl font-normal', | ||
'head-2xl/medium': 'text-5xl font-medium', | ||
'head-2xl/semibold': 'text-5xl font-semibold', | ||
'head-2xl/bold': 'text-5xl font-bold', | ||
}; | ||
|
||
export const Typography = ({ | ||
variant = 'body-m/regular', | ||
as, | ||
className, | ||
children, | ||
}: PropsWithChildren<TypographyProps>) => { | ||
const classnames = generateClassNames('text-navy-900', variantsStyles[variant], className ?? ''); | ||
|
||
switch (as) { | ||
case 'h1': | ||
return <h1 className={classnames}>{children}</h1>; | ||
case 'h2': | ||
return <h2 className={classnames}>{children}</h2>; | ||
case 'h3': | ||
return <h3 className={classnames}>{children}</h3>; | ||
case 'h4': | ||
return <h4 className={classnames}>{children}</h4>; | ||
case 'h5': | ||
return <h5 className={classnames}>{children}</h5>; | ||
case 'h6': | ||
return <p className={classnames}>{children}</p>; | ||
case 'p': | ||
default: | ||
return <p className={classnames}>{children}</p>; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Typography } from './Typography'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was considering splitting variant and font weight to different parameters, but I decided to leave it this way to stay consistent with typography styles from Figma (I only shortened 'Heading' to 'head'). I think it would be easier to use while implementing new views:
For example:
Jane Edge has a style named "Headline M/Meddium", so for the Typography component we should use the
head-m/medium
variantThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I've split button styles into two separate props to reflect Figma. Your approach makes sense to me 👌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good ideas, let's go with that