Skip to content

Commit 70ea11b

Browse files
Merge pull request #353 from salesforce-ux/timeDatePicker
Add hover style & flippable prop to Timepicker and Datepicker
2 parents ce4ab97 + 85a758b commit 70ea11b

File tree

8 files changed

+60
-8
lines changed

8 files changed

+60
-8
lines changed

RELEASENOTES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
# React Components: design-system-react
33
# Release notes
44

5+
## Release 0.0.34
6+
**BREAKING CHANGES**
7+
- Flippable prop on Timepicker and Datepicker used to default to true. Now, it defaults to false and you must explicitly add it.
8+
9+
510
## Release 0.0.33
611

712
**MAJOR CHANGES**

components/date-picker/index.jsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import {KEYS,EventUtil} from '../../utilities';
2020
const displayName = 'Datepicker';
2121
const propTypes = {
2222
abbrWeekDayLabels: React.PropTypes.array,
23+
/**
24+
* If true, allows popover to appear above input field based on available space with scroll position.
25+
*/
26+
flippable: React.PropTypes.bool,
2327
/**
2428
* Date formatting function
2529
*/
@@ -142,7 +146,7 @@ module.exports = React.createClass({
142146
popover() {
143147
if(this.state && this.state.isOpen){
144148
const date = this.state.strValue?this.parseDate(this.state.strValue):this.state.value;
145-
return <Popover className='slds-dropdown' targetElement={this.refs.date} onClose={this.handleClose}>
149+
return <Popover className='slds-dropdown' flippable={this.props.flippable} targetElement={this.refs.date} onClose={this.handleClose}>
146150
<DatePicker
147151
onChange={this.handleChange}
148152
selected={this.state.selected}
@@ -207,15 +211,17 @@ module.exports = React.createClass({
207211
<input
208212
id={this.inputRefName()}
209213
ref='date'
210-
className='slds-input'
214+
className='slds-input slds-button--neutral slds-text-align--left'
211215
type='text'
212216
placeholder={this.props.placeholder}
213217
value={this.state.strValue}
214218
onKeyDown={this.handleKeyDown}
215219
onChange={this.handleInputChange}
216220
onClick={this.handleClick}
217221
onBlur={this.handleBlur}
218-
onFocus={this.handleFocus}/>
222+
onFocus={this.handleFocus}
223+
style={{cursor: 'pointer'}}
224+
/>
219225
</div>
220226
</div>
221227
{this.popover()}

components/time-picker/index.jsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ import {KEYS,EventUtil} from '../../utilities';
2121
const displayName = 'Timepicker';
2222
const propTypes = {
2323
constrainToScrollParent: React.PropTypes.bool,
24+
/**
25+
* If true, allows dropdown to appear above input field based on available space with scroll position.
26+
*/
27+
flippable: React.PropTypes.bool,
2428

2529
/**
2630
* Time formatting function
@@ -200,12 +204,12 @@ module.exports = React.createClass({
200204
return (
201205
!this.props.disabled && this.state.isOpen?
202206
<Popover
203-
className="slds-dropdown slds-dropdown--left "
207+
className="slds-dropdown slds-dropdown--left"
204208
closeOnTabKey={true}
205209
constrainToScrollParent={this.props.constrainToScrollParent}
206210
inheritTargetWidth={this.props.inheritTargetWidth}
207211
dropClass="slds-picklist"
208-
flippable={true}
212+
flippable={this.props.flippable}
209213
onClose={this.handleCancel.bind(this)}
210214
targetElement={this.refs.triggerbutton}>
211215
{this.getPopoverContent()}
@@ -255,15 +259,17 @@ module.exports = React.createClass({
255259
<input
256260
name='date'
257261
ref='date'
258-
className='slds-input'
262+
className='slds-input slds-button--neutral slds-text-align--left'
259263
type='text'
260264
placeholder={this.props.placeholder}
261265
value={this.state.strValue}
262266
onKeyDown={this.handleKeyDown}
263267
onChange={this.handleInputChange}
264268
onClick={this.handleClick}
265269
onBlur={this.handleBlur}
266-
onFocus={this.handleFocus}/>
270+
onFocus={this.handleFocus}
271+
style={{cursor: 'pointer'}}
272+
/>
267273
</div>
268274
</div>
269275
{this.props.modal?this.getModalPopover():this.getSimplePopover()}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "design-system-react",
3-
"version": "0.0.33",
3+
"version": "0.0.34",
44
"description": "Salesforce Lightning Design System React components",
55
"license": "BSD-3-Clause",
66
"scripts": {

stories/date-picker/index.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* eslint-disable indent */
2+
3+
import React from 'react';
4+
import { storiesOf, action } from '@kadira/storybook';
5+
6+
import { DATE_PICKER } from '../../utilities/constants';
7+
import Datepicker from '../../components/date-picker';
8+
9+
const getDatepicker = props => (
10+
<Datepicker {...props} />
11+
);
12+
13+
storiesOf(DATE_PICKER, module)
14+
.addDecorator(getStory => <div className="slds-p-around--medium">{getStory()}</div>)
15+
.add('Base', () => getDatepicker({ onDateChange: action('onDateChange') }))
16+

stories/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ export default from './button';
55
export default from './card';
66
export default from './context-bar';
77
export default from './data-table';
8+
export default from './date-picker';
89
export default from './forms/input';
910
export default from './forms/input/inline';
1011
export default from './icon';
1112
export default from './lookup';
1213
export default from './spinner';
14+
export default from './time-picker';

stories/time-picker/index.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* eslint-disable indent */
2+
3+
import React from 'react';
4+
import { storiesOf, action } from '@kadira/storybook';
5+
6+
import { TIME_PICKER } from '../../utilities/constants';
7+
import Timepicker from '../../components/time-picker';
8+
9+
const getTimepicker = props => (
10+
<Timepicker {...props} />
11+
);
12+
13+
storiesOf(TIME_PICKER, module)
14+
.addDecorator(getStory => <div className="slds-p-around--medium">{getStory()}</div>)
15+
.add('Base', () => getTimepicker({ stepInMinutes: 30, onDateChange: action('onDateChange') }))
16+

utilities/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ export const LOOKUP = 'SLDSLookup';
3434
export const MEDIA_OBJECT = 'SLDSMediaObject';
3535
export const MENU_DROPDOWN = 'SLDSMenuDropdown';
3636
export const SPINNER = 'SLDSSpinner';
37+
export const TIME_PICKER = 'SLDSTimepicker';

0 commit comments

Comments
 (0)