material-ui 0.7.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +31 -0
- data/Rakefile +20 -0
- data/lib/material-ui.rb +4 -0
- data/material-ui-gem.gemspec +33 -0
- data/vendor/assets/javascripts/material-ui.js +1 -0
- data/vendor/assets/javascripts/material-ui/components/app-bar.jsx +93 -0
- data/vendor/assets/javascripts/material-ui/components/app-canvas.jsx +27 -0
- data/vendor/assets/javascripts/material-ui/components/checkbox.jsx +60 -0
- data/vendor/assets/javascripts/material-ui/components/date-picker/calendar-month.jsx +59 -0
- data/vendor/assets/javascripts/material-ui/components/date-picker/calendar-toolbar.jsx +64 -0
- data/vendor/assets/javascripts/material-ui/components/date-picker/calendar.jsx +194 -0
- data/vendor/assets/javascripts/material-ui/components/date-picker/date-display.jsx +79 -0
- data/vendor/assets/javascripts/material-ui/components/date-picker/date-picker-dialog.jsx +118 -0
- data/vendor/assets/javascripts/material-ui/components/date-picker/date-picker.jsx +116 -0
- data/vendor/assets/javascripts/material-ui/components/date-picker/day-button.jsx +49 -0
- data/vendor/assets/javascripts/material-ui/components/dialog-window.jsx +183 -0
- data/vendor/assets/javascripts/material-ui/components/dialog.jsx +54 -0
- data/vendor/assets/javascripts/material-ui/components/drop-down-icon.jsx +68 -0
- data/vendor/assets/javascripts/material-ui/components/drop-down-menu.jsx +94 -0
- data/vendor/assets/javascripts/material-ui/components/enhanced-button.jsx +147 -0
- data/vendor/assets/javascripts/material-ui/components/enhanced-switch.jsx +296 -0
- data/vendor/assets/javascripts/material-ui/components/enhanced-textarea.jsx +113 -0
- data/vendor/assets/javascripts/material-ui/components/flat-button.jsx +46 -0
- data/vendor/assets/javascripts/material-ui/components/floating-action-button.jsx +123 -0
- data/vendor/assets/javascripts/material-ui/components/font-icon.jsx +23 -0
- data/vendor/assets/javascripts/material-ui/components/icon-button.jsx +123 -0
- data/vendor/assets/javascripts/material-ui/components/ink-bar.jsx +25 -0
- data/vendor/assets/javascripts/material-ui/components/input.jsx +143 -0
- data/vendor/assets/javascripts/material-ui/components/left-nav.jsx +105 -0
- data/vendor/assets/javascripts/material-ui/components/menu/link-menu-item.jsx +42 -0
- data/vendor/assets/javascripts/material-ui/components/menu/menu-item.jsx +105 -0
- data/vendor/assets/javascripts/material-ui/components/menu/menu.jsx +325 -0
- data/vendor/assets/javascripts/material-ui/components/menu/subheader-menu-item.jsx +18 -0
- data/vendor/assets/javascripts/material-ui/components/mixins/classable.js +42 -0
- data/vendor/assets/javascripts/material-ui/components/mixins/click-awayable.js +35 -0
- data/vendor/assets/javascripts/material-ui/components/mixins/window-listenable.js +23 -0
- data/vendor/assets/javascripts/material-ui/components/overlay.jsx +58 -0
- data/vendor/assets/javascripts/material-ui/components/paper.jsx +58 -0
- data/vendor/assets/javascripts/material-ui/components/radio-button-group.jsx +112 -0
- data/vendor/assets/javascripts/material-ui/components/radio-button.jsx +65 -0
- data/vendor/assets/javascripts/material-ui/components/raised-button.jsx +102 -0
- data/vendor/assets/javascripts/material-ui/components/ripples/circle.jsx +35 -0
- data/vendor/assets/javascripts/material-ui/components/ripples/focus-ripple.jsx +40 -0
- data/vendor/assets/javascripts/material-ui/components/ripples/touch-ripple.jsx +174 -0
- data/vendor/assets/javascripts/material-ui/components/slider.jsx +178 -0
- data/vendor/assets/javascripts/material-ui/components/snackbar.jsx +76 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/drop-down-arrow.jsx +16 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/navigation-chevron-left.jsx +16 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/navigation-chevron-right.jsx +17 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/navigation-menu.jsx +16 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/svg-icon.jsx +23 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-check-box-checked.jsx +16 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-check-box-outline-blank.jsx +16 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-radio-button-off.jsx +16 -0
- data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-radio-button-on.jsx +16 -0
- data/vendor/assets/javascripts/material-ui/components/table-header.jsx +50 -0
- data/vendor/assets/javascripts/material-ui/components/table-rows-item.jsx +31 -0
- data/vendor/assets/javascripts/material-ui/components/table-rows.jsx +57 -0
- data/vendor/assets/javascripts/material-ui/components/tabs/tab.jsx +38 -0
- data/vendor/assets/javascripts/material-ui/components/tabs/tabTemplate.jsx +15 -0
- data/vendor/assets/javascripts/material-ui/components/tabs/tabs.jsx +96 -0
- data/vendor/assets/javascripts/material-ui/components/text-field.jsx +215 -0
- data/vendor/assets/javascripts/material-ui/components/toggle.jsx +62 -0
- data/vendor/assets/javascripts/material-ui/components/toolbar-group.jsx +28 -0
- data/vendor/assets/javascripts/material-ui/components/toolbar.jsx +21 -0
- data/vendor/assets/javascripts/material-ui/components/tooltip.jsx +58 -0
- data/vendor/assets/javascripts/material-ui/components/transition-groups/slide-in.jsx +48 -0
- data/vendor/assets/javascripts/material-ui/components/utils/css-event.js +52 -0
- data/vendor/assets/javascripts/material-ui/components/utils/date-time.js +132 -0
- data/vendor/assets/javascripts/material-ui/components/utils/dom.js +71 -0
- data/vendor/assets/javascripts/material-ui/components/utils/events.js +34 -0
- data/vendor/assets/javascripts/material-ui/components/utils/key-code.js +10 -0
- data/vendor/assets/javascripts/material-ui/components/utils/key-line.js +13 -0
- data/vendor/assets/javascripts/material-ui/components/utils/unique-id.js +7 -0
- data/vendor/assets/stylesheets/material-ui.less +2 -0
- data/vendor/assets/stylesheets/material-ui/components.less +5 -0
- data/vendor/assets/stylesheets/material-ui/components/app-bar.less +37 -0
- data/vendor/assets/stylesheets/material-ui/components/card.less +20 -0
- data/vendor/assets/stylesheets/material-ui/components/checkbox.less +66 -0
- data/vendor/assets/stylesheets/material-ui/components/components.less +37 -0
- data/vendor/assets/stylesheets/material-ui/components/date-picker/calendar-month.less +11 -0
- data/vendor/assets/stylesheets/material-ui/components/date-picker/calendar-toolbar.less +23 -0
- data/vendor/assets/stylesheets/material-ui/components/date-picker/calendar.less +59 -0
- data/vendor/assets/stylesheets/material-ui/components/date-picker/date-display.less +84 -0
- data/vendor/assets/stylesheets/material-ui/components/date-picker/date-picker-dialog.less +18 -0
- data/vendor/assets/stylesheets/material-ui/components/date-picker/date-picker.less +9 -0
- data/vendor/assets/stylesheets/material-ui/components/date-picker/day-button.less +35 -0
- data/vendor/assets/stylesheets/material-ui/components/dialog-window.less +42 -0
- data/vendor/assets/stylesheets/material-ui/components/dialog.less +10 -0
- data/vendor/assets/stylesheets/material-ui/components/drop-down-icon.less +43 -0
- data/vendor/assets/stylesheets/material-ui/components/drop-down-menu.less +77 -0
- data/vendor/assets/stylesheets/material-ui/components/enhanced-button.less +24 -0
- data/vendor/assets/stylesheets/material-ui/components/enhanced-switch.less +52 -0
- data/vendor/assets/stylesheets/material-ui/components/enhanced-textarea.less +16 -0
- data/vendor/assets/stylesheets/material-ui/components/flat-button.less +93 -0
- data/vendor/assets/stylesheets/material-ui/components/floating-action-button.less +95 -0
- data/vendor/assets/stylesheets/material-ui/components/font-icon.less +6 -0
- data/vendor/assets/stylesheets/material-ui/components/icon-button.less +46 -0
- data/vendor/assets/stylesheets/material-ui/components/ink-bar.less +9 -0
- data/vendor/assets/stylesheets/material-ui/components/input.less +186 -0
- data/vendor/assets/stylesheets/material-ui/components/left-nav.less +31 -0
- data/vendor/assets/stylesheets/material-ui/components/menu-item.less +69 -0
- data/vendor/assets/stylesheets/material-ui/components/menu.less +50 -0
- data/vendor/assets/stylesheets/material-ui/components/overlay.less +21 -0
- data/vendor/assets/stylesheets/material-ui/components/paper.less +59 -0
- data/vendor/assets/stylesheets/material-ui/components/radio-button.less +67 -0
- data/vendor/assets/stylesheets/material-ui/components/raised-button.less +132 -0
- data/vendor/assets/stylesheets/material-ui/components/ripples/circle.less +31 -0
- data/vendor/assets/stylesheets/material-ui/components/ripples/focus-ripple.less +30 -0
- data/vendor/assets/stylesheets/material-ui/components/ripples/touch-ripple.less +9 -0
- data/vendor/assets/stylesheets/material-ui/components/slider.less +163 -0
- data/vendor/assets/stylesheets/material-ui/components/snackbar.less +44 -0
- data/vendor/assets/stylesheets/material-ui/components/subheader.less +17 -0
- data/vendor/assets/stylesheets/material-ui/components/svg-icon.less +11 -0
- data/vendor/assets/stylesheets/material-ui/components/table.less +46 -0
- data/vendor/assets/stylesheets/material-ui/components/tabs.less +41 -0
- data/vendor/assets/stylesheets/material-ui/components/text-field.less +168 -0
- data/vendor/assets/stylesheets/material-ui/components/toggle.less +83 -0
- data/vendor/assets/stylesheets/material-ui/components/toolbar.less +95 -0
- data/vendor/assets/stylesheets/material-ui/components/tooltip.less +73 -0
- data/vendor/assets/stylesheets/material-ui/components/transition-groups/slide-in.less +92 -0
- data/vendor/assets/stylesheets/material-ui/core/base.less +31 -0
- data/vendor/assets/stylesheets/material-ui/core/core.less +4 -0
- data/vendor/assets/stylesheets/material-ui/core/keylines.less +29 -0
- data/vendor/assets/stylesheets/material-ui/core/layouts.less +12 -0
- data/vendor/assets/stylesheets/material-ui/core/typography.less +158 -0
- data/vendor/assets/stylesheets/material-ui/mixins/clearfix.less +22 -0
- data/vendor/assets/stylesheets/material-ui/mixins/mixins.less +3 -0
- data/vendor/assets/stylesheets/material-ui/mixins/no-wrap.less +3 -0
- data/vendor/assets/stylesheets/material-ui/mixins/transitions.less +17 -0
- data/vendor/assets/stylesheets/material-ui/resets/normalize.css +430 -0
- data/vendor/assets/stylesheets/material-ui/resets/typography-resets.less +34 -0
- data/vendor/assets/stylesheets/material-ui/scaffolding.less +10 -0
- data/vendor/assets/stylesheets/material-ui/variables/colors.less +285 -0
- data/vendor/assets/stylesheets/material-ui/variables/custom-variables.less +163 -0
- data/vendor/assets/stylesheets/material-ui/variables/media-queries.less +4 -0
- data/vendor/assets/stylesheets/material-ui/variables/spacing.less +16 -0
- metadata +268 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var SvgIcon = require('./svg-icon');
|
3
|
+
|
4
|
+
var DropDownArrow = React.createClass({
|
5
|
+
|
6
|
+
render: function() {
|
7
|
+
return (
|
8
|
+
<SvgIcon {...this.props}>
|
9
|
+
<polygon points="7,9.5 12,14.5 17,9.5 "/>
|
10
|
+
</SvgIcon>
|
11
|
+
);
|
12
|
+
}
|
13
|
+
|
14
|
+
});
|
15
|
+
|
16
|
+
module.exports = DropDownArrow;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var SvgIcon = require('./svg-icon');
|
3
|
+
|
4
|
+
var NavigationChevronLeft = React.createClass({
|
5
|
+
|
6
|
+
render: function() {
|
7
|
+
return (
|
8
|
+
<SvgIcon {...this.props}>
|
9
|
+
<path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/>
|
10
|
+
</SvgIcon>
|
11
|
+
);
|
12
|
+
}
|
13
|
+
|
14
|
+
});
|
15
|
+
|
16
|
+
module.exports = NavigationChevronLeft;
|
@@ -0,0 +1,17 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var SvgIcon = require('./svg-icon');
|
3
|
+
|
4
|
+
var NavigationChevronLeft = React.createClass({
|
5
|
+
|
6
|
+
render: function() {
|
7
|
+
return (
|
8
|
+
<SvgIcon {...this.props}>
|
9
|
+
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/>
|
10
|
+
</SvgIcon>
|
11
|
+
);
|
12
|
+
}
|
13
|
+
|
14
|
+
});
|
15
|
+
|
16
|
+
module.exports = NavigationChevronLeft;
|
17
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var SvgIcon = require('./svg-icon');
|
3
|
+
|
4
|
+
var NavigationMenu = React.createClass({
|
5
|
+
|
6
|
+
render: function() {
|
7
|
+
return (
|
8
|
+
<SvgIcon {...this.props}>
|
9
|
+
<path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"/>
|
10
|
+
</SvgIcon>
|
11
|
+
);
|
12
|
+
}
|
13
|
+
|
14
|
+
});
|
15
|
+
|
16
|
+
module.exports = NavigationMenu;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var Classable = require('../mixins/classable');
|
3
|
+
|
4
|
+
var SvgIcon = React.createClass({
|
5
|
+
|
6
|
+
mixins: [Classable],
|
7
|
+
|
8
|
+
render: function() {
|
9
|
+
var classes = this.getClasses('mui-svg-icon');
|
10
|
+
|
11
|
+
return (
|
12
|
+
<svg
|
13
|
+
{...this.props}
|
14
|
+
className={classes}
|
15
|
+
viewBox="0 0 24 24">
|
16
|
+
{this.props.children}
|
17
|
+
</svg>
|
18
|
+
);
|
19
|
+
}
|
20
|
+
|
21
|
+
});
|
22
|
+
|
23
|
+
module.exports = SvgIcon;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var SvgIcon = require('./svg-icon');
|
3
|
+
|
4
|
+
var ToggleCheckBoxChecked = React.createClass({
|
5
|
+
|
6
|
+
render: function() {
|
7
|
+
return (
|
8
|
+
<SvgIcon {...this.props}>
|
9
|
+
<path d="M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z M10,17l-5-5l1.4-1.4 l3.6,3.6l7.6-7.6L19,8L10,17z"/>
|
10
|
+
</SvgIcon>
|
11
|
+
);
|
12
|
+
}
|
13
|
+
|
14
|
+
});
|
15
|
+
|
16
|
+
module.exports = ToggleCheckBoxChecked;
|
data/vendor/assets/javascripts/material-ui/components/svg-icons/toggle-check-box-outline-blank.jsx
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var SvgIcon = require('./svg-icon');
|
3
|
+
|
4
|
+
var ToggleCheckBoxOutlineBlank = React.createClass({
|
5
|
+
|
6
|
+
render: function() {
|
7
|
+
return (
|
8
|
+
<SvgIcon {...this.props}>
|
9
|
+
<path d="M19,5v14H5V5H19 M19,3H5C3.9,3,3,3.9,3,5v14c0,1.1,0.9,2,2,2h14c1.1,0,2-0.9,2-2V5C21,3.9,20.1,3,19,3z"/>
|
10
|
+
</SvgIcon>
|
11
|
+
);
|
12
|
+
}
|
13
|
+
|
14
|
+
});
|
15
|
+
|
16
|
+
module.exports = ToggleCheckBoxOutlineBlank;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var SvgIcon = require('./svg-icon');
|
3
|
+
|
4
|
+
var RadioButtonOff = React.createClass({
|
5
|
+
|
6
|
+
render: function() {
|
7
|
+
return (
|
8
|
+
<SvgIcon {...this.props}>
|
9
|
+
<path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/>
|
10
|
+
</SvgIcon>
|
11
|
+
);
|
12
|
+
}
|
13
|
+
|
14
|
+
});
|
15
|
+
|
16
|
+
module.exports = RadioButtonOff;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var SvgIcon = require('./svg-icon');
|
3
|
+
|
4
|
+
var RadioButtonOn = React.createClass({
|
5
|
+
|
6
|
+
render: function() {
|
7
|
+
return (
|
8
|
+
<SvgIcon {...this.props}>
|
9
|
+
<path d="M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zm0-5C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/>
|
10
|
+
</SvgIcon>
|
11
|
+
);
|
12
|
+
}
|
13
|
+
|
14
|
+
});
|
15
|
+
|
16
|
+
module.exports = RadioButtonOn;
|
@@ -0,0 +1,50 @@
|
|
1
|
+
var React = require('react'),
|
2
|
+
Classable = require('./mixins/classable');
|
3
|
+
|
4
|
+
var TableHeader = React.createClass({
|
5
|
+
|
6
|
+
mixins: [Classable],
|
7
|
+
|
8
|
+
propTypes: {
|
9
|
+
headerItems: React.PropTypes.array.isRequired
|
10
|
+
},
|
11
|
+
|
12
|
+
getDefaultProps: function() {
|
13
|
+
return {
|
14
|
+
};
|
15
|
+
},
|
16
|
+
|
17
|
+
render: function() {
|
18
|
+
var classes = this.getClasses('mui-table-header');
|
19
|
+
|
20
|
+
return (
|
21
|
+
<div className={classes}>
|
22
|
+
{this._getChildren()}
|
23
|
+
<div className="mui-table-header-pagify">
|
24
|
+
(Pagify)
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
);
|
28
|
+
},
|
29
|
+
|
30
|
+
_getChildren: function() {
|
31
|
+
var children = [],
|
32
|
+
headerItem,
|
33
|
+
itemComponent
|
34
|
+
|
35
|
+
for (var i=0; i < this.props.headerItems.length; i++) {
|
36
|
+
headerItem = this.props.headerItems[i];
|
37
|
+
|
38
|
+
itemComponent = (
|
39
|
+
<div key={i} className="mui-table-header-column">{headerItem.text}</div>
|
40
|
+
);
|
41
|
+
|
42
|
+
children.push(itemComponent);
|
43
|
+
}
|
44
|
+
|
45
|
+
return children;
|
46
|
+
}
|
47
|
+
|
48
|
+
});
|
49
|
+
|
50
|
+
module.exports = TableHeader;
|
@@ -0,0 +1,31 @@
|
|
1
|
+
var React = require('react'),
|
2
|
+
Classable = require('./mixins/classable');
|
3
|
+
|
4
|
+
var TableRowItem = React.createClass({
|
5
|
+
|
6
|
+
mixins: [Classable],
|
7
|
+
|
8
|
+
propTypes: {
|
9
|
+
},
|
10
|
+
|
11
|
+
getDefaultProps: function() {
|
12
|
+
return {
|
13
|
+
};
|
14
|
+
},
|
15
|
+
|
16
|
+
render: function() {
|
17
|
+
var classes = this.getClasses('mui-table-rows-item');
|
18
|
+
|
19
|
+
return (
|
20
|
+
<div className={classes}>
|
21
|
+
(TableRowItem)
|
22
|
+
<div className="mui-table-rows-actions">
|
23
|
+
(Actions)
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
);
|
27
|
+
}
|
28
|
+
|
29
|
+
});
|
30
|
+
|
31
|
+
module.exports = TableRowItem;
|
@@ -0,0 +1,57 @@
|
|
1
|
+
var React = require('react'),
|
2
|
+
Classable = require('./mixins/classable'),
|
3
|
+
TableRowsItem = require('./table-rows-item');
|
4
|
+
|
5
|
+
var TableRow = React.createClass({
|
6
|
+
|
7
|
+
mixins: [Classable],
|
8
|
+
|
9
|
+
propTypes: {
|
10
|
+
rowItems: React.PropTypes.array.isRequired
|
11
|
+
},
|
12
|
+
|
13
|
+
getDefaultProps: function() {
|
14
|
+
return {
|
15
|
+
};
|
16
|
+
},
|
17
|
+
|
18
|
+
render: function() {
|
19
|
+
var classes = this.getClasses('mui-table-rows');
|
20
|
+
|
21
|
+
return (
|
22
|
+
<div className={classes}>
|
23
|
+
{this._getChildren()}
|
24
|
+
</div>
|
25
|
+
);
|
26
|
+
},
|
27
|
+
|
28
|
+
_getChildren: function() {
|
29
|
+
var children = [],
|
30
|
+
rowItem,
|
31
|
+
itemComponent
|
32
|
+
|
33
|
+
for (var i=0; i < this.props.rowItems.length; i++) {
|
34
|
+
rowItem = this.props.rowItems[i];
|
35
|
+
|
36
|
+
/*
|
37
|
+
for(var prop in rowItem) {
|
38
|
+
if(rowItem.hasOwnProperty(prop)) {
|
39
|
+
console.log(prop);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
console.log("--");
|
43
|
+
*/
|
44
|
+
|
45
|
+
itemComponent = (
|
46
|
+
<TableRowsItem />
|
47
|
+
);
|
48
|
+
|
49
|
+
children.push(itemComponent);
|
50
|
+
}
|
51
|
+
|
52
|
+
return children;
|
53
|
+
}
|
54
|
+
|
55
|
+
});
|
56
|
+
|
57
|
+
module.exports = TableRow;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
var React = require('react');
|
2
|
+
var Classable = require('../mixins/classable');
|
3
|
+
var TabTemplate = require('./tabTemplate');
|
4
|
+
|
5
|
+
|
6
|
+
var Tab = React.createClass({
|
7
|
+
|
8
|
+
mixins: [Classable],
|
9
|
+
|
10
|
+
propTypes: {
|
11
|
+
handleTouchTap: React.PropTypes.func,
|
12
|
+
selected: React.PropTypes.bool
|
13
|
+
},
|
14
|
+
|
15
|
+
|
16
|
+
handleTouchTap: function(){
|
17
|
+
this.props.handleTouchTap(this.props.tabIndex, this);
|
18
|
+
},
|
19
|
+
|
20
|
+
render: function(){
|
21
|
+
var styles = {
|
22
|
+
width: this.props.width
|
23
|
+
};
|
24
|
+
|
25
|
+
var classes = this.getClasses('mui-tab-item', {
|
26
|
+
'mui-tab-is-active': this.props.selected
|
27
|
+
});
|
28
|
+
|
29
|
+
return (
|
30
|
+
<div className={classes} style={styles} onTouchTap={this.handleTouchTap} routeName={this.props.route}>
|
31
|
+
{this.props.label}
|
32
|
+
</div>
|
33
|
+
)
|
34
|
+
}
|
35
|
+
|
36
|
+
});
|
37
|
+
|
38
|
+
module.exports = Tab;
|
@@ -0,0 +1,96 @@
|
|
1
|
+
var React = require('react/addons');
|
2
|
+
var Tab = require('./tab');
|
3
|
+
var TabTemplate = require('./tabTemplate');
|
4
|
+
var InkBar = require('../ink-bar');
|
5
|
+
|
6
|
+
var Tabs = React.createClass({
|
7
|
+
|
8
|
+
propTypes: {
|
9
|
+
initialSelectedIndex: React.PropTypes.number,
|
10
|
+
onActive: React.PropTypes.func,
|
11
|
+
tabWidth: React.PropTypes.number
|
12
|
+
},
|
13
|
+
|
14
|
+
getInitialState: function(){
|
15
|
+
var selectedIndex = 0;
|
16
|
+
if (this.props.initialSelectedIndex && this.props.initialSelectedIndex < this.props.children.length) {
|
17
|
+
selectedIndex = this.props.initialSelectedIndex;
|
18
|
+
}
|
19
|
+
return {
|
20
|
+
selectedIndex: selectedIndex
|
21
|
+
};
|
22
|
+
},
|
23
|
+
|
24
|
+
getEvenWidth: function(){
|
25
|
+
return (
|
26
|
+
parseInt(window
|
27
|
+
.getComputedStyle(this.getDOMNode())
|
28
|
+
.getPropertyValue('width'), 10)
|
29
|
+
);
|
30
|
+
},
|
31
|
+
|
32
|
+
componentDidMount: function(){
|
33
|
+
if(this.props.tabWidth) {
|
34
|
+
if(!(this.props.children.length * this.props.tabWidth > this.getEvenWidth())){
|
35
|
+
this.setState({
|
36
|
+
width: this.props.tabWidth,
|
37
|
+
fixed: false
|
38
|
+
});
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
this.setState({
|
43
|
+
width: this.getEvenWidth(),
|
44
|
+
fixed: true
|
45
|
+
});
|
46
|
+
},
|
47
|
+
|
48
|
+
handleTouchTap: function(tabIndex, tab){
|
49
|
+
if (this.props.onChange && this.state.selectedIndex !== tabIndex) {
|
50
|
+
this.props.onChange(tabIndex, tab);
|
51
|
+
}
|
52
|
+
|
53
|
+
this.setState({selectedIndex: tabIndex});
|
54
|
+
//default CB is _onActive. Can be updated in tab.jsx
|
55
|
+
if(tab.props.onActive) tab.props.onActive(tab);
|
56
|
+
},
|
57
|
+
|
58
|
+
render: function(){
|
59
|
+
var _this = this;
|
60
|
+
var width = this.state.fixed ?
|
61
|
+
this.state.width/this.props.children.length :
|
62
|
+
this.props.tabWidth;
|
63
|
+
var left = width * this.state.selectedIndex || 0;
|
64
|
+
var currentTemplate;
|
65
|
+
var tabs = React.Children.map(this.props.children, function(tab, index){
|
66
|
+
if(tab.type.displayName === "Tab"){
|
67
|
+
if(_this.state.selectedIndex === index) currentTemplate = tab.props.children;
|
68
|
+
return React.addons.cloneWithProps(tab, {
|
69
|
+
key: index,
|
70
|
+
selected: _this.state.selectedIndex === index,
|
71
|
+
tabIndex: index,
|
72
|
+
width: width,
|
73
|
+
handleTouchTap: _this.handleTouchTap
|
74
|
+
})
|
75
|
+
} else {
|
76
|
+
var type = tab.type.displayName || tab.type;
|
77
|
+
throw "Tabs only accepts Tab Components as children. Found " + type + " as child number " + (index + 1) + " of Tabs";
|
78
|
+
}
|
79
|
+
});
|
80
|
+
|
81
|
+
return (
|
82
|
+
<div className="mui-tabs-container">
|
83
|
+
<div className="mui-tab-item-container">
|
84
|
+
{tabs}
|
85
|
+
</div>
|
86
|
+
<InkBar left={left} width={width}/>
|
87
|
+
<TabTemplate>
|
88
|
+
{currentTemplate}
|
89
|
+
</TabTemplate>
|
90
|
+
</div>
|
91
|
+
)
|
92
|
+
},
|
93
|
+
|
94
|
+
});
|
95
|
+
|
96
|
+
module.exports = Tabs;
|