Skip to content
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

Typography (WIP) #3

Open
wants to merge 3 commits into
base: theme-ui-update
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { ThemeProvider } from 'theme-ui'

import theme from "../src/themes/theme"
import Global from '../src/components/Global'

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
Expand All @@ -16,6 +17,7 @@ export const parameters = {
export const decorators = [
(Story) => (
<ThemeProvider theme={theme}>
<Global />
<Story />
</ThemeProvider>
),
Expand Down
Binary file added public/fonts/noe-display/NoeDisplay-Medium.eot
Binary file not shown.
Binary file added public/fonts/noe-display/NoeDisplay-Medium.otf
Binary file not shown.
11,422 changes: 11,422 additions & 0 deletions public/fonts/noe-display/NoeDisplay-Medium.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/fonts/noe-display/NoeDisplay-Medium.ttf
Binary file not shown.
Binary file added public/fonts/noe-display/NoeDisplay-Medium.woff
Binary file not shown.
Binary file added public/fonts/noe-display/NoeDisplay-Medium.woff2
Binary file not shown.
Binary file not shown.
Binary file not shown.
13,526 changes: 13,526 additions & 0 deletions public/fonts/noe-display/noe-display-bold-italic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added public/fonts/noe-display/noe-display-bold.eot
Binary file not shown.
Binary file added public/fonts/noe-display/noe-display-bold.otf
Binary file not shown.
11,980 changes: 11,980 additions & 0 deletions public/fonts/noe-display/noe-display-bold.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/fonts/noe-display/noe-display-bold.ttf
Binary file not shown.
Binary file added public/fonts/noe-display/noe-display-bold.woff
Binary file not shown.
Binary file added public/fonts/noe-display/noe-display-bold.woff2
Binary file not shown.
24 changes: 24 additions & 0 deletions src/components/Global.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/** @jsxImportSource theme-ui */
import { ReactChild } from 'react'
import { Global as _Global, css } from '@emotion/react'

import { NoeDisplay, SourceCodePro } from '../css/fonts.js'

interface GlobalProps {
styles: any
}
const fonts = css`
${NoeDisplay};
${SourceCodePro};
`

const Global = ({ styles }: GlobalProps) => {
const globalStyles = css`
${fonts};
${styles};
`

return <_Global {...globalStyles} />
}

export default Global
22 changes: 16 additions & 6 deletions src/components/Text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@
import { ReactChild } from 'react'
import { Text as _Text, useThemeUI, get } from 'theme-ui'

// TODO: Import Typography props as well? Or merge sx object?
// I can't find any type definitions for sx or "Theme-Aware Properties"
// Is there a good way to pass down arbitrary style values?
interface TextProps {
size?: "sm" | "md" | "lg",
children: ReactChild
kind?: "nav1" | "nav1b" | "nav2" | "body2" | "error1" | "technical1" | "h1" | "h3",
capitalize?: boolean,
children: ReactChild | string | undefined
}

const Text = ({ size = "md", children }: TextProps) => {
const Text = ({ kind = "body2", children, capitalize }: TextProps) => {
const context = useThemeUI()
const styles = get(context.theme, `text.${size}`)
const kinds = get(context.theme, `text.${kind}`)

return <_Text sx={styles}>{ children }</_Text>
const sx = {
...kinds
}

if (capitalize) {
sx.textTransform = "capitalize"
}

return <_Text sx={{ ...sx }}>{ children }</_Text>
}

export default Text
Expand Down
Loading