From c73eb7155f7bb29688ae0d1a0869d6c17de1694c Mon Sep 17 00:00:00 2001 From: Brent Jackson Date: Mon, 18 Jun 2018 20:54:47 -0400 Subject: [PATCH 1/2] Remove styled-components --- core/__tests__/Cartesian.js | 12 +- core/__tests__/Colorable.js | 6 +- .../__tests__/__snapshots__/Cartesian.js.snap | 126 +++++++++++++++--- .../__tests__/__snapshots__/Colorable.js.snap | 120 ++++++++++++++--- core/package.json | 6 +- core/src/LiveEditor.js | 8 +- core/src/Markdown.js | 11 +- 7 files changed, 222 insertions(+), 67 deletions(-) diff --git a/core/__tests__/Cartesian.js b/core/__tests__/Cartesian.js index 6beae216..df4cf0ba 100644 --- a/core/__tests__/Cartesian.js +++ b/core/__tests__/Cartesian.js @@ -1,5 +1,5 @@ import React from 'react' -import styled from 'styled-components' +import styled from 'nano-style' import { render } from 'react-testing-library' import { color, space, fontSize } from 'styled-system' @@ -12,11 +12,11 @@ const buttonProps = { backgroundColor: ['pink', 'tomato', 'purple'] } -const Button = styled.a` - ${color} - ${fontSize} - ${space} -` +const Button = styled('a')( + color, + fontSize, + space, +) test('Cartesian renders all examples', () => { const { container } = render() diff --git a/core/__tests__/Colorable.js b/core/__tests__/Colorable.js index 31d552be..a0a3a796 100644 --- a/core/__tests__/Colorable.js +++ b/core/__tests__/Colorable.js @@ -1,5 +1,5 @@ import React from 'react' -import styled from 'styled-components' +import styled from 'nano-style' import { render } from 'react-testing-library' import { color } from 'styled-system' @@ -7,9 +7,7 @@ import { Colorable } from '../src' const colors = ['black', 'white', 'pink', 'tomato', 'purple'] -const Button = styled.a` - ${color} -` +const Button = styled('a')(color) test('Colorable returns all possible colors', () => { const { container } = render( diff --git a/core/__tests__/__snapshots__/Cartesian.js.snap b/core/__tests__/__snapshots__/Cartesian.js.snap index 26e50c5b..5a1d505d 100644 --- a/core/__tests__/__snapshots__/Cartesian.js.snap +++ b/core/__tests__/__snapshots__/Cartesian.js.snap @@ -3,112 +3,202 @@ exports[`Cartesian renders all examples 1`] = `
Hello, world! + Hello, world! + Hello, world! + Hello, world! + Hello, world! + Hello, world! + Hello, world! + Hello, world! + Hello, world! + Hello, world! + Hello, world! + Hello, world! + Hello, world! + Hello, world! + Hello, world! + Hello, world! + Hello, world! + Hello, world! +
`; diff --git a/core/__tests__/__snapshots__/Colorable.js.snap b/core/__tests__/__snapshots__/Colorable.js.snap index fadbbd13..2ac90416 100644 --- a/core/__tests__/__snapshots__/Colorable.js.snap +++ b/core/__tests__/__snapshots__/Colorable.js.snap @@ -4,133 +4,213 @@ exports[`Colorable returns all possible colors 1`] = `
Beep + Beep + Beep + Beep +
Beep + Beep + Beep + Beep +
Beep + Beep + Beep + Beep +
Beep + Beep + Beep + Beep +
Beep + Beep + Beep + Beep +
`; diff --git a/core/package.json b/core/package.json index cffc0516..3095bf7b 100644 --- a/core/package.json +++ b/core/package.json @@ -57,11 +57,7 @@ "react": "^16.4.0", "react-testing-library": "^3.1.3", "rebass": "^2.0.0-0", - "sinon": "^5.0.10", - "styled-components": "^3.3.2" - }, - "peerDependencies": { - "styled-components": ">=2.0.0 || >=3.0.0" + "sinon": "^5.0.10" }, "publishConfig": { "access": "public" diff --git a/core/src/LiveEditor.js b/core/src/LiveEditor.js index 2a8f8402..bff7a41f 100644 --- a/core/src/LiveEditor.js +++ b/core/src/LiveEditor.js @@ -1,7 +1,6 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import matter from 'gray-matter' -import { ThemeProvider } from 'styled-components' import nano from 'nano-style' import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live' @@ -33,16 +32,11 @@ class KitEditor extends Component { ` - -
${code}
-
- `} + transformCode={code => `
${code}
`} > diff --git a/core/src/Markdown.js b/core/src/Markdown.js index 476405dd..378a1be5 100644 --- a/core/src/Markdown.js +++ b/core/src/Markdown.js @@ -2,20 +2,17 @@ import React from 'react' import { transform } from 'buble' import mdx from '@mdx-js/mdx' import { MDXTag } from '@mdx-js/tag' -import { ThemeProvider } from 'styled-components' export default ({ children, components, theme = {} }) => { const jsx = mdx.sync(children).replace('export default ({components}) =>', '') const { code } = transform(` - - - ${jsx} - - + + ${jsx} + `) - const scope = { ThemeProvider, MDXTag, ...components, components, theme } + const scope = { MDXTag, ...components, components, theme } const keys = Object.keys(scope) const values = keys.map(k => scope[k]) From 967e29b459afe55935212a6ae82d30b5709558c2 Mon Sep 17 00:00:00 2001 From: Brent Jackson Date: Mon, 18 Jun 2018 22:04:34 -0400 Subject: [PATCH 2/2] Update snapshots --- core/__tests__/Matrix.js | 5 +- core/__tests__/__snapshots__/Matrix.js.snap | 560 ++++---------------- 2 files changed, 115 insertions(+), 450 deletions(-) diff --git a/core/__tests__/Matrix.js b/core/__tests__/Matrix.js index 2303f77a..39ba7bfa 100644 --- a/core/__tests__/Matrix.js +++ b/core/__tests__/Matrix.js @@ -1,9 +1,10 @@ import React from 'react' import { render } from 'react-testing-library' -import { Donut } from 'rebass' - +import styled from 'nano-style' import { Matrix } from '../src' +const Donut = styled('progress')(props => ({ color: props.color })) + test('Matrix renders all examples', () => { const { container } = render( - - - - + /> +