Skip to content

Commit aa7e541

Browse files
Merge pull request mui#1949 from tyfoo/feature/TimePicker-override-styles
[TimePicker] added style and textFieldStyle (same as DatePicker)
2 parents 26fef66 + 1098b59 commit aa7e541

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

docs/src/app/components/pages/components/time-picker.jsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ let TimePickerPage = React.createClass({
4949
header: 'default: false',
5050
desc: 'It\'s technically more correct to refer to "12 noon" and "12 midnight" rather than "12 a.m." and "12 p.m." and it avoids real confusion between different locales. By default (for compatibility reasons) TimePicker uses (12 a.m./12 p.m.) To use (noon/midnight) set pedantic={true}.',
5151
},
52+
{
53+
name: 'style',
54+
type: 'object',
55+
header: 'optional',
56+
desc: 'Override the inline-styles of TimePicker\'s root element.',
57+
},
58+
{
59+
name: 'textFieldStyle',
60+
type: 'object',
61+
header: 'optional',
62+
desc: 'Override the inline-styles of TimePicker\'s TextField element.',
63+
},
5264
],
5365
},
5466
{
@@ -137,6 +149,20 @@ let TimePickerPage = React.createClass({
137149
format="24hr"
138150
hintText="AutoOk"
139151
autoOk={true} />
152+
153+
<TimePicker
154+
ref="pickerTextfieldStyle"
155+
format="24hr"
156+
hintText="Override text field style"
157+
textFieldStyle={{ fontSize: 'x-large' }} />
158+
159+
<TimePicker
160+
ref="pickerStyle"
161+
format="24hr"
162+
hintText="Override style"
163+
textFieldStyle={{ width: '80%' }}
164+
style={{ padding: '5px', borderRadius: '5px', backgroundColor: '#d1d1d1' }} />
165+
140166
</CodeExample>
141167
</ComponentDoc>
142168
);

docs/src/app/components/raw-code/time-picker-code.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,15 @@
1212
<TimePicker
1313
hintText="AutoOk"
1414
autoOk={true} />
15+
16+
//Override TextField/Input Style
17+
<TimePicker
18+
format="24hr"
19+
hintText="Override text field style"
20+
textFieldStyle={{ fontSize: 'x-large' }} />
21+
22+
//Override Container/Root Element Style
23+
<TimePicker
24+
hintText="Override style"
25+
textFieldStyle={{ width: '80%' }}
26+
style={{ padding: '5px', borderRadius: '5px', backgroundColor: '#d1d1d1' }} />

src/time-picker/time-picker.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ const TimePicker = React.createClass({
2424
onChange: React.PropTypes.func,
2525
onShow: React.PropTypes.func,
2626
onDismiss: React.PropTypes.func,
27+
style: React.PropTypes.object,
28+
textFieldStyle: React.PropTypes.object,
29+
},
30+
31+
contextTypes: {
32+
muiTheme: React.PropTypes.object,
2733
},
2834

2935
windowListeners: {
@@ -36,6 +42,7 @@ const TimePicker = React.createClass({
3642
format: 'ampm',
3743
pedantic: false,
3844
autoOk: false,
45+
style: {},
3946
};
4047
},
4148

@@ -84,6 +91,8 @@ const TimePicker = React.createClass({
8491
onTouchTap,
8592
onShow,
8693
onDismiss,
94+
style,
95+
textFieldStyle,
8796
...other,
8897
} = this.props;
8998

@@ -94,9 +103,10 @@ const TimePicker = React.createClass({
94103
}
95104

96105
return (
97-
<div>
106+
<div style={this.prepareStyles(style)}>
98107
<TextField
99108
{...other}
109+
style={textFieldStyle}
100110
ref="input"
101111
defaultValue={defaultInputValue}
102112
onFocus={this._handleInputFocus}

0 commit comments

Comments
 (0)