Skip to content

Commit 4003819

Browse files
authored
Upgrade to latest Next.js (attempt 2) (emotion-js#2805)
* Remove old site, create new Next app * Site header * Fix manypkg issues, copy in bootstrap-reboot.min.css * Website progress * Website progress * Website progress * yarn.lock * Website progress * Fix manypkg errors * Website progress * Website progress: markdown CSS * Website progress * Website progress * Remove spectrum badge from README * Add Carbon ads * Add DocSearch * Add favicon and set page <title> * Website tweaks * Update Netlify config and use next-export * Remove unnecessary dependencies from root package.json * Add custom 404 page * Live editor works (no Babel yet) * [wip] Babel compilation * About to remove web worker stuff * Website: Live code editor stuff * Remove Mac-specific step from CONTRIBUTING * Update CONTRIBUTING for new website development * Done with live code editors * Bring awesome-emotion into repo as an MDX doc * Add redirects to netlify.toml * Website styling, remove @jsx pragma from live code examples * Remove incorrect slack link from community.mdx * Review & tweak website styles * Make tables responsive on mobile * Set up @next/bundle-analyzer * Get @emotion/babel-plugin to work in the browser (HACKS) * Change Carbon ad when path changes * Fix live editor issues * Do LiveEditor compilation in web worker * Fork react-live * Working on live editors * Fix LiveProvider useEffect * Live editor tweaks * Fix web worker @emotion/babel-plugin import * Add website TS TODO * Add more detail to comment * Fix some but not all manypkg issues * Fix Safari-specific styling issues * Website: Use webpack alias for @emotion/babel-plugin * Add comment explaining module aliasing hack * site: Upgrade docsearch * site: Upgrade some packages * site: Upgrade some packages * site: Upgrade next-mdx-remote * Fix layout shift when carbon ads is loading * Make CI use Node 14 This is required for next-mdx-remote v4 * Remove .nvmrc to fix Netlify build * Add Ukraine banner to new website * Fix minor issues in styled.mdx * Minor mobile fixes * Convert GFM tables to HTML so we don't need the remark-gfm plugin * Upgrade all website packages * Update docsearch appId and apiKey (see emotion-js#2718) * Fixed CacheProvider demo in the docs (see emotion-js#2678) * CodeSandbox CI node 16 * Simplify .gitignore * Website cleanup after reviewing diff * Fix multiple @types/react * Add test:typescript script to emotion-site * Make all code blocks have the same font-size * Autolink headings * Minor website fixes * remark-responsive-tables
1 parent c9a1195 commit 4003819

File tree

142 files changed

+4103
-12820
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+4103
-12820
lines changed

.codesandbox/ci.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"packages": ["packages/*"],
33
"sandboxes": ["pk1qjqpw67"],
4-
"node": "12"
4+
"node": "16"
55
}

.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@ coverage/
44
node_modules/
55
stylis.min.js
66
/demo/dist
7-
/packages/site/build
8-
flow-typed/
7+
flow-typed/
8+
9+
# This is to prevent ESLint parsing errors in the website which is written in
10+
# TypeScript. TODO: Reenable once the codebase is converted to TypeScript.
11+
/site/

.github/actions/ci-setup/action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: 'CI setup'
22
runs:
33
using: 'composite'
44
steps:
5-
- name: Set Node.js 16.x
5+
- name: Setup Node.js 16.x
66
uses: actions/setup-node@v3
77
with:
88
node-version: 16.x

.gitignore

+7-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ dist/
44
node_modules/
55
*.log
66
.idea
7-
site/build
87
package-lock.json
98
.DS_Store
109
.cache
11-
public/
12-
!playgrounds/cra/public
1310
.env
1411
.vscode
15-
.parcel-cache/
12+
.parcel-cache/
13+
*.orig
14+
*.tsbuildinfo
15+
16+
# Website
17+
site/out
18+
.next

.nvmrc

-1
This file was deleted.

CONTRIBUTING.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55

66
## Installation
77

8-
- (If using an M1 Mac) Install `vips` via Homebrew: `brew install vips`.
9-
- This step can be removed from this document if we upgrade to the latest
10-
version of Gatsby, which is compatible with sharp 0.28.0+ which does include
11-
binaries for M1 Macs.
128
- (If using Windows) Enable Developer Mode in the Windows settings app. On Windows 11, this can be done by searching the start menu for "Developer settings" and then enabling the Developer Mode toggle switch.
139
- Run `yarn` in the repository's root directory to install everything you need for development.
1410
- Run `yarn build` in the root directory to build the modules.
@@ -27,9 +23,9 @@
2723

2824
## Documentation Website Development
2925

30-
- Run above installation steps and then
31-
- Run `yarn start:site` to run a development server of gatsby.
32-
- Run `yarn build:site` to create a build of the assets for the documentation website.
26+
- Run above installation steps and then `cd` to the `site` directory.
27+
- Run `yarn dev` to run the Next.js development server.
28+
- Run `yarn build` to create a build of the assets for the documentation website.
3329

3430
## Changesets
3531

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
![@emotion/styled size](https://img.shields.io/bundlephobia/min/@emotion/styled.svg?label=@emotion/styled%20size)
1717
![@emotion/styled gzip size](https://img.shields.io/bundlephobia/minzip/@emotion/styled.svg?label=@emotion/styled%20gzip%20size)
1818
[![slack](https://img.shields.io/badge/join-slack-green)](https://join.slack.com/t/emotion-slack/shared_invite/zt-rmtwsy74-2uvyFdz5uxa8OiMguJJeuQ)
19-
[![spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/emotion)
2019

2120
Emotion is a performant and flexible CSS-in-JS library. Building on many other CSS-in-JS libraries, it allows you to style apps quickly with string or object styles. It has predictable composition to avoid specificity issues with CSS. With source maps and labels, Emotion has a great developer experience and great performance with heavy caching in production.
2221

docs/babel.mdx

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
title: 'Babel Plugin'
33
---
44

5-
`@emotion/babel-plugin` is highly recommended. All of the options that can be provided to `@emotion/babel-plugin` are documented in [`@emotion/babel-plugin`'s README](https://github.com/emotion-js/emotion/tree/main/packages/babel-plugin).
5+
`@emotion/babel-plugin` is highly recommended. All of the options that can be provided to `@emotion/babel-plugin` are documented in [`@emotion/babel-plugin`'s README](/docs/@emotion/babel-plugin).
66

7-
### Install
7+
## Install
88

99
In `emotion` version 8 and above, installation is optional. In older versions, installation is required. See the [installation instructions](/docs/install.mdx).
1010

11-
### Features which are enabled with the babel plugin
11+
## Features which are enabled with the babel plugin
1212

13-
### Minification
13+
#### Minification
1414

1515
Any leading/trailing space between properties in your `css` and `styled` blocks is removed. This can reduce the size of your final bundle.
1616

17-
### Dead Code Elimination
17+
#### Dead Code Elimination
1818

1919
Uglifyjs will use the injected `/*#__PURE__*/` flag comments to mark your `css` and `styled` blocks as candidates for dead code elimination.
2020

21-
### Source Maps
21+
#### Source Maps
2222

2323
When enabled, navigate directly to the style declaration in your javascript file.
2424

25-
### Components as selectors
25+
#### Components as selectors
2626

2727
The ability to refer to another component to apply override styles depending on nesting context. Learn more in the [styled docs](/docs/styled.mdx#targeting-another-emotion-component).

docs/cache-provider.mdx

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ It can be useful to customize emotion's options - i.e. to add custom Stylis plug
66

77
```jsx
88
// @live
9-
/** @jsx jsx */
10-
import { CacheProvider, jsx, css } from '@emotion/react'
9+
import { CacheProvider, css } from '@emotion/react'
1110
import createCache from '@emotion/cache'
1211
import { prefixer } from 'stylis'
1312

@@ -17,9 +16,10 @@ const myCache = createCache({
1716
key: 'my-prefix-key',
1817
stylisPlugins: [
1918
customPlugin,
20-
// has to be included manually when customizing `stylisPlugins` if you want to have vendor prefixes added automatically
19+
// has to be included manually when customizing `stylisPlugins` if you want
20+
// to have vendor prefixes added automatically
2121
prefixer
22-
],
22+
]
2323
})
2424

2525
render(

docs/community.mdx

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: 'Community'
3+
---
4+
5+
> A curated list of awesome stuff related to Emotion.
6+
7+
## Contents
8+
9+
- [Libraries](#libraries)
10+
- [Component Libraries](#component-libraries)
11+
- [Examples In the Wild](#examples-in-the-wild)
12+
13+
## Libraries
14+
15+
- [facepaint](https://github.com/emotion-js/facepaint) - Responsive style values for css-in-js
16+
- [ember-emotion](https://github.com/alexlafroscia/ember-emotion) - Use emotion in Ember.js
17+
- [vue-emotion](https://github.com/egoist/vue-emotion) - Use emotion in Vue.js
18+
- [CSS to emotion transform](https://transform.now.sh/css-to-emotion/)
19+
- [ShevyJS](https://github.com/kyleshevlin/shevyjs) - Configurable Vertical Rhythm & Typography in CSS-in-JS
20+
- [design-system-utils](https://github.com/mrmartineau/design-system-utils) - Utilities to give better access to your design system.
21+
- [styled-map](https://github.com/scf4/styled-map) - Super simple lib to map props to styles
22+
- [polished](https://github.com/styled-components/polished) - Lightweight set of Sass/Compass-style mixins/helpers for writing styles in JavaScript
23+
- [styled-conditions](https://github.com/karolisgrinkevicius/styled-conditions) - Ultra-lightweight flag utility to conditionally apply css depending on React props
24+
- [manipulative](https://github.com/paulshen/manipulative) - React devtool to style emotion components from the browser
25+
- [emotion-tailwind-preflight](https://github.com/flogy/emotion-tailwind-preflight) - Merge the shiny TailwindCSS base styles into your CSS-in-JS project
26+
27+
## Component Libraries
28+
29+
- [react-select](https://github.com/JedWatson/react-select) ([Website](http://jedwatson.github.io/react-select/))
30+
- [reactivesearch](https://github.com/appbaseio/reactivesearch) ([Website](https://opensource.appbase.io/reactivesearch/))
31+
- [circuit-ui](https://github.com/sumup/circuit-ui) ([Storybook](https://sumup.github.io/circuit-ui/))
32+
- [govuk-react](https://github.com/govuk-react/govuk-react) ([Storybook](https://govuk-react.github.io/govuk-react/))
33+
- [smooth-ui](https://github.com/smooth-code/smooth-ui) ([Website](https://smooth-ui.smooth-code.com/))
34+
- [material-ui](https://github.com/mui-org/material-ui) ([Website](https://mui.com/))
35+
- [mineral-ui](https://mineral-ui.com) ([Website](https://mineral-ui.com))
36+
- [sancho-ui](https://sancho-ui.com) ([Website](https://sancho-ui.com))
37+
38+
## Examples In the Wild
39+
40+
- [healthline.com](https://www.healthline.com/health/body-aches)
41+
- [nytimes.com](https://www.nytimes.com)
42+
- [vault.crucible.gg](http://vault.crucible.gg/)
43+
- [saldotuc.com](https://saldotuc.com)
44+
- [gatsbythemes.com](https://gatsbythemes.com/)
45+
- [blazity.com](https://blazity.com/)
46+
- [postmates.com](https://postmates.com/)
47+
- [thedisconnect.co](https://thedisconnect.co/one)
48+
- [zefenify.com](https://zefenify.com/about.html)
49+
- [strelkamag.com](https://strelkamag.com/)
50+
- [rookout.com](https://www.rookout.com)
51+
- [figma.com](https://www.figma.com/)
52+
- [designsystems.com](https://www.designsystems.com/)

docs/composition.mdx

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ Composition is one of the most powerful and useful patterns in Emotion. You can
66

77
```jsx
88
// @live
9-
/** @jsx jsx */
10-
import { jsx, css } from '@emotion/react'
9+
import { css } from '@emotion/react'
1110

1211
const base = css`
1312
color: hotpink;
@@ -54,8 +53,7 @@ With Emotion though, you can create styles and combine them.
5453
5554
```jsx
5655
// @live
57-
/** @jsx jsx */
58-
import { css, jsx } from '@emotion/react'
56+
import { css } from '@emotion/react'
5957

6058
const danger = css`
6159
color: red;

docs/css-prop.mdx

+32-18
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,35 @@ There are 2 ways to get started with the `css` prop.
1414
Both methods result in the same compiled code.
1515
After adding the preset or setting the pragma as a comment, compiled jsx code will use emotion's `jsx` function instead of `React.createElement`.
1616

17-
| | Input | Output |
18-
| ------ | -------------------------- | --------------------------------------------------- |
19-
| Before | `<img src="avatar.png" />` | `React.createElement('img', { src: 'avatar.png' })` |
20-
| After | `<img src="avatar.png" />` | `jsx('img', { src: 'avatar.png' })` |
17+
<table>
18+
<thead>
19+
<tr>
20+
<th></th>
21+
<th>Input</th>
22+
<th>Output</th>
23+
</tr>
24+
</thead>
25+
<tbody>
26+
<tr>
27+
<td>Before</td>
28+
<td>
29+
<code>&lt;img src="avatar.png" /&gt;</code>
30+
</td>
31+
<td>
32+
<code>React.createElement('img', &#123; src: 'avatar.png' &#125;)</code>
33+
</td>
34+
</tr>
35+
<tr>
36+
<td>After</td>
37+
<td>
38+
<code>&lt;img src="avatar.png" /&gt;</code>
39+
</td>
40+
<td>
41+
<code>jsx('img', &#123; src: 'avatar.png' &#125;)</code>
42+
</td>
43+
</tr>
44+
</tbody>
45+
</table>
2146

2247
#### Babel Preset
2348

@@ -105,9 +130,6 @@ The `css` prop accepts object styles directly and does not require an additional
105130

106131
```jsx
107132
// @live
108-
/** @jsx jsx */
109-
import { jsx } from '@emotion/react'
110-
111133
render(
112134
<div
113135
css={{
@@ -130,9 +152,7 @@ To pass string styles, you must use `css` which is exported by `@emotion/react`,
130152

131153
```jsx
132154
// @live
133-
// this comment tells babel to convert jsx to calls to a function called jsx instead of React.createElement
134-
/** @jsx jsx */
135-
import { css, jsx } from '@emotion/react'
155+
import { css } from '@emotion/react'
136156

137157
const color = 'darkgreen'
138158

@@ -165,10 +185,7 @@ The precedence order may seem counter-intuitive, but it allows components with s
165185

166186
The `P` component in this example has its default styles overridden in the `ArticleText` component.
167187

168-
```js
169-
/** @jsx jsx */
170-
import { jsx } from '@emotion/react'
171-
188+
```jsx
172189
const P = props => (
173190
<p
174191
css={{
@@ -196,10 +213,7 @@ const ArticleText = props => (
196213

197214
The `ArticleText` component can be customized and the styles composed with its default styles. The result is passed `P` and the process repeats.
198215

199-
```js
200-
/** @jsx jsx */
201-
import { jsx } from '@emotion/react'
202-
216+
```jsx
203217
const P = props => (
204218
<p
205219
css={{

docs/docs.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
- cache-provider
2424
- performance
2525
- for-library-authors
26+
- community # There is code to hide this from the menu since it has its own navbar link
2627

2728
- title: Tooling
2829
items:

docs/emotion-11.mdx

+10-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: 'Emotion 11'
44

55
Emotion 11 is a slight evolution over the Emotion 10. It focuses mainly on the developer experience, TS types improvements, switches internals to hooks and to the new version of the parser that we use: [Stylis](https://github.com/thysultan/stylis.js).
66

7-
# Package renaming
7+
## Package renaming
88

99
One of the most significant changes is that most of the user-facing packages have been renamed.
1010

@@ -16,6 +16,7 @@ Most of this renaming can be done automatically via a codemod, following these s
1616
1. Run `eslint` with the `--fix` flag. For example: `yarn eslint --config .eslintrc --ext .js,.jsx "." --fix`
1717

1818
The full list of renamed packages:
19+
1920
- `@emotion/core``@emotion/react`
2021
- `emotion``@emotion/css`
2122
- `emotion-theming` → moved into ` @emotion/react`
@@ -26,13 +27,13 @@ The full list of renamed packages:
2627
- `eslint-plugin-emotion``@emotion/eslint-plugin`
2728
- `jest-emotion``@emotion/jest`
2829

29-
# Hooks
30+
## Hooks
3031

3132
Use hooks internally for improved bundle size and a better tree in React DevTools 🎉.
3233

33-
# TypeScript
34+
## TypeScript
3435

35-
## Types overhaul
36+
### Types overhaul
3637

3738
TypeScript types have been significantly restructured.
3839

@@ -45,7 +46,7 @@ TypeScript types have been significantly restructured.
4546

4647
If you encounter build issues after upgrade, try removing any manually specified generic types and let them be inferred.
4748

48-
## Theme type
49+
### Theme type
4950

5051
It's now easier to provide a type for `Theme`. Instead of creating custom instances (like before) you can augment the builtin `Theme` interface like this:
5152

@@ -60,7 +61,7 @@ declare module '@emotion/react' {
6061
}
6162
```
6263

63-
## css prop types
64+
### css prop types
6465

6566
The way in which we provide TypeScript support for the `css` prop has changed. Based on the usage of our JSX factories, we can add support for `css` prop only for components that support `className` prop (as our JSX factory functions take the provided `css` prop, resolve it and pass the generated `className` to the rendered component).
6667

@@ -76,7 +77,7 @@ However, if you are stuck with older version of TypeScript or using the classic
7677

7778
In this particular case we are forced to extend the existing `React.Attributes` interface. Previously we've been extending both `React.DOMAttributes` and `JSX.IntrinsicAttributes`. This change is really minor and shouldn't affect any consuming code.
7879

79-
# Stylis v4
80+
## Stylis v4
8081

8182
The parser we use ([Stylis](https://github.com/thysultan/stylis.js)) got upgraded. It fixes some long-standing parsing edge cases while being smaller and faster 🚀
8283

@@ -87,13 +88,13 @@ It has been completely rewritten and comes with some breaking changes. The most
8788
- the prefixer is now just a plugin which happens to be included in the default `stylisPlugins`. If you plan to use custom `stylisPlugins` and you want to have your styles prefixed automatically you must include prefixer in your custom `stylisPlugins`. You can import `prefixer` from the `stylis` module to do that.
8889
- `@import` rules are no longer special-cased. The responsibility to put them first has been moved to the author of the styles. They also can't be nested within other rules now. It's only possible to write them at the top level of global styles.
8990

90-
# Emotion's caches
91+
## Emotion's caches
9192

9293
The `key` option is now required when creating a custom instance of a cache. Please make sure it's unique (and not equal to `'css'`) as it's used for linking styles to your cache. If multiple caches share the same key they might "fight" for each other's style elements.
9394

9495
The new `prepend` option can make Emotion add style tags at the beginning of the specified DOM container instead of the end.
9596

96-
# Other
97+
## Other
9798

9899
There are a lot of less substantial changes than what has been described here, some of them might even be breaking changes but are not relevant to the majority of users. Therefore to learn more about all of the changes please read through the full list of changes contained in the respective changelogs:
99100

0 commit comments

Comments
 (0)