-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
feb6143
commit e0ff184
Showing
5 changed files
with
64 additions
and
14 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { forwardRef, Ref, RefAttributes } from 'react'; | ||
import Box, { BoxProps } from '../box'; | ||
import { ExtractElementFromTag } from '../core/coreTypes'; | ||
|
||
type SemanticComponentType<TTag extends keyof React.JSX.IntrinsicElements> = ( | ||
props: Omit<BoxProps<TTag>, 'ref' | 'tag'> & RefAttributes<ExtractElementFromTag<TTag>>, | ||
) => React.ReactNode; | ||
|
||
function semantic<TTag extends keyof React.JSX.IntrinsicElements>(tagName: TTag, p?: BoxProps<TTag>): SemanticComponentType<TTag> { | ||
return forwardRef((props: Omit<BoxProps<TTag>, 'ref' | 'tag'>, ref: Ref<ExtractElementFromTag<TTag>>) => ( | ||
<Box tag={tagName} ref={ref} component={tagName} {...p} {...props} /> | ||
)); | ||
} | ||
|
||
export const Label = semantic('label'); | ||
export const Article = semantic('article'); | ||
export const Aside = semantic('aside'); | ||
export const Details = semantic('details'); | ||
export const Figcaption = semantic('figcaption'); | ||
export const Figure = semantic('figure'); | ||
export const Footer = semantic('footer'); | ||
export const Header = semantic('header'); | ||
export const Main = semantic('main'); | ||
export const Mark = semantic('mark'); | ||
export const Nav = semantic('nav'); | ||
export const Menu = semantic('menu'); | ||
export const Section = semantic('section'); | ||
export const Summary = semantic('summary'); | ||
export const Time = semantic('time'); | ||
export const P = semantic('p'); | ||
export const H1 = semantic('h1', { fontSize: 14 * 2.5 }); | ||
export const H2 = semantic('h2', { fontSize: 14 * 2.0 }); | ||
export const H3 = semantic('h3', { fontSize: 14 * 1.75 }); | ||
export const H4 = semantic('h4', { fontSize: 14 * 1.5 }); | ||
export const H5 = semantic('h5', { fontSize: 14 * 1.25 }); | ||
export const H6 = semantic('h6', { fontSize: 14 * 1.0 }); | ||
export const Link = semantic('a'); | ||
export const Img = semantic('img'); |
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