Skip to content

Enable syntax highlighting in the code block #6

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

Merged
merged 1 commit into from
Jun 13, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 48 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,68 +18,72 @@ Install from npm:

Configure in `webpack.config.js`:

module.exports = {
...
module: {
loaders: [
{
test: /\.react.css$/,
loader: 'babel-loader!react-css-components/webpack',
}
]
```js
module.exports = {
...
module: {
loaders: [
{
test: /\.react.css$/,
loader: 'babel-loader!react-css-components/webpack',
}
...
}

]
}
...
}
```
Now you can author React components in `Styles.react.css`:
```css
Label {
color: red;
}

Label {
color: red;
}

Label:hover {
color: white;
}
Label:hover {
color: white;
}
```

And consume them like regular React components:
```js
import {Label} from './styles.react.css'

import {Label} from './styles.react.css'

<Label /> // => <div className="<autogenerated classname>">...</div>

<Label /> // => <div className="<autogenerated classname>">...</div>
```
## Variants

You can define additional styling variants for your components:
```css
Label {
color: red;
}

Label {
color: red;
}

Label:emphasis {
font-weight: bold;
}
Label:emphasis {
font-weight: bold;
}
```

They are compiled as CSS classes which then can be controlled from JS via
`variant` prop:

<Label variant={{emphasis: true}} /> // sets both classes with `color` and `font-weight`

```js
<Label variant={{emphasis: true}} /> // sets both classes with `color` and `font-weight`
```
## Prop variants

You can define variants which are based on some JavaScript expression against
props:

Label {
color: red;
}

Label:prop(mode == "emphasis") {
font-weight: bold;
}

```css
Label {
color: red;
}

Label:prop(mode == "emphasis") {
font-weight: bold;
}
```
They are compiled as CSS classes which then can be controlled from JS:

<Label mode="emphasis" /> // sets both classes with `color` and `font-weight`
```js
<Label mode="emphasis" /> // sets both classes with `color` and `font-weight`
```

## TODO

Expand Down