-
Notifications
You must be signed in to change notification settings - Fork 673
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #807 from beerose/feat/style-guide-ts
feat(@theme-ui/style-guide): convert to typescript
- Loading branch information
Showing
17 changed files
with
158 additions
and
97 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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** @jsx jsx */ | ||
import { ComponentProps } from 'react' | ||
import { jsx } from 'theme-ui' | ||
|
||
export interface CardProps extends ComponentProps<'div'> {} | ||
export const Card: React.FC<CardProps> = props => ( | ||
<div | ||
{...props} | ||
sx={{ | ||
variant: 'styles.Card', | ||
}} | ||
/> | ||
) | ||
|
||
export default Card |
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
17 changes: 12 additions & 5 deletions
17
packages/style-guide/src/ColorSwatch.js → packages/style-guide/src/ColorSwatch.tsx
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { get } from 'theme-ui' | ||
import { useTheme } from './context' | ||
|
||
export const FontFamily = ({ name }: { name: string }) => { | ||
const { fonts } = useTheme()! | ||
return get(fonts!, name) | ||
} |
4 changes: 2 additions & 2 deletions
4
packages/style-guide/src/HeadingStyle.js → packages/style-guide/src/HeadingStyle.tsx
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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** @jsx jsx */ | ||
import { jsx } from 'theme-ui' | ||
import { useTheme } from './context' | ||
import TypeStyle from './TypeStyle' | ||
|
||
const getValue = (fontSize: string | number) => | ||
typeof fontSize === 'number' ? `${fontSize}px` : fontSize | ||
|
||
export interface TypeScaleProps { | ||
reverse?: boolean | ||
} | ||
export const TypeScale = ({ reverse = true, ...props }) => { | ||
const theme = useTheme() || {} | ||
const fontSizeEntries = reverse | ||
? Object.entries(theme.fontSizes || []).reverse() | ||
: Object.entries(theme.fontSizes || []) | ||
|
||
return ( | ||
<div | ||
sx={{ | ||
display: 'flex', | ||
flexWrap: 'wrap', | ||
alignItems: 'baseline', | ||
}}> | ||
{fontSizeEntries.map(([key, val]) => { | ||
if (typeof val === 'object') { | ||
// TODO: can theme.fontSizes be a deeply nested object? | ||
// This wasn't handled previously | ||
// We should either update the types or recursively render here. | ||
return null | ||
} | ||
|
||
return ( | ||
<TypeStyle | ||
key={key} | ||
fontSize={key} | ||
sx={{ | ||
mr: 3, | ||
}} | ||
children={getValue(val)} | ||
{...props} | ||
/> | ||
) | ||
})} | ||
</div> | ||
) | ||
} | ||
|
||
export default TypeScale |
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
File renamed without changes.
File renamed without changes.
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,7 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"jsx": "react" | ||
}, | ||
"include": ["src"] | ||
} |
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 |
---|---|---|
|
@@ -3921,11 +3921,25 @@ | |
dependencies: | ||
"@types/node" "*" | ||
|
||
"@types/color-name@^1.1.1": | ||
"@types/color-convert@*": | ||
version "1.9.0" | ||
resolved "https://registry.yarnpkg.com/@types/color-convert/-/color-convert-1.9.0.tgz#bfa8203e41e7c65471e9841d7e306a7cd8b5172d" | ||
integrity sha512-OKGEfULrvSL2VRbkl/gnjjgbbF7ycIlpSsX7Nkab4MOWi5XxmgBYvuiQ7lcCFY5cPDz7MUNaKgxte2VRmtr4Fg== | ||
dependencies: | ||
"@types/color-name" "*" | ||
|
||
"@types/color-name@*", "@types/color-name@^1.1.1": | ||
version "1.1.1" | ||
resolved "https://registry.yarnpkg.com/@types/color-name/-/color-name-1.1.1.tgz#1c1261bbeaa10a8055bbc5d8ab84b7b2afc846a0" | ||
integrity sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ== | ||
|
||
"@types/[email protected]": | ||
version "3.0.1" | ||
resolved "https://registry.yarnpkg.com/@types/color/-/color-3.0.1.tgz#2900490ed04da8116c5058cd5dba3572d5a25071" | ||
integrity sha512-oeUWVaAwI+xINDUx+3F2vJkl/vVB03VChFF/Gl3iQCdbcakjuoJyMOba+3BXRtnBhxZ7uBYqQBi9EpLnvSoztA== | ||
dependencies: | ||
"@types/color-convert" "*" | ||
|
||
"@types/configstore@^2.1.1": | ||
version "2.1.1" | ||
resolved "https://registry.yarnpkg.com/@types/configstore/-/configstore-2.1.1.tgz#cd1e8553633ad3185c3f2f239ecff5d2643e92b6" | ||
|