Skip to content

Commit

Permalink
switch back to style-system v3, until v4 changes the format back
Browse files Browse the repository at this point in the history
  • Loading branch information
kof committed Apr 30, 2019
1 parent c98e9c1 commit 18c9a62
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 65 deletions.
2 changes: 1 addition & 1 deletion packages/react-jss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
},
"devDependencies": {
"@types/react": "^16.7.20",
"styled-system": "^4.1.0"
"styled-system": "3"
}
}
52 changes: 16 additions & 36 deletions packages/react-jss/tests/styledSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TestRenderer from 'react-test-renderer'
import {stripIndent} from 'common-tags'
import {space, width, color, fontSize, fontWeight, lineHeight, compose} from 'styled-system'

import withStyles, {styled, SheetsRegistry, JssProvider, ThemeProvider, jss} from '../src'
import withStyles, {styled, SheetsRegistry, JssProvider, ThemeProvider} from '../src'

const createGenerateId = () => {
let counter = 0
Expand All @@ -34,27 +34,6 @@ const theme = {
}
}

const transform = stylesArr => {
const transformed = {}
for (let i = 0; i < stylesArr.length; i++) {
const objOrArr = stylesArr[i]
const block = Array.isArray(objOrArr) ? transform(objOrArr) : objOrArr
for (const key in block) {
if (key in transformed) Object.assign(transformed[key], block[key])
else transformed[key] = block[key]
}
}
return transformed
}

// Should this be part of the core???
// - It needs to run before any other plugins run
// - If this ensures interoperability with SC/emotion to some extent, it's a great thing
jss.plugins.registry.onProcessStyle.unshift(style => {
if (!Array.isArray(style)) return style
return transform(style)
})

describe.only('React-JSS: styled-system', () => {
it('should reder basic spacing', () => {
const registry = new SheetsRegistry()
Expand Down Expand Up @@ -141,7 +120,7 @@ describe.only('React-JSS: styled-system', () => {
it('should render a number of composed style rules with withStyles API', () => {
const registry = new SheetsRegistry()
const styles = {
css: compose(
root: compose(
space,
color,
fontSize,
Expand All @@ -151,23 +130,21 @@ describe.only('React-JSS: styled-system', () => {
)
}

const MyComponent = ({classes}) => <div className={classes.css} />
const MyComponent = ({classes}) => <div className={classes.root} />

const MyStyledComponent = withStyles(styles, {injectTheme: true})(MyComponent)

const renderer = TestRenderer.create(
<JssProvider registry={registry} generateId={createGenerateId()}>
<ThemeProvider theme={theme}>
<MyStyledComponent
px={[3, 4]}
py={[1, 2]}
color="white"
bg="blue"
fontSize={[4, 5, 6]}
fontWeight="bold"
/>
</ThemeProvider>
</JssProvider>
<ThemeProvider theme={theme}>
<MyStyledComponent
px={[3, 4]}
py={[1, 2]}
color="white"
bg="blue"
fontSize={[4, 5, 6]}
fontWeight="bold"
/>
</ThemeProvider>
)

expect(registry.toString()).to.be(stripIndent`
Expand Down Expand Up @@ -201,4 +178,7 @@ describe.only('React-JSS: styled-system', () => {
expect(className).to.be('css-0 css-0-1')
expect(classes).to.be(undefined)
})

it.skip('should handle the propTypes/meta for validation from function rules', () => {})
it.skip('should do compose() automatically', () => {})
})
42 changes: 14 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -717,20 +717,20 @@
"@babel/plugin-transform-react-jsx-self" "^7.0.0"
"@babel/plugin-transform-react-jsx-source" "^7.0.0"

"@babel/runtime@^7.1.2":
version "7.4.4"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.4.4.tgz#dc2e34982eb236803aa27a07fea6857af1b9171d"
integrity sha512-w0+uT71b6Yi7i5SE0co4NioIpSYS6lLiXvCzWzGSKvpK5vdQtCbICHMj+gbAKAOtxiV6HsVh/MBdaF9EQ6faSg==
dependencies:
regenerator-runtime "^0.13.2"

"@babel/runtime@^7.3.1":
version "7.3.1"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.3.1.tgz#574b03e8e8a9898eaf4a872a92ea20b7846f6f2a"
integrity sha512-7jGW8ppV0ant637pIqAcFfQDDH1orEPGJb8aXfUozuCU3QqX7rX4DA8iwrbPrR1hcH0FTTHz47yQnk+bl5xHQA==
dependencies:
regenerator-runtime "^0.12.0"

"@babel/runtime@^7.4.2":
version "7.4.3"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.4.3.tgz#79888e452034223ad9609187a0ad1fe0d2ad4bdc"
integrity sha512-9lsJwJLxDh/T3Q3SZszfWOTkk3pHbkmH+3KY+zwIDmsNlxsumuhS2TH3NIpktU4kNvfzy+k3eLT7aTJSPTo0OA==
dependencies:
regenerator-runtime "^0.13.2"

"@babel/template@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0.tgz#c2bc9870405959c89a9c814376a2ecb247838c80"
Expand Down Expand Up @@ -6239,7 +6239,7 @@ longest@^1.0.1:
resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097"
integrity sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=

loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1, loose-envify@^1.4.0:
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==
Expand Down Expand Up @@ -7625,15 +7625,6 @@ prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.2:
loose-envify "^1.3.1"
object-assign "^4.1.1"

prop-types@^15.7.2:
version "15.7.2"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
dependencies:
loose-envify "^1.4.0"
object-assign "^4.1.1"
react-is "^16.8.1"

proto-list@~1.2.1:
version "1.2.4"
resolved "https://registry.yarnpkg.com/proto-list/-/proto-list-1.2.4.tgz#212d5bfe1318306a420f6402b8e26ff39647a849"
Expand Down Expand Up @@ -7813,11 +7804,6 @@ react-is@^16.7.0:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.7.0.tgz#c1bd21c64f1f1364c6f70695ec02d69392f41bfa"
integrity sha512-Z0VRQdF4NPDoI0tsXVMLkJLiwEBa+RP66g0xDHxgxysxSoCUccSten4RTF/UFvZF1dZvZ9Zu1sx+MDXwcOR34g==

react-is@^16.8.1:
version "16.8.6"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16"
integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA==

react-test-renderer@^16.7.0:
version "16.7.0"
resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.7.0.tgz#1ca96c2b450ab47c36ba92cd8c03fcefc52ea01c"
Expand Down Expand Up @@ -9017,13 +9003,13 @@ strong-log-transformer@^2.0.0:
minimist "^1.2.0"
through "^2.3.4"

styled-system@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/styled-system/-/styled-system-4.1.0.tgz#e5a58be23b89cf8fb7b181c8e425ab107b166693"
integrity sha512-ioIAJ029tRr6eJhiUrE3VZeahN+GBuJHv/jmckkfikY4ej8BaxvIKAaavmjFoqzNsIzr+x5HCpry1ybQYpchtQ==
styled-system@3:
version "3.2.1"
resolved "https://registry.yarnpkg.com/styled-system/-/styled-system-3.2.1.tgz#491e1e6f88d7ee021f6f49376f12852cde8007cb"
integrity sha512-ag0Yp7UeVHHc3t+1uM3jvlljaZYzwqpbJ8hMrFvpaKfUd8xsB9JeQXLwMpEsz8iLx8Lz/+9j0coWFZjmw8MogQ==
dependencies:
"@babel/runtime" "^7.4.2"
prop-types "^15.7.2"
"@babel/runtime" "^7.1.2"
prop-types "^15.6.2"

supports-color@3.1.2:
version "3.1.2"
Expand Down

0 comments on commit 18c9a62

Please sign in to comment.