Skip to content

Commit

Permalink
Merge pull request #423 from styled-system/typography-scoped
Browse files Browse the repository at this point in the history
Typography scoped option
  • Loading branch information
jxnblk committed Mar 12, 2019
2 parents 939d868 + 32d3976 commit fbf6c91
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/typography/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/typography/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@styled-system/typography",
"version": "1.0.0-4",
"version": "1.0.0-8",
"description": "Add typographic styles to child elements using styled-system and themes",
"main": "dist/index.js",
"scripts": {
Expand Down
6 changes: 6 additions & 0 deletions packages/typography/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ export const typographyStyles = compose(
export const typography = props => {
// handle emotion's Global and css props
const theme = props.theme || props
theme.typography = theme.typography || {}
const styles = {}
const scoped = theme.typography.scoped
const elements = pick(theme.typography, tagNames)
for (const key in elements) {
const el = elements[key]
const rules = typographyStyles({ theme, ...el })
// flatten & merge??
if (scoped && key === 'body') {
styles['&'] = [ el, ...rules ]
continue
}
styles[key] = [ el, ...rules ]
}

Expand Down
1 change: 1 addition & 0 deletions packages/typography/src/reset.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const reset = {
'pre code': {
fontSize: 'inherit',
color: 'inherit',
backgroundColor: 'inherit',
},
'li > p': {
fontSize: 'inherit',
Expand Down
4 changes: 4 additions & 0 deletions packages/typography/src/themes/modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ export const modern = {
lineHeight: 1.25,
},
pre: {
fontFamily: 'monospace',
p: [2, 3],
},
code: {
fontFamily: 'monospace',
}
}

export default modern

0 comments on commit fbf6c91

Please sign in to comment.