Comparing version 0.0.14 to 0.0.15
{ | ||
"name": "theme-ui", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"main": "dist/index.js", | ||
@@ -19,3 +19,2 @@ "module": "dist/index.esm.js", | ||
"@styled-system/css": "^2.0.2", | ||
"css-what": "^2.1.3", | ||
"emotion-theming": "^10.0.0", | ||
@@ -26,3 +25,3 @@ "lodash.get": "^4.4.0", | ||
"styled-system": "^4.0.0", | ||
"typography": "^0.16.0" | ||
"theme-ui-typography": "^0.0.15" | ||
}, | ||
@@ -37,4 +36,3 @@ "devDependencies": { | ||
"react-test-renderer": "^16.8.6", | ||
"react-testing-library": "^7.0.0", | ||
"typography-theme-wordpress-2016": "^0.16.19" | ||
"react-testing-library": "^7.0.0" | ||
}, | ||
@@ -55,3 +53,4 @@ "jest": { | ||
} | ||
} | ||
}, | ||
"gitHead": "822695c47385342cfaa971126e45b038bae162db" | ||
} |
@@ -1,55 +0,2 @@ | ||
// based on https://github.com/jxnblk/typography-mdx | ||
import Typography from 'typography' | ||
import merge from 'lodash.merge' | ||
import cssWhat from 'css-what' | ||
const isMedia = str => /^@/.test(str) | ||
const parseSelectors = styles => { | ||
const parsed = {} | ||
for (const key in styles) { | ||
// todo: handle media queries | ||
if (isMedia(key)) continue | ||
const selectors = key.split(',') //cssWhat(key) | ||
selectors.forEach(selector => { | ||
const [ parent, ...children ] = cssWhat(selector)[0] | ||
if (parent.type === 'universal') return | ||
if (parent.type !== 'tag') { | ||
// todo... | ||
// console.log('!TAG', selector, parent.type) | ||
return | ||
} | ||
if (children.length) { | ||
const sub = selector.replace(parent.name, '&') | ||
parsed[parent.name] = merge({}, parsed[parent.name], { | ||
[sub]: styles[key] | ||
}) | ||
} else { | ||
parsed[parent.name] = merge({}, parsed[parent.name], styles[key]) | ||
} | ||
}) | ||
} | ||
for (const key in parsed) { | ||
if (key === 'html' || key === 'body') { | ||
// todo: what should this be named? | ||
parsed.root = merge({}, parsed.root, parsed[key]) | ||
} | ||
} | ||
return parsed | ||
} | ||
export const toStyles = (theme) => { | ||
const typography = new Typography({ | ||
...theme, | ||
rhythmUnit: 'px', | ||
includeNormalize: false, | ||
}) | ||
const json = typography.toJSON() | ||
const styles = parseSelectors(json) | ||
typography.styles = styles | ||
return typography | ||
} | ||
export default toStyles | ||
// for backwards compatibility | ||
module.exports = require('theme-ui-typography') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10
8
78997
1191
+ Addedtheme-ui-typography@^0.0.15
+ Addedmodularscale@2.0.1(transitive)
+ Addedtheme-ui-typography@0.0.15(transitive)
- Removedcss-what@^2.1.3
- Removedtypography@^0.16.0