Skip to content

Commit c6e7e53

Browse files
committed
Edit docs
1 parent beb1772 commit c6e7e53

File tree

7 files changed

+57
-64
lines changed

7 files changed

+57
-64
lines changed

packages/components/src/Input.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const Input = React.forwardRef((props, ref) => (
1818
border: '1px solid',
1919
borderRadius: 4,
2020
color: 'inherit',
21-
bg: 'background',
21+
bg: 'transparent',
2222
}}
2323
/>
2424
))

packages/components/src/Textarea.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const Textarea = React.forwardRef((props, ref) => (
1818
border: '1px solid',
1919
borderRadius: 4,
2020
color: 'inherit',
21-
bg: 'background',
21+
bg: 'transparent',
2222
}}
2323
/>
2424
))

packages/docs/src/pages/customize.js

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,13 @@ import Button from '../components/button'
2222
const reducer = (state, next) => merge({}, state, next)
2323

2424
export default props => {
25-
// TODO
26-
// const [ theme, setTheme ] = useReducer(reducer, {...presets.base})
27-
// const context = { theme, setTheme, }
28-
// const json = stringify(context.theme, { indent: ' ' })
25+
const [theme, setTheme] = useReducer(reducer, { ...presets.base })
26+
const json = stringify(theme, { indent: ' ' })
2927

3028
return (
3129
<div>
32-
<Styled.h1>
33-
Create a Custom Theme
34-
</Styled.h1>
35-
<EditorProvider theme={presets.base}>
30+
<Styled.h1>Create a Custom Theme</Styled.h1>
31+
<EditorProvider theme={theme}>
3632
<b>Colors</b>
3733
<Theme.Colors size={64} />
3834
<div
@@ -45,48 +41,47 @@ export default props => {
4541
bg: 'background',
4642
}}>
4743
<TypeStyle
48-
fontFamily='heading'
49-
lineHeight='heading'
50-
fontWeight='heading'
51-
fontSize={[ 5, 6 ]}>
52-
Aa <FontFamily name='heading' />
44+
fontFamily="heading"
45+
lineHeight="heading"
46+
fontWeight="heading"
47+
fontSize={[5, 6]}>
48+
Aa <FontFamily name="heading" />
5349
</TypeStyle>
5450
<TypeStyle fontSize={3}>
55-
Aa <FontFamily name='body' />
51+
Aa <FontFamily name="body" />
5652
</TypeStyle>
5753
</div>
58-
<Theme.Fonts />
54+
<Grid columns={3}>
55+
<Theme.Fonts />
56+
</Grid>
5957
<div sx={{ my: 2 }}>
6058
<b>Font Sizes</b>
61-
<Grid>
59+
<Grid columns={9}>
6260
<Theme.FontSizes />
6361
</Grid>
6462
</div>
6563
<div sx={{ my: 2 }}>
6664
<div>
6765
<b>Font Weights</b>
68-
<Grid>
66+
<Grid columns={3}>
6967
<Theme.FontWeights />
7068
</Grid>
7169
</div>
7270
<div>
7371
<b>Line Heights</b>
74-
<Grid>
72+
<Grid columns={3}>
7573
<Theme.LineHeights />
7674
</Grid>
7775
</div>
7876
</div>
7977
<div sx={{ my: 2 }}>
8078
<b>Space</b>
81-
<Grid>
79+
<Grid columns={9}>
8280
<Theme.Space />
8381
</Grid>
8482
</div>
85-
<p>
86-
Note: some web fonts may not render unless installed locally.
87-
</p>
83+
<p>Note: some web fonts may not render unless installed locally.</p>
8884
</EditorProvider>
89-
{/* TODO
9085
<Button
9186
onClick={e => {
9287
copy(json)
@@ -100,7 +95,6 @@ export default props => {
10095
overflowY: 'auto',
10196
}}
10297
/>
103-
*/}
10498
</div>
10599
)
106100
}

packages/docs/src/pages/guides/global-styles.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import Note from '../../components/note'
88

99
Use the Emotion `Global` component to add global CSS with theme-based values.
1010

11+
By default, the `ThemeProvider` component will apply styles in `theme.styles.root` to the `<body>` element.
12+
It will also apply `color` and `background-color` styles based on `theme.colors.text` and `theme.colors.background` respectively.
13+
1114
<Note>
1215
Generally, you should try to avoid adding CSS to global scope.
1316
Many styles can be safely encapsulated into a component without the need for global styles.
@@ -20,9 +23,8 @@ import { Global } from '@emotion/core'
2023
export default props =>
2124
<Global
2225
styles={theme => ({
23-
body: {
24-
color: theme.colors.text,
25-
backgroundColor: theme.colors.background,
26+
*: {
27+
boxSizing: 'border-box',
2628
}
2729
})}
2830
/>

packages/docs/src/pages/guides/motivation.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ For many, the choice between using object literal syntax for styles versus tagge
4646
The `theme` object itself is an object, and keeping styles in a similar format helps reduce the API surface area.
4747
Using and parsing strings that represent embedded DSLs introduces overhead when mapping over key-value pairs.
4848
Theme UI avoids this overhead for reasons related to performance, testing, and overall bundle size.
49-
For some of the [same reasons](https://facebook.github.io/jsx/) that React itself uses JSX (i.e. function calls) instead of tagged template literals, Theme UI only included support for authoring CSS with object literal syntax.
49+
For some of the [same reasons](https://facebook.github.io/jsx/) that React itself uses JSX (i.e. function calls) instead of tagged template literals, Theme UI only includes support for authoring CSS with object literal syntax.
5050
Additionally, using native JavaScript types has many other benefits that are outside of the scope of this document.
5151

5252
## Why Emotion

packages/docs/src/pages/styled.mdx

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -43,39 +43,9 @@ This can also be used to style components like the Gatsby `Link` component to ma
4343
</Styled.a>
4444
```
4545

46-
## `Styled.root`
46+
## Body Styles
4747

48-
By default, Theme UI does _not_ apply any global styles for typography.
49-
To apply top-level typographic styles, the `Styled.root` component can be used to wrap any page layout or MDX document.
50-
By adding styles to `theme.styles.root`, this component will apply any base styles that you define.
48+
To add base typographic styles to the `<body>` element, add styles to `theme.styles.root`.
49+
Previous versions of Theme UI used the `Styled.root` component.
50+
See the [theming docs](/theming/#body-styles) for more information.
5151

52-
```js
53-
// example theme.js
54-
export default {
55-
fonts: {
56-
body: 'system-ui, sans-serif',
57-
monospace: 'Menlo, monospace',
58-
},
59-
fontWeights: {
60-
body: 400,
61-
heading: 700,
62-
},
63-
lineHeights: {
64-
body: 1.5,
65-
heading: 1.125,
66-
},
67-
styles: {
68-
root: {
69-
fontFamily: 'body',
70-
fontWeight: 'body',
71-
lineHeight: 'body',
72-
},
73-
},
74-
}
75-
```
76-
77-
```jsx
78-
<Styled.root>
79-
<MyMDXDocument />
80-
</Styled.root>
81-
```

packages/docs/src/pages/theming.mdx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,33 @@ Styles within this object have access to other values in the theme object, such
121121
}
122122
```
123123

124+
## Body Styles
125+
126+
To add base, top-level styles to the `<body>` element, use `theme.styles.root`.
127+
128+
```js
129+
// example with root styles
130+
{
131+
fonts: {
132+
body: 'system-ui, sans-serif',
133+
heading: 'Georgia, serif',
134+
},
135+
fontWeights: {
136+
body: 400,
137+
heading: 700,
138+
},
139+
styles: {
140+
root: {
141+
// uses the theme values provided above
142+
fontFamily: 'body',
143+
fontWeight: 'body',
144+
},
145+
},
146+
}
147+
```
148+
149+
To disable applying styles to the `<body>` element, add the `useBodyStyles: false` flag to your theme.
150+
124151
## Breakpoints
125152

126153
To configure the default breakpoints used in responsive array values, add a `breakpoints` array to your theme.

0 commit comments

Comments
 (0)