-
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.
Implement some basic typography styling
- Loading branch information
Showing
16 changed files
with
215 additions
and
42 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,28 @@ | ||
import type { ElementType, ReactNode } from 'react'; | ||
import { Box } from './Box'; | ||
import * as typographyStyles from './typography.css'; | ||
|
||
type TextSize = keyof typeof typographyStyles.text; | ||
|
||
interface TextProps { | ||
component?: ElementType; | ||
children: ReactNode; | ||
size?: TextSize; | ||
} | ||
|
||
export const Text = ({ | ||
component: rawComponent, | ||
children, | ||
size = 'standard', | ||
}: TextProps) => { | ||
const component = rawComponent || 'span'; | ||
|
||
return ( | ||
<Box | ||
component={component} | ||
className={[typographyStyles.font, typographyStyles.text[size]]} | ||
> | ||
{children} | ||
</Box> | ||
); | ||
}; |
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,77 @@ | ||
import { createFontStack } from '@capsizecss/core'; | ||
import { createTextStyle } from '@capsizecss/vanilla-extract'; | ||
import openSansMetrics from '@capsizecss/metrics/openSans'; | ||
import arialMetrics from '@capsizecss/metrics/arial'; | ||
import { globalFontFace, style, styleVariants } from '@vanilla-extract/css'; | ||
|
||
const headingLevels = { | ||
1: { | ||
fontSize: 44, | ||
lineGap: 18, | ||
}, | ||
2: { | ||
fontSize: 38, | ||
lineGap: 16, | ||
}, | ||
3: { | ||
fontSize: 32, | ||
lineGap: 14, | ||
}, | ||
4: { | ||
fontSize: 24, | ||
lineGap: 12, | ||
}, | ||
}; | ||
|
||
export const heading = styleVariants( | ||
headingLevels, | ||
({ fontSize, lineGap }, level) => [ | ||
createTextStyle( | ||
{ | ||
fontSize, | ||
lineGap, | ||
fontMetrics: openSansMetrics, | ||
}, | ||
`heading_${level}`, | ||
), | ||
], | ||
); | ||
|
||
const textSizes = { | ||
large: { | ||
fontSize: 20, | ||
lineGap: 14, | ||
}, | ||
standard: { | ||
fontSize: 18, | ||
lineGap: 12, | ||
}, | ||
small: { | ||
fontSize: 16, | ||
lineGap: 12, | ||
}, | ||
}; | ||
|
||
export const text = styleVariants(textSizes, ({ fontSize, lineGap }, size) => [ | ||
createTextStyle( | ||
{ | ||
fontSize, | ||
lineGap, | ||
fontMetrics: openSansMetrics, | ||
}, | ||
`text_${size}`, | ||
), | ||
]); | ||
|
||
const { fontFamily, fontFaces } = createFontStack( | ||
[openSansMetrics, arialMetrics], | ||
{ | ||
fontFaceFormat: 'styleObject', | ||
}, | ||
); | ||
|
||
export const font = style({ fontFamily: `${fontFamily}, sans-serif` }); | ||
|
||
fontFaces.forEach((face) => | ||
globalFontFace(face['@font-face'].fontFamily, face['@font-face']), | ||
); |
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,2 +1,3 @@ | ||
export { Box } from './components/Box'; | ||
export { Heading } from './components/Heading'; | ||
export { Text } from './components/Text'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,13 @@ | ||
--- | ||
import { Box } from '@askoufis/system'; | ||
import { block } from './Block.css'; | ||
import type { ElementType } from 'react'; | ||
interface Props { | ||
component?: ElementType; | ||
} | ||
const { component = 'div' } = Astro.props; | ||
--- | ||
|
||
<Box component={component} className={block}><slot /></Box> |
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,3 @@ | ||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const block = style({ margin: '0 auto', paddingBottom: 20 }); |
Oops, something went wrong.