├── .changeset ├── README.md └── config.json ├── .codesandbox └── ci.json ├── .editorconfig ├── .eslintignore ├── .gitattributes ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── --bug-report.md │ ├── --documentation-issue.md │ ├── --feature-request.md │ └── config.yml ├── PULL_REQUEST_TEMPLATE.md ├── actions │ └── ci-setup │ │ └── action.yml ├── no-response.yml ├── stale.yml └── workflows │ ├── main.yml │ └── release.yml ├── .gitignore ├── .nvmrc ├── .prettierignore ├── .prettierrc.yaml ├── .yarn ├── patches │ └── @definitelytyped-dtslint-npm-0.0.112-1e6b842976.patch ├── plugins │ └── @yarnpkg │ │ └── plugin-workspace-tools.cjs └── releases │ └── yarn-3.2.3.cjs ├── .yarnrc.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── RELEASING.md ├── SECURITY.md ├── __mocks__ ├── react-native.js └── react-primitives.js ├── babel.config.js ├── codecov.yml ├── docs ├── README.md ├── babel-macros.mdx ├── babel.mdx ├── best-practices.mdx ├── cache-provider.mdx ├── class-names.mdx ├── community.mdx ├── composition.mdx ├── css-prop.mdx ├── docs.yaml ├── emotion-11.mdx ├── eslint-plugin-react.mdx ├── extract-static.mdx ├── for-library-authors.mdx ├── globals.mdx ├── install.mdx ├── introduction.mdx ├── keyframes.mdx ├── labels.mdx ├── media-queries.mdx ├── migrating-to-emotion-10.mdx ├── nested.mdx ├── object-styles.mdx ├── package-summary.mdx ├── performance.mdx ├── source-maps.mdx ├── ssr.mdx ├── styled.mdx ├── testing.mdx ├── theming.mdx ├── typescript.mdx └── with-props.mdx ├── emotion.png ├── flow-typed └── npm │ └── vitest_vx.x.x.js ├── jest-react18.config.js ├── jest.config.js ├── jest.dist.js ├── jest.prod.js ├── netlify.toml ├── package.json ├── packages ├── babel-plugin-jsx-pragmatic │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── __fixtures__ │ │ │ ├── existing-imports.js │ │ │ ├── fragment-only.js │ │ │ └── minimal.js │ │ ├── __snapshots__ │ │ │ └── index.js.snap │ │ └── index.js │ ├── babel__plugin-syntax-jsx.d.ts │ ├── package.json │ └── src │ │ └── index.ts ├── babel-plugin │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── __fixtures__ │ │ │ ├── autolabel-and-css-property-label.js │ │ │ ├── core-with-component.js │ │ │ ├── core-with-css-import-dynamic.js │ │ │ ├── core-with-css-import.js │ │ │ ├── css-prop-complex-array.js │ │ │ ├── does-not-change-other-props.js │ │ │ ├── dynamic.js │ │ │ ├── function-declaration.js │ │ │ ├── import-namespace-does-not-throw.js │ │ │ ├── jsx-hoist.js │ │ │ ├── object-property.js │ │ │ ├── static-object-with-camel-case.js │ │ │ └── static-object-with-child-selectors.js │ │ ├── __snapshots__ │ │ │ ├── css-requires-options.js.snap │ │ │ ├── css.js.snap │ │ │ ├── global-requires-options.js.snap │ │ │ ├── global.js.snap │ │ │ ├── index.js.snap │ │ │ ├── styled-requires-options.js.snap │ │ │ ├── styled.js.snap │ │ │ └── vanilla-emotion.js.snap │ │ ├── css-macro │ │ │ ├── __fixtures__ │ │ │ │ ├── actual-expected-usage.js │ │ │ │ ├── already-transpiled-by-babel.js │ │ │ │ ├── basic.js │ │ │ │ ├── call-expression.js │ │ │ │ ├── call-inside-call.js │ │ │ │ ├── comment-with-interpolation.js │ │ │ │ ├── impure.js │ │ │ │ ├── inside-anonymous-arrow-function.js │ │ │ │ ├── inside-anonymous-function.js │ │ │ │ ├── inside-class.js │ │ │ │ ├── label-1.js │ │ │ │ ├── label-arrow-as-obj-property.js │ │ │ │ ├── label-arrow-function-expression.js │ │ │ │ ├── label-function-expression-as-obj-property.js │ │ │ │ ├── label-function-expression-named.js │ │ │ │ ├── label-function-expression.js │ │ │ │ ├── label-no-final-semi.js │ │ │ │ ├── label-obj-method.js │ │ │ │ ├── label-obj-property-literal.js │ │ │ │ ├── label-object.js │ │ │ │ ├── label-transpiled-by-ts-with-interpolations.js │ │ │ │ ├── label-transpiled-by-ts.js │ │ │ │ ├── multiple-calls.js │ │ │ │ ├── no-actual-import.js │ │ │ │ ├── no-label-array-pattern.js │ │ │ │ ├── no-label-obj-pattern-computed-property.js │ │ │ │ ├── object-dynamic-property.js │ │ │ │ ├── object-pattern-variable-declarator.js │ │ │ │ ├── other-imports.js │ │ │ │ ├── remove-block-comments.js │ │ │ │ ├── remove-line-comments.js │ │ │ │ └── tagged-template-args-forwarded.js │ │ │ ├── __snapshots__ │ │ │ │ └── index.js.snap │ │ │ └── index.js │ │ ├── css-requires-options.js │ │ ├── css.js │ │ ├── disable-source-map │ │ │ ├── __fixtures__ │ │ │ │ ├── css.js │ │ │ │ ├── styled.js │ │ │ │ └── vanilla.js │ │ │ ├── __snapshots__ │ │ │ │ └── index.js.snap │ │ │ └── index.js │ │ ├── global-macro │ │ │ ├── __fixtures__ │ │ │ │ ├── basic-array.js │ │ │ │ ├── basic-obj.js │ │ │ │ ├── complex-array.js │ │ │ │ ├── complex-obj.js │ │ │ │ ├── css-used-as-value.js │ │ │ │ ├── no-jsx.js │ │ │ │ ├── no-styles-prop.js │ │ │ │ ├── spread-styles.js │ │ │ │ └── with-closing-element.js │ │ │ ├── __snapshots__ │ │ │ │ └── index.js.snap │ │ │ └── index.js │ │ ├── global-requires-options.js │ │ ├── global.js │ │ ├── import-mapping │ │ │ ├── __fixtures__ │ │ │ │ ├── global-needs-css.js │ │ │ │ ├── global.js │ │ │ │ ├── jsx.js │ │ │ │ ├── non-default-styled-aliased.js │ │ │ │ ├── non-default-styled.js │ │ │ │ ├── styled-with-base-specified.js │ │ │ │ └── vanilla.js │ │ │ ├── __snapshots__ │ │ │ │ └── import-mapping.js.snap │ │ │ └── import-mapping.js │ │ ├── index.js │ │ ├── source-maps │ │ │ ├── __fixtures__ │ │ │ │ ├── css-object.js │ │ │ │ ├── css-prop-dynamic.js │ │ │ │ ├── css-prop.js │ │ │ │ ├── css-string.js │ │ │ │ ├── css-transpiled-by-ts-with-interpolations.js │ │ │ │ ├── css-transpiled-by-ts.js │ │ │ │ ├── global-styles-prop.js │ │ │ │ ├── styled-object.js │ │ │ │ └── styled-string.js │ │ │ ├── __snapshots__ │ │ │ │ └── index.js.snap │ │ │ └── index.js │ │ ├── styled-macro │ │ │ ├── __fixtures__ │ │ │ │ ├── already-transpiled-by-babel.js │ │ │ │ ├── auto-inserted-rule-in-at-rule-preceeded-by-interpolation.js │ │ │ │ ├── basic.js │ │ │ │ ├── call-expression.js │ │ │ │ ├── comments.js │ │ │ │ ├── component-selector.js │ │ │ │ ├── existing-options.js │ │ │ │ ├── function-interpolation.js │ │ │ │ ├── label-assignment-expression.js │ │ │ │ ├── label-class-fields.js │ │ │ │ ├── label-member-expression.js │ │ │ │ ├── label-sanitize.js │ │ │ │ ├── label.js │ │ │ │ ├── more-than-10-interpolations.js │ │ │ │ ├── multiple-calls.js │ │ │ │ ├── native.js │ │ │ │ ├── no-call.js │ │ │ │ ├── no-import.js │ │ │ │ ├── object-call-expression.js │ │ │ │ ├── object-function.js │ │ │ │ ├── object.js │ │ │ │ ├── other-imports.js │ │ │ │ ├── primitives-other-name.js │ │ │ │ ├── primitives.js │ │ │ │ ├── same-nested-contex-value.js │ │ │ │ ├── shorthand-property.js │ │ │ │ ├── two-consecutive-interpolations.js │ │ │ │ └── with-spread.js │ │ │ ├── __snapshots__ │ │ │ │ └── index.js.snap │ │ │ └── index.js │ │ ├── styled-requires-options.js │ │ ├── styled.js │ │ ├── vanilla-emotion-macro │ │ │ ├── __fixtures__ │ │ │ │ ├── comments.js │ │ │ │ ├── css-basic.js │ │ │ │ ├── css-object.js │ │ │ │ ├── does-not-minify-inside-content-property.js │ │ │ │ ├── hoisting.js │ │ │ │ ├── inject-global-basic.js │ │ │ │ ├── inject-global-change-import.js │ │ │ │ ├── inject-global-with-font-face.js │ │ │ │ ├── inject-global-with-interpolation.js │ │ │ │ ├── keyframes-basic.js │ │ │ │ ├── keyframes-with-interpolation.js │ │ │ │ ├── nested-orphaned-pseudo.js │ │ │ │ └── object-label.js │ │ │ ├── __snapshots__ │ │ │ │ └── index.js.snap │ │ │ └── index.js │ │ └── vanilla-emotion.js │ ├── package.json │ └── src │ │ ├── core-macro.js │ │ ├── emotion-macro.js │ │ ├── index.js │ │ ├── styled-macro.js │ │ └── utils │ │ ├── add-import.js │ │ ├── create-node-env-conditional.js │ │ ├── get-styled-options.js │ │ ├── get-target-class-name.js │ │ ├── index.js │ │ ├── label.js │ │ ├── minify.js │ │ ├── object-to-string.js │ │ ├── source-maps.js │ │ ├── strings.js │ │ ├── transform-expression-with-styles.js │ │ ├── transformer-macro.js │ │ └── transpiled-output-utils.js ├── babel-preset-css-prop │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── __fixtures__ │ │ │ ├── array-css-prop.js │ │ │ └── index.js │ │ ├── __snapshots__ │ │ │ ├── index.js.snap │ │ │ └── options-are-used.js.snap │ │ ├── index.js │ │ └── options-are-used.js │ ├── package.json │ └── src │ │ └── index.js ├── cache │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ ├── hydration.js.snap │ │ │ └── index.js.snap │ │ ├── hydration.js │ │ └── index.js │ ├── package.json │ ├── src │ │ ├── conditions │ │ │ ├── false.ts │ │ │ ├── is-browser.ts │ │ │ └── true.ts │ │ ├── index.ts │ │ ├── prefixer.ts │ │ ├── stylis-plugins.ts │ │ └── types.ts │ └── types │ │ ├── index.d.ts │ │ ├── resolved-condition.ts │ │ ├── tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── css-prettifier │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── package.json │ └── src │ │ └── index.ts ├── css │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── create-instance │ │ └── package.json │ ├── macro.d.mts │ ├── macro.d.ts │ ├── macro.js │ ├── package.json │ ├── src │ │ ├── conditions │ │ │ ├── false.ts │ │ │ └── true.ts │ │ ├── create-instance.ts │ │ └── index.ts │ ├── test │ │ ├── __snapshots__ │ │ │ ├── component-selector.test.js.snap │ │ │ ├── css.test.js.snap │ │ │ ├── cx.test.js.snap │ │ │ ├── inject-global.test.js.snap │ │ │ ├── keyframes.test.js.snap │ │ │ ├── label-pattern.test.js.snap │ │ │ ├── selectivity.test.js.snap │ │ │ ├── sheet.dom.test.js.snap │ │ │ └── warnings.test.js.snap │ │ ├── component-selector.test.js │ │ ├── css.test.js │ │ ├── cx.test.js │ │ ├── inject-global.test.js │ │ ├── instance │ │ │ ├── __snapshots__ │ │ │ │ ├── css.test.js.snap │ │ │ │ ├── inline.test.js.snap │ │ │ │ ├── instance.test.js.snap │ │ │ │ └── stream.test.js.snap │ │ │ ├── css.test.js │ │ │ ├── emotion-instance.js │ │ │ ├── inline.test.js │ │ │ ├── instance.test.js │ │ │ └── stream.test.js │ │ ├── keyframes.test.js │ │ ├── label-pattern.test.js │ │ ├── no-babel │ │ │ ├── __snapshots__ │ │ │ │ └── index.test.js.snap │ │ │ ├── index.test.js │ │ │ └── warnings.test.js │ │ ├── selectivity.test.js │ │ ├── sheet.dom.test.js │ │ ├── source-map │ │ │ ├── .babelrc │ │ │ ├── __snapshots__ │ │ │ │ └── source-map.test.js.snap │ │ │ └── source-map.test.js │ │ └── warnings.test.js │ └── types │ │ ├── create-instance.d.ts │ │ ├── index.d.ts │ │ ├── tests-create-instance.ts │ │ ├── tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── eslint-plugin │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── docs │ │ └── rules │ │ │ ├── import-from-emotion.md │ │ │ ├── jsx-import.md │ │ │ ├── no-vanilla.md │ │ │ ├── styled-import.md │ │ │ └── syntax-preference.md │ ├── package.json │ ├── src │ │ ├── index.ts │ │ ├── rules │ │ │ ├── import-from-emotion.ts │ │ │ ├── jsx-import.ts │ │ │ ├── no-vanilla.ts │ │ │ ├── pkg-renaming.ts │ │ │ ├── styled-import.ts │ │ │ └── syntax-preference.ts │ │ └── utils.ts │ └── test │ │ ├── rules │ │ ├── import-from-emotion.test.ts │ │ ├── jsx-import.test.ts │ │ ├── no-vanilla.test.ts │ │ ├── pkg-renaming.test.ts │ │ ├── styled-import.test.ts │ │ └── syntax-preference.test.ts │ │ └── test-utils.ts ├── hash │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ └── index.js │ ├── package.json │ ├── src │ │ └── index.ts │ └── types │ │ ├── index.d.ts │ │ ├── tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── is-prop-valid │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── props.js │ └── types │ │ ├── index.d.ts │ │ ├── tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── jest │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── enzyme-serializer │ │ └── package.json │ ├── enzyme │ │ └── package.json │ ├── package.json │ ├── serializer │ │ └── package.json │ ├── src │ │ ├── create-enzyme-serializer.js │ │ ├── create-serializer.js │ │ ├── enzyme-serializer.d.ts │ │ ├── enzyme-serializer.js │ │ ├── enzyme-tickler.js │ │ ├── enzyme.d.ts │ │ ├── enzyme.js │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── matchers.js │ │ ├── replace-class-names.js │ │ ├── serializer.d.ts │ │ ├── serializer.js │ │ └── utils.js │ ├── test │ │ ├── __snapshots__ │ │ │ ├── matchers.test.js.snap │ │ │ ├── printer.test.js.snap │ │ │ └── react-enzyme.test.js.snap │ │ ├── matchers.test.js │ │ ├── printer.test.js │ │ ├── prod.test.js │ │ └── react-enzyme.test.js │ └── types │ │ ├── enzyme-serializer.d.ts │ │ ├── enzyme.d.ts │ │ ├── index.d.ts │ │ ├── serializer.d.ts │ │ ├── test.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── memoize │ ├── CHANGELOG.md │ ├── LICENSE │ ├── package.json │ ├── src │ │ └── index.ts │ └── types │ │ ├── index.d.ts │ │ ├── tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── native │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── macro.d.mts │ ├── macro.d.ts │ ├── macro.js │ ├── package.json │ ├── src │ │ ├── base.js │ │ ├── index.d.ts │ │ └── index.js │ ├── test │ │ ├── __snapshots__ │ │ │ └── native-styled.test.js.snap │ │ ├── native-css.test.js │ │ └── native-styled.test.js │ ├── tsconfig.json │ └── types │ │ ├── base.d.ts │ │ ├── index.d.ts │ │ ├── resolved-condition.ts │ │ ├── tests.tsx │ │ ├── tsconfig.json │ │ └── tslint.json ├── primitives-core │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── package.json │ └── src │ │ ├── conditions │ │ ├── false.ts │ │ └── true.ts │ │ ├── css.ts │ │ ├── index.ts │ │ ├── styled.ts │ │ ├── types.ts │ │ └── utils.ts ├── primitives │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── examples │ │ └── index.js │ ├── macro.js │ ├── package.json │ ├── src │ │ ├── conditions │ │ │ ├── false.js │ │ │ └── true.js │ │ ├── index.js │ │ ├── styled.js │ │ └── test-props.js │ └── test │ │ ├── __snapshots__ │ │ └── emotion-primitives.test.js.snap │ │ ├── css.test.js │ │ ├── emotion-primitives.test.js │ │ ├── no-babel │ │ ├── __snapshots__ │ │ │ └── basic.test.js.snap │ │ └── basic.test.js │ │ └── warnings.test.js ├── react │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ ├── at-import.js.snap │ │ │ ├── class-names.js.snap │ │ │ ├── css-cache-hash.js.snap │ │ │ ├── css.js.snap │ │ │ ├── global-with-theme.js.snap │ │ │ ├── global.js.snap │ │ │ ├── globals-are-the-worst.js.snap │ │ │ ├── keyframes.js.snap │ │ │ ├── legacy-class-name.js.snap │ │ │ ├── server.js.snap │ │ │ ├── theme-provider.dom.js.snap │ │ │ ├── theme-provider.js.snap │ │ │ ├── use-theme.js.snap │ │ │ ├── warnings.js.snap │ │ │ └── with-theme.js.snap │ │ ├── at-import.js │ │ ├── automatic-dev-runtime.js │ │ ├── automatic-runtime.js │ │ ├── babel │ │ │ ├── __snapshots__ │ │ │ │ ├── css.js.snap │ │ │ │ └── source-map-server.js.snap │ │ │ ├── css.js │ │ │ └── source-map-server.js │ │ ├── class-names.js │ │ ├── clone-element.js │ │ ├── compat │ │ │ ├── __snapshots__ │ │ │ │ ├── browser.js.snap │ │ │ │ └── server.js.snap │ │ │ ├── browser.js │ │ │ └── server.js │ │ ├── css-cache-hash.js │ │ ├── css.js │ │ ├── custom-cache.js │ │ ├── element.js │ │ ├── get-label-from-stack-trace.js │ │ ├── global-insertion-after-others.js │ │ ├── global-with-theme.js │ │ ├── global.js │ │ ├── globals-are-the-worst.js │ │ ├── import-prod.js │ │ ├── keyframes.js │ │ ├── legacy-class-name.js │ │ ├── prod.js │ │ ├── ref.js │ │ ├── rehydration.js │ │ ├── server.js │ │ ├── theme-provider.dom.js │ │ ├── theme-provider.js │ │ ├── use-theme.js │ │ ├── warnings.js │ │ └── with-theme.js │ ├── _isolated-hnrs │ │ └── package.json │ ├── jsx-dev-runtime │ │ └── package.json │ ├── jsx-runtime │ │ └── package.json │ ├── macro.d.mts │ ├── macro.d.ts │ ├── macro.js │ ├── package.json │ ├── src │ │ ├── _isolated-hnrs.ts │ │ ├── class-names.tsx │ │ ├── conditions │ │ │ ├── false.ts │ │ │ ├── is-browser.ts │ │ │ └── true.ts │ │ ├── context.tsx │ │ ├── css.ts │ │ ├── emotion-element.tsx │ │ ├── get-label-from-stack-trace.ts │ │ ├── global.tsx │ │ ├── index.ts │ │ ├── jsx-dev-runtime.ts │ │ ├── jsx-namespace.ts │ │ ├── jsx-runtime.ts │ │ ├── jsx.ts │ │ ├── keyframes.ts │ │ ├── theming.tsx │ │ ├── types.ts │ │ └── utils.ts │ └── types │ │ ├── css-prop.d.ts │ │ ├── index.d.ts │ │ ├── resolved-condition.ts │ │ ├── tests-css.tsx │ │ ├── tests-theming.tsx │ │ ├── tests.tsx │ │ ├── tsconfig.json │ │ └── tslint.json ├── serialize │ ├── CHANGELOG.md │ ├── LICENSE │ ├── package.json │ ├── src │ │ ├── conditions │ │ │ ├── false.ts │ │ │ └── true.ts │ │ └── index.ts │ └── types │ │ ├── index.d.ts │ │ ├── tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── server │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── create-instance │ │ └── package.json │ ├── package.json │ ├── src │ │ ├── conditions │ │ │ ├── false.js │ │ │ └── true.js │ │ ├── create-instance │ │ │ ├── construct-style-tags-from-chunks.js │ │ │ ├── extract-critical-to-chunks.js │ │ │ ├── extract-critical.js │ │ │ ├── index.d.ts │ │ │ ├── index.js │ │ │ ├── inline.js │ │ │ ├── stream.js │ │ │ └── utils.js │ │ ├── index.d.ts │ │ └── index.js │ ├── test │ │ ├── __snapshots__ │ │ │ ├── extract-critical-to-chunks.test.js.snap │ │ │ ├── index.test.js.snap │ │ │ ├── inline.test.js.snap │ │ │ └── stream.test.js.snap │ │ ├── extract-critical-to-chunks.test.js │ │ ├── index.test.js │ │ ├── inline.test.js │ │ ├── stream.test.js │ │ └── util.js │ └── types │ │ ├── create-instance.d.ts │ │ ├── index.d.ts │ │ ├── resolved-condition.ts │ │ ├── tests-create-instance.ts │ │ ├── tests.tsx │ │ ├── tsconfig.json │ │ └── tslint.json ├── sheet │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── index.js.snap │ │ └── index.js │ ├── package.json │ ├── src │ │ ├── conditions │ │ │ ├── false.ts │ │ │ └── true.ts │ │ └── index.ts │ └── types │ │ ├── index.d.ts │ │ ├── tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json ├── styled │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ ├── edge-cases.js.snap │ │ │ └── styled.js.snap │ │ ├── as-prop.js │ │ ├── edge-cases.js │ │ ├── styled-dom.js │ │ ├── styled.js │ │ └── warnings.js │ ├── base │ │ └── package.json │ ├── macro.d.mts │ ├── macro.d.ts │ ├── macro.js │ ├── package.json │ ├── src │ │ ├── base.tsx │ │ ├── conditions │ │ │ ├── false.ts │ │ │ ├── is-browser.ts │ │ │ └── true.ts │ │ ├── index.ts │ │ ├── jsx-namespace.ts │ │ ├── tags.ts │ │ ├── types.ts │ │ └── utils.ts │ ├── test │ │ ├── __snapshots__ │ │ │ ├── component-selector.test.js.snap │ │ │ ├── composition.test.js.snap │ │ │ ├── index.test.js.snap │ │ │ ├── prop-filtering.test.js.snap │ │ │ ├── source-map.test.js.snap │ │ │ ├── theming.dom.test.js.snap │ │ │ └── theming.test.js.snap │ │ ├── babel-plugin.test.js │ │ ├── component-selector.test.js │ │ ├── composition.test.js │ │ ├── index.test.js │ │ ├── prop-filtering.test.js │ │ ├── source-map.test.js │ │ ├── theming.dom.test.js │ │ └── theming.test.js │ └── types │ │ ├── base.d.ts │ │ ├── index.d.ts │ │ ├── resolved-condition.ts │ │ ├── tests-base.tsx │ │ ├── tests.tsx │ │ ├── tsconfig.json │ │ └── tslint.json ├── unitless │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── package.json │ └── src │ │ └── index.ts ├── use-insertion-effect-with-fallbacks │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── package.json │ └── src │ │ ├── conditions │ │ ├── false.ts │ │ ├── is-browser.ts │ │ └── true.ts │ │ └── index.ts ├── utils │ ├── CHANGELOG.md │ ├── LICENSE │ ├── package.json │ ├── src │ │ ├── conditions │ │ │ ├── false.ts │ │ │ ├── is-browser.ts │ │ │ └── true.ts │ │ ├── index.ts │ │ └── types.ts │ └── types │ │ ├── index.d.ts │ │ ├── resolved-condition.ts │ │ ├── tests.ts │ │ ├── tsconfig.json │ │ └── tslint.json └── weak-memoize │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── __tests__ │ └── index.js │ ├── package.json │ ├── src │ └── index.ts │ └── types │ ├── index.d.ts │ ├── tests.ts │ ├── tsconfig.json │ └── tslint.json ├── playgrounds ├── README.md ├── cra │ ├── .env │ ├── .gitignore │ ├── README.md │ ├── package.json │ ├── public │ │ ├── favicon.ico │ │ └── index.html │ └── src │ │ ├── App.js │ │ └── index.js └── nextjs │ ├── .babelrc.js │ ├── .gitignore │ ├── README.md │ ├── next.config.js │ ├── package.json │ ├── pages │ ├── _app.js │ └── index.js │ └── public │ ├── favicon.ico │ └── vercel.svg ├── scripts ├── babel-preset-emotion-dev │ ├── package.json │ └── src │ │ └── index.js ├── babel-tester │ ├── babel-check-duplicated-nodes.d.ts │ ├── package.json │ └── src │ │ └── index.ts ├── benchmarks │ ├── .babelrc │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── run.js │ └── src │ │ ├── app │ │ ├── App.js │ │ ├── Benchmark │ │ │ ├── index.js │ │ │ ├── math.js │ │ │ ├── timing.js │ │ │ └── types.js │ │ ├── Button.js │ │ ├── Icons.js │ │ ├── Layout.js │ │ ├── ReportCard.js │ │ ├── Text.js │ │ └── theme.js │ │ ├── cases │ │ ├── SierpinskiTriangle.js │ │ └── Tree.js │ │ ├── impl.js │ │ ├── implementations │ │ ├── emotion-css-func │ │ │ ├── Box.js │ │ │ ├── Dot.js │ │ │ ├── Provider.js │ │ │ ├── View.js │ │ │ └── index.js │ │ ├── emotion-css-prop │ │ │ ├── Box.js │ │ │ ├── Dot.js │ │ │ ├── Provider.js │ │ │ ├── View.js │ │ │ └── index.js │ │ └── emotion-styled │ │ │ ├── Box.js │ │ │ ├── Dot.js │ │ │ ├── Provider.js │ │ │ ├── View.js │ │ │ └── index.js │ │ ├── index.html │ │ └── index.js ├── ensure-yarn.js ├── replace-slack-link.js ├── ssr-benchmarks │ ├── .babelrc │ ├── basic.js │ ├── bench.js │ ├── package.json │ └── triangle.js └── test-utils │ ├── enzyme-env.js │ ├── index.d.ts │ ├── legacy-env.js │ ├── next-env.js │ ├── package.json │ ├── pretty-css.js │ ├── resolved-conditions │ ├── false.js │ └── true.js │ ├── src │ └── index.js │ └── testSetup.js ├── site ├── .babelrc.js ├── README.md ├── components │ ├── carbon-ads.tsx │ ├── container.tsx │ ├── doc-wrapper.tsx │ ├── global-styles.tsx │ ├── index.ts │ ├── live-editor │ │ ├── compiler │ │ │ ├── babel-worker.ts │ │ │ ├── compile.ts │ │ │ ├── index.ts │ │ │ └── message.ts │ │ ├── components │ │ │ ├── README.md │ │ │ ├── error-boundary.tsx │ │ │ ├── index.ts │ │ │ ├── live-context.ts │ │ │ ├── live-editor.tsx │ │ │ ├── live-error.tsx │ │ │ ├── live-preview.tsx │ │ │ ├── live-provider.tsx │ │ │ └── render-element-async.tsx │ │ ├── emotion-live-editor.tsx │ │ ├── index.ts │ │ └── remark-live-editor.ts │ ├── markdown-css.tsx │ ├── search.tsx │ ├── site-header.tsx │ └── title.tsx ├── misc.d.ts ├── module-stubs │ ├── README.md │ ├── cosmiconfig.cjs │ ├── find-root.cjs │ └── resolve.cjs ├── next-env.d.ts ├── next.config.js ├── package.json ├── pages │ ├── 404.tsx │ ├── _app.tsx │ └── docs │ │ ├── @emotion │ │ └── [packageName].tsx │ │ └── [slug].tsx ├── public │ ├── bootstrap-reboot.min.css │ ├── link.svg │ ├── logo-32x32.png │ ├── logo-48x48.png │ └── logo-96x96.png ├── queries │ ├── docQueries.ts │ └── index.ts ├── tsconfig.json └── util │ ├── dracula-prism.ts │ ├── index.ts │ ├── prism-customizations.ts │ ├── remark-fix-links.ts │ └── style-constants.ts ├── tsconfig.json └── yarn.lock /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.0.2/schema.json", 3 | "changelog": [ 4 | "@changesets/changelog-github", 5 | { "repo": "emotion-js/emotion" } 6 | ], 7 | "baseBranch": "main", 8 | "commit": false, 9 | "linked": [ 10 | [ 11 | "@emotion/react", 12 | "@emotion/styled", 13 | "@emotion/cache", 14 | "@emotion/css", 15 | "@emotion/server", 16 | "@emotion/babel-plugin", 17 | "@emotion/babel-preset-css-prop", 18 | "@emotion/jest", 19 | "@emotion/native", 20 | "@emotion/primitives", 21 | "@emotion/primitives-core", 22 | "@emotion/eslint-plugin" 23 | ] 24 | ], 25 | "access": "public", 26 | "privatePackages": false, 27 | "___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": { 28 | "onlyUpdatePeerDependentsWhenOutOfRange": true 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /.codesandbox/ci.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": ["packages/*"], 3 | "sandboxes": ["pk1qjqpw67"], 4 | "node": "16" 5 | } 6 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | charset = utf-8 7 | indent_style = space 8 | 9 | [*.{js,ts,tsx,json,yml}] 10 | indent_size = 2 -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | lib/ 2 | dist/ 3 | coverage/ 4 | node_modules/ 5 | stylis.min.js 6 | /demo/dist 7 | /site/out -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto eol=lf 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: emotion 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/--documentation-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F4D6Documentation issue" 3 | about: The documentation is unclear, missing informations, or could be improved 4 | labels: documentation, needs triage 5 | assignees: '' 6 | --- 7 | 8 | 13 | 14 | **Description:** 15 | 16 | 22 | 23 | **Documentation links:** 24 | 25 | 30 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/--feature-request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "\U0001F680Feature request" 3 | about: I have a suggestion (and might want to implement myself) 4 | title: '' 5 | labels: feature request, needs triage 6 | assignees: '' 7 | --- 8 | 9 | **The problem** 10 | 11 | 12 | 13 | **Proposed solution** 14 | 15 | 16 | 17 | **Alternative solutions** 18 | 19 | 20 | 21 | **Additional context** 22 | 23 | 24 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: 🤔 Support question 4 | url: https://stackoverflow.com/questions/ask?tags=emotion 5 | about: Issues are dedicated to feature requests and bugs, if you have questions, please use Stack Overflow. 6 | -------------------------------------------------------------------------------- /.github/actions/ci-setup/action.yml: -------------------------------------------------------------------------------- 1 | name: 'CI setup' 2 | runs: 3 | using: 'composite' 4 | steps: 5 | - name: Setup Node.js 16.x 6 | uses: actions/setup-node@v3 7 | with: 8 | node-version: 16.x 9 | cache: yarn 10 | 11 | - name: Install Dependencies 12 | run: yarn --immutable 13 | shell: bash 14 | -------------------------------------------------------------------------------- /.github/no-response.yml: -------------------------------------------------------------------------------- 1 | # Configuration for probot-no-response - https://github.com/probot/no-response 2 | 3 | # Number of days of inactivity before an Issue is closed for lack of response 4 | daysUntilClose: 14 5 | # Label requiring a response 6 | responseRequiredLabel: needs more information 7 | # Comment to post when closing an Issue for lack of response. Set to `false` to disable 8 | closeComment: > 9 | This issue has been automatically closed because there has been no response 10 | to our request for more information from the original author. With only the 11 | information that is currently in the issue, we don't have enough information 12 | to take action. Please reach out if you have or find the answers we need so 13 | that we can investigate further. 14 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 60 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 7 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | # Label to use when marking an issue as stale 9 | staleLabel: stale 10 | # Comment to post when marking an issue as stale. Set to `false` to disable 11 | markComment: > 12 | This issue has been automatically marked as stale because it has not had 13 | recent activity. It will be closed in 7 days if no further activity occurs. Thank you 14 | for your contributions. 15 | # Comment to post when closing a stale issue. Set to `false` to disable 16 | closeComment: false 17 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | - next 8 | 9 | concurrency: ${{ github.workflow }}-${{ github.ref }} 10 | 11 | permissions: {} 12 | jobs: 13 | release: 14 | permissions: 15 | contents: write # to create release 16 | issues: write # to post issue comments 17 | pull-requests: write # to create pull request 18 | 19 | name: Release 20 | runs-on: ubuntu-latest 21 | steps: 22 | - uses: actions/checkout@v3 23 | - uses: ./.github/actions/ci-setup 24 | 25 | - name: Create Release Pull Request or Publish to npm 26 | uses: changesets/action@v1 27 | with: 28 | publish: yarn release 29 | version: yarn version-packages 30 | env: 31 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 32 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 33 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /coverage 2 | /demo/dist 3 | dist/ 4 | node_modules/ 5 | *.log 6 | .idea 7 | package-lock.json 8 | .DS_Store 9 | .cache 10 | .env 11 | .vscode 12 | .parcel-cache/ 13 | *.orig 14 | *.tsbuildinfo 15 | 16 | .yarn/* 17 | !.yarn/patches 18 | !.yarn/plugins 19 | !.yarn/releases 20 | !.yarn/sdks 21 | !.yarn/versions 22 | 23 | # Website 24 | /site/out 25 | .next 26 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 16 -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | package.json -------------------------------------------------------------------------------- /.prettierrc.yaml: -------------------------------------------------------------------------------- 1 | arrowParens: avoid 2 | semi: false 3 | singleQuote: true 4 | trailingComma: none 5 | overrides: 6 | - files: 'docs/*.md' 7 | options: 8 | printWidth: 60 9 | -------------------------------------------------------------------------------- /.yarn/patches/@definitelytyped-dtslint-npm-0.0.112-1e6b842976.patch: -------------------------------------------------------------------------------- 1 | diff --git a/dist/lint.js b/dist/lint.js 2 | index ae29f2a0936fe8e4dee9b4a607ed5c611872d30d..96746c55f2df24c6d09ee30ff85e404138ad0fbe 100644 3 | --- a/dist/lint.js 4 | +++ b/dist/lint.js 5 | @@ -107,9 +107,9 @@ function startsWithDirectory(filePath, dirPath) { 6 | return normalFilePath.startsWith(normalDirPath + "/") || normalFilePath.startsWith(normalDirPath + "\\"); 7 | } 8 | function testNoTsIgnore(text) { 9 | - const tsIgnore = "ts-ignore"; 10 | - const pos = text.indexOf(tsIgnore); 11 | - return pos === -1 ? undefined : { pos, message: "'ts-ignore' is forbidden." }; 12 | + // const tsIgnore = "ts-ignore"; 13 | + // const pos = text.indexOf(tsIgnore); 14 | + // return pos === -1 ? undefined : { pos, message: "'ts-ignore' is forbidden." }; 15 | } 16 | function testNoTslintDisables(text) { 17 | const tslintDisable = "tslint:disable"; 18 | -------------------------------------------------------------------------------- /.yarnrc.yml: -------------------------------------------------------------------------------- 1 | nodeLinker: node-modules 2 | 3 | npmPublishAccess: public 4 | 5 | plugins: 6 | - path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs 7 | spec: "@yarnpkg/plugin-workspace-tools" 8 | 9 | yarnPath: .yarn/releases/yarn-3.2.3.cjs 10 | -------------------------------------------------------------------------------- /RELEASING.md: -------------------------------------------------------------------------------- 1 | # Releasing Emotion 2 | 3 | Emotion uses [changesets](https://github.com/Noviny/changesets) to do versioning. This makes releasing really easy and changelogs are automatically generated. 4 | 5 | ## How to do a release 6 | 7 | 1. Run `yarn` to make sure everything is up to date 8 | 2. Run `yarn version-packages`. 9 | 3. Run `NPM_CONFIG_OTP=PUTANOTPCODEHERE yarn release`. If the 2FA code times out while publishing, run the command again with a new code, only the packages that were not published will be published. 10 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security policy 2 | 3 | ## Supported versions 4 | 5 | The latest version of the project is currently supported with security updates. 6 | 7 | ## Reporting a vulnerability 8 | 9 | You can report a vulnerability by contacting maintainers via email. 10 | -------------------------------------------------------------------------------- /__mocks__/react-primitives.js: -------------------------------------------------------------------------------- 1 | export * from 'react-primitives/lib/index.web' 2 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: # https://docs.codecov.io/docs/pull-request-comments 2 | layout: 'files' 3 | behavior: once 4 | require_changes: true # if true: only post the comment if coverage changes 5 | require_base: no # [yes :: must have a base report to post] 6 | require_head: yes # [yes :: must have a head report to post] 7 | branches: null 8 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # [Read the docs at https://emotion.sh/docs](https://emotion.sh/docs) 2 | -------------------------------------------------------------------------------- /docs/babel-macros.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Babel Macros' 3 | --- 4 | 5 | [Create React App recently added support for Babel Macros](https://reactjs.org/blog/2018/10/01/create-react-app-v2.html) which makes it possible to run Babel transforms without changing a Babel config. 6 | 7 | All of Emotion's Babel Macros are available by adding `/macro` to the end of the import you'd normally use. (assuming you're using Create React App v2 or you've added babel-plugin-macros to your .babelrc) For example, to use the macro for styled, use `@emotion/styled/macro`. 8 | 9 | ```jsx 10 | import styled from '@emotion/styled/macro' 11 | import { jsx, css, Global, keyframes } from '@emotion/react/macro' 12 | import { css, keyframes, injectGlobal } from '@emotion/css/macro' 13 | ``` 14 | 15 | > Note 16 | > 17 | > There are some optimisations which aren't possible with Babel Macros, so if it's possible, we still recommend using @emotion/babel-plugin 18 | -------------------------------------------------------------------------------- /docs/eslint-plugin-react.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'eslint-plugin-react' 3 | --- 4 | 5 | The [`react/no-unknown-property` rule](https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/no-unknown-property.md) from [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) will produce an error if the `css` prop is passed to a DOM element. This violation of the rule can be safely ignored because `@emotion/react` intercepts the `css` prop before it is applied to the DOM element. 6 | 7 | The rule can be configured to ignore the `css` prop like so: 8 | 9 | ```json 10 | { 11 | "rules": { 12 | "react/no-unknown-property": ["error", { "ignore": ["css"] }] 13 | } 14 | } 15 | ``` 16 | -------------------------------------------------------------------------------- /docs/globals.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Global Styles' 3 | --- 4 | 5 | Sometimes you might want to insert global css like resets or font faces. You can use the `Global` component to do this. It accepts a `styles` prop which accepts the same values as the `css` prop except it inserts styles globally. Global styles are also removed when the styles change or when the Global component unmounts. 6 | 7 | ```jsx 8 | // @live 9 | import { Global, css } from '@emotion/react' 10 | 11 | render( 12 |
13 | 20 | 28 |
This is hotpink now!
29 |
30 | ) 31 | ``` 32 | -------------------------------------------------------------------------------- /docs/keyframes.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Keyframes' 3 | --- 4 | 5 | You can define animations using the `keyframes` helper from `@emotion/react`. `keyframes` takes in a css keyframe definition and returns an object you can use in styles. You can use strings or objects just like `css`. 6 | 7 | ```jsx 8 | // @live 9 | import { css, keyframes } from '@emotion/react' 10 | 11 | const bounce = keyframes` 12 | from, 20%, 53%, 80%, to { 13 | transform: translate3d(0,0,0); 14 | } 15 | 16 | 40%, 43% { 17 | transform: translate3d(0, -30px, 0); 18 | } 19 | 20 | 70% { 21 | transform: translate3d(0, -15px, 0); 22 | } 23 | 24 | 90% { 25 | transform: translate3d(0,-4px,0); 26 | } 27 | ` 28 | 29 | render( 30 |
35 | some bouncing text! 36 |
37 | ) 38 | ``` 39 | -------------------------------------------------------------------------------- /docs/source-maps.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Source Maps' 3 | --- 4 | 5 | > Note: 6 | > 7 | > `@emotion/babel-plugin` is required for source maps 8 | 9 | Emotion supports source maps for styles authored in JavaScript. 10 | 11 | ![Source map demo](https://user-images.githubusercontent.com/662750/30778580-78fbeae4-a096-11e7-82e1-120b6984e875.gif) 12 | 13 | Required For Source Maps: 14 | 15 | 1. `@emotion/babel-plugin` must be in your Babel setup. [[documentation]](/docs/install.mdx) 16 | 2. `process.env.NODE_ENV` must be any value except `"production"` 17 | 18 | > Note: 19 | > 20 | > Source maps are on by default in @emotion/babel-plugin but they will be removed in production builds 21 | -------------------------------------------------------------------------------- /docs/with-props.mdx: -------------------------------------------------------------------------------- 1 | --- 2 | title: 'Attaching Props' 3 | --- 4 | 5 | Some css-in-js libraries offer APIs to attach props to components, instead of having our own API to do that, we recommend creating a regular react component, using the css prop and attaching props like you would with any other React component. 6 | 7 | Note that if css is passed down via props, it will take precedence over the css in the component. 8 | 9 | ```jsx 10 | // @live 11 | import { css } from '@emotion/react' 12 | 13 | const pinkInput = css` 14 | background-color: pink; 15 | ` 16 | const RedPasswordInput = props => ( 17 | 25 | ) 26 | 27 | render( 28 |
29 | 30 | 31 |
32 | ) 33 | ``` 34 | -------------------------------------------------------------------------------- /emotion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotion-js/emotion/cce67ec6b2fc94261028b4f4778aae8c3d6c5fd6/emotion.png -------------------------------------------------------------------------------- /flow-typed/npm/vitest_vx.x.x.js: -------------------------------------------------------------------------------- 1 | declare var vi: {} 2 | -------------------------------------------------------------------------------- /jest-react18.config.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('./jest.config.js') 2 | 3 | module.exports = Object.assign({}, baseConfig, { 4 | moduleNameMapper: { 5 | '^react($|\\/.+)': 'react18$1', 6 | '^react-dom($|\\/.+)': 'react18-dom$1', 7 | '^react-test-renderer($|\\/.+)': 'react18-test-renderer$1' 8 | } 9 | }) 10 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | testEnvironment: 'jsdom', 3 | testEnvironmentOptions: { 4 | customExportConditions: ['development'] 5 | }, 6 | transform: { 7 | '^.+\\.(tsx|ts|js)?$': 'babel-jest' 8 | }, 9 | watchPlugins: [ 10 | 'jest-watch-typeahead/filename', 11 | 'jest-watch-typeahead/testname' 12 | ], 13 | testPathIgnorePatterns: [ 14 | '/node_modules/', 15 | '/__fixtures__/', 16 | '/site/', 17 | '/types/' 18 | ], 19 | setupFilesAfterEnv: ['test-utils/testSetup.js'], 20 | coveragePathIgnorePatterns: [ 21 | '/node_modules/', 22 | '/packages/babel-plugin/test/util.js' 23 | ], 24 | snapshotFormat: { 25 | escapeString: false, 26 | printBasicPrototype: false 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /jest.dist.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('./jest.config.js') 2 | 3 | module.exports = Object.assign({}, baseConfig, { 4 | transformIgnorePatterns: ['dist', 'node_modules'] 5 | }) 6 | -------------------------------------------------------------------------------- /jest.prod.js: -------------------------------------------------------------------------------- 1 | const baseConfig = require('./jest.config.js') 2 | 3 | module.exports = Object.assign({}, baseConfig, { 4 | testEnvironmentOptions: { 5 | ...baseConfig.testEnvironmentOptions, 6 | customExportConditions: 7 | baseConfig.testEnvironmentOptions.customExportConditions.filter( 8 | c => c !== 'development' 9 | ) 10 | } 11 | }) 12 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "yarn build && cd site && yarn build" 3 | publish = "site/out" 4 | 5 | [build.environment] 6 | NODE_VERSION = "16" 7 | YARN_VERSION = "1.22.19" 8 | YARN_FLAGS = "--immutable" 9 | NETLIFY = "true" 10 | 11 | # These take effect in production and should match the redirects in next.config.js 12 | [[redirects]] 13 | from = "/" 14 | to = "/docs/introduction" 15 | 16 | [[redirects]] 17 | from = "/docs" 18 | to = "/docs/introduction" 19 | 20 | [[redirects]] 21 | from = "/community" 22 | to = "/docs/community" -------------------------------------------------------------------------------- /packages/babel-plugin-jsx-pragmatic/__tests__/__fixtures__/existing-imports.js: -------------------------------------------------------------------------------- 1 | // inserted import has to go AFTER polyfills 2 | import 'react-app-polyfill/ie11' 3 | import 'react-app-polyfill/stable' 4 | 5 | import React from 'react' 6 | import ReactDOM from 'react-dom' 7 | import App from './App' 8 | 9 | ReactDOM.render(, document.getElementById('root')) 10 | -------------------------------------------------------------------------------- /packages/babel-plugin-jsx-pragmatic/__tests__/__fixtures__/fragment-only.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | 3 | const F = () => <> 4 | -------------------------------------------------------------------------------- /packages/babel-plugin-jsx-pragmatic/__tests__/__fixtures__/minimal.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | 3 | const P = () =>

4 | -------------------------------------------------------------------------------- /packages/babel-plugin-jsx-pragmatic/__tests__/index.js: -------------------------------------------------------------------------------- 1 | import babelTester from 'babel-tester' 2 | import jsxPragmatic from '@emotion/babel-plugin-jsx-pragmatic' 3 | import { transformSync } from '@babel/core' 4 | 5 | babelTester('@emotion/babel-plugin-jsx-pragmatic', __dirname, { 6 | plugins: [ 7 | [ 8 | jsxPragmatic, 9 | { 10 | export: 'jsx', 11 | module: '@emotion/react', 12 | import: '___EmotionJSX' 13 | } 14 | ] 15 | ] 16 | }) 17 | 18 | test('babel-plugin-jsx-pragmatic should throw error when invalid options', () => { 19 | expect(() => { 20 | transformSync('<>', { 21 | filename: __filename, 22 | plugins: [[jsxPragmatic, { export: 'jsx' }]] 23 | }) 24 | }).toThrow( 25 | '@emotion/babel-plugin-jsx-pragmatic: You must specify `module` and `import`' 26 | ) 27 | }) 28 | -------------------------------------------------------------------------------- /packages/babel-plugin-jsx-pragmatic/babel__plugin-syntax-jsx.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@babel/plugin-syntax-jsx' { 2 | const plugin: any 3 | export default plugin 4 | } 5 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/__fixtures__/autolabel-and-css-property-label.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { jsx, css } from '@emotion/react' 3 | 4 | const SomeComponent = () => ( 5 |

11 | ) 12 | 13 | const OtherComponent = () => ( 14 |
20 | ) 21 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/__fixtures__/core-with-component.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled' 2 | 3 | const MyComponent = styled.div({ color: 'hotpink' }) 4 | 5 | const OtherComponent = MyComponent.withComponent('section') 6 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/__fixtures__/core-with-css-import-dynamic.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { jsx, css } from '@emotion/react' 3 | 4 | const SomeComponent = props => ( 5 |
11 | ) 12 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/__fixtures__/core-with-css-import.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { jsx, css } from '@emotion/react' 3 | 4 | const SomeComponent = props => ( 5 |
11 | ) 12 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/__fixtures__/css-prop-complex-array.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { jsx, Global } from '@emotion/react/macro' 3 | 4 | const css1 = theme => ({ backgroundColor: theme.bgColor }) 5 | const css2 = theme => ({ padding: theme.spacing.small }) 6 | 7 | function SomeComponent(props) { 8 | return
{'Emotion'}
9 | } 10 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/__fixtures__/does-not-change-other-props.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { jsx } from '@emotion/react' 3 | 4 | const Svg = 5 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/__fixtures__/dynamic.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { jsx } from '@emotion/react' 3 | 4 | const SomeComponent = props =>
5 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/__fixtures__/function-declaration.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { jsx } from '@emotion/react' 3 | 4 | function Logo(props) { 5 | return ( 6 | 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/__fixtures__/import-namespace-does-not-throw.js: -------------------------------------------------------------------------------- 1 | import * as emotionCore from '@emotion/react' 2 | // could probably support this for real but it's pretty rare so I'm not gonna spend time on it now 3 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/__fixtures__/jsx-hoist.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { jsx } from '@emotion/react' 3 | 4 | const SomeComponent = props => ( 5 |
11 | ) 12 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/__fixtures__/object-property.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { jsx } from '@emotion/react' 3 | import styled from '@emotion/styled' 4 | 5 | const MyObject = { 6 | MyProperty: styled.div({ color: 'hotpink' }) 7 | } 8 | 9 | function Logo(props) { 10 | return 11 | } 12 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/__fixtures__/static-object-with-camel-case.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { jsx } from '@emotion/react' 3 | 4 | const SomeComponent = props => ( 5 |
12 | ) 13 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/__fixtures__/static-object-with-child-selectors.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | 3 | import { jsx } from '@emotion/react' 4 | 5 | const SomeComponent = props => { 6 | return ( 7 |
16 | ) 17 | } 18 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/actual-expected-usage.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { jsx, css } from '@emotion/react/macro' 3 | 4 | const SomeComponent = () => ( 5 |
10 | ) 11 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/already-transpiled-by-babel.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import css from '@emotion/css/macro' 3 | import _taggedTemplateLiteralLoose from '@babel/runtime/helpers/esm/taggedTemplateLiteralLoose' 4 | 5 | function _templateObject() { 6 | var data = _taggedTemplateLiteralLoose(['\n color: hotpink;\n ']) 7 | 8 | _templateObject = function _templateObject() { 9 | return data 10 | } 11 | 12 | return data 13 | } 14 | 15 | // no label & source maps should be appended 16 | const fooStyles = css(_templateObject()) 17 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/basic.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | function doThing() { 4 | return css` 5 | display: flex; 6 | ` 7 | } 8 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/call-expression.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | function doThing() { 4 | return css({ color: 'hotpink' }) 5 | } 6 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/call-inside-call.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | const thing = css` 4 | display: flex; 5 | &:hover { 6 | ${css` 7 | color: hotpink; 8 | `}; 9 | } 10 | ` 11 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/comment-with-interpolation.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | css` 4 | // color: ${'green'}; 5 | /* 6 | 7 | something: ${'something'}; 8 | 9 | */ 10 | color: hotpink; 11 | ` 12 | 13 | css` 14 | // color: ${'green'}; 15 | /* 16 | 17 | something: ${'something'}; 18 | 19 | */ 20 | color: ${'hotpink'}; 21 | ` 22 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/impure.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | function thing() {} 4 | 5 | function doThing() { 6 | return css` 7 | display: ${thing()}; 8 | ` 9 | } 10 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/inside-anonymous-arrow-function.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | export default () => { 4 | css` 5 | color: hotpink; 6 | ` 7 | } 8 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/inside-anonymous-function.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | export default () => { 4 | css` 5 | color: hotpink; 6 | ` 7 | } 8 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/inside-class.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { Component } from 'react' 3 | import { jsx, css } from '@emotion/react/macro' 4 | 5 | class SomeComponent extends Component { 6 | render() { 7 | return ( 8 |
13 | ) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/label-1.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | const thing = css` 4 | color: hotpink; 5 | ` 6 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/label-arrow-as-obj-property.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | export const styles = { 4 | colorFn1: () => css` 5 | color: hotpink; 6 | ` 7 | } 8 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/label-arrow-function-expression.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | const thing = () => css` 4 | color: hotpink; 5 | ` 6 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/label-function-expression-as-obj-property.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | export const styles = { 4 | colorFn1: function () { 5 | return css` 6 | color: hotpink; 7 | ` 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/label-function-expression-named.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | const thing = function someName() { 4 | return css` 5 | color: hotpink; 6 | ` 7 | } 8 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/label-function-expression.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | const thing = function () { 4 | return css` 5 | color: hotpink; 6 | ` 7 | } 8 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/label-no-final-semi.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | // prettier-ignore 4 | const thing = css` 5 | color: hotpink 6 | ` 7 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/label-obj-method.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | const obj = { 4 | FooBar() { 5 | return ( 6 |
11 | ) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/label-obj-property-literal.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | const obj = { 4 | 'red component': ( 5 |
10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/label-object.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | const thing = { 4 | thisShouldBeTheLabel: css` 5 | color: hotpink; 6 | `, 7 | // prettier-ignore 8 | 'shouldBeAnotherLabel':css` 9 | color:green; 10 | ` 11 | } 12 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/label-transpiled-by-ts-with-interpolations.js: -------------------------------------------------------------------------------- 1 | import { __makeTemplateObject } from 'tslib' 2 | import css from '@emotion/react/macro' 3 | import { hoverStyles } from './styles' 4 | 5 | var templateObject_1 6 | 7 | const someVar = css( 8 | templateObject_1 || 9 | (templateObject_1 = __makeTemplateObject( 10 | ['\n color: hotpink;\n'], 11 | ['\n color: hotpink;\n'] 12 | )), 13 | hoverStyles 14 | ) 15 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/label-transpiled-by-ts.js: -------------------------------------------------------------------------------- 1 | import { __makeTemplateObject } from 'tslib' 2 | import { css } from '@emotion/react/macro' 3 | 4 | var templateObject_1 5 | 6 | const someVar = css( 7 | templateObject_1 || 8 | (templateObject_1 = __makeTemplateObject( 9 | ['\n color: hotpink;\n'], 10 | ['\n color: hotpink;\n'] 11 | )) 12 | ) 13 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/multiple-calls.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | const thing = css` 4 | color: hotpink; 5 | ` 6 | 7 | const otherThing = css` 8 | color: green; 9 | ` 10 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/no-actual-import.js: -------------------------------------------------------------------------------- 1 | import '@emotion/react/macro' 2 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/no-label-array-pattern.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | const [weirdo] = [ 4 | css` 5 | color: hotpink; 6 | ` 7 | ] 8 | 9 | export default weirdo 10 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/no-label-obj-pattern-computed-property.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | const computed = 'weirdo' 4 | 5 | const { weirdo } = { 6 | [computed]: css` 7 | color: hotpink; 8 | ` 9 | } 10 | 11 | export default weirdo 12 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/object-dynamic-property.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | function doThing() { 4 | return { 5 | [css({ color: 'hotpink' })]: 'coldblue' 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/object-pattern-variable-declarator.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react' 2 | import { extractCritical } from '@emotion/server' 3 | import React from 'react' 4 | import { renderToString } from 'react-dom/server' 5 | 6 | const { css: styles } = extractCritical( 7 | renderToString( 8 |
13 | ) 14 | ) 15 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/other-imports.js: -------------------------------------------------------------------------------- 1 | import { nonExistantImport } from '@emotion/react/macro' 2 | 3 | nonExistantImport() 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/remove-block-comments.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | css` 4 | /* color:green; 5 | ddjfwjkng 6 | */ 7 | color: hotpink; 8 | ` 9 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/remove-line-comments.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | css` 4 | // color: green; 5 | color: hotpink; 6 | ` 7 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/__fixtures__/tagged-template-args-forwarded.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react/macro' 2 | 3 | function media(...args) { 4 | return css` 5 | @media (min-width: 100px) { 6 | ${css(...args)}; 7 | } 8 | ` 9 | } 10 | 11 | const test = css` 12 | ${media`color: red;`}; 13 | ` 14 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css-macro/index.js: -------------------------------------------------------------------------------- 1 | import babelTester from 'babel-tester' 2 | 3 | babelTester('@emotion/react - css macro', __dirname) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/css.js: -------------------------------------------------------------------------------- 1 | import babelTester from 'babel-tester' 2 | import plugin from '@emotion/babel-plugin' 3 | import path from 'path' 4 | 5 | babelTester('emotion-babel-plugin css', path.join(__dirname, 'css-macro'), { 6 | plugins: [plugin], 7 | transform: src => src.replace(/\/macro/g, '') 8 | }) 9 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/disable-source-map/__fixtures__/css.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react' 2 | 3 | let style = css({ color: 'hotpink' }) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/disable-source-map/__fixtures__/styled.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled' 2 | 3 | let Comp = styled.div({ color: 'hotpink' }) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/disable-source-map/__fixtures__/vanilla.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/css' 2 | 3 | let cls = css({ color: 'hotpink' }) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/disable-source-map/index.js: -------------------------------------------------------------------------------- 1 | import babelTester from 'babel-tester' 2 | import plugin from '@emotion/babel-plugin' 3 | 4 | babelTester('disable source map', __dirname, { 5 | plugins: [[plugin, { sourceMap: false }]] 6 | }) 7 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/global-macro/__fixtures__/basic-array.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { Global } from '@emotion/react/macro' 3 | 4 | export default () => ( 5 | 6 | ) 7 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/global-macro/__fixtures__/basic-obj.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { Global } from '@emotion/react/macro' 3 | 4 | export default () => 5 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/global-macro/__fixtures__/complex-array.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { Global } from '@emotion/react/macro' 3 | 4 | const getBgColor = () => ({ backgroundColor: '#fff' }) 5 | 6 | export default () => 7 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/global-macro/__fixtures__/complex-obj.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { Global } from '@emotion/react/macro' 3 | 4 | const getBgColor = () => ({ backgroundColor: '#fff' }) 5 | 6 | export default () => 7 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/global-macro/__fixtures__/css-used-as-value.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { Global, css } from '@emotion/react/macro' 3 | 4 | // this gets ignored by Global macro, but it tests that this combination doesn't crash or something 5 | export default () => 6 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/global-macro/__fixtures__/no-jsx.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { Global } from '@emotion/react/macro' 3 | 4 | const foo = Global 5 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/global-macro/__fixtures__/no-styles-prop.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { Global } from '@emotion/react/macro' 3 | 4 | export default () => 5 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/global-macro/__fixtures__/spread-styles.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import * as React from 'react' 3 | import { Global } from '@emotion/react/macro' 4 | 5 | export default () => 6 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/global-macro/__fixtures__/with-closing-element.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import * as React from 'react' 3 | import { Global } from '@emotion/react/macro' 4 | 5 | // prettier-ignore 6 | export default () => 7 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/global-macro/index.js: -------------------------------------------------------------------------------- 1 | import babelTester from 'babel-tester' 2 | 3 | babelTester('@emotion/react - Global macro', __dirname) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/global-requires-options.js: -------------------------------------------------------------------------------- 1 | import babelTester from 'babel-tester' 2 | import plugin from '@emotion/babel-plugin' 3 | 4 | const cases = { 5 | 'source maps can be disabled': { 6 | code: ` 7 | import * as React from 'react' 8 | import { Global } from '@emotion/react' 9 | 10 | export default () => 11 | `, 12 | plugins: [[plugin, { sourceMap: false }]] 13 | } 14 | } 15 | 16 | babelTester('Global inline', cases) 17 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/global.js: -------------------------------------------------------------------------------- 1 | import babelTester from 'babel-tester' 2 | import plugin from '@emotion/babel-plugin' 3 | import path from 'path' 4 | 5 | babelTester( 6 | 'emotion-babel-plugin Global', 7 | path.join(__dirname, 'global-macro'), 8 | { 9 | plugins: [plugin], 10 | transform: src => src.replace(/\/macro/g, '') 11 | } 12 | ) 13 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/import-mapping/__fixtures__/global-needs-css.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { SomeGlobalFromCore } from 'package-two' 3 | 4 | const getBgColor = () => ({ backgroundColor: '#fff' }) 5 | 6 | export default () => ( 7 | 8 | ) 9 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/import-mapping/__fixtures__/global.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { SomeGlobalFromCore } from 'package-two' 3 | 4 | export default () => 5 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/import-mapping/__fixtures__/jsx.js: -------------------------------------------------------------------------------- 1 | /** @jsx someJsx */ 2 | import { someJsx } from 'package-two' 3 | 4 | const SomeComponent = props =>
5 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/import-mapping/__fixtures__/non-default-styled-aliased.js: -------------------------------------------------------------------------------- 1 | import { nonDefaultStyled as someAlias } from 'package-one' 2 | 3 | let SomeComp = someAlias.div({ color: 'hotpink' }) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/import-mapping/__fixtures__/non-default-styled.js: -------------------------------------------------------------------------------- 1 | import { nonDefaultStyled } from 'package-one' 2 | 3 | let SomeComp = nonDefaultStyled.div({ color: 'hotpink' }) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/import-mapping/__fixtures__/styled-with-base-specified.js: -------------------------------------------------------------------------------- 1 | import { nonDefaultStyled } from 'package-four' 2 | 3 | let SomeComp = nonDefaultStyled.div({ color: 'hotpink' }) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/import-mapping/__fixtures__/vanilla.js: -------------------------------------------------------------------------------- 1 | import { something } from 'package-three' 2 | 3 | something({ color: 'green' }) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/index.js: -------------------------------------------------------------------------------- 1 | import babelTester from 'babel-tester' 2 | import plugin from '@emotion/babel-plugin' 3 | 4 | babelTester('@emotion/babel-plugin', __dirname, { 5 | // we add a duplicate of our own plugin 6 | // users may run babel twice, and our plugin should be smart enough to not duplicate fields 7 | plugins: [plugin, [plugin, undefined, 'emotion-copy']] 8 | }) 9 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/source-maps/__fixtures__/css-object.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react' 2 | 3 | css({ color: 'hotpink' }) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/source-maps/__fixtures__/css-prop-dynamic.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { jsx } from '@emotion/react' 3 | 4 | const SomeComponent = props => ( 5 |
11 | ) 12 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/source-maps/__fixtures__/css-prop.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { jsx } from '@emotion/react' 3 | 4 | const SomeComponent = props =>
5 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/source-maps/__fixtures__/css-string.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/react' 2 | 3 | css` 4 | color: hotpink; 5 | ` 6 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/source-maps/__fixtures__/css-transpiled-by-ts-with-interpolations.js: -------------------------------------------------------------------------------- 1 | import { __makeTemplateObject } from 'tslib' 2 | import { css } from '@emotion/react' 3 | import { hoverStyles } from './styles' 4 | 5 | var templateObject_1 6 | 7 | css( 8 | templateObject_1 || 9 | (templateObject_1 = __makeTemplateObject( 10 | ['\n color: hotpink;\n'], 11 | ['\n color: hotpink;\n'] 12 | )), 13 | hoverStyles 14 | ) 15 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/source-maps/__fixtures__/css-transpiled-by-ts.js: -------------------------------------------------------------------------------- 1 | import { __makeTemplateObject } from 'tslib' 2 | import { css } from '@emotion/react' 3 | 4 | var templateObject_1 5 | 6 | css( 7 | templateObject_1 || 8 | (templateObject_1 = __makeTemplateObject( 9 | ['\n color: hotpink;\n'], 10 | ['\n color: hotpink;\n'] 11 | )) 12 | ) 13 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/source-maps/__fixtures__/global-styles-prop.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { Global } from '@emotion/react' 3 | 4 | export default () => 5 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/source-maps/__fixtures__/styled-object.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled' 2 | 3 | const SomeComponent = styled.div({ 4 | color: 'hotpink' 5 | }) 6 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/source-maps/__fixtures__/styled-string.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled' 2 | 3 | const SomeComponent = styled.div` 4 | color: hotpink; 5 | ` 6 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/source-maps/index.js: -------------------------------------------------------------------------------- 1 | import babelTester from 'babel-tester' 2 | import plugin from '@emotion/babel-plugin' 3 | 4 | babelTester('source maps', __dirname, { 5 | plugins: [[plugin, { sourceMap: true }]], 6 | filename: 'source-map.test.js' 7 | }) 8 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/already-transpiled-by-babel.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import styled from '@emotion/styled/macro' 3 | import _taggedTemplateLiteralLoose from '@babel/runtime/helpers/esm/taggedTemplateLiteralLoose' 4 | 5 | function _templateObject() { 6 | var data = _taggedTemplateLiteralLoose(['\n color: hotpink;\n ']) 7 | 8 | _templateObject = function _templateObject() { 9 | return data 10 | } 11 | 12 | return data 13 | } 14 | 15 | // source maps should not be appended 16 | const SomeComponent = styled('div')(_templateObject()) 17 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/auto-inserted-rule-in-at-rule-preceeded-by-interpolation.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | import { css } from '@emotion/react' 3 | 4 | const fullWidth = css` 5 | width: 100%; 6 | ` 7 | 8 | const StyledRoot = styled.div` 9 | ${fullWidth} 10 | 11 | button { 12 | @media (min-width: 768px) { 13 | color: red; 14 | } 15 | } 16 | ` 17 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/basic.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | const SomeComponent = styled.div` 4 | color: hotpink; 5 | ` 6 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/call-expression.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | const SomeComponent = styled('div')` 4 | color: hotpink; 5 | ` 6 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/comments.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | styled.div` 4 | // display:flex; 5 | 6 | /* 7 | wef 8 | 9 | dfwf */ 10 | color: hotpink; 11 | ` 12 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/component-selector.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | const SomeComponent = styled.div` 4 | color: hotpink; 5 | ` 6 | 7 | let SomeOtherComponent = styled.div({ color: 'hotpink' }) 8 | 9 | let AnotherComponent = styled.div` 10 | ${SomeComponent} { 11 | color: green; 12 | } 13 | ${SomeOtherComponent} { 14 | color: green; 15 | } 16 | ` 17 | 18 | let OneLastComponent = styled.div({ 19 | [SomeComponent]: { 20 | color: 'green' 21 | }, 22 | [SomeOtherComponent]: { 23 | color: 'green' 24 | } 25 | }) 26 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/existing-options.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | styled('div', { shouldForwardProp: window.whatever }, window.whatever)() 4 | 5 | styled('div', { shouldForwardProp: window.whatever }, window.whatever)`` 6 | 7 | styled( 8 | window.whatever, 9 | { shouldForwardProp: window.whatever }, 10 | window.whatever 11 | )() 12 | 13 | styled( 14 | window.whatever, 15 | { shouldForwardProp: window.whatever }, 16 | window.whatever 17 | )`` 18 | 19 | const cfg = { shouldForwardProp: window.whatever } 20 | styled('button', cfg)({}) 21 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/function-interpolation.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | let Avatar = styled.img` 4 | width: 96px; 5 | height: 96px; 6 | border-radius: ${props => props.theme.borderRadius}; 7 | border: 1px solid ${props => props.theme.borderColor}; 8 | ` 9 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/label-assignment-expression.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import styled from '@emotion/styled/macro' 3 | import { jsx } from '@emotion/react' 4 | 5 | let Comp 6 | Comp = styled.div`` 7 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/label-class-fields.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import styled from '@emotion/styled/macro' 3 | import { jsx } from '@emotion/react' 4 | 5 | class Thing { 6 | static SomeComponent = styled.div` 7 | color: hotpink; 8 | ` 9 | BadIdeaComponent = styled.div` 10 | background: hotpink; 11 | ` 12 | } 13 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/label-member-expression.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import styled from '@emotion/styled/macro' 3 | import { jsx } from '@emotion/react' 4 | 5 | const Timeline = styled.ul`` 6 | Timeline.Item = styled.li`` 7 | Timeline.Item.Anchor = styled.a`` 8 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/label-sanitize.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | /* eslint-disable react/jsx-pascal-case */ 3 | import styled from '@emotion/styled/macro' 4 | import { jsx } from '@emotion/react' 5 | 6 | const MiniCalWrap$ = styled.div` 7 | color: red; 8 | ` 9 | const Test = () => 10 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/label.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | /* eslint-disable react/jsx-pascal-case */ 3 | import styled from '@emotion/styled/macro' 4 | import { jsx } from '@emotion/react' 5 | 6 | let SomeComp = styled.div({ color: 'hotpink' }) 7 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/more-than-10-interpolations.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | // yes, this was actually a bug at one point 4 | const H1 = styled.h1` 5 | text-decoration: ${'underline'}; 6 | border-right: solid blue ${54}px; 7 | background: ${'white'}; 8 | color: ${'black'}; 9 | display: ${'block'}; 10 | border-radius: ${'3px'}; 11 | padding: ${'25px'}; 12 | width: ${'500px'}; 13 | z-index: ${100}; 14 | font-size: ${'18px'}; 15 | text-align: ${'center'}; 16 | border-left: ${p => p.theme.blue}; 17 | ` 18 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/multiple-calls.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | const SomeComponent = styled.div` 4 | color: hotpink; 5 | ` 6 | 7 | const SomeOtherComponent = styled.button` 8 | color: green; 9 | ` 10 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/native.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/native' 2 | 3 | styled.View` 4 | color: hotpink; 5 | ` 6 | 7 | styled.View({}) 8 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/no-call.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | export let thing = styled 4 | 5 | console.log(styled) 6 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/no-import.js: -------------------------------------------------------------------------------- 1 | import '@emotion/styled' 2 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/object-call-expression.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | const SomeComponent = styled('div')({ color: 'hotpink' }) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/object-function.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | const SomeComponent = styled.div(props => ({ color: props.color })) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/object.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | const SomeComponent = styled.div({ color: 'hotpink' }) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/other-imports.js: -------------------------------------------------------------------------------- 1 | import { something, otherThing } from '@emotion/styled' 2 | 3 | something() 4 | otherThing() 5 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/primitives-other-name.js: -------------------------------------------------------------------------------- 1 | import something from '@emotion/primitives' 2 | 3 | something.View` 4 | color: hotpink; 5 | ` 6 | 7 | something.View({}) 8 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/primitives.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/primitives' 2 | 3 | styled('SomeFakeComponent')` 4 | color: hotpink; 5 | ` 6 | 7 | styled('SomeFakeComponent')({}) 8 | 9 | styled.View` 10 | color: hotpink; 11 | ` 12 | 13 | styled.View({}) 14 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/same-nested-contex-value.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | export const Comp = styled.div` 4 | > div { 5 | color: blue; 6 | 7 | > div { 8 | color: hotpink; 9 | } 10 | } 11 | ` 12 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/shorthand-property.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | let fontSize = window.whatever 4 | 5 | const H1 = styled.h1({ fontSize }) 6 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/two-consecutive-interpolations.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | import { css } from '@emotion/react' 3 | 4 | const H1 = styled.h1` 5 | ${props => css` 6 | color: red; 7 | `} 8 | /* dummy comment */ 9 | ${props => css` 10 | text-transform: uppercase; 11 | `} 12 | ` 13 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/__fixtures__/with-spread.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled/macro' 2 | 3 | const H1 = styled.h1({ ...window.whatever }) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-macro/index.js: -------------------------------------------------------------------------------- 1 | import babelTester from 'babel-tester' 2 | 3 | babelTester('@emotion/styled.macro', __dirname) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled-requires-options.js: -------------------------------------------------------------------------------- 1 | import babelTester from 'babel-tester' 2 | import plugin from '@emotion/babel-plugin' 3 | 4 | const cases = { 5 | 'hash generation no file system': { 6 | code: ` 7 | import styled from '@emotion/styled' 8 | styled.h1\`color:blue;\` 9 | `, 10 | plugins: [plugin], 11 | babelFileName: undefined 12 | }, 13 | 'autoLabel set to never': { 14 | code: ` 15 | import styled from '@emotion/styled' 16 | const Foo = styled.h1\`color:hotpink;\` 17 | `, 18 | plugins: [[plugin, { autoLabel: 'never' }]], 19 | babelFileName: __filename 20 | } 21 | } 22 | 23 | babelTester('styled inline', cases) 24 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/styled.js: -------------------------------------------------------------------------------- 1 | import babelTester from 'babel-tester' 2 | import plugin from '@emotion/babel-plugin' 3 | import path from 'path' 4 | 5 | babelTester( 6 | 'emotion-babel-plugin styled', 7 | path.join(__dirname, 'styled-macro'), 8 | { 9 | plugins: [plugin], 10 | transform: src => src.replace(/\/macro/g, '') 11 | } 12 | ) 13 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/vanilla-emotion-macro/__fixtures__/comments.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/css/macro' 2 | 3 | css` 4 | // display:flex; 5 | 6 | /* 7 | wef 8 | 9 | dfwf*/ 10 | color: hotpink; 11 | ` 12 | 13 | css` 14 | /* @noflip */ 15 | left: 1px; 16 | ` 17 | 18 | css` 19 | left: 2px; 20 | 21 | /* @noflip */ 22 | &.foo { 23 | left: 3px; 24 | } 25 | 26 | &.zot { 27 | /* @noflip */ 28 | right: 1px; 29 | } 30 | ` 31 | 32 | css` 33 | /* @whatever */ 34 | left: 4px; 35 | ` 36 | 37 | css` 38 | left: 5px; 39 | 40 | /* @whatever */ 41 | &.foo { 42 | left: 6px; 43 | } 44 | 45 | &.zot { 46 | /* @whatever */ 47 | right: 2px; 48 | } 49 | ` 50 | 51 | css` 52 | // @noflip should-be-removed 53 | left: 7px; 54 | ` 55 | 56 | css` 57 | // @shouldberemoved 58 | left: 8px; 59 | ` 60 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/vanilla-emotion-macro/__fixtures__/css-basic.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/css/macro' 2 | 3 | css` 4 | margin: 12px 48px; 5 | color: #ffffff; 6 | display: flex; 7 | flex: 1 0 auto; 8 | color: blue; 9 | @media (min-width: 420px) { 10 | line-height: 40px; 11 | } 12 | width: ${window.whatever}; 13 | ` 14 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/vanilla-emotion-macro/__fixtures__/css-object.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/css/macro' 2 | 3 | let someCls = css({ 4 | color: window.whatever 5 | }) 6 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/vanilla-emotion-macro/__fixtures__/does-not-minify-inside-content-property.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/css/macro' 2 | 3 | const cls1 = css` 4 | content: ' { } '; 5 | ` 6 | // prettier-ignore 7 | const cls2 = css` 8 | content: " { } "; 9 | ` 10 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/vanilla-emotion-macro/__fixtures__/inject-global-basic.js: -------------------------------------------------------------------------------- 1 | import { injectGlobal } from '@emotion/css/macro' 2 | 3 | injectGlobal` 4 | body { 5 | margin: 0; 6 | padding: 0; 7 | & > div { 8 | display: flex; 9 | } 10 | } 11 | html { 12 | background: green; 13 | } 14 | ` 15 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/vanilla-emotion-macro/__fixtures__/inject-global-change-import.js: -------------------------------------------------------------------------------- 1 | import { injectGlobal as inject } from '@emotion/css/macro' 2 | 3 | inject` 4 | body { 5 | margin: 0; 6 | padding: 0; 7 | & > div { 8 | display: flex; 9 | } 10 | } 11 | html { 12 | background: green; 13 | } 14 | ` 15 | 16 | let injectGlobal = window.whatever 17 | 18 | injectGlobal` 19 | body { 20 | margin: 0; 21 | padding: 0; 22 | & > div { 23 | display: flex; 24 | } 25 | } 26 | html { 27 | background: green; 28 | } 29 | ` 30 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/vanilla-emotion-macro/__fixtures__/inject-global-with-font-face.js: -------------------------------------------------------------------------------- 1 | import { injectGlobal } from '@emotion/css/macro' 2 | 3 | injectGlobal` 4 | @font-face { 5 | font-family: 'Patrick Hand SC'; 6 | font-style: normal; 7 | font-weight: 400; 8 | src: local('Patrick Hand SC'), local('PatrickHandSC-Regular'), 9 | url(https://fonts.gstatic.com/s/patrickhandsc/v4/OYFWCgfCR-7uHIovjUZXsZ71Uis0Qeb9Gqo8IZV7ckE.woff2) 10 | format('woff2'); 11 | unicode-range: U+0100-024f, U+1-1eff, U+20a0-20ab, U+20ad-20cf, U+2c60-2c7f, 12 | U+A720-A7FF; 13 | } 14 | ` 15 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/vanilla-emotion-macro/__fixtures__/inject-global-with-interpolation.js: -------------------------------------------------------------------------------- 1 | import { injectGlobal } from '@emotion/css/macro' 2 | 3 | let display = window.whatever 4 | 5 | injectGlobal` 6 | body { 7 | margin: 0; 8 | padding: 0; 9 | display: ${display}; 10 | & > div { 11 | display: none; 12 | } 13 | } 14 | html { 15 | background: green; 16 | } 17 | ` 18 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/vanilla-emotion-macro/__fixtures__/keyframes-basic.js: -------------------------------------------------------------------------------- 1 | import { keyframes } from '@emotion/css/macro' 2 | 3 | const rotate360 = keyframes` 4 | from { 5 | transform: rotate(0deg); 6 | } 7 | to { 8 | transform: rotate(360deg); 9 | } 10 | ` 11 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/vanilla-emotion-macro/__fixtures__/keyframes-with-interpolation.js: -------------------------------------------------------------------------------- 1 | import { keyframes } from '@emotion/css/macro' 2 | 3 | let endingRotation = window.whatever 4 | 5 | const rotate360 = keyframes` 6 | from { 7 | transform: rotate(0deg); 8 | } 9 | to { 10 | transform: rotate(${endingRotation}); 11 | } 12 | ` 13 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/vanilla-emotion-macro/__fixtures__/nested-orphaned-pseudo.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/css/macro' 2 | 3 | // whitespace before pseudo should be preserved 4 | css` 5 | & :hover { 6 | color: hotpink; 7 | } 8 | ` 9 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/vanilla-emotion-macro/__fixtures__/object-label.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/css/macro' 2 | 3 | let obj = { 4 | someProp: css({ color: 'green' }), 5 | anotherProp: css({ color: 'hotpink' }) 6 | } 7 | class Thing { 8 | static Prop = css({ color: 'yellow' }) 9 | BadIdea = css({ color: 'red' }) 10 | } 11 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/vanilla-emotion-macro/index.js: -------------------------------------------------------------------------------- 1 | import babelTester from 'babel-tester' 2 | 3 | babelTester('vanilla emotion', __dirname) 4 | -------------------------------------------------------------------------------- /packages/babel-plugin/__tests__/vanilla-emotion.js: -------------------------------------------------------------------------------- 1 | import babelTester from 'babel-tester' 2 | import plugin from '@emotion/babel-plugin' 3 | import path from 'path' 4 | 5 | babelTester('vanilla emotion', path.join(__dirname, 'vanilla-emotion-macro'), { 6 | plugins: [plugin], 7 | transform: src => src.replace(/\/macro/g, '') 8 | }) 9 | -------------------------------------------------------------------------------- /packages/babel-plugin/src/utils/add-import.js: -------------------------------------------------------------------------------- 1 | import { addDefault, addNamed } from '@babel/helper-module-imports' 2 | 3 | export function addImport( 4 | state, 5 | importSource /*: string */, 6 | importedSpecifier /*: string */, 7 | nameHint /* ?: string */ 8 | ) { 9 | let cacheKey = ['import', importSource, importedSpecifier].join(':') 10 | if (state[cacheKey] === undefined) { 11 | let importIdentifier 12 | if (importedSpecifier === 'default') { 13 | importIdentifier = addDefault(state.file.path, importSource, { nameHint }) 14 | } else { 15 | importIdentifier = addNamed( 16 | state.file.path, 17 | importedSpecifier, 18 | importSource, 19 | { 20 | nameHint 21 | } 22 | ) 23 | } 24 | state[cacheKey] = importIdentifier.name 25 | } 26 | return { 27 | type: 'Identifier', 28 | name: state[cacheKey] 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /packages/babel-plugin/src/utils/create-node-env-conditional.js: -------------------------------------------------------------------------------- 1 | export default function createNodeEnvConditional(t, production, development) { 2 | return t.conditionalExpression( 3 | t.binaryExpression( 4 | '===', 5 | t.memberExpression( 6 | t.memberExpression(t.identifier('process'), t.identifier('env')), 7 | t.identifier('NODE_ENV') 8 | ), 9 | t.stringLiteral('production') 10 | ), 11 | production, 12 | development 13 | ) 14 | } 15 | -------------------------------------------------------------------------------- /packages/babel-plugin/src/utils/index.js: -------------------------------------------------------------------------------- 1 | export { getLabelFromPath } from './label' 2 | export { getSourceMap } from './source-maps' 3 | export { getTargetClassName } from './get-target-class-name' 4 | export { simplifyObject } from './object-to-string' 5 | export { transformExpressionWithStyles } from './transform-expression-with-styles' 6 | export { getStyledOptions } from './get-styled-options' 7 | export { 8 | appendStringReturningExpressionToArguments, 9 | joinStringLiterals 10 | } from './strings' 11 | export { addImport } from './add-import' 12 | export { createTransformerMacro } from './transformer-macro' 13 | -------------------------------------------------------------------------------- /packages/babel-preset-css-prop/__tests__/__fixtures__/array-css-prop.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | 3 | const Component = props =>
4 | -------------------------------------------------------------------------------- /packages/babel-preset-css-prop/__tests__/__fixtures__/index.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | 3 | export let Button = props => { 4 | return ( 5 | <> 6 | 9 | ) 10 | 11 | const cfg = { shouldForwardProp: p => p !== 'isRed' } 12 | const StyledButton = styled(Button, cfg)({}) 13 | const tree = renderer.create().toJSON() 14 | expect(tree.children).toEqual(['not forwarded']) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/styled/test/source-map.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { css } from '@emotion/react' 3 | import styled from '@emotion/styled' 4 | import renderer from 'react-test-renderer' 5 | 6 | test('inserts source map', () => { 7 | let Comp = styled.div` 8 | color: hotpink; 9 | ` 10 | renderer.create() 11 | expect(document.documentElement).toMatchSnapshot() 12 | }) 13 | 14 | test('source map with composed component', () => { 15 | let Comp = styled.div` 16 | color: hotpink; 17 | ` 18 | let Comp2 = styled(Comp)` 19 | background: yellow; 20 | ` 21 | renderer.create() 22 | expect(document.documentElement).toMatchSnapshot() 23 | }) 24 | 25 | test('source map with composed style', () => { 26 | let style = css({ color: 'green' }) 27 | let Comp2 = styled.div` 28 | background: yellow; 29 | ${style} 30 | ` 31 | renderer.create() 32 | expect(document.documentElement).toMatchSnapshot() 33 | }) 34 | -------------------------------------------------------------------------------- /packages/styled/types/base.d.ts: -------------------------------------------------------------------------------- 1 | // TypeScript Version: 4.1 2 | export * from '../base' 3 | -------------------------------------------------------------------------------- /packages/styled/types/index.d.ts: -------------------------------------------------------------------------------- 1 | // TypeScript Version: 4.1 2 | export * from '..' 3 | -------------------------------------------------------------------------------- /packages/styled/types/resolved-condition.ts: -------------------------------------------------------------------------------- 1 | export default true as boolean 2 | -------------------------------------------------------------------------------- /packages/styled/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "../", 4 | "forceConsistentCasingInFileNames": true, 5 | "isolatedModules": true, 6 | "jsx": "react", 7 | "lib": ["es6", "dom"], 8 | "module": "commonjs", 9 | "esModuleInterop": true, 10 | "resolveJsonModule": true, 11 | "noEmit": true, 12 | "strict": true, 13 | "target": "es5", 14 | "typeRoots": ["../"], 15 | "types": [], 16 | "paths": { 17 | "#is-browser": ["./types/resolved-condition.ts"], 18 | "#is-development": ["./types/resolved-condition.ts"] 19 | } 20 | }, 21 | "include": ["./*.ts", "./*.tsx"] 22 | } 23 | -------------------------------------------------------------------------------- /packages/styled/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@definitelytyped/dtslint/dtslint.json", 3 | "rules": { 4 | "array-type": [true, "generic"], 5 | "file-name-casing": false, 6 | "semicolon": false, 7 | "whitespace": [ 8 | true, 9 | "check-branch", 10 | "check-decl", 11 | "check-operator", 12 | "check-module", 13 | "check-rest-spread", 14 | "check-type", 15 | "check-typecast", 16 | "check-type-operator", 17 | "check-preblock" 18 | ], 19 | "no-unnecessary-generics": false, 20 | "unnecessary-bind": false, 21 | "ban-ts-ignore": false, 22 | "no-empty-interface": false, 23 | "strict-export-declare-modifiers": false 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/unitless/README.md: -------------------------------------------------------------------------------- 1 | # @emotion/unitless 2 | 3 | > An object of css properties that don't accept values with units 4 | 5 | ```jsx 6 | import unitless from '@emotion/unitless' 7 | 8 | unitless.flex === 1 9 | 10 | unitless.padding === undefined 11 | ``` 12 | -------------------------------------------------------------------------------- /packages/unitless/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@emotion/unitless", 3 | "version": "0.10.0", 4 | "description": "An object of css properties that don't accept values with units", 5 | "main": "dist/emotion-unitless.cjs.js", 6 | "module": "dist/emotion-unitless.esm.js", 7 | "types": "dist/emotion-unitless.cjs.d.ts", 8 | "license": "MIT", 9 | "repository": "https://github.com/emotion-js/emotion/tree/main/packages/unitless", 10 | "publishConfig": { 11 | "access": "public" 12 | }, 13 | "files": [ 14 | "src", 15 | "dist" 16 | ], 17 | "exports": { 18 | ".": { 19 | "types": { 20 | "import": "./dist/emotion-unitless.cjs.mjs", 21 | "default": "./dist/emotion-unitless.cjs.js" 22 | }, 23 | "module": "./dist/emotion-unitless.esm.js", 24 | "import": "./dist/emotion-unitless.cjs.mjs", 25 | "default": "./dist/emotion-unitless.cjs.js" 26 | }, 27 | "./package.json": "./package.json" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/use-insertion-effect-with-fallbacks/README.md: -------------------------------------------------------------------------------- 1 | # @emotion/use-insertion-effect-with-fallbacks 2 | -------------------------------------------------------------------------------- /packages/use-insertion-effect-with-fallbacks/src/conditions/false.ts: -------------------------------------------------------------------------------- 1 | export default false 2 | -------------------------------------------------------------------------------- /packages/use-insertion-effect-with-fallbacks/src/conditions/is-browser.ts: -------------------------------------------------------------------------------- 1 | export default typeof document !== 'undefined' 2 | -------------------------------------------------------------------------------- /packages/use-insertion-effect-with-fallbacks/src/conditions/true.ts: -------------------------------------------------------------------------------- 1 | export default true 2 | -------------------------------------------------------------------------------- /packages/use-insertion-effect-with-fallbacks/src/index.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import isBrowser from '#is-browser' 3 | 4 | const syncFallback = (create: () => T) => create() 5 | 6 | const useInsertionEffect = React[ 7 | ('useInsertion' + 'Effect') as 'useInsertionEffect' 8 | ] 9 | ? (React[('useInsertion' + 'Effect') as 'useInsertionEffect'] as ( 10 | create: () => T 11 | ) => T | undefined) 12 | : false 13 | 14 | export const useInsertionEffectAlwaysWithSyncFallback: ( 15 | create: () => T 16 | ) => T | undefined = !isBrowser 17 | ? syncFallback 18 | : useInsertionEffect || syncFallback 19 | 20 | export const useInsertionEffectWithLayoutFallback: typeof React.useLayoutEffect = 21 | useInsertionEffect || React.useLayoutEffect 22 | -------------------------------------------------------------------------------- /packages/utils/src/conditions/false.ts: -------------------------------------------------------------------------------- 1 | export default false as boolean 2 | -------------------------------------------------------------------------------- /packages/utils/src/conditions/is-browser.ts: -------------------------------------------------------------------------------- 1 | export default typeof document !== 'undefined' 2 | -------------------------------------------------------------------------------- /packages/utils/src/conditions/true.ts: -------------------------------------------------------------------------------- 1 | export default true as boolean 2 | -------------------------------------------------------------------------------- /packages/utils/src/types.ts: -------------------------------------------------------------------------------- 1 | import type { StyleSheet } from '@emotion/sheet' 2 | 3 | export type { StyleSheet } 4 | 5 | export type RegisteredCache = Record 6 | 7 | export type SerializedStyles = { 8 | name: string 9 | styles: string 10 | next?: SerializedStyles 11 | } 12 | 13 | export type EmotionCache = { 14 | inserted: Record 15 | registered: RegisteredCache 16 | sheet: StyleSheet 17 | key: string 18 | compat?: true 19 | nonce?: string 20 | insert: ( 21 | selector: string, 22 | serialized: SerializedStyles, 23 | sheet: StyleSheet, 24 | shouldCache: boolean 25 | ) => string | void 26 | } 27 | -------------------------------------------------------------------------------- /packages/utils/types/index.d.ts: -------------------------------------------------------------------------------- 1 | // TypeScript Version: 2.2 2 | 3 | export * from '..' 4 | -------------------------------------------------------------------------------- /packages/utils/types/resolved-condition.ts: -------------------------------------------------------------------------------- 1 | export default true as boolean 2 | -------------------------------------------------------------------------------- /packages/utils/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "../", 4 | "forceConsistentCasingInFileNames": true, 5 | "jsx": "react", 6 | "lib": ["es6", "dom"], 7 | "module": "commonjs", 8 | "noEmit": true, 9 | "strict": true, 10 | "target": "es5", 11 | "typeRoots": ["../"], 12 | "types": [], 13 | "paths": { 14 | "#is-browser": ["./types/resolved-condition.ts"], 15 | "#is-development": ["./src/conditions/true.ts"] 16 | } 17 | }, 18 | "include": ["./*.ts", "./*.tsx"] 19 | } 20 | -------------------------------------------------------------------------------- /packages/utils/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@definitelytyped/dtslint/dtslint.json", 3 | "rules": { 4 | "array-type": [true, "generic"], 5 | "semicolon": false 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /packages/weak-memoize/README.md: -------------------------------------------------------------------------------- 1 | # @emotion/weak-memoize 2 | 3 | > A memoization function that uses a WeakMap 4 | 5 | ## Install 6 | 7 | ```bash 8 | yarn add @emotion/weak-memoize 9 | ``` 10 | 11 | ## Usage 12 | 13 | Because @emotion/weak-memoize uses a WeakMap the argument must be a non primitive type, e.g. objects, functions, arrays and etc. The function passed to `weakMemoize` must also only accept a single argument. 14 | 15 | ```jsx 16 | import weakMemoize from '@emotion/weak-memoize' 17 | 18 | let doThing = weakMemoize(({ someProperty }) => { 19 | return { newName: someProperty } 20 | }) 21 | 22 | let obj = { someProperty: true } 23 | 24 | let firstResult = doThing(obj) 25 | 26 | let secondResult = doThing(obj) 27 | 28 | firstResult === secondResult // true 29 | 30 | let newObj = { someProperty: true } 31 | 32 | let thirdResult = doThing(newObj) 33 | 34 | thirdResult === firstResult // false 35 | ``` 36 | -------------------------------------------------------------------------------- /packages/weak-memoize/__tests__/index.js: -------------------------------------------------------------------------------- 1 | import weakMemoize from '@emotion/weak-memoize' 2 | 3 | test('it works', () => { 4 | let doThing = weakMemoize(obj => { 5 | return {} 6 | }) 7 | 8 | let firstArg = {} 9 | 10 | let firstResult = doThing(firstArg) 11 | 12 | let secondResult = doThing(firstArg) 13 | 14 | expect(firstResult).toBe(secondResult) 15 | 16 | let newObj = {} 17 | 18 | let newResult = doThing(newObj) 19 | 20 | expect(newResult).not.toBe(firstResult) 21 | }) 22 | -------------------------------------------------------------------------------- /packages/weak-memoize/src/index.ts: -------------------------------------------------------------------------------- 1 | let weakMemoize = function ( 2 | func: (arg: Arg) => Return 3 | ): (arg: Arg) => Return { 4 | let cache = new WeakMap() 5 | return (arg: Arg) => { 6 | if (cache.has(arg)) { 7 | // Use non-null assertion because we just checked that the cache `has` it 8 | // This allows us to remove `undefined` from the return value 9 | return cache.get(arg)! 10 | } 11 | let ret = func(arg) 12 | cache.set(arg, ret) 13 | return ret 14 | } 15 | } 16 | 17 | export default weakMemoize 18 | -------------------------------------------------------------------------------- /packages/weak-memoize/types/index.d.ts: -------------------------------------------------------------------------------- 1 | // TypeScript Version: 2.2 2 | 3 | export { default } from '..' 4 | -------------------------------------------------------------------------------- /packages/weak-memoize/types/tests.ts: -------------------------------------------------------------------------------- 1 | import weakMemoize from '@emotion/weak-memoize' 2 | 3 | interface Foo { 4 | bar: 'xyz' 5 | } 6 | 7 | declare class Qwe { 8 | answer: number 9 | } 10 | 11 | // $ExpectType Foo[] 12 | weakMemoize((arg: Foo) => [arg])({ bar: 'xyz' }) 13 | 14 | // $ExpectError 15 | weakMemoize((arg: string) => [arg])('foo') 16 | 17 | // $ExpectError 18 | weakMemoize((arg: Foo) => [arg])(42) 19 | 20 | // $ExpectError 21 | weakMemoize((arg: string) => [arg]) 22 | // $ExpectError 23 | weakMemoize((arg: number) => [arg]) 24 | // $ExpectError 25 | weakMemoize((arg: boolean) => [arg]) 26 | // $ExpectError 27 | weakMemoize((arg: symbol) => [arg]) 28 | // $ExpectError 29 | weakMemoize((arg: null) => [arg]) 30 | // $ExpectError 31 | weakMemoize((arg: undefined) => [arg]) 32 | 33 | weakMemoize((arg: () => void) => [arg]) 34 | weakMemoize((arg: Map) => [arg]) 35 | weakMemoize((arg: Set) => [arg]) 36 | weakMemoize((arg: Qwe) => [arg]) 37 | -------------------------------------------------------------------------------- /packages/weak-memoize/types/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": "../", 4 | "forceConsistentCasingInFileNames": true, 5 | "lib": ["es6", "dom"], 6 | "module": "commonjs", 7 | "noEmit": true, 8 | "strict": true, 9 | "target": "es5", 10 | "typeRoots": ["../"], 11 | "types": [] 12 | }, 13 | "include": ["./*.ts", "./*.tsx"] 14 | } 15 | -------------------------------------------------------------------------------- /packages/weak-memoize/types/tslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@definitelytyped/dtslint/dtslint.json", 3 | "rules": { 4 | "array-type": [true, "generic"], 5 | "import-spacing": false, 6 | "semicolon": false, 7 | "whitespace": [ 8 | true, 9 | "check-branch", 10 | "check-decl", 11 | "check-operator", 12 | "check-module", 13 | "check-rest-spread", 14 | "check-type", 15 | "check-typecast", 16 | "check-type-operator", 17 | "check-preblock" 18 | ], 19 | 20 | "no-unnecessary-generics": false, 21 | "strict-export-declare-modifiers": false, 22 | "no-default-import": false, 23 | "unnecessary-bind": false 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /playgrounds/README.md: -------------------------------------------------------------------------------- 1 | # Emotion Development Playgrounds 2 | 3 | These are intended to be places to experiment with behaviour that is hard to do in tests or a CodeSandbox. These are not intended to be perfect examples of how you would write emotion code with these other libraries as they will generally be focused on edge cases. 4 | 5 | ## Getting Started 6 | 7 | In the root of the repository, run this command to start building emotion 8 | 9 | ```bash 10 | yarn build:watch 11 | ``` 12 | 13 | Then choose the playground you want to use and run the commands in the given package.json 14 | -------------------------------------------------------------------------------- /playgrounds/cra/.env: -------------------------------------------------------------------------------- 1 | # Necessary because we might have a different version of babel-jest, .etc than 2 | # what react-scripts wants 3 | SKIP_PREFLIGHT_CHECK=true 4 | 5 | # Uncomment if you want to test stuff with the old JSX transform. 6 | # You also need to change the `@jsxImportSource @emotion/react` line 7 | # to `@jsx jsx` and import `jsx` from @emotion/react. 8 | # DISABLE_NEW_JSX_TRANSFORM=true -------------------------------------------------------------------------------- /playgrounds/cra/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /playgrounds/cra/README.md: -------------------------------------------------------------------------------- 1 | # CRA Playground 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | -------------------------------------------------------------------------------- /playgrounds/cra/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cra-playground", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "react": "16.14.0", 7 | "react-dom": "16.14.0", 8 | "react-scripts": "4.0.3", 9 | "theme-ui": "^0.12.0" 10 | }, 11 | "scripts": { 12 | "start": "react-scripts start", 13 | "build": "react-scripts build", 14 | "test": "react-scripts test", 15 | "eject": "react-scripts eject" 16 | }, 17 | "browserslist": { 18 | "production": [ 19 | ">0.2%", 20 | "not dead", 21 | "not op_mini all" 22 | ], 23 | "development": [ 24 | "last 1 chrome version", 25 | "last 1 firefox version", 26 | "last 1 safari version" 27 | ] 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /playgrounds/cra/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotion-js/emotion/cce67ec6b2fc94261028b4f4778aae8c3d6c5fd6/playgrounds/cra/public/favicon.ico -------------------------------------------------------------------------------- /playgrounds/cra/src/App.js: -------------------------------------------------------------------------------- 1 | /** @jsxImportSource @emotion/react */ 2 | import React from 'react' 3 | import { Global } from '@emotion/react' 4 | 5 | function App() { 6 | return ( 7 |
8 | 19 | 20 |

CRA Playground

21 |
Some colored text
22 |
23 | ) 24 | } 25 | 26 | export default App 27 | -------------------------------------------------------------------------------- /playgrounds/cra/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import ReactDOM from 'react-dom' 3 | import App from './App' 4 | 5 | ReactDOM.render( 6 | 7 | 8 | , 9 | document.getElementById('root') 10 | ) 11 | -------------------------------------------------------------------------------- /playgrounds/nextjs/.babelrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | [ 4 | 'next/babel', 5 | { 6 | 'preset-react': { 7 | runtime: 'automatic', 8 | importSource: '@emotion/react' 9 | } 10 | } 11 | ] 12 | ], 13 | plugins: ['@emotion/babel-plugin'] 14 | } 15 | -------------------------------------------------------------------------------- /playgrounds/nextjs/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # local env files 28 | .env.local 29 | .env.development.local 30 | .env.test.local 31 | .env.production.local 32 | 33 | # vercel 34 | .vercel 35 | -------------------------------------------------------------------------------- /playgrounds/nextjs/next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | reactStrictMode: true 3 | } 4 | -------------------------------------------------------------------------------- /playgrounds/nextjs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nextjs-playground", 3 | "version": "0.0.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev -p 4000", 7 | "build": "next build", 8 | "start": "next start" 9 | }, 10 | "dependencies": { 11 | "next": "^12.2.0", 12 | "react": "16.14.0", 13 | "react-dom": "16.14.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /playgrounds/nextjs/pages/_app.js: -------------------------------------------------------------------------------- 1 | function MyApp({ Component, pageProps }) { 2 | return 3 | } 4 | 5 | export default MyApp 6 | -------------------------------------------------------------------------------- /playgrounds/nextjs/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotion-js/emotion/cce67ec6b2fc94261028b4f4778aae8c3d6c5fd6/playgrounds/nextjs/public/favicon.ico -------------------------------------------------------------------------------- /scripts/babel-preset-emotion-dev/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-preset-emotion-dev", 3 | "main": "src/index", 4 | "version": "9.2.6", 5 | "private": true, 6 | "dependencies": { 7 | "@babel/plugin-proposal-class-properties": "^7.17.12", 8 | "babel-plugin-add-basic-constructor-for-react-components": "^0.1.0", 9 | "babel-plugin-fix-dce-for-classes-with-statics": "^0.1.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /scripts/babel-tester/babel-check-duplicated-nodes.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'babel-check-duplicated-nodes' { 2 | export default function checkDuplicatedNodes( 3 | babel: typeof import('@babel/core'), 4 | ast: import('@babel/core').types.File 5 | ): void 6 | } 7 | -------------------------------------------------------------------------------- /scripts/babel-tester/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel-tester", 3 | "main": "src/index.ts", 4 | "version": "0.4.5", 5 | "private": true, 6 | "dependencies": { 7 | "@babel/plugin-syntax-class-properties": "^7.12.13", 8 | "@babel/plugin-syntax-object-rest-spread": "^7.8.3", 9 | "babel-check-duplicated-nodes": "^1.0.0" 10 | }, 11 | "devDependencies": { 12 | "@types/jest-in-case": "^1.0.5" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /scripts/benchmarks/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["@babel/env", { "modules": false, "loose": true }], 4 | "@babel/react" 5 | ], 6 | "plugins": [ 7 | ["@babel/plugin-proposal-class-properties", { "loose": false }], 8 | "babel-plugin-react-native-web", 9 | "@emotion", 10 | "transform-inline-environment-variables" 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /scripts/benchmarks/README.md: -------------------------------------------------------------------------------- 1 | # Benchmarks 2 | 3 | These benchmarks test how fast emotion renders with react components. They do not necessarily represent how fast a css-in-js library will be in the real world and are used by emotion to stop performance regressions in render performance/caching. 4 | 5 | To run these benchmarks, visit https://benchmarks.emotion.sh and choose a commit. (If a benchmark says artifact not found, that means the build hasn't finished yet and you have to wait or the build may have failed) 6 | 7 | These benchmarks are a modified version of react-native-web's benchmarks. 8 | 9 | ## Running Locally 10 | 11 | The benchmarks can also be run locally, in this folder run `yarn build` and then `open ./dist/index.html` or use `yarn run-benchmark` to run them automatically. 12 | -------------------------------------------------------------------------------- /scripts/benchmarks/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "benchmarks", 4 | "version": "0.8.28", 5 | "scripts": { 6 | "start": "parcel src/index.html", 7 | "build": "parcel build src/index.html --public-url .", 8 | "run-benchmark": "node run.js" 9 | }, 10 | "dependencies": { 11 | "@babel/core": "^7.18.5", 12 | "@emotion/babel-plugin": "^11.13.5", 13 | "babel-plugin-react-native-web": "^0.17.5", 14 | "d3-scale-chromatic": "^3.0.0", 15 | "http-server": "^14.0.0", 16 | "parcel": "^2.12.0", 17 | "puppeteer": "^11.0.0", 18 | "react": "16.14.0", 19 | "react-dom": "16.14.0", 20 | "react-native-web": "0.17.5", 21 | "stats-analysis": "^2.0.0" 22 | }, 23 | "alias": { 24 | "react-native": "react-native-web" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/app/Benchmark/math.js: -------------------------------------------------------------------------------- 1 | import stats from 'stats-analysis' 2 | 3 | export const getStdDev = values => { 4 | const avg = getMean(values) 5 | 6 | const squareDiffs = values.map(value => { 7 | const diff = value - avg 8 | return diff * diff 9 | }) 10 | 11 | return Math.sqrt(getMean(squareDiffs)) 12 | } 13 | 14 | export const getMean = values => { 15 | let valuesWithoutOutliers = stats.filterMADoutliers(values) 16 | return stats.mean(valuesWithoutOutliers) 17 | } 18 | 19 | export const getMedian = stats.median 20 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/app/Benchmark/timing.js: -------------------------------------------------------------------------------- 1 | const NS_PER_MS = 1e6 2 | const MS_PER_S = 1e3 3 | 4 | // Returns a high resolution time (if possible) in milliseconds 5 | export function now() { 6 | if (window && window.performance) { 7 | return window.performance.now() 8 | } else if (process && process.hrtime) { 9 | const [seconds, nanoseconds] = process.hrtime() 10 | const secInMS = seconds * MS_PER_S 11 | const nSecInMS = nanoseconds / NS_PER_MS 12 | return secInMS + nSecInMS 13 | } else { 14 | return Date.now() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/app/Benchmark/types.js: -------------------------------------------------------------------------------- 1 | /* 2 | export type FullSampleTimingType = { 3 | start: number 4 | end: number 5 | scriptingStart: number 6 | scriptingEnd: number 7 | layoutStart?: number 8 | layoutEnd?: number 9 | } 10 | 11 | export type BenchResultsType = { 12 | startTime: number 13 | endTime: number 14 | runTime: number 15 | sampleCount: number 16 | samples: Array 17 | max: number 18 | min: number 19 | median: number 20 | mean: number 21 | stdDev: number 22 | } 23 | 24 | export type SampleTimingType = { 25 | scriptingStart: number 26 | scriptingEnd?: number 27 | layoutStart?: number 28 | layoutEnd?: number 29 | } 30 | */ 31 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/app/Text.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable react/prop-types */ 2 | 3 | import { bool } from 'prop-types' 4 | import React from 'react' 5 | import { StyleSheet, Text } from 'react-native' 6 | import { colors } from './theme' 7 | 8 | class AppText extends React.Component { 9 | static displayName = '@app/Text' 10 | 11 | static contextTypes = { 12 | isInAParentText: bool 13 | } 14 | 15 | render() { 16 | const { style, ...rest } = this.props 17 | const { isInAParentText } = this.context 18 | return ( 19 | 20 | ) 21 | } 22 | } 23 | 24 | const styles = StyleSheet.create({ 25 | baseText: { 26 | color: colors.textBlack, 27 | fontSize: '1rem', 28 | lineHeight: '1.3125em' 29 | } 30 | }) 31 | 32 | export default AppText 33 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/implementations/emotion-css-func/Dot.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { css } from '@emotion/css' 3 | 4 | const Dot = ({ size, x, y, children, color }) => ( 5 |
15 | {children} 16 |
17 | ) 18 | 19 | const styles = { 20 | root: css({ 21 | position: 'absolute', 22 | cursor: 'pointer', 23 | width: 0, 24 | height: 0, 25 | borderColor: 'transparent', 26 | borderStyle: 'solid', 27 | borderTopWidth: 0, 28 | transform: 'translate(50%, 50%)' 29 | }) 30 | } 31 | 32 | export default Dot 33 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/implementations/emotion-css-func/Provider.js: -------------------------------------------------------------------------------- 1 | import View from './View' 2 | export default View 3 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/implementations/emotion-css-func/View.js: -------------------------------------------------------------------------------- 1 | import { css } from '@emotion/css' 2 | import React from 'react' 3 | 4 | const View = ({ style, ...other }) => { 5 | return
6 | } 7 | 8 | export const viewStyle = css({ 9 | alignItems: 'stretch', 10 | borderWidth: 0, 11 | borderStyle: 'solid', 12 | boxSizing: 'border-box', 13 | display: 'flex', 14 | flexBasis: 'auto', 15 | flexDirection: 'column', 16 | flexShrink: 0, 17 | margin: 0, 18 | padding: 0, 19 | position: 'relative', 20 | // fix flexbox bugs 21 | minHeight: 0, 22 | minWidth: 0 23 | }) 24 | 25 | export default View 26 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/implementations/emotion-css-func/index.js: -------------------------------------------------------------------------------- 1 | export { default as Box } from './Box' 2 | export { default as Dot } from './Dot' 3 | export { default as Provider } from './Provider' 4 | export { default as View } from './View' 5 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/implementations/emotion-css-prop/Dot.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { css, jsx } from '@emotion/react' 3 | 4 | const Dot = ({ size, x, y, children, color }) => ( 5 |
15 | {children} 16 |
17 | ) 18 | 19 | const styles = { 20 | root: css({ 21 | position: 'absolute', 22 | cursor: 'pointer', 23 | width: 0, 24 | height: 0, 25 | borderColor: 'transparent', 26 | borderStyle: 'solid', 27 | borderTopWidth: 0, 28 | transform: 'translate(50%, 50%)' 29 | }) 30 | } 31 | 32 | export default Dot 33 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/implementations/emotion-css-prop/Provider.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { CacheProvider } from '@emotion/react' 3 | import createCache from '@emotion/cache' 4 | 5 | let cache = createCache({ key: 'emo' }) 6 | 7 | export default props => { 8 | return {props.children} 9 | } 10 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/implementations/emotion-css-prop/View.js: -------------------------------------------------------------------------------- 1 | /** @jsx jsx */ 2 | import { css, jsx } from '@emotion/react' 3 | 4 | const View = ({ style, ...other }) => { 5 | return
6 | } 7 | 8 | export const viewStyle = css({ 9 | alignItems: 'stretch', 10 | borderWidth: 0, 11 | borderStyle: 'solid', 12 | boxSizing: 'border-box', 13 | display: 'flex', 14 | flexBasis: 'auto', 15 | flexDirection: 'column', 16 | flexShrink: 0, 17 | margin: 0, 18 | padding: 0, 19 | position: 'relative', 20 | // fix flexbox bugs 21 | minHeight: 0, 22 | minWidth: 0 23 | }) 24 | 25 | export default View 26 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/implementations/emotion-css-prop/index.js: -------------------------------------------------------------------------------- 1 | export { default as Box } from './Box' 2 | export { default as Dot } from './Dot' 3 | export { default as Provider } from './Provider' 4 | export { default as View } from './View' 5 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/implementations/emotion-styled/Box.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled' 2 | import View from './View' 3 | 4 | const getColor = ({ color }) => { 5 | switch (color) { 6 | case 0: 7 | return '#14171A' 8 | case 1: 9 | return '#AAB8C2' 10 | case 2: 11 | return '#E6ECF0' 12 | case 3: 13 | return '#FFAD1F' 14 | case 4: 15 | return '#F45D22' 16 | case 5: 17 | return '#E0245E' 18 | default: 19 | return 'transparent' 20 | } 21 | } 22 | 23 | const Box = styled(View)` 24 | align-self: flex-start; 25 | flex-direction: ${props => (props.layout === 'column' ? 'column' : 'row')}; 26 | padding: ${props => (props.outer ? '4px' : '0')}; 27 | ${props => props.fixed && 'height:6px;width:6px;'}; 28 | background-color: ${getColor}; 29 | ` 30 | 31 | export default Box 32 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/implementations/emotion-styled/Dot.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled' 2 | import { css } from '@emotion/react' 3 | import View from './View' 4 | 5 | const Dot = styled(View)` 6 | position: absolute; 7 | cursor: pointer; 8 | width: 0; 9 | height: 0; 10 | border-color: transparent; 11 | border-style: solid; 12 | border-top-width: 0; 13 | transform: translate(50%, 50%); 14 | ${props => css` 15 | margin-left: ${props.x}px; 16 | margin-top: ${props.y}px; 17 | border-right-width: ${props.size / 2}px; 18 | border-bottom-width: ${props.size / 2}px; 19 | border-left-width: ${props.size / 2}px; 20 | border-bottom-color: ${props.color}; 21 | `}; 22 | ` 23 | 24 | export default Dot 25 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/implementations/emotion-styled/Provider.js: -------------------------------------------------------------------------------- 1 | import * as React from 'react' 2 | import { CacheProvider } from '@emotion/react' 3 | import createCache from '@emotion/cache' 4 | 5 | let cache = createCache({ key: 'emo' }) 6 | 7 | export default props => { 8 | return {props.children} 9 | } 10 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/implementations/emotion-styled/View.js: -------------------------------------------------------------------------------- 1 | import styled from '@emotion/styled' 2 | 3 | const View = styled.div` 4 | align-items: stretch; 5 | border-width: 0; 6 | border-style: solid; 7 | box-sizing: border-box; 8 | display: flex; 9 | flex-basis: auto; 10 | flex-direction: column; 11 | flex-shrink: 0; 12 | margin: 0; 13 | padding: 0; 14 | position: relative; 15 | min-height: 0; 16 | min-width: 0; 17 | ` 18 | 19 | export default View 20 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/implementations/emotion-styled/index.js: -------------------------------------------------------------------------------- 1 | export { default as Box } from './Box' 2 | export { default as Dot } from './Dot' 3 | export { default as Provider } from './Provider' 4 | export { default as View } from './View' 5 | -------------------------------------------------------------------------------- /scripts/benchmarks/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Performance tests 6 | 7 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /scripts/ensure-yarn.js: -------------------------------------------------------------------------------- 1 | if (!/yarn\//.test(process.env.npm_config_user_agent)) { 2 | throw new Error('Please use `yarn` for installs.') 3 | } 4 | -------------------------------------------------------------------------------- /scripts/replace-slack-link.js: -------------------------------------------------------------------------------- 1 | // slack invite links expire after 30 days and you can't(at least as far as i can tell) create tokens for things like slackin anymore 2 | 3 | const fs = require('fs') 4 | 5 | const slackInviteLink = process.argv[2] 6 | 7 | const siteHeaderPath = `${__dirname}/../site/src/components/SiteHeader.js` 8 | const readmePath = `${__dirname}/../README.md` 9 | 10 | const slackInviteLinkRegex = 11 | /https:\/\/join\.slack\.com\/t\/emotion-slack\/shared_invite\/[^/]+\// 12 | 13 | const siteHeader = fs.readFileSync(siteHeaderPath, 'utf8') 14 | 15 | fs.writeFileSync( 16 | siteHeaderPath, 17 | siteHeader.replace(slackInviteLinkRegex, slackInviteLink) 18 | ) 19 | 20 | const readme = fs.readFileSync(readmePath, 'utf8') 21 | 22 | fs.writeFileSync( 23 | readmePath, 24 | readme.replace(slackInviteLinkRegex, slackInviteLink) 25 | ) 26 | -------------------------------------------------------------------------------- /scripts/ssr-benchmarks/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-react"] 3 | } 4 | -------------------------------------------------------------------------------- /scripts/ssr-benchmarks/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "ssr-benchmarks", 4 | "version": "0.8.13", 5 | "type": "module", 6 | "scripts": { 7 | "start": "NODE_ENV=production node bench.js", 8 | "start-basic": "NODE_ENV=production node basic.js" 9 | }, 10 | "dependencies": { 11 | "benchmark": "^2.1.4", 12 | "d3-scale-chromatic": "^3.0.0", 13 | "react": "16.14.0", 14 | "react-dom": "16.14.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /scripts/test-utils/enzyme-env.js: -------------------------------------------------------------------------------- 1 | import Enzyme from 'enzyme' 2 | import Adapter from 'enzyme-adapter-react-16' 3 | 4 | Enzyme.configure({ adapter: new Adapter() }) 5 | -------------------------------------------------------------------------------- /scripts/test-utils/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | 3 | interface Flags { 4 | development: boolean 5 | } 6 | 7 | declare global { 8 | function gate( 9 | flags: Flags, 10 | exec: ({ test }: { test: typeof globalThis.test }) => void 11 | ): void 12 | } 13 | 14 | export {} 15 | -------------------------------------------------------------------------------- /scripts/test-utils/legacy-env.js: -------------------------------------------------------------------------------- 1 | /* eslint-env jest */ 2 | import 'test-utils/enzyme-env' 3 | import { createEnzymeSerializer } from '@emotion/jest/enzyme' 4 | 5 | expect.addSnapshotSerializer(createEnzymeSerializer()) 6 | -------------------------------------------------------------------------------- /scripts/test-utils/next-env.js: -------------------------------------------------------------------------------- 1 | /* eslint-env jest */ 2 | import { createSerializer } from '@emotion/jest' 3 | 4 | expect.addSnapshotSerializer(createSerializer()) 5 | -------------------------------------------------------------------------------- /scripts/test-utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test-utils", 3 | "main": "src/index", 4 | "version": "0.3.2", 5 | "private": true, 6 | "imports": { 7 | "#is-development": { 8 | "development": "./resolved-conditions/true.js", 9 | "default": "./resolved-conditions/false.js" 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /scripts/test-utils/pretty-css.js: -------------------------------------------------------------------------------- 1 | import prettify from '@emotion/css-prettifier' 2 | 3 | /* 4 | type StyleSheet = { 5 | tags: Array 6 | } 7 | */ 8 | 9 | export default { 10 | test: val => val && val.tags !== undefined && Array.isArray(val.tags), 11 | serialize( 12 | val /* : StyleSheet */, 13 | config, 14 | indentation /* : string */, 15 | depth /* : number */, 16 | refs, 17 | printer /* : Function */ 18 | ) { 19 | let styles = val.tags.map(tag => tag.textContent || '').join('') 20 | return printer( 21 | prettify(styles, config.indent), 22 | config, 23 | indentation, 24 | depth, 25 | refs 26 | ) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /scripts/test-utils/resolved-conditions/false.js: -------------------------------------------------------------------------------- 1 | export default false 2 | -------------------------------------------------------------------------------- /scripts/test-utils/resolved-conditions/true.js: -------------------------------------------------------------------------------- 1 | export default true 2 | -------------------------------------------------------------------------------- /site/.babelrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | [ 4 | 'next/babel', 5 | { 6 | 'preset-react': { 7 | runtime: 'automatic', 8 | importSource: '@emotion/react' 9 | } 10 | } 11 | ] 12 | ], 13 | plugins: ['@emotion/babel-plugin'] 14 | } 15 | -------------------------------------------------------------------------------- /site/components/container.tsx: -------------------------------------------------------------------------------- 1 | import { PropsWithChildren, ReactElement } from 'react' 2 | import { mediaQueries } from '../util' 3 | 4 | type ContainerProps = PropsWithChildren<{ 5 | className?: string 6 | }> 7 | 8 | export function Container({ 9 | className, 10 | children 11 | }: PropsWithChildren): ReactElement { 12 | return ( 13 |
27 | {children} 28 |
29 | ) 30 | } 31 | -------------------------------------------------------------------------------- /site/components/global-styles.tsx: -------------------------------------------------------------------------------- 1 | import { Global, css } from '@emotion/react' 2 | import { ReactElement } from 'react' 3 | import { colors, draculaPrism } from '../util' 4 | 5 | const globalCss = css({ 6 | a: { 7 | color: colors.pink, 8 | textDecoration: 'none' 9 | }, 10 | 'a:hover': { 11 | color: colors.hightlight, 12 | textDecoration: 'underline' 13 | } 14 | }) 15 | 16 | export function GlobalStyles(): ReactElement { 17 | return 18 | } 19 | -------------------------------------------------------------------------------- /site/components/index.ts: -------------------------------------------------------------------------------- 1 | export * from './site-header' 2 | export * from './doc-wrapper' 3 | export * from './title' 4 | export * from './global-styles' 5 | export * from './markdown-css' 6 | export * from './container' 7 | -------------------------------------------------------------------------------- /site/components/live-editor/compiler/index.ts: -------------------------------------------------------------------------------- 1 | export * from './compile' 2 | -------------------------------------------------------------------------------- /site/components/live-editor/compiler/message.ts: -------------------------------------------------------------------------------- 1 | export interface CompilationRequestMessage { 2 | id: number 3 | code: string 4 | } 5 | 6 | export interface CompilationSuccessMessage { 7 | id: number 8 | type: 'success' 9 | compiledCode: string 10 | } 11 | 12 | export interface CompilationFailureMessage { 13 | id: number 14 | type: 'failure' 15 | errorMessage: string 16 | } 17 | -------------------------------------------------------------------------------- /site/components/live-editor/components/README.md: -------------------------------------------------------------------------------- 1 | These components were forked from [react-live](https://github.com/FormidableLabs/react-live). 2 | -------------------------------------------------------------------------------- /site/components/live-editor/components/error-boundary.tsx: -------------------------------------------------------------------------------- 1 | import React, { PropsWithChildren, ReactNode } from 'react' 2 | 3 | type ErrorBoundaryProps = PropsWithChildren<{ 4 | onError(error: unknown): void 5 | }> 6 | 7 | export class ErrorBoundary extends React.Component { 8 | componentDidCatch(error: unknown): void { 9 | this.props.onError(error) 10 | } 11 | 12 | render(): ReactNode { 13 | return this.props.children 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /site/components/live-editor/components/index.ts: -------------------------------------------------------------------------------- 1 | export * from './live-editor' 2 | export * from './live-provider' 3 | export * from './live-error' 4 | export * from './live-preview' 5 | export type { Scope } from './render-element-async' 6 | -------------------------------------------------------------------------------- /site/components/live-editor/components/live-context.ts: -------------------------------------------------------------------------------- 1 | import React, { ReactElement } from 'react' 2 | 3 | export interface LiveContextData { 4 | code: string 5 | onCodeChange(code: string): void 6 | 7 | element: ReactElement | undefined 8 | errorMessage: string | undefined 9 | } 10 | 11 | export const LiveContext = React.createContext({ 12 | code: '', 13 | onCodeChange: () => {}, 14 | 15 | element: undefined, 16 | errorMessage: undefined 17 | }) 18 | -------------------------------------------------------------------------------- /site/components/live-editor/components/live-error.tsx: -------------------------------------------------------------------------------- 1 | import { useContext, ReactElement } from 'react' 2 | import { LiveContext } from './live-context' 3 | 4 | interface LiveErrorProps { 5 | className?: string 6 | } 7 | 8 | export function LiveError({ className }: LiveErrorProps): ReactElement | null { 9 | const { errorMessage } = useContext(LiveContext) 10 | 11 | if (!errorMessage) return null 12 | 13 | return
{errorMessage}
14 | } 15 | -------------------------------------------------------------------------------- /site/components/live-editor/components/live-preview.tsx: -------------------------------------------------------------------------------- 1 | import { ReactElement, useContext } from 'react' 2 | import { LiveContext } from './live-context' 3 | 4 | interface LivePreviewProps { 5 | className?: string 6 | } 7 | 8 | export function LivePreview({ className }: LivePreviewProps): ReactElement { 9 | const { element } = useContext(LiveContext) 10 | 11 | return
{element}
12 | } 13 | -------------------------------------------------------------------------------- /site/components/live-editor/index.ts: -------------------------------------------------------------------------------- 1 | export * from './remark-live-editor' 2 | export * from './emotion-live-editor' 3 | -------------------------------------------------------------------------------- /site/components/title.tsx: -------------------------------------------------------------------------------- 1 | import { PropsWithChildren, ReactElement } from 'react' 2 | 3 | type TitleProps = PropsWithChildren<{ className?: string }> 4 | 5 | export function Title({ className, children }: TitleProps): ReactElement { 6 | return ( 7 |

14 | {children} 15 |

16 | ) 17 | } 18 | -------------------------------------------------------------------------------- /site/misc.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@emotion/babel-plugin' // TODO Remove as part of TS migration 2 | -------------------------------------------------------------------------------- /site/module-stubs/README.md: -------------------------------------------------------------------------------- 1 | `@emotion/babel-plugin` depends on some modules which require `fs` which obviously cannot be imported in the browser. (Furthermore, it's unclear if Next.js will allow you to require `fs` during SSR, if the require is located in code that is shared between client and server.) 2 | 3 | So to get `@emotion/babel-plugin` to work in the browser / Next.js, we have to stub out any dependencies which require `fs`. This works via Webpack `require.alias` in `next.config.js`. 4 | 5 | This is a very hacky workaround that could easily break things in the future. 6 | -------------------------------------------------------------------------------- /site/module-stubs/cosmiconfig.cjs: -------------------------------------------------------------------------------- 1 | module.exports = () => ({}) 2 | -------------------------------------------------------------------------------- /site/module-stubs/find-root.cjs: -------------------------------------------------------------------------------- 1 | module.exports = function findRoot() { 2 | return '' 3 | } 4 | -------------------------------------------------------------------------------- /site/module-stubs/resolve.cjs: -------------------------------------------------------------------------------- 1 | module.exports = () => 'FAKE_PATH' 2 | -------------------------------------------------------------------------------- /site/next-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | 4 | // NOTE: This file should not be edited 5 | // see https://nextjs.org/docs/basic-features/typescript for more information. 6 | -------------------------------------------------------------------------------- /site/pages/404.tsx: -------------------------------------------------------------------------------- 1 | import Head from 'next/head' 2 | import { ReactElement } from 'react' 3 | import { styleConstants } from '../util' 4 | 5 | export default function NotFoundPage(): ReactElement { 6 | const title = 'Page not found' 7 | 8 | return ( 9 | <> 10 | 11 | {title} 12 | 13 |

{title}

14 |

15 | You just hit a route that doesn't exist... the sadness. 😢 16 |

17 | 18 | ) 19 | } 20 | -------------------------------------------------------------------------------- /site/pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import '../public/bootstrap-reboot.min.css' 2 | import '@docsearch/css' 3 | import Head from 'next/head' 4 | import type { AppProps } from 'next/app' 5 | import '../util/prism-customizations' 6 | import { SiteHeader, GlobalStyles, Container } from '../components' 7 | 8 | export default function MyApp({ Component, pageProps }: AppProps) { 9 | return ( 10 | <> 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ) 21 | } 22 | -------------------------------------------------------------------------------- /site/public/logo-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotion-js/emotion/cce67ec6b2fc94261028b4f4778aae8c3d6c5fd6/site/public/logo-32x32.png -------------------------------------------------------------------------------- /site/public/logo-48x48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotion-js/emotion/cce67ec6b2fc94261028b4f4778aae8c3d6c5fd6/site/public/logo-48x48.png -------------------------------------------------------------------------------- /site/public/logo-96x96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/emotion-js/emotion/cce67ec6b2fc94261028b4f4778aae8c3d6c5fd6/site/public/logo-96x96.png -------------------------------------------------------------------------------- /site/queries/index.ts: -------------------------------------------------------------------------------- 1 | export * from './docQueries' 2 | -------------------------------------------------------------------------------- /site/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2018", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "noEmit": true, 10 | "esModuleInterop": true, 11 | "module": "esnext", 12 | "moduleResolution": "Bundler", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve", 16 | "jsxImportSource": "@emotion/react", 17 | "incremental": true 18 | }, 19 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], 20 | "exclude": ["node_modules"] 21 | } 22 | -------------------------------------------------------------------------------- /site/util/index.ts: -------------------------------------------------------------------------------- 1 | export * from './style-constants' 2 | export * from './dracula-prism' 3 | -------------------------------------------------------------------------------- /site/util/remark-fix-links.ts: -------------------------------------------------------------------------------- 1 | import { visit } from 'unist-util-visit' 2 | 3 | export function remarkFixLinks() { 4 | return (markdownAST: any) => { 5 | visit(markdownAST, 'link', (node: { url: string }) => { 6 | node.url = node.url.replace(/^https?:\/\/emotion.sh/i, '') 7 | node.url = node.url.replace( 8 | /^https?:\/\/github.com\/emotion-js\/emotion\/tree\/main/i, 9 | '' 10 | ) 11 | 12 | if (!node.url.startsWith('http')) { 13 | node.url = node.url 14 | .replace(/\.mdx?(#.*)?$/, (_, hash) => { 15 | return hash || '' 16 | }) 17 | .replace(/^\/packages\//, '/docs/@emotion/') 18 | } 19 | }) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "esModuleInterop": true, 4 | "forceConsistentCasingInFileNames": true, 5 | "isolatedModules": true, 6 | "jsx": "react", 7 | "lib": ["es6", "dom"], 8 | "moduleResolution": "Node16", 9 | "module": "Node16", 10 | "noEmit": true, 11 | "skipLibCheck": true, 12 | "skipDefaultLibCheck": true, 13 | "resolveJsonModule": true, 14 | "strict": true, 15 | "target": "es5", 16 | "types": [] 17 | }, 18 | "include": ["packages", "scripts", "test", "playgrounds"], 19 | "exclude": [ 20 | "node_modules", 21 | "packages/*/types/test/*", 22 | "packages/*/types/test*", 23 | "packages/native" 24 | ] 25 | } 26 | --------------------------------------------------------------------------------