Skip to content

Commit c7f8d83

Browse files
committedMay 15, 2016
Add themr to AppBar
1 parent 33ff491 commit c7f8d83

File tree

8 files changed

+73
-55
lines changed

8 files changed

+73
-55
lines changed
 

‎.babelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
]
1717
}
1818
}
19-
}
19+
}

‎components/app_bar/AppBar.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React from 'react';
2-
import ClassNames from 'classnames';
3-
import style from './style';
2+
import { themr } from 'react-css-themr';
3+
import classnames from 'classnames';
44

5-
const AppBar = (props) => {
6-
const className = ClassNames(style.root, {
7-
[style.fixed]: props.fixed,
8-
[style.flat]: props.flat
5+
const AppBar = ({ theme, ...props }) => {
6+
const className = classnames(theme.appBar, {
7+
[theme.fixed]: props.fixed,
8+
[theme.flat]: props.flat
99
}, props.className);
1010

1111
return (
@@ -19,7 +19,12 @@ AppBar.propTypes = {
1919
children: React.PropTypes.node,
2020
className: React.PropTypes.string,
2121
fixed: React.PropTypes.bool,
22-
flat: React.PropTypes.bool
22+
flat: React.PropTypes.bool,
23+
theme: React.PropTypes.shape({
24+
appBar: React.PropTypes.string.isRequired,
25+
fixed: React.PropTypes.string.isRequired,
26+
flat: React.PropTypes.string.isRequired
27+
})
2328
};
2429

2530
AppBar.defaultProps = {
@@ -28,4 +33,4 @@ AppBar.defaultProps = {
2833
flat: false
2934
};
3035

31-
export default AppBar;
36+
export default themr('ToolboxAppBar')(AppBar);

‎components/app_bar/readme.md

+11-3
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,29 @@ The app bar is a special kind of toolbar that’s used for branding, navigation,
44

55
```jsx
66
import AppBar from 'react-toolbox/lib/app_bar';
7+
import theme from 'react-toolbox/lib/app_bar/style';
78

89
const AppBarTest = () => (
9-
<AppBar fixed flat>
10+
<AppBar theme={theme} fixed flat>
1011
<a href="/home">React Toolbox Docs</a>
1112
<Navigation />
1213
</AppBar>
1314
);
1415
```
1516

16-
Coming soon, the `AppBar` component will support arbitrary content attributes for left and right content and a title, for now it's just a wrapper.
17-
1817
## Properties
1918

2019
| Name | Type | Default | Description|
2120
|:-----|:-----|:-----|:-----|
2221
| `className` | `String` | `''` | Set a class for the root component.|
2322
| `fixed` | `Bool` | `false` | Determine if the bar should have position `fixed` or `relative`.|
2423
| `flat` | `Bool` | `false` | If true, the AppBar shows a shadow.|
24+
| `theme` | `Object` | `null` | Classnames object defining the component style.|
25+
26+
## Theme interface
27+
28+
| Name | Description|
29+
|:---------|:-----------|
30+
| `appBar` | Root class.|
31+
| `fixed` | Implemented when the app bar is fixed.|
32+
| `flat` | Implemented when the app bar is flat.|

‎components/app_bar/style.scss ‎components/app_bar/theme.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@import "../base";
22
@import "./config";
33

4-
.root {
4+
.appBar {
55
display: flex;
66
height: $appbar-height;
77
align-items: center;

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"toolkit"
3737
],
3838
"dependencies": {
39-
"classnames": "^2.2.5"
39+
"classnames": "^2.2.5",
40+
"react-css-themr": "^1.0.0"
4041
},
4142
"devDependencies": {
4243
"autoprefixer": "^6.3.6",

‎spec/root.js

+40-39
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* global VERSION */
22
import React from 'react';
3+
import { ThemeProvider } from 'react-css-themr';
4+
import theme from './theme';
5+
36
import AppBarToolbox from '../components/app_bar';
47
import Avatar from './components/avatar';
58
import ButtonToolbox from '../components/button';
@@ -27,47 +30,45 @@ import Tabs from './components/tabs';
2730
import Tooltip from './components/tooltip';
2831
import style from './style';
2932

30-
const _hrefProject = () => {
31-
window.href = 'http://react-toolbox';
32-
};
33-
3433
const Root = () => (
35-
<div className={style.app}>
36-
<AppBarToolbox fixed flat className={style.appbar}>
37-
<h1>React Toolbox <small>Spec {VERSION}</small></h1>
38-
<ButtonToolbox
39-
accent
40-
className={style.github}
41-
icon='web'
42-
floating
43-
onClick={_hrefProject}
44-
/>
45-
</AppBarToolbox>
34+
<ThemeProvider theme={theme}>
35+
<div className={style.app}>
36+
<AppBarToolbox className={style.appbar} fixed flat>
37+
<h1>React Toolbox <small>Spec {VERSION}</small></h1>
38+
<ButtonToolbox
39+
accent
40+
className={style.github}
41+
icon='web'
42+
floating
43+
onClick={() => {window.href = 'http://react-toolbox';}}
44+
/>
45+
</AppBarToolbox>
4646

47-
<Autocomplete />
48-
<Avatar />
49-
<Button />
50-
<Card />
51-
<Checkbox />
52-
<Chip />
53-
<Dialog />
54-
<Drawer />
55-
<Dropdown />
56-
<IconMenu />
57-
<Input />
58-
<Layout />
59-
<List />
60-
<Menu />
61-
<Pickers />
62-
<Progress />
63-
<Radio />
64-
<Slider />
65-
<Snackbar />
66-
<Switch />
67-
<Table />
68-
<Tabs />
69-
<Tooltip />
70-
</div>
47+
<Autocomplete />
48+
<Avatar />
49+
<Button />
50+
<Card />
51+
<Checkbox />
52+
<Chip />
53+
<Dialog />
54+
<Drawer />
55+
<Dropdown />
56+
<IconMenu />
57+
<Input />
58+
<Layout />
59+
<List />
60+
<Menu />
61+
<Pickers />
62+
<Progress />
63+
<Radio />
64+
<Slider />
65+
<Snackbar />
66+
<Switch />
67+
<Table />
68+
<Tabs />
69+
<Tooltip />
70+
</div>
71+
</ThemeProvider>
7172
);
7273

7374
export default Root;

‎spec/theme.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import ToolboxAppBar from '../components/app_bar/theme.scss';
2+
3+
export default { ToolboxAppBar };

‎webpack.config.development.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const ExtractTextPlugin = require('extract-text-webpack-plugin');
66

77
module.exports = {
88
context: __dirname,
9-
devtool: 'inline-source-map',
9+
devtool: 'inline-source-map',
1010
entry: [
1111
'webpack-hot-middleware/client',
1212
'./spec/index.js'
@@ -25,7 +25,7 @@ module.exports = {
2525
{
2626
test: /\.js$/,
2727
loader: 'babel',
28-
exclude: /(node_modules)/
28+
exclude: [/(node_modules)/, /react-css-themr/]
2929
}, {
3030
test: /\.(scss|css)$/,
3131
loader: ExtractTextPlugin.extract('style', 'css?sourceMap&modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass?sourceMap')

0 commit comments

Comments
 (0)
Please sign in to comment.