Skip to content

Commit 05a6ef5

Browse files
author
Brian Stone
committed
docs: add additional theming documentation
1 parent 9c97b76 commit 05a6ef5

File tree

3 files changed

+44
-4
lines changed

3 files changed

+44
-4
lines changed

README.md

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# drywall
2-
31
[![npm version](https://badge.fury.io/js/drywall.svg)](https://badge.fury.io/js/drywall)
42

53
Drywall is a style agnostic component library built with [React](https://reactjs.org/) and

docs/theming.md

+43-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,43 @@
1-
Build your own theme, or view our [example theme](https://zillow.github.io/drywall-theme-bootstrap/) based on the [Bootstrap](https://getbootstrap.com/) UI system.
1+
All styles in drywall come from a theme object that is passed down to components via the [`ThemeProvider`](https://www.styled-components.com/docs/api#themeprovider) component.
2+
Wrap your application in the component, and pass it your theme to see your library come to life!
3+
4+
```jsx static
5+
import React from 'react';
6+
import ReactDOM from 'react-dom';
7+
import { ThemeProvider } from 'styled-components';
8+
import { ThemeBoostrap } from 'drywall-theme-bootstrap';
9+
import { Button } from 'drywall';
10+
11+
ReactDOM.render(
12+
<ThemeProvider theme={ThemeBootstrap}>
13+
<Button>Bootstrap button</Button>
14+
</ThemeProvider>,
15+
document.getElementById('root')
16+
);
17+
```
18+
19+
If you're not interested in building a theme yourself, check out our [example theme](https://zillow.github.io/drywall-theme-bootstrap/) based on the [Bootstrap](https://getbootstrap.com/) UI system.
20+
If you are interested, keep reading!
21+
22+
At the simplest level, a theme is just a plain javascript object consisting of many [styled-components `css` objects](https://www.styled-components.com/docs/api#css).
23+
Drywall components know how to pull their corresponding styles from the theme object through the convention, `theme.namespace.Component`.
24+
For example, `Button` styles for the bootstrap example theme will always live at `theme.bootstrap.Button`.
25+
There is some additional functionality supporting namespacing, but for now, just make sure to wrap your theme with the `withNamespace` function:
26+
27+
```jsx static
28+
import { withNamespace } from 'drywall';
29+
import { css } from 'styled-components';
30+
31+
const CustomTheme = {
32+
CustomTheme: {
33+
Button: css`
34+
color: blue;
35+
`
36+
}
37+
};
38+
39+
export default withNamespace(CustomTheme, 'CustomTheme');
40+
```
41+
42+
Other than the location of the top level component css objects, drywall makes no assumptions about what your theme object looks like.
43+
Feel free to add design tokens and other shared functionality to the theme as you please.

styleguide.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = createStyleguideConfig({
77
href: 'https://github.com/zillow/drywall/blob/master/CHANGELOG.md',
88
external: true
99
}, {
10-
name: 'README',
10+
name: 'Introduction',
1111
content: 'README.md'
1212
}, {
1313
name: 'Theming',

0 commit comments

Comments
 (0)