Skip to content

Commit 132820d

Browse files
committed
Adds base and custom theme.
1 parent 7522576 commit 132820d

File tree

5 files changed

+80
-30
lines changed

5 files changed

+80
-30
lines changed

gulpfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ var config = {
3737
alias: {
3838
// fluxmax : absPath('../../src/index'),
3939
'event-emitter' : 'wolfy87-eventemitter',
40+
'tinycolor' : 'tinycolor2',
4041
},
4142
},
4243
plugins: [

src/ui/CustomTheme.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var BaseTheme = require('./tottys/BaseTheme');
2+
var tinycolor = require('tinycolor');
3+
var _ = require('lodash');
4+
5+
6+
7+
8+
9+
var CustomTheme = _.merge({}, BaseTheme, {
10+
// colors:
11+
});
12+
13+
14+
15+
16+
17+
module.exports = CustomTheme;

src/ui/Tasks.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
var React = require('react');
2-
var SmartCSS = require('smart-css');
3-
var App = require('fluxmax').App;
4-
var Task = React.createFactory(require('./Task'));
5-
var MainButton = require('./tottys/MainButton');
1+
var React = require('react');
2+
var SmartCSS = require('smart-css');
3+
var App = require('fluxmax').App;
4+
var Task = React.createFactory(require('./Task'));
5+
var CustomTheme = require('./CustomTheme');
6+
var MainButton = require('./tottys/MainButton')({
7+
theme: CustomTheme
8+
});
69

710

811

src/ui/tottys/BaseTheme.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var tinycolor = require('tinycolor');
2+
3+
4+
5+
6+
7+
var BaseTheme = {
8+
colors: {
9+
main: tinycolor('hsl(196, 100%, 50%)')
10+
}
11+
};
12+
13+
14+
15+
16+
17+
module.exports = BaseTheme;

src/ui/tottys/MainButton.js

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,59 @@ var _ = require('lodash');
66

77

88

9-
var css = new SmartCSS();
9+
module.exports = function(options){
10+
options = _.extend({
11+
theme: void 0,
12+
}, options);
13+
var theme = options.theme;
14+
if(!theme) throw new Error('No theme defined.');
1015

1116

1217

13-
css.setClass('root', {
14-
width : '320px',
15-
padding : '13px',
16-
border : '0',
17-
background : 'hsl(196, 100%, 50%)',
18-
color : 'white',
19-
fontSize : '26px',
20-
outline : 'none',
21-
marginBottom : '1px',
22-
boxSizing : 'border-box',
23-
cursor : 'pointer',
24-
transition : 'all 0.2s',
25-
':hover': {
26-
background : 'hsl(196, 100%, 40%)',
27-
}
28-
})
18+
var css = new SmartCSS();
2919

3020

3121

22+
css.setClass('root', {
23+
width : '320px',
24+
padding : '13px',
25+
border : '0',
26+
background : theme.colors.main.toString(),
27+
color : 'white',
28+
fontSize : '26px',
29+
outline : 'none',
30+
marginBottom : '1px',
31+
boxSizing : 'border-box',
32+
cursor : 'pointer',
33+
transition : 'all 0.2s',
34+
':hover': {
35+
background : 'hsl(196, 100%, 40%)',
36+
}
37+
})
3238

3339

34-
module.exports = React.createClass({
3540

3641

3742

38-
displayName: 'tottys.MainButton',
43+
var MainButton = React.createClass({
3944

4045

4146

42-
render: function(){
43-
return React.DOM.button(_.extend({}, _.omit(this.props, 'className'), {
44-
className: css.getClass('root'),
45-
}), this.props.label)
46-
}
47+
displayName: 'tottys.MainButton',
4748

4849

4950

50-
});
51+
render: function(){
52+
return React.DOM.button(_.extend({}, _.omit(this.props, 'className'), {
53+
className: css.getClass('root'),
54+
}), this.props.label)
55+
}
5156

5257

58+
59+
});
60+
61+
62+
63+
return MainButton;
64+
}

0 commit comments

Comments
 (0)