Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to latest Next.js (attempt 2) #2805

Merged
merged 73 commits into from Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
3e22f94
Remove old site, create new Next app
srmagura Jul 2, 2022
19ade76
Site header
srmagura Jul 2, 2022
56dfe5f
Fix manypkg issues, copy in bootstrap-reboot.min.css
srmagura Jul 2, 2022
221eb44
Website progress
srmagura Dec 19, 2021
51b769b
Website progress
srmagura Dec 19, 2021
8cad941
Website progress
srmagura Jul 2, 2022
73c2882
yarn.lock
srmagura Jul 2, 2022
11f202c
Website progress
srmagura Jul 2, 2022
9c48dac
Fix manypkg errors
srmagura Jul 2, 2022
1f4f0c8
Website progress
srmagura Dec 20, 2021
8fbd5d5
Website progress: markdown CSS
srmagura Dec 26, 2021
6248beb
Website progress
srmagura Jul 2, 2022
7a1615c
Website progress
srmagura Dec 26, 2021
e2a13a6
Remove spectrum badge from README
srmagura Dec 26, 2021
46a550d
Add Carbon ads
srmagura Dec 28, 2021
8551160
Add DocSearch
srmagura Jul 2, 2022
71927a0
Add favicon and set page <title>
srmagura Dec 28, 2021
6cc6d0a
Website tweaks
srmagura Jul 2, 2022
5ee98e8
Update Netlify config and use next-export
srmagura Jul 2, 2022
837ad5c
Remove unnecessary dependencies from root package.json
srmagura Jul 2, 2022
39681bc
Add custom 404 page
srmagura Dec 30, 2021
0a1004b
Live editor works (no Babel yet)
srmagura Dec 30, 2021
e6d8a7a
[wip] Babel compilation
srmagura Dec 30, 2021
341aa1c
About to remove web worker stuff
srmagura Dec 30, 2021
1a84bee
Website: Live code editor stuff
srmagura Dec 30, 2021
2ab6723
Remove Mac-specific step from CONTRIBUTING
srmagura Jul 2, 2022
dc59c84
Update CONTRIBUTING for new website development
srmagura Dec 31, 2021
ed556c2
Done with live code editors
srmagura Jan 1, 2022
da9937c
Bring awesome-emotion into repo as an MDX doc
srmagura Jul 2, 2022
2776bda
Add redirects to netlify.toml
srmagura Jan 1, 2022
ed58cd4
Website styling, remove @jsx pragma from live code examples
srmagura Jan 1, 2022
53274ae
Remove incorrect slack link from community.mdx
srmagura Jan 1, 2022
d456076
Review & tweak website styles
srmagura Jul 2, 2022
b67153b
Make tables responsive on mobile
srmagura Jan 2, 2022
fd7b80f
Set up @next/bundle-analyzer
srmagura Jul 2, 2022
a3c1383
Get @emotion/babel-plugin to work in the browser (HACKS)
srmagura Jan 2, 2022
454e36b
Change Carbon ad when path changes
srmagura Jul 2, 2022
d3bb78d
Fix live editor issues
srmagura Jan 8, 2022
96a45f9
Do LiveEditor compilation in web worker
srmagura Jan 8, 2022
aa50f5c
Fork react-live
srmagura Jul 2, 2022
b86da6c
Working on live editors
srmagura Jul 2, 2022
ed0fd61
Fix LiveProvider useEffect
srmagura Jan 15, 2022
489418e
Live editor tweaks
srmagura Jan 15, 2022
b285eb9
Fix web worker @emotion/babel-plugin import
srmagura Jan 15, 2022
064f13d
Add website TS TODO
srmagura Jan 15, 2022
15e7e8d
Add more detail to comment
srmagura Jan 15, 2022
96093fb
Fix some but not all manypkg issues
srmagura Jul 2, 2022
057430a
Fix Safari-specific styling issues
srmagura Jan 16, 2022
1def49f
Website: Use webpack alias for @emotion/babel-plugin
srmagura Jul 2, 2022
a3d1500
Add comment explaining module aliasing hack
srmagura Apr 30, 2022
c42d489
site: Upgrade docsearch
srmagura Apr 30, 2022
f7ba4e8
site: Upgrade some packages
srmagura Jul 2, 2022
0fc42a9
site: Upgrade some packages
srmagura Jul 2, 2022
b211570
site: Upgrade next-mdx-remote
srmagura Jul 2, 2022
3f63d9c
Fix layout shift when carbon ads is loading
srmagura Apr 30, 2022
e54ab91
Make CI use Node 14
srmagura Jul 2, 2022
d35d9a9
Remove .nvmrc to fix Netlify build
srmagura Apr 30, 2022
9cf5544
Add Ukraine banner to new website
srmagura Apr 30, 2022
7fd9558
Fix minor issues in styled.mdx
srmagura Jul 2, 2022
833858a
Minor mobile fixes
srmagura Jul 2, 2022
6493bb3
Convert GFM tables to HTML so we don't need the remark-gfm plugin
srmagura Jul 2, 2022
2e7a091
Upgrade all website packages
srmagura Jul 2, 2022
272a287
Update docsearch appId and apiKey (see #2718)
srmagura Jul 2, 2022
cae08d2
Fixed CacheProvider demo in the docs (see #2678)
srmagura Jul 2, 2022
95c82c1
CodeSandbox CI node 16
srmagura Jul 2, 2022
978b04c
Simplify .gitignore
srmagura Jul 2, 2022
55e89db
Website cleanup after reviewing diff
srmagura Jul 2, 2022
635b829
Fix multiple @types/react
srmagura Jul 2, 2022
0d89ea1
Add test:typescript script to emotion-site
srmagura Jul 2, 2022
c311a5c
Make all code blocks have the same font-size
srmagura Jul 2, 2022
c4d40a2
Autolink headings
srmagura Jul 3, 2022
14f73a8
Minor website fixes
srmagura Jul 3, 2022
280290b
remark-responsive-tables
srmagura Jul 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codesandbox/ci.json
@@ -1,5 +1,5 @@
{
"packages": ["packages/*"],
"sandboxes": ["pk1qjqpw67"],
"node": "12"
"node": "16"
}
10 changes: 10 additions & 0 deletions .editorconfig
@@ -0,0 +1,10 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space

[*.{js,ts,tsx,json,yml}]
indent_size = 2
7 changes: 5 additions & 2 deletions .eslintignore
Expand Up @@ -4,5 +4,8 @@ coverage/
node_modules/
stylis.min.js
/demo/dist
/packages/site/build
flow-typed/
flow-typed/

# This is to prevent ESLint parsing errors in the website which is written in
# TypeScript. TODO: Reenable once the codebase is converted to TypeScript.
/site/
2 changes: 1 addition & 1 deletion .github/actions/ci-setup/action.yml
Expand Up @@ -2,7 +2,7 @@ name: 'CI setup'
runs:
using: 'composite'
steps:
- name: Set Node.js 16.x
- name: Setup Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
Expand Down
11 changes: 7 additions & 4 deletions .gitignore
Expand Up @@ -4,12 +4,15 @@ dist/
node_modules/
*.log
.idea
site/build
package-lock.json
.DS_Store
.cache
public/
!playgrounds/cra/public
.env
.vscode
.parcel-cache/
.parcel-cache/
*.orig
*.tsbuildinfo

# Website
site/out
.next
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

10 changes: 3 additions & 7 deletions CONTRIBUTING.md
Expand Up @@ -5,10 +5,6 @@

## Installation

- (If using an M1 Mac) Install `vips` via Homebrew: `brew install vips`.
- This step can be removed from this document if we upgrade to the latest
version of Gatsby, which is compatible with sharp 0.28.0+ which does include
binaries for M1 Macs.
- (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.
- Run `yarn` in the repository's root directory to install everything you need for development.
- Run `yarn build` in the root directory to build the modules.
Expand All @@ -27,9 +23,9 @@

## Documentation Website Development

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

## Changesets

Expand Down
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -16,7 +16,6 @@
![@emotion/styled size](https://img.shields.io/bundlephobia/min/@emotion/styled.svg?label=@emotion/styled%20size)
![@emotion/styled gzip size](https://img.shields.io/bundlephobia/minzip/@emotion/styled.svg?label=@emotion/styled%20gzip%20size)
[![slack](https://img.shields.io/badge/join-slack-green)](https://join.slack.com/t/emotion-slack/shared_invite/zt-rmtwsy74-2uvyFdz5uxa8OiMguJJeuQ)
[![spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/emotion)

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.

Expand Down
14 changes: 7 additions & 7 deletions docs/babel.mdx
Expand Up @@ -2,26 +2,26 @@
title: 'Babel Plugin'
---

`@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).
`@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).
srmagura marked this conversation as resolved.
Show resolved Hide resolved

### Install
## Install

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

### Features which are enabled with the babel plugin
## Features which are enabled with the babel plugin

### Minification
#### Minification

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

### Dead Code Elimination
#### Dead Code Elimination

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

### Source Maps
#### Source Maps

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

### Components as selectors
#### Components as selectors

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).
8 changes: 4 additions & 4 deletions docs/cache-provider.mdx
Expand Up @@ -6,8 +6,7 @@ It can be useful to customize emotion's options - i.e. to add custom Stylis plug

```jsx
// @live
/** @jsx jsx */
import { CacheProvider, jsx, css } from '@emotion/react'
import { CacheProvider, css } from '@emotion/react'
import createCache from '@emotion/cache'
import { prefixer } from 'stylis'

Expand All @@ -17,9 +16,10 @@ const myCache = createCache({
key: 'my-prefix-key',
stylisPlugins: [
customPlugin,
// has to be included manually when customizing `stylisPlugins` if you want to have vendor prefixes added automatically
// has to be included manually when customizing `stylisPlugins` if you want
// to have vendor prefixes added automatically
prefixer
],
]
})

render(
Expand Down
52 changes: 52 additions & 0 deletions docs/community.mdx
@@ -0,0 +1,52 @@
---
title: 'Community'
---

> A curated list of awesome stuff related to Emotion.

## Contents

- [Libraries](#libraries)
- [Component Libraries](#component-libraries)
- [Examples In the Wild](#examples-in-the-wild)

## Libraries

- [facepaint](https://github.com/emotion-js/facepaint) - Responsive style values for css-in-js
- [ember-emotion](https://github.com/alexlafroscia/ember-emotion) - Use emotion in Ember.js
- [vue-emotion](https://github.com/egoist/vue-emotion) - Use emotion in Vue.js
- [CSS to emotion transform](https://transform.now.sh/css-to-emotion/)
- [ShevyJS](https://github.com/kyleshevlin/shevyjs) - Configurable Vertical Rhythm & Typography in CSS-in-JS
- [design-system-utils](https://github.com/mrmartineau/design-system-utils) - Utilities to give better access to your design system.
- [styled-map](https://github.com/scf4/styled-map) - Super simple lib to map props to styles
- [polished](https://github.com/styled-components/polished) - Lightweight set of Sass/Compass-style mixins/helpers for writing styles in JavaScript
- [styled-conditions](https://github.com/karolisgrinkevicius/styled-conditions) - Ultra-lightweight flag utility to conditionally apply css depending on React props
- [manipulative](https://github.com/paulshen/manipulative) - React devtool to style emotion components from the browser
- [emotion-tailwind-preflight](https://github.com/flogy/emotion-tailwind-preflight) - Merge the shiny TailwindCSS base styles into your CSS-in-JS project

## Component Libraries

- [react-select](https://github.com/JedWatson/react-select) ([Website](http://jedwatson.github.io/react-select/))
- [reactivesearch](https://github.com/appbaseio/reactivesearch) ([Website](https://opensource.appbase.io/reactivesearch/))
- [circuit-ui](https://github.com/sumup/circuit-ui) ([Storybook](https://sumup.github.io/circuit-ui/))
- [govuk-react](https://github.com/govuk-react/govuk-react) ([Storybook](https://govuk-react.github.io/govuk-react/))
- [smooth-ui](https://github.com/smooth-code/smooth-ui) ([Website](https://smooth-ui.smooth-code.com/))
- [material-ui](https://github.com/mui-org/material-ui) ([Website](https://mui.com/))
- [mineral-ui](https://mineral-ui.com) ([Website](https://mineral-ui.com))
- [sancho-ui](https://sancho-ui.com) ([Website](https://sancho-ui.com))

## Examples In the Wild

- [healthline.com](https://www.healthline.com/health/body-aches)
- [nytimes.com](https://www.nytimes.com)
- [vault.crucible.gg](http://vault.crucible.gg/)
- [saldotuc.com](https://saldotuc.com)
- [gatsbythemes.com](https://gatsbythemes.com/)
- [blazity.com](https://blazity.com/)
- [postmates.com](https://postmates.com/)
- [thedisconnect.co](https://thedisconnect.co/one)
- [zefenify.com](https://zefenify.com/about.html)
- [strelkamag.com](https://strelkamag.com/)
- [rookout.com](https://www.rookout.com)
- [figma.com](https://www.figma.com/)
- [designsystems.com](https://www.designsystems.com/)
6 changes: 2 additions & 4 deletions docs/composition.mdx
Expand Up @@ -6,8 +6,7 @@ Composition is one of the most powerful and useful patterns in Emotion. You can

```jsx
// @live
/** @jsx jsx */
import { jsx, css } from '@emotion/react'
import { css } from '@emotion/react'

const base = css`
color: hotpink;
Expand Down Expand Up @@ -54,8 +53,7 @@ With Emotion though, you can create styles and combine them.

```jsx
// @live
/** @jsx jsx */
import { css, jsx } from '@emotion/react'
import { css } from '@emotion/react'

const danger = css`
color: red;
Expand Down
50 changes: 32 additions & 18 deletions docs/css-prop.mdx
Expand Up @@ -14,10 +14,35 @@ There are 2 ways to get started with the `css` prop.
Both methods result in the same compiled code.
After adding the preset or setting the pragma as a comment, compiled jsx code will use emotion's `jsx` function instead of `React.createElement`.

| | Input | Output |
| ------ | -------------------------- | --------------------------------------------------- |
| Before | `<img src="avatar.png" />` | `React.createElement('img', { src: 'avatar.png' })` |
| After | `<img src="avatar.png" />` | `jsx('img', { src: 'avatar.png' })` |
<table>
srmagura marked this conversation as resolved.
Show resolved Hide resolved
<thead>
<tr>
<th></th>
<th>Input</th>
<th>Output</th>
</tr>
</thead>
<tbody>
<tr>
<td>Before</td>
<td>
<code>&lt;img src="avatar.png" /&gt;</code>
</td>
<td>
<code>React.createElement('img', &#123; src: 'avatar.png' &#125;)</code>
</td>
</tr>
<tr>
<td>After</td>
<td>
<code>&lt;img src="avatar.png" /&gt;</code>
</td>
<td>
<code>jsx('img', &#123; src: 'avatar.png' &#125;)</code>
</td>
</tr>
</tbody>
</table>

#### Babel Preset

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

```jsx
// @live
/** @jsx jsx */
import { jsx } from '@emotion/react'

render(
<div
css={{
Expand All @@ -130,9 +152,7 @@ To pass string styles, you must use `css` which is exported by `@emotion/react`,

```jsx
// @live
// this comment tells babel to convert jsx to calls to a function called jsx instead of React.createElement
/** @jsx jsx */
import { css, jsx } from '@emotion/react'
import { css } from '@emotion/react'

const color = 'darkgreen'

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

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

```js
/** @jsx jsx */
import { jsx } from '@emotion/react'

```jsx
const P = props => (
<p
css={{
Expand Down Expand Up @@ -196,10 +213,7 @@ const ArticleText = props => (

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

```js
/** @jsx jsx */
import { jsx } from '@emotion/react'

```jsx
const P = props => (
<p
css={{
Expand Down
1 change: 1 addition & 0 deletions docs/docs.yaml
Expand Up @@ -23,6 +23,7 @@
- cache-provider
- performance
- for-library-authors
- community # There is code to hide this from the menu since it has its own navbar link

- title: Tooling
items:
Expand Down
19 changes: 10 additions & 9 deletions docs/emotion-11.mdx
Expand Up @@ -4,7 +4,7 @@ title: 'Emotion 11'

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).

# Package renaming
## Package renaming

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

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

The full list of renamed packages:

- `@emotion/core` → `@emotion/react`
- `emotion` → `@emotion/css`
- `emotion-theming` → moved into ` @emotion/react`
Expand All @@ -26,13 +27,13 @@ The full list of renamed packages:
- `eslint-plugin-emotion` → `@emotion/eslint-plugin`
- `jest-emotion` → `@emotion/jest`

# Hooks
## Hooks

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

# TypeScript
## TypeScript

## Types overhaul
### Types overhaul

TypeScript types have been significantly restructured.

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

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

## Theme type
### Theme type

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:

Expand All @@ -60,7 +61,7 @@ declare module '@emotion/react' {
}
```

## css prop types
### css prop types

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).

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

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.

# Stylis v4
## Stylis v4

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 🚀

Expand All @@ -87,13 +88,13 @@ It has been completely rewritten and comes with some breaking changes. The most
- 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.
- `@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.

# Emotion's caches
## Emotion's caches

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.

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

# Other
## Other

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:

Expand Down