diff --git a/babel.config.js b/babel.config.js index 9ff820b8..04954ded 100644 --- a/babel.config.js +++ b/babel.config.js @@ -19,6 +19,7 @@ module.exports = api => { }, ], '@babel/preset-react', + '@emotion/babel-preset-css-prop', ], plugins: [ [ diff --git a/docs/components.md b/docs/components.md index e69de29b..4a6a4720 100644 --- a/docs/components.md +++ b/docs/components.md @@ -0,0 +1,14 @@ +- [Buttons] (#/Components/Buttons) +- [Forms] (#/Components/Forms) +- [Typography] (#/Components/Typography) +- [Grid] (#/Components/Grid) +- [Icon] (#/Components/Icon) +- [SVGIcon] (#/Components/SVGIcon) +- [Link] (#/Components/Link) +- [Loading] (#/Components/Loading) +- [Menus] (#/Components/Menus) +- [NavigationPills] (#/Components/NavigationPills) +- [Pill] (#/Components/Pill) +- [ScrollTrack] (#/Components/ScrollTrack) +- [Tooltip] (#/Components/Tooltip) +- [Transitions] (#/Components/Transitions) diff --git a/lib/styleguide/Wrapper.js b/lib/styleguide/Wrapper.js index 2f96d2b6..c19e4367 100644 --- a/lib/styleguide/Wrapper.js +++ b/lib/styleguide/Wrapper.js @@ -1,14 +1,11 @@ -import React, { Component } from 'react'; -import { StyleRoot } from 'radium' +import React from 'react' import SetStyles from '../../src/styles/SetStyles' -export default class Wrapper extends Component { - render() { - return ( - - - { this.props.children } - - ) - } +export default function Wrapper(props) { + return ( + <> + + {props.children} + + ) } diff --git a/package.json b/package.json index 99a483eb..b969a1a0 100644 --- a/package.json +++ b/package.json @@ -13,13 +13,13 @@ "release:build": "babel-node scripts/release/build_release.js", "release:verifyBuild": "babel-node scripts/release/verify_build.js", "release:publish": "babel-node scripts/release/publish_release.js", - "lint": "eslint src --ext .js,.jsx --ignore-pattern '*.spec.js'", + "lint": "eslint src --ext .js,.jsx,.ts,.tsx --ignore-pattern '*.spec.js'", "lint:fix": "npm run lint -- --fix", "test:lint": "npm run lint -- --quiet", "start": "webpack --progress --watch --config webpack.config.js", "styleguide": "styleguidist server", "styleguide:build": "styleguidist build && node scripts/moveBuildAssets.js", - "test:watch": "npm test -- --watch --bail", + "test:watch": "jest --watch --bail", "test": "jest --silent && npm run test:lint", "test:ci": "jest --silent --maxWorkers=2 && npm run test:lint", "test:generate-coverage-report": "codecov" @@ -52,6 +52,8 @@ "@babel/plugin-transform-runtime": "7.4.4", "@babel/preset-env": "^7.0.0", "@babel/preset-react": "^7.0.0", + "@emotion/babel-preset-css-prop": "10.0.9", + "@emotion/core": "10.0.10", "@instacart/eslint-config": "0.1.9", "@instacart/prettier-config": "0.1.1", "@instacart/tsconfig": "0.1.1", @@ -62,21 +64,21 @@ "babel-loader": "^8.0.0", "codecov": "^3.5.0", "coveralls": "^3.0.5", - "enzyme": "^3.3.0", - "enzyme-adapter-react-16": "^1.1.1", - "enzyme-to-json": "^3.3.3", + "enzyme": "^3.10.0", + "enzyme-adapter-react-16": "^1.14.0", + "enzyme-to-json": "^3.4.0", "eslint": "5.16.0", "eslint-import-resolver-webpack": "0.11.0", "fs-extra": "^5.0.0", "glob": "7.1.4", "jest": "^24.8.0", + "jest-emotion": "10.0.14", "prettier": "1.16.4", "prompt": "^1.0.0", - "radium": "^0.22.0", "react": "16.4.2", "react-dom": "16.4.2", "react-styleguidist": "9.0.9", - "react-test-renderer": "^16.2.0", + "react-test-renderer": "16.4.2", "react-transition-group": "^2.2.1", "sinon": "^7.3.2", "typescript": "^3.2.2", @@ -88,7 +90,6 @@ }, "dependencies": { "@babel/runtime": "^7.1.2", - "@types/radium": "0.24.2", "@types/react-text-mask": "5.4.4", "@types/react-transition-group": "2.9.1", "@types/validator": "10.11.0", @@ -102,16 +103,17 @@ "validator": "^9.1.1" }, "peerDependencies": { - "prop-types": "^15.0.0 || ^16.0.0", - "radium": ">=0.18.0", - "react": "^15.0.0 || ^16.0.0", - "react-dom": "^15.0.0 || ^16.0.0", + "@emotion/core": "^10.0.10", + "prop-types": "^15.0.0", + "react": "^16.3.0", + "react-dom": "^16.3.0", "react-transition-group": "^2.2.1" }, "jest": { "transform": { "^.+\\.js$": "babel-jest" }, + "snapshotSerializers": ["jest-emotion"], "coverageDirectory": "./coverage/", "testURL": "http://localhost", "collectCoverage": true, diff --git a/src/base/RadioCheckboxBase.js b/src/base/RadioCheckboxBase.js index b25e87a2..46f8e99a 100644 --- a/src/base/RadioCheckboxBase.js +++ b/src/base/RadioCheckboxBase.js @@ -1,6 +1,5 @@ import React from 'react' import PropTypes from 'prop-types' -import Radium from 'radium' import colors from '../styles/colors' import withTheme from '../styles/themer/withTheme' import { themePropTypes } from '../styles/themer/utils' @@ -113,13 +112,13 @@ class RadioCheckboxBase extends React.PureComponent { const internalStyle = getStyles(this.props) return ( -
+
{renderInputButton(isSelected, getInputStyles(this.props, this.state))} + {this.renderInputBtn()} - @@ -158,4 +154,4 @@ class RadioCheckboxBase extends React.PureComponent { } } -export default withTheme(Radium(RadioCheckboxBase)) +export default withTheme(RadioCheckboxBase) diff --git a/src/components/Buttons/Button.d.ts b/src/components/Buttons/Button.d.ts index 3f6e6d7a..0a5f374a 100644 --- a/src/components/Buttons/Button.d.ts +++ b/src/components/Buttons/Button.d.ts @@ -1,10 +1,13 @@ import * as React from 'react' -import { RadiumStyles, ElementAttributes } from '../..' +import { Interpolation } from '@emotion/core' +import { ElementAttributes } from '../..' import { WithThemeInjectedProps, ApplyWithTheme } from '../../styles/themer/withTheme' export interface ButtonProps extends WithThemeInjectedProps { children?: React.ReactNode + className?: string + /** Whether or not the button is disabled. */ disabled?: boolean @@ -14,8 +17,14 @@ export interface ButtonProps extends WithThemeInjectedProps { /** Snacks button variants. */ snacksStyle?: 'primary' | 'secondary' | 'flat' | 'coupon' - /** Optional style overrides. */ - style?: RadiumStyles + /** + * Optional style overrides merged into emotion css + * + * @deprecated + * This prop exists for backwards compatibility and will be + * removed in a future version + */ + style?: Interpolation /** An optional icon. Can be a an icon name or a Snacks `Icon` component. */ icon?: string | React.ReactElement // eslint-disable-line @typescript-eslint/no-explicit-any diff --git a/src/components/Buttons/Button.js b/src/components/Buttons/Button.js index ec6fe2e5..921db7e4 100644 --- a/src/components/Buttons/Button.js +++ b/src/components/Buttons/Button.js @@ -1,6 +1,5 @@ import React from 'react' import PropTypes from 'prop-types' -import Radium from 'radium' import Icon from '../Icon/Icon' import withTheme from '../../styles/themer/withTheme' import { themePropTypes } from '../../styles/themer/utils' @@ -213,7 +212,8 @@ const Button = props => { disabled: props.disabled, tabIndex: props.tabIndex, type: props.type, - style: [ + className: props.className, + css: [ baseStyles, sizeStyles[props.size], snacksStyles[props.snacksStyle][props.disabled ? 'disabled' : 'base'], @@ -249,7 +249,7 @@ const Button = props => { return ( {icon} - + {props.children} ) @@ -259,7 +259,7 @@ const Button = props => { return ( {props.children} - + {icon} ) @@ -275,9 +275,17 @@ Button.propTypes = { /** Snacks button variants. */ snacksStyle: PropTypes.oneOf(['primary', 'secondary', 'flat', 'coupon']), - /** Optional style overrides. */ + /** + * Optional style overrides merged into emotion css + * + * @deprecated + * This prop exists for backwards compatibility and will be + * removed in a future version + */ style: PropTypes.object, + className: PropTypes.string, + /** Whether or not the button is disabled. */ disabled: PropTypes.bool, @@ -333,4 +341,4 @@ Button.defaultProps = { elementAttributes: {}, } -export default withTheme(Radium(Button)) +export default withTheme(Button) diff --git a/src/components/Buttons/Checkbox.js b/src/components/Buttons/Checkbox.js index 3f391069..85811d03 100644 --- a/src/components/Buttons/Checkbox.js +++ b/src/components/Buttons/Checkbox.js @@ -6,7 +6,7 @@ import checkboxSelectedSvg from '../../assets/checkboxSelected.svg' const renderInputButton = (isSelected, style) => { const SvgComponent = isSelected ? checkboxSelectedSvg : checkboxBaseSvg - return