-
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
Changes from 6 commits
2af694c
b3486b7
1a79fdc
b6370ff
79df2cd
2c9cf2d
7d5fb0e
baa728f
d60cb57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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> | ||
); | ||
} |
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> | ||
); | ||
} |
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); | ||
} |
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> | ||
); | ||
} |
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> | ||
); |
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 = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Good ideas, let's go with that |
||
| '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'; |
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>; | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Typography } from './Typography'; |
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.
maybe something like that: