├── .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 | 
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 |
12 | >
13 | )
14 | }
15 |
--------------------------------------------------------------------------------
/packages/babel-preset-css-prop/__tests__/index.js:
--------------------------------------------------------------------------------
1 | import babelTester from 'babel-tester'
2 | import preset from '@emotion/babel-preset-css-prop'
3 |
4 | babelTester('@emotion/babel-preset-css-prop', __dirname, {
5 | presets: [preset]
6 | })
7 |
--------------------------------------------------------------------------------
/packages/babel-preset-css-prop/__tests__/options-are-used.js:
--------------------------------------------------------------------------------
1 | import babelTester from 'babel-tester'
2 | import preset from '@emotion/babel-preset-css-prop'
3 |
4 | babelTester('options are used', __dirname, {
5 | presets: [
6 | [
7 | preset,
8 | {
9 | sourceMap: false,
10 | labelFormat: '[dirname]--[filename]--[local]'
11 | }
12 | ]
13 | ]
14 | })
15 |
--------------------------------------------------------------------------------
/packages/cache/__tests__/__snapshots__/hydration.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`it works 1`] = `
4 |
5 |
6 |
12 |
13 |
14 |
15 | `;
16 |
17 | exports[`rehydrated styles to head can be flushed 1`] = `
18 |
19 |
20 |
26 |
27 |
28 |
29 | `;
30 |
31 | exports[`rehydrated styles to head can be flushed 2`] = `
32 |
33 |
34 |
35 |
36 | `;
37 |
--------------------------------------------------------------------------------
/packages/cache/src/conditions/false.ts:
--------------------------------------------------------------------------------
1 | export default false
2 |
--------------------------------------------------------------------------------
/packages/cache/src/conditions/is-browser.ts:
--------------------------------------------------------------------------------
1 | export default typeof document !== 'undefined'
2 |
--------------------------------------------------------------------------------
/packages/cache/src/conditions/true.ts:
--------------------------------------------------------------------------------
1 | export default true
2 |
--------------------------------------------------------------------------------
/packages/cache/src/types.ts:
--------------------------------------------------------------------------------
1 | export interface StylisElement {
2 | type: string
3 | value: string
4 | props: Array | string
5 | root: StylisElement | null
6 | parent: StylisElement | null
7 | children: Array | string
8 | line: number
9 | column: number
10 | length: number
11 | return: string
12 | }
13 | export type StylisPluginCallback = (
14 | element: StylisElement,
15 | index: number,
16 | children: Array,
17 | callback: StylisPluginCallback
18 | ) => string | void
19 |
20 | export type StylisPlugin = (
21 | element: StylisElement,
22 | index: number,
23 | children: Array,
24 | callback: StylisPluginCallback
25 | ) => string | void
26 |
--------------------------------------------------------------------------------
/packages/cache/types/index.d.ts:
--------------------------------------------------------------------------------
1 | export * from '..'
2 |
--------------------------------------------------------------------------------
/packages/cache/types/resolved-condition.ts:
--------------------------------------------------------------------------------
1 | export default true as boolean
2 |
--------------------------------------------------------------------------------
/packages/cache/types/tests.ts:
--------------------------------------------------------------------------------
1 | import createCache, { Options } from '@emotion/cache'
2 |
3 | declare const testOptions: Options
4 |
5 | // $ExpectType EmotionCache
6 | createCache({ key: 'test-key' })
7 | // $ExpectType EmotionCache
8 | createCache(testOptions)
9 |
--------------------------------------------------------------------------------
/packages/cache/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": ["./types/resolved-condition.ts"]
16 | }
17 | },
18 | "include": ["./*.ts", "./*.tsx"]
19 | }
20 |
--------------------------------------------------------------------------------
/packages/cache/types/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@definitelytyped/dtslint/dtslint.json",
3 | "rules": {
4 | "array-type": [true, "generic"],
5 | "semicolon": false,
6 | "unnecessary-bind": false
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/packages/css-prettifier/README.md:
--------------------------------------------------------------------------------
1 | # @emotion/css-prettifier
2 |
--------------------------------------------------------------------------------
/packages/css/create-instance/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "dist/emotion-css-create-instance.cjs.js",
3 | "module": "dist/emotion-css-create-instance.esm.js",
4 | "umd:main": "dist/emotion-css-create-instance.umd.min.js",
5 | "types": "dist/emotion-css-create-instance.cjs.d.ts",
6 | "preconstruct": {
7 | "umdName": "createEmotion"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/packages/css/macro.d.mts:
--------------------------------------------------------------------------------
1 | export * from './macro.js'
2 |
--------------------------------------------------------------------------------
/packages/css/macro.d.ts:
--------------------------------------------------------------------------------
1 | export * from '@emotion/css'
2 |
--------------------------------------------------------------------------------
/packages/css/macro.js:
--------------------------------------------------------------------------------
1 | module.exports = require('@emotion/babel-plugin').macros.vanillaEmotion
2 |
--------------------------------------------------------------------------------
/packages/css/src/conditions/false.ts:
--------------------------------------------------------------------------------
1 | export default false as boolean
2 |
--------------------------------------------------------------------------------
/packages/css/src/conditions/true.ts:
--------------------------------------------------------------------------------
1 | export default true as boolean
2 |
--------------------------------------------------------------------------------
/packages/css/src/index.ts:
--------------------------------------------------------------------------------
1 | import createEmotion from './create-instance'
2 |
3 | export const {
4 | flush,
5 | hydrate,
6 | cx,
7 | merge,
8 | getRegisteredStyles,
9 | injectGlobal,
10 | keyframes,
11 | css,
12 | sheet,
13 | cache
14 | } = createEmotion({ key: 'css' })
15 |
--------------------------------------------------------------------------------
/packages/css/test/__snapshots__/component-selector.test.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`component selector should be converted to use the emotion target className 1`] = `
4 | .emotion-0 .emotion-2 {
5 | color: red;
6 | }
7 |
8 | .emotion-1 {
9 | color: blue;
10 | }
11 |
12 |
19 | `;
20 |
--------------------------------------------------------------------------------
/packages/css/test/__snapshots__/label-pattern.test.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`label pattern input + label styled 1`] = `
4 | .emotion-0+label::after {
5 | color: pink;
6 | background: orange;
7 | }
8 |
9 |
10 |
13 |
14 | Label
15 |
16 |
17 | `;
18 |
--------------------------------------------------------------------------------
/packages/css/test/__snapshots__/sheet.dom.test.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`sheet .speedy throws when a rule has already been inserted 1`] = `"speedy must be changed before any rules are inserted"`;
4 |
5 | exports[`sheet tags 1`] = `
6 | [
7 | ,
13 | ]
14 | `;
15 |
--------------------------------------------------------------------------------
/packages/css/test/component-selector.test.js:
--------------------------------------------------------------------------------
1 | import 'test-utils/legacy-env'
2 | import React from 'react'
3 | import styled from '@emotion/styled'
4 | import renderer from 'react-test-renderer'
5 | import { css } from '@emotion/css'
6 |
7 | describe('component selector', () => {
8 | test('should be converted to use the emotion target className', () => {
9 | const FakeComponent = styled.div`
10 | color: blue;
11 | `
12 |
13 | const cls2 = css`
14 | ${FakeComponent} {
15 | color: red;
16 | }
17 | `
18 | const tree = renderer
19 | .create(
20 |
21 |
22 |
23 | )
24 | .toJSON()
25 | expect(tree).toMatchSnapshot()
26 | })
27 | })
28 |
--------------------------------------------------------------------------------
/packages/css/test/instance/__snapshots__/instance.test.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`general instance tests throws with invalid key 1`] = `"Emotion key must only contain lower case alphabetical characters and - but "css1" was passed"`;
4 |
--------------------------------------------------------------------------------
/packages/css/test/instance/instance.test.js:
--------------------------------------------------------------------------------
1 | import createEmotion from '@emotion/css/create-instance'
2 | import { container, css, sheet } from './emotion-instance'
3 |
4 | describe('general instance tests', () => {
5 | test('inserts style tags into container', () => {
6 | css`
7 | display: flex;
8 | `
9 | sheet.tags.forEach(tag => {
10 | expect(tag.getAttribute('data-emotion')).toBe('some-key')
11 | expect(tag.getAttribute('nonce')).toBe('some-nonce')
12 | expect(tag.parentNode).toBe(container)
13 | })
14 | })
15 | test('throws with invalid key', () => {
16 | expect(() => {
17 | createEmotion({ key: 'css1' })
18 | }).toThrowErrorMatchingSnapshot()
19 | })
20 | })
21 |
--------------------------------------------------------------------------------
/packages/css/test/label-pattern.test.js:
--------------------------------------------------------------------------------
1 | import 'test-utils/legacy-env'
2 | import React from 'react'
3 | import styled from '@emotion/styled'
4 | import renderer from 'react-test-renderer'
5 | import { flush } from '@emotion/css'
6 |
7 | describe('label pattern', () => {
8 | afterEach(() => flush())
9 |
10 | test('input + label styled', () => {
11 | const Input = styled.input`
12 | & + label::after {
13 | color: pink;
14 | background: orange;
15 | }
16 | `
17 |
18 | const tree = renderer
19 | .create(
20 |
21 |
22 | Label
23 |
24 | )
25 | .toJSON()
26 |
27 | expect(tree).toMatchSnapshot()
28 | })
29 | })
30 |
--------------------------------------------------------------------------------
/packages/css/test/source-map/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["babel-preset-emotion-dev"],
3 | "plugins": [["@emotion/babel-plugin", { "sourceMap": true }]]
4 | }
5 |
--------------------------------------------------------------------------------
/packages/css/types/create-instance.d.ts:
--------------------------------------------------------------------------------
1 | // Definitions by: Junyoung Clare Jang
2 | // TypeScript Version: 2.8
3 | export * from '../create-instance'
4 | export { default } from '../create-instance'
5 |
--------------------------------------------------------------------------------
/packages/css/types/index.d.ts:
--------------------------------------------------------------------------------
1 | export * from '..'
2 |
--------------------------------------------------------------------------------
/packages/css/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": ["./src/conditions/true.ts"],
15 | "#is-development": ["./src/conditions/true.ts"]
16 | }
17 | },
18 | "include": ["./*.ts", "./*.tsx"]
19 | }
20 |
--------------------------------------------------------------------------------
/packages/css/types/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@definitelytyped/dtslint/dtslint.json",
3 | "rules": {
4 | "array-type": [true, "generic"],
5 | "import-spacing": false,
6 | "file-name-casing": false,
7 | "no-default-import": false,
8 | "no-null-undefined-union": false,
9 | "semicolon": false,
10 | "whitespace": [
11 | true,
12 | "check-branch",
13 | "check-decl",
14 | "check-operator",
15 | "check-module",
16 | "check-rest-spread",
17 | "check-type",
18 | "check-typecast",
19 | "check-type-operator",
20 | "check-preblock"
21 | ],
22 | "unnecessary-bind": false
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/packages/eslint-plugin/docs/rules/import-from-emotion.md:
--------------------------------------------------------------------------------
1 | # Ensure styled is imported from @emotion/styled (import-from-emotion)
2 |
3 | ## Rule Details
4 |
5 | This rule reports an error if anything other than styled is imported from `react-emotion` because `emotion`'s exports are not re-exported from `react-emotion` in emotion 10 and above. This rule can usually be auto-fixed so you should not usually have to do anything yourself. This rule primarily exists for migration purposes because ideally the `emotion` package should not be used in a React app with Emotion 10 and above.
6 |
7 | Examples of **incorrect** code for this rule.
8 |
9 | ```jsx
10 | import { css } from 'react-emotion'
11 | ```
12 |
13 | Examples of **correct** code for this rule.
14 |
15 | ```jsx
16 | import { css } from 'emotion'
17 | ```
18 |
--------------------------------------------------------------------------------
/packages/eslint-plugin/docs/rules/jsx-import.md:
--------------------------------------------------------------------------------
1 | # Ensure jsx from @emotion/react is imported (jsx-import)
2 |
3 | ## Rule Details
4 |
5 | This rule ensures that `jsx` from `@emotion/react` is imported. This rule can usually be auto-fixed so you should not usually have to do anything yourself.
6 |
7 | Examples of **incorrect** code for this rule.
8 |
9 | ```jsx
10 | let element = (
11 |
16 | )
17 | ```
18 |
19 | Examples of **correct** code for this rule.
20 |
21 | ```js
22 | /** @jsx jsx */
23 | import { jsx } from '@emotion/react'
24 |
25 | let element = (
26 |
31 | )
32 | ```
33 |
34 | ## When Not To Use It
35 |
36 | If you are using a babel plugin or something like that to add imports and set the jsx pragma.
37 |
--------------------------------------------------------------------------------
/packages/eslint-plugin/docs/rules/no-vanilla.md:
--------------------------------------------------------------------------------
1 | # Ensure vanilla emotion is not using (no-vanilla)
2 |
3 | ## Rule Details
4 |
5 | This rule reports an error if there is an import from the `emotion` package which is not recommended if you are using emotion with React.
6 |
7 | Examples of **incorrect** code for this rule.
8 |
9 | ```jsx
10 | import { css } from '@emotion/css'
11 | ```
12 |
13 | ## When Not To Use It
14 |
15 | If you are using vanilla emotion because you are not using React.
16 |
--------------------------------------------------------------------------------
/packages/eslint-plugin/docs/rules/styled-import.md:
--------------------------------------------------------------------------------
1 | # Ensure styled is imported from @emotion/styled (styled-import)
2 |
3 | ## Rule Details
4 |
5 | This rule reports an error if styled is imported from `react-emotion` which is not where styled should be imported from in emotion 10 and above. This rule can usually be auto-fixed so you should not usually have to do anything yourself.
6 |
7 | Examples of **incorrect** code for this rule.
8 |
9 | ```jsx
10 | import styled from 'react-emotion'
11 | ```
12 |
13 | Examples of **correct** code for this rule.
14 |
15 | ```jsx
16 | import styled from '@emotion/styled'
17 | ```
18 |
--------------------------------------------------------------------------------
/packages/eslint-plugin/src/index.ts:
--------------------------------------------------------------------------------
1 | import importFromEmotion from './rules/import-from-emotion'
2 | import noVanilla from './rules/no-vanilla'
3 | import syntaxPreference from './rules/syntax-preference'
4 | import styledImport from './rules/styled-import'
5 | import jsxImport from './rules/jsx-import'
6 | import pkgRenaming from './rules/pkg-renaming'
7 |
8 | export const rules = {
9 | 'import-from-emotion': importFromEmotion,
10 | 'no-vanilla': noVanilla,
11 | 'syntax-preference': syntaxPreference,
12 | 'styled-import': styledImport,
13 | 'jsx-import': jsxImport,
14 | 'pkg-renaming': pkgRenaming
15 | }
16 |
--------------------------------------------------------------------------------
/packages/eslint-plugin/src/rules/no-vanilla.ts:
--------------------------------------------------------------------------------
1 | import { createRule } from '../utils'
2 |
3 | const messages = {
4 | vanillaEmotion: 'Vanilla emotion should not be used'
5 | }
6 |
7 | export default createRule({
8 | name: __filename,
9 | meta: {
10 | docs: {
11 | description: 'Ensure vanilla emotion is not used',
12 | recommended: false
13 | },
14 | messages,
15 | schema: [],
16 | type: 'problem'
17 | },
18 | defaultOptions: [],
19 | create(context) {
20 | return {
21 | ImportDeclaration(node) {
22 | if (node.source.value === '@emotion/css') {
23 | context.report({
24 | node: node.source,
25 | messageId: 'vanillaEmotion'
26 | })
27 | }
28 | }
29 | }
30 | }
31 | })
32 |
--------------------------------------------------------------------------------
/packages/eslint-plugin/src/utils.ts:
--------------------------------------------------------------------------------
1 | import { ESLintUtils } from '@typescript-eslint/utils'
2 | import { parse as parsePath } from 'path'
3 |
4 | const { version } = require('../package.json')
5 |
6 | export const REPO_URL = 'https://github.com/emotion-js/emotion'
7 |
8 | export const createRule = ESLintUtils.RuleCreator(name => {
9 | const ruleName = parsePath(name).name
10 |
11 | return `${REPO_URL}/blob/@emotion/eslint-plugin@${version}/packages/eslint-plugin/docs/rules/${ruleName}.md`
12 | })
13 |
--------------------------------------------------------------------------------
/packages/eslint-plugin/test/rules/no-vanilla.test.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * @jest-environment node
3 | */
4 |
5 | import { TSESLint } from '@typescript-eslint/utils'
6 | import rule from '../../src/rules/no-vanilla'
7 | import { espreeParser } from '../test-utils'
8 |
9 | const ruleTester = new TSESLint.RuleTester({
10 | parser: espreeParser,
11 | parserOptions: {
12 | ecmaVersion: 2018,
13 | sourceType: 'module',
14 | ecmaFeatures: {
15 | jsx: true
16 | }
17 | }
18 | })
19 |
20 | ruleTester.run('no-vanilla', rule, {
21 | valid: [{ code: `import { css } from '@emotion/react'` }],
22 | invalid: [
23 | {
24 | code: `import { css } from '@emotion/css'`,
25 | errors: [
26 | {
27 | messageId: 'vanillaEmotion'
28 | }
29 | ]
30 | }
31 | ]
32 | })
33 |
--------------------------------------------------------------------------------
/packages/eslint-plugin/test/test-utils.ts:
--------------------------------------------------------------------------------
1 | import resolveFrom from 'resolve-from'
2 |
3 | export const espreeParser: string = resolveFrom(
4 | require.resolve('eslint'),
5 | 'espree'
6 | )
7 |
--------------------------------------------------------------------------------
/packages/hash/README.md:
--------------------------------------------------------------------------------
1 | # @emotion/hash
2 |
3 | > A MurmurHash2 implementation
4 |
5 | ```jsx
6 | import hash from '@emotion/hash'
7 |
8 | hash('some-string') // 12fj1d
9 | ```
10 |
11 | The source of this is from https://github.com/garycourt/murmurhash-js/blob/master/murmurhash2_gc.js.
12 |
--------------------------------------------------------------------------------
/packages/hash/__tests__/index.js:
--------------------------------------------------------------------------------
1 | import hash from '@emotion/hash'
2 |
3 | test('accepts a string and returns a string as a hash', () => {
4 | expect(hash('something')).toBe('crsxd7')
5 | })
6 |
--------------------------------------------------------------------------------
/packages/hash/types/index.d.ts:
--------------------------------------------------------------------------------
1 | export { default } from '..'
2 |
--------------------------------------------------------------------------------
/packages/hash/types/tests.ts:
--------------------------------------------------------------------------------
1 | import hash from '@emotion/hash'
2 |
3 | // $ExpectType string
4 | hash('color: hotpink;')
5 |
6 | // $ExpectError
7 | hash()
8 | // $ExpectError
9 | const hashed2: number = hash('color: hotpink;')
10 | // $ExpectError
11 | hash(42)
12 | // $ExpectError
13 | hash({})
14 | // $ExpectError
15 | hash('color: hotpink;', 'background-color: #fff;')
16 |
--------------------------------------------------------------------------------
/packages/hash/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/hash/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 | "unnecessary-bind": false
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/packages/is-prop-valid/README.md:
--------------------------------------------------------------------------------
1 | # @emotion/is-prop-valid
2 |
3 | > Check whether a prop is valid for HTML and SVG elements
4 |
5 | ```bash
6 | yarn add @emotion/is-prop-valid
7 | ```
8 |
9 | ```jsx
10 | import isPropValid from '@emotion/is-prop-valid'
11 |
12 | isPropValid('href') // true
13 |
14 | isPropValid('someRandomProp') // false
15 | ```
16 |
--------------------------------------------------------------------------------
/packages/is-prop-valid/src/index.ts:
--------------------------------------------------------------------------------
1 | import memoize from '@emotion/memoize'
2 |
3 | declare const codegen: { require: (path: string) => any }
4 |
5 | // eslint-disable-next-line no-undef
6 | const reactPropsRegex: RegExp = codegen.require('./props')
7 |
8 | // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23
9 | const isPropValid = /* #__PURE__ */ memoize(
10 | prop =>
11 | reactPropsRegex.test(prop) ||
12 | (prop.charCodeAt(0) === 111 /* o */ &&
13 | prop.charCodeAt(1) === 110 /* n */ &&
14 | prop.charCodeAt(2) < 91) /* Z+1 */
15 | )
16 |
17 | export default isPropValid
18 |
--------------------------------------------------------------------------------
/packages/is-prop-valid/types/index.d.ts:
--------------------------------------------------------------------------------
1 | // TypeScript Version: 2.1
2 |
3 | export { default } from '..'
4 |
--------------------------------------------------------------------------------
/packages/is-prop-valid/types/tests.ts:
--------------------------------------------------------------------------------
1 | import isPropValid from '@emotion/is-prop-valid'
2 |
3 | isPropValid('ref')
4 |
5 | // $ExpectError
6 | isPropValid()
7 | // $ExpectError
8 | isPropValid({})
9 | // $ExpectError
10 | isPropValid('ref', 'def')
11 |
--------------------------------------------------------------------------------
/packages/is-prop-valid/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/is-prop-valid/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 | "no-default-import": false,
22 | "unnecessary-bind": false
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/packages/jest/enzyme-serializer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "dist/emotion-jest-enzyme-serializer.cjs.js",
3 | "module": "dist/emotion-jest-enzyme-serializer.esm.js",
4 | "types": "../types/enzyme-serializer"
5 | }
6 |
--------------------------------------------------------------------------------
/packages/jest/enzyme/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "dist/emotion-jest-enzyme.cjs.js",
3 | "module": "dist/emotion-jest-enzyme.esm.js"
4 | }
5 |
--------------------------------------------------------------------------------
/packages/jest/serializer/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "dist/emotion-jest-serializer.cjs.js",
3 | "module": "dist/emotion-jest-serializer.esm.js",
4 | "types": "../types/serializer"
5 | }
6 |
--------------------------------------------------------------------------------
/packages/jest/src/enzyme-serializer.d.ts:
--------------------------------------------------------------------------------
1 | export * from '../types/enzyme-serializer'
2 |
--------------------------------------------------------------------------------
/packages/jest/src/enzyme-serializer.js:
--------------------------------------------------------------------------------
1 | import { createEnzymeSerializer } from './create-enzyme-serializer'
2 | export const { test, serialize } = createEnzymeSerializer()
3 |
--------------------------------------------------------------------------------
/packages/jest/src/enzyme-tickler.js:
--------------------------------------------------------------------------------
1 | import { unwrapFromPotentialFragment } from './utils'
2 |
3 | const tickledCssProps = new WeakMap()
4 |
5 | export const getTickledClassName = cssProp => tickledCssProps.get(cssProp)
6 |
7 | export const tickle = wrapper => {
8 | const isShallow = typeof wrapper.dive === 'function'
9 |
10 | wrapper.find('EmotionCssPropInternal').forEach(el => {
11 | const cssProp = el.props().css
12 |
13 | if (!cssProp) {
14 | return
15 | }
16 |
17 | const rendered = (isShallow ? el.dive() : el.children()).last()
18 | tickledCssProps.set(
19 | cssProp,
20 | unwrapFromPotentialFragment(rendered).props().className
21 | )
22 | })
23 | return wrapper
24 | }
25 |
--------------------------------------------------------------------------------
/packages/jest/src/enzyme.d.ts:
--------------------------------------------------------------------------------
1 | export * from '../types/enzyme'
2 |
--------------------------------------------------------------------------------
/packages/jest/src/enzyme.js:
--------------------------------------------------------------------------------
1 | export { createEnzymeSerializer } from './create-enzyme-serializer'
2 | export { matchers } from './matchers'
3 |
--------------------------------------------------------------------------------
/packages/jest/src/index.d.ts:
--------------------------------------------------------------------------------
1 | export * from '../types'
2 |
--------------------------------------------------------------------------------
/packages/jest/src/index.js:
--------------------------------------------------------------------------------
1 | export { createSerializer } from './create-serializer'
2 | export { matchers } from './matchers'
3 |
--------------------------------------------------------------------------------
/packages/jest/src/serializer.d.ts:
--------------------------------------------------------------------------------
1 | export * from '../types/serializer'
2 |
--------------------------------------------------------------------------------
/packages/jest/src/serializer.js:
--------------------------------------------------------------------------------
1 | import { createSerializer } from './create-serializer'
2 | export const { test, serialize } = createSerializer()
3 |
--------------------------------------------------------------------------------
/packages/jest/test/__snapshots__/matchers.test.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`toHaveStyleRule returns a message explaining the failure 1`] = `
4 | "Expected color to match:
5 | [32mblue[39m
6 | Received:
7 | [31mred[39m"
8 | `;
9 |
10 | exports[`toHaveStyleRule returns a message explaining the failure 2`] = `
11 | "Expected color not to match:
12 | [32mred[39m
13 | Received:
14 | [31mred[39m"
15 | `;
16 |
--------------------------------------------------------------------------------
/packages/jest/types/enzyme-serializer.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | type SnapshotSerializerPlugin = Extract<
4 | jest.SnapshotSerializerPlugin,
5 | { serialize: any }
6 | >
7 |
8 | export const test: SnapshotSerializerPlugin['test']
9 | export const serialize: SnapshotSerializerPlugin['serialize']
10 |
--------------------------------------------------------------------------------
/packages/jest/types/enzyme.d.ts:
--------------------------------------------------------------------------------
1 | // TypeScript Version: 4.3
2 |
3 | ///
4 |
5 | import {
6 | CreateSerializerOptions,
7 | EmotionMatchers,
8 | StyleRuleOptions
9 | } from './index'
10 | export { CreateSerializerOptions, EmotionMatchers, StyleRuleOptions }
11 |
12 | type SnapshotSerializerPlugin = Extract<
13 | jest.SnapshotSerializerPlugin,
14 | { serialize: any }
15 | >
16 |
17 | export const matchers: EmotionMatchers
18 |
19 | export function createEnzymeSerializer(
20 | options?: CreateSerializerOptions
21 | ): SnapshotSerializerPlugin
22 |
--------------------------------------------------------------------------------
/packages/jest/types/serializer.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
3 | type SnapshotSerializerPlugin = Extract<
4 | jest.SnapshotSerializerPlugin,
5 | { serialize: any }
6 | >
7 |
8 | export const test: SnapshotSerializerPlugin['test']
9 | export const serialize: SnapshotSerializerPlugin['serialize']
10 |
--------------------------------------------------------------------------------
/packages/jest/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 | "types": []
12 | },
13 | "include": ["./*.ts", "./*.tsx"]
14 | }
15 |
--------------------------------------------------------------------------------
/packages/jest/types/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@definitelytyped/dtslint/dtslint.json",
3 | "rules": {
4 | "array-type": [true, "generic"],
5 | "semicolon": false,
6 | "file-name-casing": false,
7 | "strict-export-declare-modifiers": false,
8 | "unnecessary-bind": false
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/packages/memoize/src/index.ts:
--------------------------------------------------------------------------------
1 | export default function memoize(fn: (arg: string) => V): (arg: string) => V {
2 | const cache: Record = Object.create(null)
3 |
4 | return (arg: string) => {
5 | if (cache[arg] === undefined) cache[arg] = fn(arg)
6 | return cache[arg]
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/packages/memoize/types/index.d.ts:
--------------------------------------------------------------------------------
1 | export { default } from '..'
2 |
--------------------------------------------------------------------------------
/packages/memoize/types/tests.ts:
--------------------------------------------------------------------------------
1 | import memoize from '@emotion/memoize'
2 |
3 | // $ExpectType string[]
4 | memoize((arg: string) => [arg])('foo')
5 |
6 | // $ExpectError
7 | memoize((arg: number) => [arg])
8 |
--------------------------------------------------------------------------------
/packages/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/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 |
--------------------------------------------------------------------------------
/packages/native/macro.d.mts:
--------------------------------------------------------------------------------
1 | import styled from '@emotion/native'
2 | export * from '@emotion/native'
3 | export default styled
4 |
--------------------------------------------------------------------------------
/packages/native/macro.d.ts:
--------------------------------------------------------------------------------
1 | import styled from '@emotion/native'
2 | export * from '@emotion/native'
3 | export default styled
4 |
--------------------------------------------------------------------------------
/packages/native/macro.js:
--------------------------------------------------------------------------------
1 | module.exports = require('@emotion/babel-plugin').macros.nativeStyled
2 |
--------------------------------------------------------------------------------
/packages/native/src/base.js:
--------------------------------------------------------------------------------
1 | import { StyleSheet } from 'react-native'
2 | import { createStyled } from '@emotion/primitives-core'
3 |
4 | /**
5 | * a function that returns a styled component which render styles in React Native
6 | */
7 | let styled = createStyled(StyleSheet)
8 |
9 | export { styled }
10 |
--------------------------------------------------------------------------------
/packages/native/src/index.d.ts:
--------------------------------------------------------------------------------
1 | export * from '../types'
2 | export { default } from '../types'
3 |
--------------------------------------------------------------------------------
/packages/native/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "esModuleInterop": true,
4 | "forceConsistentCasingInFileNames": true,
5 | "isolatedModules": true,
6 | "jsx": "react",
7 | "lib": ["es6", "dom"],
8 | "module": "commonjs",
9 | "noEmit": true,
10 | "skipLibCheck": true,
11 | "skipDefaultLibCheck": true,
12 | "resolveJsonModule": true,
13 | "strict": true,
14 | "target": "es5",
15 | "types": []
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/packages/native/types/resolved-condition.ts:
--------------------------------------------------------------------------------
1 | export default true as boolean
2 |
--------------------------------------------------------------------------------
/packages/native/types/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": "../",
4 | "forceConsistentCasingInFileNames": true,
5 | "jsx": "react",
6 | "lib": ["es6", "dom"],
7 | "module": "commonjs",
8 | "esModuleInterop": true,
9 | "resolveJsonModule": true,
10 | "noEmit": true,
11 | "strict": true,
12 | "target": "es5",
13 | "typeRoots": ["../"],
14 | "types": [],
15 | "skipLibCheck": true,
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/native/types/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@definitelytyped/dtslint/dtslint.json",
3 | "rules": {
4 | "array-type": [true, "generic"],
5 | "callable-types": false,
6 | "import-spacing": false,
7 | "semicolon": false,
8 | "whitespace": [
9 | true,
10 | "check-branch",
11 | "check-decl",
12 | "check-operator",
13 | "check-module",
14 | "check-rest-spread",
15 | "check-type",
16 | "check-typecast",
17 | "check-type-operator",
18 | "check-preblock"
19 | ],
20 | "no-null-undefined-union": false,
21 | "no-unnecessary-generics": false,
22 | "strict-export-declare-modifiers": false,
23 | "unnecessary-bind": false,
24 | "ban-ts-ignore": false
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/packages/primitives-core/src/conditions/false.ts:
--------------------------------------------------------------------------------
1 | export default false
2 |
--------------------------------------------------------------------------------
/packages/primitives-core/src/conditions/true.ts:
--------------------------------------------------------------------------------
1 | export default true
2 |
--------------------------------------------------------------------------------
/packages/primitives-core/src/index.ts:
--------------------------------------------------------------------------------
1 | export { createCss } from './css'
2 | export { createStyled } from './styled'
3 |
--------------------------------------------------------------------------------
/packages/primitives-core/src/types.ts:
--------------------------------------------------------------------------------
1 | type NamedStyles = { [P in keyof T]: unknown }
2 |
3 | // This is based on the StyleSheet type from @types/react-native
4 | export interface AbstractStyleSheet {
5 | create | NamedStyles>(
6 | styles: T | NamedStyles
7 | ): T
8 |
9 | flatten(style?: unknown[]): unknown
10 | }
11 |
--------------------------------------------------------------------------------
/packages/primitives-core/src/utils.ts:
--------------------------------------------------------------------------------
1 | export function interleave(
2 | vals: [TemplateStringsArray, ...unknown[]]
3 | ): unknown[] {
4 | let strings = vals[0]
5 | let finalArray: unknown[] = [strings[0]]
6 | for (let i = 1, len = vals.length; i < len; i++) {
7 | finalArray.push(vals[i])
8 | if (strings[i] !== undefined) {
9 | finalArray.push(strings[i])
10 | }
11 | }
12 | return finalArray
13 | }
14 |
--------------------------------------------------------------------------------
/packages/primitives/examples/index.js:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 |
3 | import styled from '@emotion/primitives'
4 |
5 | const Container = styled.View`
6 | display: flex;
7 | justify-content: center;
8 | margin-top: 50px;
9 | `
10 |
11 | const Title = styled.Text`
12 | font-size: 20px;
13 | color: hotpink;
14 | `
15 |
16 | const Description = styled.Text`
17 | font-size: 15px;
18 | color: #4c4c4c;
19 | `
20 |
21 | class App extends React.Component {
22 | render() {
23 | return (
24 |
25 | Emotion Primitives
26 | Style and render primitives across targets.
27 |
28 | )
29 | }
30 | }
31 |
32 | export default App
33 |
--------------------------------------------------------------------------------
/packages/primitives/macro.js:
--------------------------------------------------------------------------------
1 | module.exports = require('@emotion/babel-plugin').macros.primitivesStyled
2 |
--------------------------------------------------------------------------------
/packages/primitives/src/conditions/false.js:
--------------------------------------------------------------------------------
1 | export default false
2 |
--------------------------------------------------------------------------------
/packages/primitives/src/conditions/true.js:
--------------------------------------------------------------------------------
1 | export default true
2 |
--------------------------------------------------------------------------------
/packages/primitives/src/index.js:
--------------------------------------------------------------------------------
1 | import { StyleSheet, Text, View, Image } from 'react-primitives'
2 | import { createCss } from '@emotion/primitives-core'
3 |
4 | import { styled as createStyled } from './styled'
5 |
6 | const css = createCss(StyleSheet)
7 |
8 | const assignPrimitives = styled => {
9 | createStyled.Text = createStyled(Text)
10 | createStyled.View = createStyled(View)
11 | createStyled.Image = createStyled(Image)
12 |
13 | return styled
14 | }
15 |
16 | export { css }
17 |
18 | export default /* #__PURE__ */ assignPrimitives(createStyled)
19 |
--------------------------------------------------------------------------------
/packages/primitives/test/no-babel/__snapshots__/basic.test.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`should render the primitive when styles applied using object style notation 1`] = `
4 |
13 | Emotion Primitives
14 |
15 | `;
16 |
--------------------------------------------------------------------------------
/packages/primitives/test/warnings.test.js:
--------------------------------------------------------------------------------
1 | import { css } from '@emotion/primitives'
2 |
3 | console.error = jest.fn()
4 |
5 | afterEach(() => {
6 | jest.clearAllMocks()
7 | })
8 |
9 | test('does warn when functions are passed to cx calls ', () => {
10 | css(() => ({}))
11 | expect(console.error).toBeCalledWith(
12 | 'Interpolating functions in css calls is not allowed.\n' +
13 | 'If you want to have a css call based on props, create a function that returns a css call like this\n' +
14 | 'let dynamicStyle = (props) => css`color: ${props.color}`\n' +
15 | 'It can be called directly with props or interpolated in a styled call like this\n' +
16 | 'let SomeComponent = styled.View`${dynamicStyle}`'
17 | )
18 | })
19 |
--------------------------------------------------------------------------------
/packages/react/README.md:
--------------------------------------------------------------------------------
1 | # @emotion/react
2 |
3 | > Simple styling in React.
4 |
5 | ## Install
6 |
7 | ```bash
8 | yarn add @emotion/react
9 | ```
10 |
11 | ## Usage
12 |
13 | ```jsx
14 | /** @jsx jsx */
15 | import { jsx, css, Global, ClassNames } from '@emotion/react'
16 |
17 | render(
18 |
19 |
24 |
32 |
33 | {({ css, cx }) => (
34 |
42 | )}
43 |
44 |
45 | )
46 | ```
47 |
48 | More documentation is available at [https://emotion.sh](https://emotion.sh).
49 |
--------------------------------------------------------------------------------
/packages/react/__tests__/__snapshots__/at-import.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`basic 1`] = `
4 |
5 |
11 |
17 |
18 | `;
19 |
20 | exports[`basic 2`] = `
21 |
22 |
29 |
30 | `;
31 |
32 | exports[`basic 4`] = `
33 |
34 |
40 |
41 | `;
42 |
43 | exports[`basic 5`] = `
44 |
45 |
48 |
49 | `;
50 |
--------------------------------------------------------------------------------
/packages/react/__tests__/__snapshots__/class-names.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`css 1`] = `
4 | .emotion-0 {
5 | color: hotpink;
6 | }
7 |
8 |
11 | `;
12 |
13 | exports[`cx 1`] = `
14 | .emotion-0 {
15 | color: hotpink;
16 | color: green;
17 | }
18 |
19 |
22 | `;
23 |
24 | exports[`should get the theme 1`] = `
25 | .emotion-0 {
26 | color: green;
27 | }
28 |
29 |
32 | `;
33 |
--------------------------------------------------------------------------------
/packages/react/__tests__/__snapshots__/css-cache-hash.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`does not rehash if value is css call return value 1`] = `
4 | .emotion-0 {
5 | color: hotpink;
6 | }
7 |
8 |
13 | `;
14 |
--------------------------------------------------------------------------------
/packages/react/__tests__/__snapshots__/legacy-class-name.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`object className 1`] = `
4 | .emotion-0 {
5 | color: hotpink;
6 | }
7 |
8 |
11 | `;
12 |
13 | exports[`string className 1`] = `
14 | .emotion-0 {
15 | color: hotpink;
16 | }
17 |
18 |
21 | `;
22 |
--------------------------------------------------------------------------------
/packages/react/__tests__/__snapshots__/theme-provider.dom.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`provider with theme value that changes 1`] = `
4 | .emotion-0 {
5 | color: hotpink;
6 | padding: 4px;
7 | }
8 |
9 |
15 | `;
16 |
17 | exports[`provider with theme value that changes 2`] = `
18 | .emotion-0 {
19 | color: hotpink;
20 | padding: 8px;
21 | }
22 |
23 |
29 | `;
30 |
--------------------------------------------------------------------------------
/packages/react/__tests__/__snapshots__/use-theme.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`Nested useTheme works 1`] = `
4 | .emotion-0 {
5 | color: green;
6 | }
7 |
8 | .emotion-0:hover {
9 | color: darkgreen;
10 | }
11 |
12 | .emotion-1 {
13 | color: lawngreen;
14 | }
15 |
16 | .emotion-1:hover {
17 | color: seagreen;
18 | }
19 |
20 |
23 | Should be green
24 |
27 | Should be lawngreen
28 |
29 |
30 | `;
31 |
32 | exports[`useTheme works 1`] = `
33 | .emotion-0 {
34 | color: green;
35 | }
36 |
37 | .emotion-0:hover {
38 | color: darkgreen;
39 | }
40 |
41 |
44 | Should be green
45 |
46 | `;
47 |
--------------------------------------------------------------------------------
/packages/react/__tests__/__snapshots__/with-theme.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`withTheme works 1`] = `"green"`;
4 |
--------------------------------------------------------------------------------
/packages/react/__tests__/babel/__snapshots__/css.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`composition of dynamic array css prop with cssprop-generated className (#1730) 1`] = `
4 | .emotion-0 {
5 | width: 50px;
6 | height: 50px;
7 | background-color: green;
8 | color: hotpink;
9 | }
10 |
11 |
14 | I'm hotpink on the green background.
15 |
16 | `;
17 |
18 | exports[`tagged template args forwarded 1`] = `
19 | @media (min-width: 100px) {
20 | .emotion-0 {
21 | color: red;
22 | }
23 | }
24 |
25 |
28 | something
29 |
30 | `;
31 |
--------------------------------------------------------------------------------
/packages/react/__tests__/babel/source-map-server.js:
--------------------------------------------------------------------------------
1 | /** @jsx jsx
2 | * @jest-environment node
3 | */
4 |
5 | import { jsx } from '@emotion/react'
6 | import { renderToString } from 'react-dom/server'
7 |
8 | test('basic', () => {
9 | let html = renderToString(
10 |
18 | some hotpink text
19 |
20 | )
21 | expect(html).toMatchSnapshot()
22 | })
23 |
--------------------------------------------------------------------------------
/packages/react/__tests__/clone-element.js:
--------------------------------------------------------------------------------
1 | /** @jsx jsx */
2 | import { jsx } from '@emotion/react'
3 | import * as React from 'react'
4 | import { render, cleanup } from '@testing-library/react'
5 |
6 | afterEach(cleanup)
7 |
8 | test('can cloneElement with element with css prop', () => {
9 | let element =
10 |
11 | let cloned = React.cloneElement(element, { id: 'cloned' })
12 |
13 | let { container } = render(cloned)
14 |
15 | expect(container.firstChild.id).toBe('cloned')
16 | })
17 |
--------------------------------------------------------------------------------
/packages/react/__tests__/compat/__snapshots__/browser.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`composition works from old emotion css calls 1`] = `
4 |
5 |
6 |
13 |
14 |
15 |
20 |
21 |
22 | `;
23 |
--------------------------------------------------------------------------------
/packages/react/__tests__/compat/browser.js:
--------------------------------------------------------------------------------
1 | /** @jsx jsx */
2 | import { throwIfFalsy } from 'test-utils'
3 | import { jsx, CacheProvider } from '@emotion/react'
4 | import { render } from '@testing-library/react'
5 | import { css, cache } from '@emotion/css'
6 |
7 | test('composition works from old emotion css calls', () => {
8 | const cls = css`
9 | color: green;
10 | `
11 | render(
12 |
13 |
14 |
15 | )
16 | expect(document.documentElement).toMatchSnapshot()
17 | })
18 |
--------------------------------------------------------------------------------
/packages/react/__tests__/css-cache-hash.js:
--------------------------------------------------------------------------------
1 | /** @jsx jsx */
2 | import 'test-utils/next-env'
3 | import { jsx, css } from '@emotion/react'
4 | import { serializeStyles } from '@emotion/serialize'
5 | import * as renderer from 'react-test-renderer'
6 | const utils = require('@emotion/utils')
7 |
8 | const spy = jest.spyOn(utils, 'insertStyles')
9 |
10 | test('does not rehash if value is css call return value', () => {
11 | const val = css`
12 | color: hotpink;
13 | `
14 | const tree = renderer.create(
15 |
18 | )
19 | expect(serializeStyles([val])).toBe(val)
20 |
21 | expect(spy.mock.calls[0][1]).toBe(val)
22 | expect(tree.toJSON()).toMatchSnapshot()
23 | })
24 |
--------------------------------------------------------------------------------
/packages/react/__tests__/global-insertion-after-others.js:
--------------------------------------------------------------------------------
1 | /** @jsx jsx */
2 | import { jsx, Global } from '@emotion/react'
3 | import { render } from '@testing-library/react'
4 |
5 | let getDataAttributes = () =>
6 | Array.from(document.querySelectorAll('style[data-emotion]'), x =>
7 | x.getAttribute('data-emotion')
8 | )
9 |
10 | test('Global style element insertion after insertion of other styles', () => {
11 | let Comp = ({ second }) => (
12 |
13 |
18 | {second && (
19 |
26 | )}
27 |
28 | )
29 | let { rerender } = render( )
30 | expect(getDataAttributes()).toEqual(['css'])
31 | rerender( )
32 | expect(getDataAttributes()).toEqual(['css-global', 'css'])
33 | })
34 |
--------------------------------------------------------------------------------
/packages/react/__tests__/legacy-class-name.js:
--------------------------------------------------------------------------------
1 | /** @jsx jsx */
2 | import 'test-utils/next-env'
3 | import { jsx, css } from '@emotion/react'
4 | import renderer from 'react-test-renderer'
5 |
6 | test('string className', () => {
7 | const tree = renderer
8 | .create(
9 |
15 | )
16 | .toJSON()
17 |
18 | expect(tree).toMatchSnapshot()
19 | })
20 |
21 | test('object className', () => {
22 | const tree = renderer
23 | .create(
24 | 'legacy__class' }}
26 | css={css`
27 | color: hotpink;
28 | `}
29 | />
30 | )
31 | .toJSON()
32 |
33 | expect(tree).toMatchSnapshot()
34 | })
35 |
--------------------------------------------------------------------------------
/packages/react/__tests__/prod.js:
--------------------------------------------------------------------------------
1 | /** @jsx jsx */
2 | import { css, jsx } from '@emotion/react'
3 | import renderer from 'react-test-renderer'
4 |
5 | gate({ development: false }, ({ test }) => {
6 | test('css works', () => {
7 | // css has a different return in prod so this is just making sure that isn't broken
8 |
9 | expect(css({ color: 'hotpink' })).toMatchInlineSnapshot(`
10 | {
11 | "name": "1lrxbo5",
12 | "next": undefined,
13 | "styles": "color:hotpink;",
14 | }
15 | `)
16 | })
17 |
18 | test('props work', () => {
19 | let tree = renderer.create(
)
20 | expect(tree.toJSON().props.hidden).toBe(true)
21 | })
22 | })
23 |
--------------------------------------------------------------------------------
/packages/react/__tests__/ref.js:
--------------------------------------------------------------------------------
1 | /** @jsx jsx */
2 | import { jsx } from '@emotion/react'
3 | import * as React from 'react'
4 | import { render, cleanup } from '@testing-library/react'
5 |
6 | afterEach(cleanup)
7 |
8 | test('ref works', () => {
9 | let ref = React.createRef()
10 | let { getByTestId } = render(
11 |
12 | )
13 |
14 | expect(getByTestId('test')).toBe(ref.current)
15 | })
16 |
--------------------------------------------------------------------------------
/packages/react/_isolated-hnrs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "dist/emotion-react-_isolated-hnrs.cjs.js",
3 | "module": "dist/emotion-react-_isolated-hnrs.esm.js",
4 | "umd:main": "dist/emotion-react-_isolated-hnrs.umd.min.js",
5 | "types": "dist/emotion-react-_isolated-hnrs.cjs.d.ts",
6 | "sideEffects": false,
7 | "preconstruct": {
8 | "umdName": "emotionHoistNonReactStatics"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/packages/react/jsx-dev-runtime/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "dist/emotion-react-jsx-dev-runtime.cjs.js",
3 | "module": "dist/emotion-react-jsx-dev-runtime.esm.js",
4 | "umd:main": "dist/emotion-react-jsx-dev-runtime.umd.min.js",
5 | "types": "dist/emotion-react-jsx-dev-runtime.cjs.d.ts",
6 | "sideEffects": false,
7 | "preconstruct": {
8 | "umdName": "emotionReactJSXDevRuntime"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/packages/react/jsx-runtime/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "dist/emotion-react-jsx-runtime.cjs.js",
3 | "module": "dist/emotion-react-jsx-runtime.esm.js",
4 | "umd:main": "dist/emotion-react-jsx-runtime.umd.min.js",
5 | "types": "dist/emotion-react-jsx-runtime.cjs.d.ts",
6 | "sideEffects": false,
7 | "preconstruct": {
8 | "umdName": "emotionReactJSXRuntime"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/packages/react/macro.d.mts:
--------------------------------------------------------------------------------
1 | export * from './macro.js'
2 |
--------------------------------------------------------------------------------
/packages/react/macro.d.ts:
--------------------------------------------------------------------------------
1 | export * from '@emotion/react'
2 |
--------------------------------------------------------------------------------
/packages/react/macro.js:
--------------------------------------------------------------------------------
1 | module.exports = require('@emotion/babel-plugin').macros.core
2 |
--------------------------------------------------------------------------------
/packages/react/src/_isolated-hnrs.ts:
--------------------------------------------------------------------------------
1 | // this file isolates this package that is not tree-shakeable
2 | // and allows it to be dropped - if it stays unused
3 | // it happens thanks to sideEffects: false in our package.json
4 | import hoistNonReactStatics from 'hoist-non-react-statics'
5 |
6 | // have to wrap it in a proxy function because Rollup is too damn smart
7 | // and if this module doesn't actually contain any logic of its own
8 | // then Rollup just use 'hoist-non-react-statics' directly in other chunks
9 | export default <
10 | T extends React.ComponentType
,
11 | S extends React.ComponentType
12 | >(
13 | targetComponent: T,
14 | sourceComponent: S
15 | ) => hoistNonReactStatics(targetComponent, sourceComponent)
16 |
--------------------------------------------------------------------------------
/packages/react/src/conditions/false.ts:
--------------------------------------------------------------------------------
1 | export default false
2 |
--------------------------------------------------------------------------------
/packages/react/src/conditions/is-browser.ts:
--------------------------------------------------------------------------------
1 | export default typeof document !== 'undefined'
2 |
--------------------------------------------------------------------------------
/packages/react/src/conditions/true.ts:
--------------------------------------------------------------------------------
1 | export default true
2 |
--------------------------------------------------------------------------------
/packages/react/src/css.ts:
--------------------------------------------------------------------------------
1 | import type { SerializedStyles } from '@emotion/utils'
2 | import type { CSSInterpolation } from '@emotion/serialize'
3 | import { serializeStyles } from '@emotion/serialize'
4 |
5 | function css(
6 | template: TemplateStringsArray,
7 | ...args: CSSInterpolation[]
8 | ): SerializedStyles
9 | function css(...args: CSSInterpolation[]): SerializedStyles
10 | function css(...args: CSSInterpolation[]) {
11 | return serializeStyles(args)
12 | }
13 |
14 | export default css
15 |
--------------------------------------------------------------------------------
/packages/react/src/keyframes.ts:
--------------------------------------------------------------------------------
1 | import { CSSInterpolation } from '@emotion/serialize'
2 | import css from './css'
3 |
4 | type Keyframes = {
5 | name: string
6 | styles: string
7 | anim: 1
8 | toString: () => string
9 | } & string
10 |
11 | export function keyframes(
12 | template: TemplateStringsArray,
13 | ...args: CSSInterpolation[]
14 | ): Keyframes
15 | export function keyframes(...args: CSSInterpolation[]): Keyframes
16 | export function keyframes(...args: CSSInterpolation[]) {
17 | let insertable = css(...args)
18 | const name = `animation-${insertable.name}`
19 | return {
20 | name,
21 | styles: `@keyframes ${name}{${insertable.styles}}`,
22 | anim: 1,
23 | toString() {
24 | return `_EMO_${this.name}_${this.styles}_EMO_`
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/packages/react/src/types.ts:
--------------------------------------------------------------------------------
1 | import { ReactJSX } from './jsx-namespace'
2 |
3 | /**
4 | * @desc Utility type for getting props type of React component.
5 | * It takes `defaultProps` into an account - making props with defaults optional.
6 | */
7 | export type PropsOf<
8 | C extends keyof ReactJSX.IntrinsicElements | React.JSXElementConstructor
9 | > = ReactJSX.LibraryManagedAttributes>
10 |
11 | // We need to use this version of Omit as it's distributive (Will preserve unions)
12 | export type DistributiveOmit = T extends any
13 | ? Pick>
14 | : never
15 |
--------------------------------------------------------------------------------
/packages/react/src/utils.ts:
--------------------------------------------------------------------------------
1 | export const hasOwn = {}.hasOwnProperty
2 |
--------------------------------------------------------------------------------
/packages/react/types/css-prop.d.ts:
--------------------------------------------------------------------------------
1 | import {} from 'react'
2 | import { Interpolation } from '@emotion/serialize'
3 | import { Theme } from '@emotion/react'
4 |
5 | declare module 'react' {
6 | interface Attributes {
7 | css?: Interpolation
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/packages/react/types/index.d.ts:
--------------------------------------------------------------------------------
1 | // TypeScript Version: 4.1
2 | export * from '..'
3 |
--------------------------------------------------------------------------------
/packages/react/types/resolved-condition.ts:
--------------------------------------------------------------------------------
1 | export default true as boolean
2 |
--------------------------------------------------------------------------------
/packages/react/types/tests-css.tsx:
--------------------------------------------------------------------------------
1 | import { css } from '@emotion/react'
2 |
3 | // $ExpectType SerializedStyles
4 | css()
5 | // $ExpectType SerializedStyles
6 | css([])
7 | // $ExpectType SerializedStyles
8 | css('abc')
9 | // $ExpectType SerializedStyles
10 | css('width: 200px;')
11 | // $ExpectType SerializedStyles
12 | css('display: block;', {
13 | flexGrow: 1,
14 | backgroundColor: 'red'
15 | })
16 | // $ExpectType SerializedStyles
17 | css`
18 | position: relative;
19 | top: 20px;
20 | `
21 | // $ExpectType SerializedStyles
22 | css`
23 | position: relative;
24 | top: ${'20px'};
25 | `
26 | // $ExpectType SerializedStyles
27 | css`
28 | position: relative;
29 | top: ${'20px'};
30 | `
31 |
32 | // $ExpectError
33 | css(() => 'height: 300px;')
34 |
35 | css`
36 | position: relative;
37 | flexgrow: ${
38 | // $ExpectError
39 | () => 20
40 | };
41 | `
42 |
--------------------------------------------------------------------------------
/packages/react/types/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": "../",
4 | "forceConsistentCasingInFileNames": true,
5 | "jsx": "react",
6 | "lib": ["es6", "dom"],
7 | "module": "commonjs",
8 | "esModuleInterop": true,
9 | "resolveJsonModule": true,
10 | "noEmit": true,
11 | "strict": true,
12 | "target": "es5",
13 | "typeRoots": ["../"],
14 | "types": [],
15 | "paths": {
16 | "#is-browser": ["./types/resolved-condition.ts"],
17 | "#is-development": ["./types/resolved-condition.ts"]
18 | }
19 | },
20 | "include": ["./*.ts", "./*.tsx"],
21 | "exclude": ["./css-prop.d.ts"]
22 | }
23 |
--------------------------------------------------------------------------------
/packages/react/types/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@definitelytyped/dtslint/dtslint.json",
3 | "rules": {
4 | "array-type": [true, "generic"],
5 | "callable-types": false,
6 | "file-name-casing": false,
7 | "import-spacing": false,
8 | "semicolon": false,
9 | "whitespace": [
10 | true,
11 | "check-branch",
12 | "check-decl",
13 | "check-operator",
14 | "check-module",
15 | "check-rest-spread",
16 | "check-type",
17 | "check-typecast",
18 | "check-type-operator",
19 | "check-preblock"
20 | ],
21 | "no-null-undefined-union": false,
22 | "no-object-literal-type-assertion": false,
23 | "no-unnecessary-generics": false,
24 | "no-empty-interface": false,
25 | "strict-export-declare-modifiers": false,
26 | "unnecessary-bind": false,
27 | "ban-ts-ignore": false
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/packages/serialize/src/conditions/false.ts:
--------------------------------------------------------------------------------
1 | export default false as boolean
2 |
--------------------------------------------------------------------------------
/packages/serialize/src/conditions/true.ts:
--------------------------------------------------------------------------------
1 | export default true as boolean
2 |
--------------------------------------------------------------------------------
/packages/serialize/types/index.d.ts:
--------------------------------------------------------------------------------
1 | export * from '..'
2 |
--------------------------------------------------------------------------------
/packages/serialize/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": ["./src/conditions/true.ts"],
15 | "#is-development": ["./src/conditions/true.ts"]
16 | }
17 | },
18 | "include": ["./*.ts", "./*.tsx"]
19 | }
20 |
--------------------------------------------------------------------------------
/packages/serialize/types/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@definitelytyped/dtslint/dtslint.json",
3 | "rules": {
4 | "array-type": [true, "generic"],
5 | "semicolon": false,
6 | "no-null-undefined-union": false,
7 | "callable-types": false
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/packages/server/README.md:
--------------------------------------------------------------------------------
1 | # @emotion/server
2 |
3 | > Extract and inline critical css with emotion.
4 |
5 | `@emotion/server` provides three APIs for doing server-side rendering with emotion to extract critical css, inline critical css in html to a string and inline critical css in html to a stream.
6 |
7 | [`@emotion/server`'s APIs are documented here.](https://emotion.sh/docs/ssr)
8 |
9 | ```bash
10 | npm install --save @emotion/css @emotion/server
11 | ```
12 |
--------------------------------------------------------------------------------
/packages/server/create-instance/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "dist/emotion-server-create-instance.cjs.js",
3 | "module": "dist/emotion-server-create-instance.esm.js",
4 | "types": "../types/create-instance"
5 | }
6 |
--------------------------------------------------------------------------------
/packages/server/src/conditions/false.js:
--------------------------------------------------------------------------------
1 | export default false
2 |
--------------------------------------------------------------------------------
/packages/server/src/conditions/true.js:
--------------------------------------------------------------------------------
1 | export default true
2 |
--------------------------------------------------------------------------------
/packages/server/src/create-instance/construct-style-tags-from-chunks.js:
--------------------------------------------------------------------------------
1 | /* import type { EmotionCache } from '@emotion/utils' */
2 | import { generateStyleTag } from './utils'
3 |
4 | const createConstructStyleTagsFromChunks =
5 | (cache /*: EmotionCache */, nonceString /*: string */) =>
6 | (
7 | criticalData /*: {
8 | html: string,
9 | styles: Array<{ key: string, ids: Array, css: string }>
10 | } */
11 | ) => {
12 | let styleTagsString = ''
13 |
14 | criticalData.styles.forEach(item => {
15 | styleTagsString += generateStyleTag(
16 | item.key,
17 | item.ids.join(' '),
18 | item.css,
19 | nonceString
20 | )
21 | })
22 |
23 | return styleTagsString
24 | }
25 |
26 | export default createConstructStyleTagsFromChunks
27 |
--------------------------------------------------------------------------------
/packages/server/src/create-instance/index.d.ts:
--------------------------------------------------------------------------------
1 | export * from '../../types/create-instance'
2 | export { default } from '../../types/create-instance'
3 |
--------------------------------------------------------------------------------
/packages/server/src/create-instance/utils.js:
--------------------------------------------------------------------------------
1 | export function generateStyleTag(
2 | cssKey /*: string */,
3 | ids /*: string */,
4 | styles /*: string */,
5 | nonceString /*: string */
6 | ) {
7 | return ``
8 | }
9 |
--------------------------------------------------------------------------------
/packages/server/src/index.d.ts:
--------------------------------------------------------------------------------
1 | export * from '../types'
2 |
--------------------------------------------------------------------------------
/packages/server/src/index.js:
--------------------------------------------------------------------------------
1 | import createEmotionServer from './create-instance'
2 | import { cache } from '@emotion/css'
3 |
4 | export const {
5 | extractCritical,
6 | extractCriticalToChunks,
7 | renderStylesToString,
8 | renderStylesToNodeStream,
9 | constructStyleTagsFromChunks
10 | } = createEmotionServer(cache)
11 |
--------------------------------------------------------------------------------
/packages/server/types/create-instance.d.ts:
--------------------------------------------------------------------------------
1 | // Definitions by: Junyoung Clare Jang
2 | // TypeScript Version: 2.8
3 |
4 | ///
5 | import { EmotionCache } from '@emotion/utils'
6 |
7 | export interface EmotionCritical {
8 | html: string
9 | ids: Array
10 | css: string
11 | }
12 |
13 | export interface EmotionCriticalToChunks {
14 | html: string
15 | styles: Array<{ key: string; ids: Array; css: string }>
16 | }
17 |
18 | export interface EmotionServer {
19 | extractCritical(html: string): EmotionCritical
20 | extractCriticalToChunks(html: string): EmotionCriticalToChunks
21 | renderStylesToString(html: string): string
22 | renderStylesToNodeStream(): NodeJS.ReadWriteStream
23 | constructStyleTagsFromChunks(criticalData: EmotionCriticalToChunks): string
24 | }
25 |
26 | export default function createEmotionServer(cache: EmotionCache): EmotionServer
27 |
--------------------------------------------------------------------------------
/packages/server/types/index.d.ts:
--------------------------------------------------------------------------------
1 | // Definitions by: Junyoung Clare Jang
2 | // TypeScript Version: 2.8
3 |
4 | import { EmotionServer } from '@emotion/server/create-instance'
5 |
6 | export const extractCritical: EmotionServer['extractCritical']
7 | export const extractCriticalToChunks: EmotionServer['extractCriticalToChunks']
8 | export const renderStylesToString: EmotionServer['renderStylesToString']
9 | export const renderStylesToNodeStream: EmotionServer['renderStylesToNodeStream']
10 | export const constructStyleTagsFromChunks: EmotionServer['constructStyleTagsFromChunks']
11 |
--------------------------------------------------------------------------------
/packages/server/types/resolved-condition.ts:
--------------------------------------------------------------------------------
1 | export default true as boolean
2 |
--------------------------------------------------------------------------------
/packages/server/types/tests.tsx:
--------------------------------------------------------------------------------
1 | import {
2 | extractCritical,
3 | renderStylesToNodeStream,
4 | renderStylesToString
5 | } from '@emotion/server'
6 |
7 | declare const renderedString: string
8 | declare const renderedNodeStream: NodeJS.ReadableStream
9 |
10 | // $ExpectType EmotionCritical
11 | extractCritical(renderedString)
12 | // $ExpectError
13 | extractCritical()
14 | // $ExpectError
15 | extractCritical(renderedString, undefined as any)
16 |
17 | // $ExpectType string
18 | renderStylesToString(renderedString)
19 | // $ExpectError
20 | renderStylesToString()
21 | // $ExpectError
22 | renderStylesToString(renderedString, undefined as any)
23 |
24 | // $ExpectType ReadWriteStream
25 | renderStylesToNodeStream()
26 | // $ExpectError
27 | renderStylesToNodeStream(undefined as any)
28 |
29 | renderedNodeStream.pipe(renderStylesToNodeStream())
30 |
--------------------------------------------------------------------------------
/packages/server/types/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "baseUrl": "../",
4 | "forceConsistentCasingInFileNames": true,
5 | "jsx": "react",
6 | "lib": [
7 | "es6",
8 | // dom is needed here because @emotion/server depends on @emotion/css
9 | // which depends on @emotion/sheet, which depends on DOM types
10 | "dom"
11 | ],
12 | "module": "commonjs",
13 | "noEmit": true,
14 | "strict": true,
15 | "target": "es5",
16 | "typeRoots": ["../"],
17 | "types": [],
18 | "skipLibCheck": true,
19 | "paths": {
20 | "#is-browser": ["./types/resolved-condition.ts"],
21 | "#is-development": ["./types/resolved-condition.ts"]
22 | }
23 | },
24 | "include": ["./*.ts", "./*.tsx"]
25 | }
26 |
--------------------------------------------------------------------------------
/packages/server/types/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@definitelytyped/dtslint/dtslint.json",
3 | "rules": {
4 | "array-type": [true, "generic"],
5 | "semicolon": false,
6 | "file-name-casing": false,
7 | "unnecessary-bind": false
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/packages/sheet/src/conditions/false.ts:
--------------------------------------------------------------------------------
1 | export default false
2 |
--------------------------------------------------------------------------------
/packages/sheet/src/conditions/true.ts:
--------------------------------------------------------------------------------
1 | export default true
2 |
--------------------------------------------------------------------------------
/packages/sheet/types/index.d.ts:
--------------------------------------------------------------------------------
1 | // TypeScript Version: 2.0
2 |
3 | export * from '..'
4 |
--------------------------------------------------------------------------------
/packages/sheet/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-development": ["./src/conditions/true.ts"]
15 | }
16 | },
17 | "include": ["./*.ts", "./*.tsx"]
18 | }
19 |
--------------------------------------------------------------------------------
/packages/sheet/types/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@definitelytyped/dtslint/dtslint.json",
3 | "rules": {
4 | "array-type": [true, "generic"],
5 | "semicolon": false,
6 | "unnecessary-bind": false
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/packages/styled/README.md:
--------------------------------------------------------------------------------
1 | # @emotion/styled
2 |
3 | > The styled API for @emotion/react
4 |
5 | ## Install
6 |
7 | ```bash
8 | yarn add @emotion/react @emotion/styled
9 | ```
10 |
11 | ## Usage
12 |
13 | ```jsx
14 | import styled from '@emotion/styled'
15 |
16 | let SomeComp = styled.div({
17 | color: 'hotpink'
18 | })
19 |
20 | let AnotherComp = styled.div`
21 | color: ${props => props.color};
22 | `
23 |
24 | render(
25 |
26 |
27 |
28 | )
29 | ```
30 |
31 | More documentation is available at [https://emotion.sh/docs/styled](https://emotion.sh/docs/styled).
32 |
--------------------------------------------------------------------------------
/packages/styled/__tests__/__snapshots__/edge-cases.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`nested function using css 1`] = `
4 | .emotion-0 {
5 | color: blue;
6 | border: 2px solid #000;
7 | background-color: red;
8 | padding: 30px;
9 | }
10 |
11 |
14 | `;
15 |
16 | exports[`nested function using css and keyframes 1`] = `
17 | @keyframes animation-0 {
18 | from, to {
19 | color: green;
20 | }
21 |
22 | 50% {
23 | color: hotpink;
24 | }
25 | }
26 |
27 | .emotion-0 {
28 | -webkit-animation: animation-0;
29 | animation: animation-0;
30 | }
31 |
32 |
35 | `;
36 |
--------------------------------------------------------------------------------
/packages/styled/__tests__/edge-cases.js:
--------------------------------------------------------------------------------
1 | import 'test-utils/next-env'
2 | import * as React from 'react'
3 | import renderer from 'react-test-renderer'
4 | import styled from '@emotion/styled'
5 | import { css, keyframes } from '@emotion/react'
6 |
7 | test('nested function using css', () => {
8 | let Comp = styled.div`
9 | color: blue;
10 | border: 2px solid #000;
11 | ${() => css`
12 | background-color: red;
13 | `};
14 | padding: 30px;
15 | `
16 | const tree = renderer.create( )
17 |
18 | expect(tree.toJSON()).toMatchSnapshot()
19 | })
20 |
21 | test('nested function using css and keyframes', () => {
22 | let Comp = styled.div`
23 | ${() => css`
24 | animation: ${keyframes({
25 | 'from,to': { color: 'green' },
26 | '50%': {
27 | color: 'hotpink'
28 | }
29 | })};
30 | `};
31 | `
32 | const tree = renderer.create( )
33 |
34 | expect(tree.toJSON()).toMatchSnapshot()
35 | })
36 |
--------------------------------------------------------------------------------
/packages/styled/__tests__/styled-dom.js:
--------------------------------------------------------------------------------
1 | import * as React from 'react'
2 | import styled from '@emotion/styled'
3 | import { render, cleanup } from '@testing-library/react'
4 |
5 | afterEach(cleanup)
6 |
7 | test('ref', () => {
8 | const H1 = styled.h1`
9 | font-size: 12px;
10 | `
11 | let node
12 |
13 | render(
14 | {
16 | node = val
17 | }}
18 | id="thing"
19 | >
20 | hello world
21 |
22 | )
23 | expect(node).toBe(document.getElementById('thing'))
24 | })
25 |
--------------------------------------------------------------------------------
/packages/styled/base/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "main": "dist/emotion-styled-base.cjs.js",
3 | "module": "dist/emotion-styled-base.esm.js",
4 | "umd:main": "dist/emotion-styled-base.umd.min.js",
5 | "types": "dist/emotion-styled-base.cjs.d.ts",
6 | "preconstruct": {
7 | "umdName": "emotionStyledBase"
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/packages/styled/macro.d.mts:
--------------------------------------------------------------------------------
1 | import styled from '@emotion/styled'
2 | export * from '@emotion/styled'
3 | export default styled
4 |
--------------------------------------------------------------------------------
/packages/styled/macro.d.ts:
--------------------------------------------------------------------------------
1 | import styled from '@emotion/styled'
2 | export * from '@emotion/styled'
3 | export default styled
4 |
--------------------------------------------------------------------------------
/packages/styled/macro.js:
--------------------------------------------------------------------------------
1 | module.exports = require('@emotion/babel-plugin').macros.webStyled
2 |
--------------------------------------------------------------------------------
/packages/styled/src/conditions/false.ts:
--------------------------------------------------------------------------------
1 | export default false
2 |
--------------------------------------------------------------------------------
/packages/styled/src/conditions/is-browser.ts:
--------------------------------------------------------------------------------
1 | export default typeof document !== 'undefined'
2 |
--------------------------------------------------------------------------------
/packages/styled/src/conditions/true.ts:
--------------------------------------------------------------------------------
1 | export default true
2 |
--------------------------------------------------------------------------------
/packages/styled/src/jsx-namespace.ts:
--------------------------------------------------------------------------------
1 | // this is basically a slimmed down copy of https://github.com/emotion-js/emotion/blob/main/packages/react/types/jsx-namespace.d.ts
2 | // it helps to avoid issues when combining newer `@emotion/styled` and older `@emotion/react` versions
3 | // in such setup, ReactJSX namespace won't exist in `@emotion/react` and that would lead to errors
4 | import 'react'
5 |
6 | type IsPreReact19 = 2 extends Parameters>['length']
7 | ? true
8 | : false
9 |
10 | // prettier-ignore
11 | /** @ts-ignore */
12 | export type ReactJSXIntrinsicElements = true extends IsPreReact19 ? JSX.IntrinsicElements : React.JSX.IntrinsicElements
13 |
--------------------------------------------------------------------------------
/packages/styled/test/__snapshots__/theming.dom.test.js.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`change theme 1`] = `
4 | .emotion-0 {
5 | color: green;
6 | }
7 |
8 |
9 |
12 | this will be green then pink
13 |
14 |
15 | `;
16 |
17 | exports[`change theme 2`] = `
18 | .emotion-0 {
19 | color: pink;
20 | }
21 |
22 |
23 |
26 | this will be green then pink
27 |
28 |
29 | `;
30 |
31 | exports[`change theme 3`] = `
`;
32 |
--------------------------------------------------------------------------------
/packages/styled/test/babel-plugin.test.js:
--------------------------------------------------------------------------------
1 | import 'test-utils/legacy-env'
2 | import React from 'react'
3 | import * as renderer from 'react-test-renderer'
4 | import styled from '@emotion/styled'
5 |
6 | test("config merging works even if it's referenced by variable", () => {
7 | const Button = ({ isRed, ...rest }) => (
8 | {isRed ? 'forwarded' : 'not forwarded'}
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 |
--------------------------------------------------------------------------------