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

Emotion 10 docs #799

Merged
merged 39 commits into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1957b95
Update benchmarks from rnw
emmatown Jul 16, 2018
2139992
I don't want people to use this to compare libraries.
emmatown Jul 16, 2018
77dde4a
Prettier and stuff
emmatown Jul 16, 2018
398d18d
It's still broken
emmatown Jul 16, 2018
d9839aa
It works
emmatown Jul 17, 2018
29ac451
oooppps
emmatown Jul 17, 2018
10c8ffb
Update with some stuff from s-c
emmatown Jul 17, 2018
40cf8f1
Change some math stuff with inspiration from the benchmarks in the re…
emmatown Jul 17, 2018
02a4c38
Try running benchmarks on ci
emmatown Jul 17, 2018
5482846
Remove flow comment because i'm too lazy to fix the errors right now
emmatown Jul 17, 2018
4abec7f
Change circle config
emmatown Jul 17, 2018
7302258
Maybe this will fix it
emmatown Jul 17, 2018
d548df8
Maybe this'll work
emmatown Jul 17, 2018
be96cea
Try another thing
emmatown Jul 17, 2018
103d927
Fix thing
emmatown Jul 17, 2018
db05db4
Store built benchmark files
emmatown Jul 17, 2018
c43169d
Fix intentation
emmatown Jul 17, 2018
b347e49
Move store artifacts
emmatown Jul 17, 2018
370cf0c
Add --public-url option to parcel build
emmatown Jul 17, 2018
97d0ef0
Update yarn.lock
emmatown Jul 18, 2018
a68af25
Merge branch 'master' into change-benchmarks
emmatown Jul 18, 2018
393a158
Fix some stuff and add styled benchmarks
emmatown Jul 18, 2018
bf708a9
Add another benchmark
emmatown Jul 18, 2018
1c01c4f
Merge branch 'master' into change-benchmarks
emmatown Jul 21, 2018
f67422e
Don't run benchmarks on ci, only build and save them
emmatown Jul 21, 2018
7458d8f
Change lots of the docs
emmatown Jul 21, 2018
73fa3cc
Merge branch 'master' into next-docs
emmatown Jul 29, 2018
5b45535
moar stuff
emmatown Jul 29, 2018
b734f26
Merge branch 'master' into next-docs
emmatown Aug 8, 2018
3803426
Change to // @live comments
emmatown Aug 8, 2018
1eda8d7
migration stuff
emmatown Aug 10, 2018
3d3c024
Fix some stuff
emmatown Aug 11, 2018
3e4604b
Remove configurable imports as it's not relevant anymore
emmatown Aug 28, 2018
c3c6222
stuff
emmatown Sep 12, 2018
324673a
Merge branch 'master' into next-docs
emmatown Sep 30, 2018
e703139
Merge branch 'master' into next-docs
emmatown Oct 1, 2018
e057d2e
Fix site
emmatown Oct 1, 2018
60e3d50
Lots of docs changes
emmatown Oct 1, 2018
9c6391c
Merge branch 'master' into next-docs
emmatown Oct 8, 2018
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
20 changes: 10 additions & 10 deletions BREAKING_CHANGES_IN_V10.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Breaking Changes

* Only supports react@16.3 and above(+ preact)
* functions in interpolations are stringified in css and cx calls(probably won't affect you very much, there's a warning about it in v9)
* `create-emotion-styled` is gone, use the new styled api and a provider
* The css prop doesn't work via the babel plugin. `jsx` can be manually imported from `@emotion/core` or [babel-plugin-jsx-pragmatic](https://github.com/jmm/babel-plugin-jsx-pragmatic) can be used. (should we make a babel preset for that?)
* MORE STUFF THAT I CAN'T REMEMBER RIGHT NOW
* emotion will not be stored on the global object so create-emotion only accepts 1 argument, the options
* channel and createBroadcast from emotion-theming no longer exist
* extractStatic is gone
* create-emotion-server accepts the cache instead of the emotion instance
* jest-emotion no longer accepts an emotion instance, only the options arg, it also requires a DOM now
- Only supports react@16.3 and above(+ preact)
- functions in interpolations are stringified in css and cx calls(probably won't affect you very much, there's a warning about it in v9)
- `create-emotion-styled` is gone, use the new styled api and a provider
- The css prop doesn't work via the babel plugin. `jsx` can be manually imported from `@emotion/core` or [babel-plugin-jsx-pragmatic](https://github.com/jmm/babel-plugin-jsx-pragmatic) can be used. (should we make a babel preset for that?)
- MORE STUFF THAT I CAN'T REMEMBER RIGHT NOW
- emotion will not be stored on the global object so create-emotion only accepts 1 argument, the options
- channel and createBroadcast from emotion-theming no longer exist
- extractStatic is gone
- create-emotion-server accepts the cache instead of the emotion instance
- jest-emotion no longer accepts an emotion instance, only the options arg, it also requires a DOM now
26 changes: 13 additions & 13 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
## Prerequisites

* [Node.js](http://nodejs.org/) >= v7 must be installed.
* [Yarn](https://yarnpkg.com/en/docs/install)
- [Node.js](http://nodejs.org/) >= v7 must be installed.
- [Yarn](https://yarnpkg.com/en/docs/install)

## Installation

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

> NOTE:
>
> lerna is **NOT** used for installing packages. Only yarn is used. lerna is only used for publishing

## Running Tests

* `yarn test` will run the tests once.
* `yarn coverage` will run the tests and produce a coverage report in `coverage/`.
* `yarn test:watch` will run the tests on every change.
- `yarn test` will run the tests once.
- `yarn coverage` will run the tests and produce a coverage report in `coverage/`.
- `yarn test:watch` will run the tests on every change.

## Building

* Run `yarn build` in the root directory to build the modules. (Required before publishing)
* Run `yarn build PACKAGE_NAME ANOTHER_PACKAGE_NAME` to only build certain packages.
* Run `yarn build:watch` to build packages on every change.
- Run `yarn build` in the root directory to build the modules. (Required before publishing)
- Run `yarn build PACKAGE_NAME ANOTHER_PACKAGE_NAME` to only build certain packages.
- Run `yarn build:watch` to build packages on every change.

## 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
- 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.
63 changes: 31 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

**Emotion 10 is currently in beta, there are many breaking changes between versions, [for docs on Emotion 9 please go to the latest v9 tag](https://github.com/emotion-js/emotion/tree/v9.2.12/docs) or https://emotion.sh**


[![Backers on Open Collective](https://opencollective.com/emotion/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/emotion/sponsors/badge.svg)](#sponsors) [![npm version](https://badge.fury.io/js/emotion.svg)](https://badge.fury.io/js/emotion)
[![Build Status](https://img.shields.io/circleci/project/github/emotion-js/emotion/master.svg)](https://circleci.com/gh/emotion-js/emotion)
[![codecov](https://codecov.io/gh/emotion-js/emotion/branch/master/graph/badge.svg)](https://codecov.io/gh/emotion-js/emotion)
Expand All @@ -25,13 +24,13 @@ Emotion is a performant and flexible CSS-in-JS library. Building on many other C

Frequently viewed docs:

* [Introduction](https://emotion.sh/docs/introduction)
* [Install](https://emotion.sh/docs/install)
* [CSS](https://emotion.sh/docs/css)
* [Styled Components](https://emotion.sh/docs/styled)
* [Composition](https://emotion.sh/docs/composition)
* [Nested Selectors](https://emotion.sh/docs/nested)
* [Media Queries](https://emotion.sh/docs/media-queries)
- [Introduction](https://emotion.sh/docs/introduction)
- [Install](https://emotion.sh/docs/install)
- [CSS](https://emotion.sh/docs/css)
- [Styled Components](https://emotion.sh/docs/styled)
- [Composition](https://emotion.sh/docs/composition)
- [Nested Selectors](https://emotion.sh/docs/nested)
- [Media Queries](https://emotion.sh/docs/media-queries)

### Quick Start

Expand Down Expand Up @@ -87,36 +86,36 @@ Look here 👉 _[emotion babel plugin feature table and documentation](https://g

### Examples

* [emotion website](site) [[Demo Here](https://emotion.sh)]
* [next-hnpwa-guide-kit](https://github.com/tkh44/next-hnpwa-guide-kit) [[Demo Here](https://hnpwa.life)]
* [reactivesearch](https://github.com/appbaseio/reactivesearch), a react UI library for Elasticsearch [[Website](https://opensource.appbase.io/reactivesearch/)]
* [circuit-ui](https://github.com/sumup/circuit-ui), a react component library built at SumUp [[Storybook](https://sumup.github.io/circuit-ui/)]
* [govuk-react](https://github.com/penx/govuk-react/), a React component library built for UK Government departments
* **open a PR and add yours!**
- [emotion website](site) [[Demo Here](https://emotion.sh)]
- [next-hnpwa-guide-kit](https://github.com/tkh44/next-hnpwa-guide-kit) [[Demo Here](https://hnpwa.life)]
- [reactivesearch](https://github.com/appbaseio/reactivesearch), a react UI library for Elasticsearch [[Website](https://opensource.appbase.io/reactivesearch/)]
- [circuit-ui](https://github.com/sumup/circuit-ui), a react component library built at SumUp [[Storybook](https://sumup.github.io/circuit-ui/)]
- [govuk-react](https://github.com/penx/govuk-react/), a React component library built for UK Government departments
- **open a PR and add yours!**

### Ecosystem

* [stylelint](https://github.com/stylelint/stylelint) - A mighty, modern linter that helps you avoid errors and enforce conventions in your styles.
* [facepaint](https://github.com/emotion-js/facepaint)
* [emotion-vue](https://github.com/egoist/emotion-vue)
* [ember-emotion](https://github.com/alexlafroscia/ember-emotion)
* [CSS to emotion transform](https://transform.now.sh/css-to-emotion/)
* [ShevyJS](https://github.com/kyleshevlin/shevyjs)
* [design-system-utils](https://github.com/mrmartineau/design-system-utils) - Utilities to give better access to your design system.
* [polished](https://github.com/styled-components/polished) - Lightweight set of Sass/Compass-style mixins/helpers for writing styles in JavaScript.
- [stylelint](https://github.com/stylelint/stylelint) - A mighty, modern linter that helps you avoid errors and enforce conventions in your styles.
- [facepaint](https://github.com/emotion-js/facepaint)
- [emotion-vue](https://github.com/egoist/emotion-vue)
- [ember-emotion](https://github.com/alexlafroscia/ember-emotion)
- [CSS to emotion transform](https://transform.now.sh/css-to-emotion/)
- [ShevyJS](https://github.com/kyleshevlin/shevyjs)
- [design-system-utils](https://github.com/mrmartineau/design-system-utils) - Utilities to give better access to your design system.
- [polished](https://github.com/styled-components/polished) - Lightweight set of Sass/Compass-style mixins/helpers for writing styles in JavaScript.

### In the Wild

* [healthline.com](https://www.healthline.com)
* [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)
* [sentry.io](https://sentry.io)
- [healthline.com](https://www.healthline.com)
- [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)
- [sentry.io](https://sentry.io)

## Contributors

Expand Down
2 changes: 1 addition & 1 deletion docs/babel.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Babel Plugin"
title: 'Babel Plugin'
---

`babel-plugin-emotion` is highly recommended. All of the options that can be provided to `babel-plugin-emotion` are documented in [`babel-plugin-emotion`'s README](https://github.com/emotion-js/emotion/tree/master/packages/babel-plugin-emotion).
Expand Down
33 changes: 33 additions & 0 deletions docs/class-names.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: 'Class Names'
---

It can be useful to create to create a className that is not passed to a component, for example if a component accepts a `wrapperClassName` prop or similar. To do this, Emotion exposes a render prop component which you can pass a function which accepts `css` and `cx`. If you have used versions of Emotion prior to Emotion 10 or used vanilla Emotion, the `css` and `cx` functions work exactly like they do in versions.

```jsx
// @live
import { ClassNames } from '@emotion/core'

// this might be a component from npm that accepts a wrapperClassName prop
let SomeComponent = props => (
<div className={props.wrapperClassName}>
in the wrapper!
<div className={props.className}>{props.children}</div>
</div>
)

render(
<ClassNames>
{({ css, cx }) => (
<SomeComponent
wrapperClassName={css({ color: 'green' })}
className={css`
color: hotpink;
`}
>
from children!!
</SomeComponent>
)}
</ClassNames>
)
```
72 changes: 39 additions & 33 deletions docs/composition.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,20 @@
title: "Composition"
---

Composition is one of the most powerful and useful patterns in Emotion. You can compose styles together by interpolating the class name returned from `css` in another style block.
Composition is one of the most powerful and useful patterns in Emotion. You can compose styles together by interpolating value returned from `css` in another style block.

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

const base = css`
color: hotpink;
`

render(
<div
className={css`
css={css`
${base};
background-color: #eee;
`}
Expand All @@ -30,68 +31,72 @@ For example, we have some base styles and a danger style, we want the danger sty

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

const danger = css`
color: red;
`

const base = css`
background-color: lightgray;
color: turquoise;
`

render(
<div className={`${base} ${danger}`}>
What color will this be?
<div>
<style>
{`
.danger {
color: red;
}
.base {
background-color: lightgray;
color: turquoise;
}
`}
>
</style>
<p className="base danger">What color will this be?</p>
</div>
)
```

With Emotion though, it's much easier, all we have to change is add `css` before the template literal where we combine the classes and Emotion will use the styles that were passed to danger and base and merge them in the order that they're interpolated.
With Emotion though, we can create styles and combine them

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

const danger = css`
color: red;
`

const base = css`
background-color: lightgray;
background-color: darkgreen;
color: turquoise;
`

render(
<div
className={css`
${base} ${danger};
`}
>
What color will this be?
<div>
<div css={base}>This will be turquoise</div>
<div css={[danger, base]}>
This will be also be turquoise since the base styles
overwrite the danger styles.
</div>
<div css={[base, danger]}>This will be red</div>
</div>
)
```

> Note:
>
> This is just an example to demonstrate composition, for class name merging with emotion you should use [cx](/docs/cx.md).

## Composing dynamic styles

## I FEEL LIKE THIS IS A REALLY SPECIFIC THING AND MORE NEEDS TO BE SAID ABOUT THE STUFF ABOVE

## ALSO, WE PROBABLY NEED A PLACE TO TALK ABOUT PATTERNS

You can also do dynamic composition based on props and use it in `styled`.

```jsx
// @live
import styled, { css } from 'react-emotion'
import styled from '@emotion/styled'
import { css } from '@emotion/core'

const dynamicStyle = props =>
css`
color: ${props.color};
`

const Container = styled('div')`
const Container = styled.div`
${dynamicStyle};
`
render(
Expand All @@ -105,14 +110,15 @@ If you're composing lots of other styles and aren't using any string styles dire

```jsx
// @live
import styled, { css } from 'react-emotion'
import styled from '@emotion/styled'
import { css } from '@emotion/core'

const dynamicStyle = props =>
css`
color: ${props.color};
`

const Container = styled('div')(dynamicStyle)
const Container = styled.div(dynamicStyle)

render(
<Container color="lightgreen">
Expand Down