Skip to content

Commit 209d0f2

Browse files
committed
Update README 🙃
1 parent d3df699 commit 209d0f2

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

‎README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ Easy theming and composition for CSS Modules.
66
$ npm install --save react-css-themr
77
```
88

9-
**Note: Feedback and contributions on the docs are highly appreciated. Please open issues for comments of reach me.**
9+
**Note: Feedback and contributions on the docs are highly appreciated.**
1010

1111
## Why?
1212

1313
When you use [CSS Modules](https://github.com/css-modules/css-modules) to style your components, a classnames object is usually imported from the same component. Since css classes are scoped by default, there is no easy way to make your component customizable for the outside world.
1414

1515
## The approach
1616

17-
Taking ideas from [future-react-ui](https://github.com/nikgraf/future-react-ui) and [react-themeable](https://github.com/markdalgleish/react-themeable), a component should be shipped without styles. This means we can consider the styles as an injectable dependency. In CSS Modules you can consider the imported classnames object as a theme for a component. Therefore, every styled component should define a classname API to be used in the rendering function.
17+
Taking ideas from [future-react-ui](https://github.com/nikgraf/future-react-ui) and [react-themeable](https://github.com/markdalgleish/react-themeable), a component should be shipped **without** styles. This means we can consider the styles as an **injectable dependency**. In CSS Modules you can consider the imported classnames object as a **theme** for a component. Therefore, every styled component should define a *classname API* to be used in the rendering function.
1818

19-
The most immediate way of providing a classname object is via props. In case you want to import a component with a theme already injected, you have to write a higher order component that does the job. This is ok for your own components, but for ui-kits like [React Toolbox](www.react-toolbox.com) or [Belle](http://http://nikgraf.github.io/belle/), you'd have to write a wrapper for every single component you want to use. In this fancy, you can understand the theme as a set of related classname objects for different components. It makes sense to group them together in a single object and move it through the component tree using a context. This way, you can provide a theme either via context, hoc or props.
19+
The most immediate way of providing a classname object is via *props*. In case you want to import a component with a theme already injected, you have to write a higher order component that does the job. This is ok for your own components, but for ui-kits like [React Toolbox](www.react-toolbox.com) or [Belle](http://http://nikgraf.github.io/belle/), you'd have to write a wrapper for every single component you want to use. In this fancy, you can understand the theme as a **set** of related classname objects for different components. It makes sense to group them together in a single object and move it through the component tree using a context. This way, you can provide a theme either via **context**, **hoc** or **props**.
2020

21-
The approach of react-css-themr consists of a provider and a decorator. The provider sets a context theme. The decorator adds to your components the logic to figure out which theme should be used, depending on configuration, context and props.
21+
The approach of react-css-themr consists of a *provider* and a *decorator*. The provider sets a context theme. The decorator adds to your components the logic to figure out which theme should be used or how should it be composed, depending on configuration, context and props.
2222

2323
## Combining CSS modules
2424

25-
There are three possible sources for your component. Sorted by priority: context, configuration and props. Any of them can be missing. In case multiple themes are present, you may want to compose the final classnames object in three different ways:
25+
There are three possible sources for your component. Sorted by priority: **context**, **configuration** and **props**. Any of them can be missing. In case multiple themes are present, you may want to compose the final classnames object in three different ways:
2626

27-
- Override: the theme object with the highest priority is the one used.
28-
- Softly merging: theme objects are merged but if a key is present in more than one object, the final value corresponds to the theme with highest priority.
29-
- Deeply merging: theme objects are merged and if a key is present in more than one object, the values for each objects are concatenated.
27+
- *Override*: the theme object with the highest priority is the one used.
28+
- *Softly merging*: theme objects are merged but if a key is present in more than one object, the final value corresponds to the theme with highest priority.
29+
- *Deeply merging*: theme objects are merged and if a key is present in more than one object, the values for each objects are concatenated.
3030

31-
You can choose whatever you want. We consider the last one as the most flexible so it's selected by default.
31+
You can choose whatever you want. We consider the last one as the most flexible so it's selected *by default*.
3232

3333
## How does it work?
3434

@@ -71,7 +71,7 @@ export default (props) => (
7171
7272
### Default theming
7373
74-
If you use a component with a base theme, you may to want import the component with the theme already injected. Then you can compose its style via props with another theme object. In this case the base css will always be bundled:
74+
If you use a component with a base theme, you may to want import the component with the theme already injected. Then you can compose its style via props with another theme object. In this case the base css will **always** be bundled:
7575
7676
```jsx
7777
// SuccessButton.js
@@ -120,7 +120,7 @@ The final classnames object for the `Button` component would include class value
120120
121121
### Context theming
122122
123-
Although context theming is not limited to ui-kits, it's very useful to avoid declaring hoc for every component. For example, in react-toolbox, you can define a context theme like:
123+
Although context theming is not limited to ui-kits, it's very useful to avoid declaring hoc for every component. For example, in [react-toolbox](www.react-toolbox.com), you can define a context theme like:
124124
125125
```jsx
126126
import React from 'react';

0 commit comments

Comments
 (0)