<commit_before># emotion-theming

> A CSS-in-JS theming solution for React(-like) views.

*`emotion-theming` is a theming library inspired by [styled-components](https://github.com/styled-components/styled-components)*


## Table of Contents

* [Install](#install)
* [Usage](#usage)
* [API](#api)
  * [ThemeProvider](#themeprovider)
  * [withTheme](#withthemecomponent)
  * [channel](#channel)
* [Credits](#credits)
* [License](#license)


## Install


```bash
# add --save if using npm@4 or lower
npm i emotion-theming

# or
yarn add emotion-theming
```

## Usage

Theming is accomplished by placing the `ThemeProvider` component, at the top of the React component tree and wrapping descendants with the `withTheme` higher-order component (HOC). This HOC seamlessly acquires the current theme and injects it as a "prop" into your own component.

The theme prop is automatically injected into components created with `react-emotion`'s `styled`.

Here is a complete example for a typical React + Emotion app (information about each piece of the theming API is listed afterward):

```jsx
/** child.js */
import React from 'react';
import styled from 'react-emotion';

const Container = styled.div`
  background: whitesmoke;
  height: 100vh;
`

const Headline = styled.h1`
  color: ${props => props.theme.color};
  font: 20px/1.5 sans-serif;
`

export default Page extends React.Component {
  render() {
    return (
      <Container>
        <Headline>
          I'm red!
        </Headline>
      </Container>
    );
  }
}

/** parent.js */
import React from 'react';
import ReactDOM from 'react-dom';
import { ThemeProvider } from 'emotion-theming';

import Page from './child.js';

const theme = {
  color: 'red',
};

class App extends React.Component {
  render() {
    return (
      <ThemeProvider theme={theme}>
        <Page />
      </ThemeProvider>
    );
  }
}

// this assumes the HTML page template has a <main> element already inside <body>
ReactDOM.render(<App />, document.querySelector('main'));
```

`<ThemeProvider>` acts as a conductor in the component hierarchy and themed components receive the `theme` for whatever purposes are necessary, be it styling or perhaps toggling a piece of functionality.


## API

### ThemeProvider: ReactComponent

A React component that passes the theme object down the component tree via [context](https://facebook.github.io/react/docs/context.html). Additional `<ThemeProvider>` wrappers may be added deeper in the hierarchy to override the original theme. The theme object will be merged into its ancestor as if by [`Object.assign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign). If a function is passed instead of an object it will be called with the ancestor theme and the result will be the new theme.

*Accepts:*
* **`children`: ReactComponent** - A single React component.
* **`theme`: Object|Function** - An object or function that provides an object.

```jsx
import React from 'react';
import styled from 'react-emotion'
import { ThemeProvider, withTheme } from 'emotion-theming';

// object-style theme

const theme = {
  backgroundColor: 'green',
  color: 'red',
};

// function-style theme; note that if multiple <ThemeProvider> are used,
// the parent theme will be passed as a function argument

const adjustedTheme = ancestorTheme => ({ ...ancestorTheme, color: 'blue' });

class Container extends React.Component {
  render() {
    return (
      <ThemeProvider theme={theme}>
        <ThemeProvider theme={adjustedTheme}>
          <Text>
            Boom shaka laka!
          </Text>
        </ThemeProvider>
      </ThemeProvider>
    );
  }
}

const Text = styled.div`
  background-color: ${props => props.theme.backgroundColor};  // will be green
  color: ${props => props.theme.color};                       // will be blue
`
```


### withTheme(component: ReactComponent): Function

A higher-order component that provides the current theme as a prop to the wrapped child and listens for changes. If the theme is updated, the child component will be re-rendered accordingly.

```jsx
import PropTypes from 'prop-types';
import React from 'react';
import { withTheme } from 'emotion-theming';

class TellMeTheColor extends React.Component {
  render() {
    return (
      <div>
        The color is {this.props.theme.color}.
      </div>
    );
  }
}

TellMeTheColor.propTypes = {
  theme: PropTypes.shape({
    color: PropTypes.string,
  }),
};

const TellMeTheColorWithTheme = withTheme(TellMeTheColor);
```

### channel: String

The emotion-theming package uses this string as the React context key by default.

If you wish to build your own components on top of this library, it is recommended to import the context key from this package instead of hardcoding its value.

```js
import { channel } from 'emotion-theming';

console.log(channe;); '__EMOTION_THEMING__';
```

## Credits

Thanks goes to the [styled-components team](https://github.com/styled-components/styled-components) and [their contributors](https://github.com/styled-components/styled-components/graphs/contributors) who originally wrote this.
<commit_msg>docs(emotion-theming): fix typo in README of packages/emotion-theming (#445)<commit_after># emotion-theming

> A CSS-in-JS theming solution for React(-like) views.

*`emotion-theming` is a theming library inspired by [styled-components](https://github.com/styled-components/styled-components)*


## Table of Contents

* [Install](#install)
* [Usage](#usage)
* [API](#api)
  * [ThemeProvider](#themeprovider)
  * [withTheme](#withthemecomponent)
  * [channel](#channel)
* [Credits](#credits)
* [License](#license)


## Install


```bash
# add --save if using npm@4 or lower
npm i emotion-theming

# or
yarn add emotion-theming
```

## Usage

Theming is accomplished by placing the `ThemeProvider` component, at the top of the React component tree and wrapping descendants with the `withTheme` higher-order component (HOC). This HOC seamlessly acquires the current theme and injects it as a "prop" into your own component.

The theme prop is automatically injected into components created with `react-emotion`'s `styled`.

Here is a complete example for a typical React + Emotion app (information about each piece of the theming API is listed afterward):

```jsx
/** child.js */
import React from 'react';
import styled from 'react-emotion';

const Container = styled.div`
  background: whitesmoke;
  height: 100vh;
`

const Headline = styled.h1`
  color: ${props => props.theme.color};
  font: 20px/1.5 sans-serif;
`

export default Page extends React.Component {
  render() {
    return (
      <Container>
        <Headline>
          I'm red!
        </Headline>
      </Container>
    );
  }
}

/** parent.js */
import React from 'react';
import ReactDOM from 'react-dom';
import { ThemeProvider } from 'emotion-theming';

import Page from './child.js';

const theme = {
  color: 'red',
};

class App extends React.Component {
  render() {
    return (
      <ThemeProvider theme={theme}>
        <Page />
      </ThemeProvider>
    );
  }
}

// this assumes the HTML page template has a <main> element already inside <body>
ReactDOM.render(<App />, document.querySelector('main'));
```

`<ThemeProvider>` acts as a conductor in the component hierarchy and themed components receive the `theme` for whatever purposes are necessary, be it styling or perhaps toggling a piece of functionality.


## API

### ThemeProvider: ReactComponent

A React component that passes the theme object down the component tree via [context](https://facebook.github.io/react/docs/context.html). Additional `<ThemeProvider>` wrappers may be added deeper in the hierarchy to override the original theme. The theme object will be merged into its ancestor as if by [`Object.assign`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign). If a function is passed instead of an object it will be called with the ancestor theme and the result will be the new theme.

*Accepts:*
* **`children`: ReactComponent** - A single React component.
* **`theme`: Object|Function** - An object or function that provides an object.

```jsx
import React from 'react';
import styled from 'react-emotion'
import { ThemeProvider, withTheme } from 'emotion-theming';

// object-style theme

const theme = {
  backgroundColor: 'green',
  color: 'red',
};

// function-style theme; note that if multiple <ThemeProvider> are used,
// the parent theme will be passed as a function argument

const adjustedTheme = ancestorTheme => ({ ...ancestorTheme, color: 'blue' });

class Container extends React.Component {
  render() {
    return (
      <ThemeProvider theme={theme}>
        <ThemeProvider theme={adjustedTheme}>
          <Text>
            Boom shaka laka!
          </Text>
        </ThemeProvider>
      </ThemeProvider>
    );
  }
}

const Text = styled.div`
  background-color: ${props => props.theme.backgroundColor};  // will be green
  color: ${props => props.theme.color};                       // will be blue
`
```


### withTheme(component: ReactComponent): Function

A higher-order component that provides the current theme as a prop to the wrapped child and listens for changes. If the theme is updated, the child component will be re-rendered accordingly.

```jsx
import PropTypes from 'prop-types';
import React from 'react';
import { withTheme } from 'emotion-theming';

class TellMeTheColor extends React.Component {
  render() {
    return (
      <div>
        The color is {this.props.theme.color}.
      </div>
    );
  }
}

TellMeTheColor.propTypes = {
  theme: PropTypes.shape({
    color: PropTypes.string,
  }),
};

const TellMeTheColorWithTheme = withTheme(TellMeTheColor);
```

### channel: String

The emotion-theming package uses this string as the React context key by default.

If you wish to build your own components on top of this library, it is recommended to import the context key from this package instead of hardcoding its value.

```js
import { channel } from 'emotion-theming';

console.log(channel); '__EMOTION_THEMING__';
```

## Credits

Thanks goes to the [styled-components team](https://github.com/styled-components/styled-components) and [their contributors](https://github.com/styled-components/styled-components/graphs/contributors) who originally wrote this.

{'fraction_non_alphanumeric': 0.11382270666538054, 'fraction_numerical': 0.002025658338960162, 'mean_word_length': 3.815606130980028, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 55, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '345932', 'n_tokens_mistral': 3014, 'n_tokens_neox': 2899, 'n_words': 1075}