Skip to content

Add hover style & flippable prop to Timepicker and Datepicker #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# React Components: design-system-react
# Release notes

## Release 0.0.34
**BREAKING CHANGES**
- Flippable prop on Timepicker and Datepicker used to default to true. Now, it defaults to false and you must explicitly add it.


## Release 0.0.33

**MAJOR CHANGES**
Expand Down
12 changes: 9 additions & 3 deletions components/date-picker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import {KEYS,EventUtil} from '../../utilities';
const displayName = 'Datepicker';
const propTypes = {
abbrWeekDayLabels: React.PropTypes.array,
/**
* If true, allows popover to appear above input field based on available space with scroll position.
*/
flippable: React.PropTypes.bool,
/**
* Date formatting function
*/
Expand Down Expand Up @@ -142,7 +146,7 @@ module.exports = React.createClass({
popover() {
if(this.state && this.state.isOpen){
const date = this.state.strValue?this.parseDate(this.state.strValue):this.state.value;
return <Popover className='slds-dropdown' targetElement={this.refs.date} onClose={this.handleClose}>
return <Popover className='slds-dropdown' flippable={this.props.flippable} targetElement={this.refs.date} onClose={this.handleClose}>
<DatePicker
onChange={this.handleChange}
selected={this.state.selected}
Expand Down Expand Up @@ -207,15 +211,17 @@ module.exports = React.createClass({
<input
id={this.inputRefName()}
ref='date'
className='slds-input'
className='slds-input slds-button--neutral slds-text-align--left'
type='text'
placeholder={this.props.placeholder}
value={this.state.strValue}
onKeyDown={this.handleKeyDown}
onChange={this.handleInputChange}
onClick={this.handleClick}
onBlur={this.handleBlur}
onFocus={this.handleFocus}/>
onFocus={this.handleFocus}
style={{cursor: 'pointer'}}
/>
</div>
</div>
{this.popover()}
Expand Down
14 changes: 10 additions & 4 deletions components/time-picker/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import {KEYS,EventUtil} from '../../utilities';
const displayName = 'Timepicker';
const propTypes = {
constrainToScrollParent: React.PropTypes.bool,
/**
* If true, allows dropdown to appear above input field based on available space with scroll position.
*/
flippable: React.PropTypes.bool,

/**
* Time formatting function
Expand Down Expand Up @@ -200,12 +204,12 @@ module.exports = React.createClass({
return (
!this.props.disabled && this.state.isOpen?
<Popover
className="slds-dropdown slds-dropdown--left "
className="slds-dropdown slds-dropdown--left"
closeOnTabKey={true}
constrainToScrollParent={this.props.constrainToScrollParent}
inheritTargetWidth={this.props.inheritTargetWidth}
dropClass="slds-picklist"
flippable={true}
flippable={this.props.flippable}
onClose={this.handleCancel.bind(this)}
targetElement={this.refs.triggerbutton}>
{this.getPopoverContent()}
Expand Down Expand Up @@ -255,15 +259,17 @@ module.exports = React.createClass({
<input
name='date'
ref='date'
className='slds-input'
className='slds-input slds-button--neutral slds-text-align--left'
type='text'
placeholder={this.props.placeholder}
value={this.state.strValue}
onKeyDown={this.handleKeyDown}
onChange={this.handleInputChange}
onClick={this.handleClick}
onBlur={this.handleBlur}
onFocus={this.handleFocus}/>
onFocus={this.handleFocus}
style={{cursor: 'pointer'}}
/>
</div>
</div>
{this.props.modal?this.getModalPopover():this.getSimplePopover()}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "design-system-react",
"version": "0.0.33",
"version": "0.0.34",
"description": "Salesforce Lightning Design System React components",
"license": "BSD-3-Clause",
"scripts": {
Expand Down
16 changes: 16 additions & 0 deletions stories/date-picker/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable indent */

import React from 'react';
import { storiesOf, action } from '@kadira/storybook';

import { DATE_PICKER } from '../../utilities/constants';
import Datepicker from '../../components/date-picker';

const getDatepicker = props => (
<Datepicker {...props} />
);

storiesOf(DATE_PICKER, module)
.addDecorator(getStory => <div className="slds-p-around--medium">{getStory()}</div>)
.add('Base', () => getDatepicker({ onDateChange: action('onDateChange') }))

2 changes: 2 additions & 0 deletions stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ export default from './button';
export default from './card';
export default from './context-bar';
export default from './data-table';
export default from './date-picker';
export default from './forms/input';
export default from './forms/input/inline';
export default from './icon';
export default from './spinner';
export default from './time-picker';
16 changes: 16 additions & 0 deletions stories/time-picker/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* eslint-disable indent */

import React from 'react';
import { storiesOf, action } from '@kadira/storybook';

import { TIME_PICKER } from '../../utilities/constants';
import Timepicker from '../../components/time-picker';

const getTimepicker = props => (
<Timepicker {...props} />
);

storiesOf(TIME_PICKER, module)
.addDecorator(getStory => <div className="slds-p-around--medium">{getStory()}</div>)
.add('Base', () => getTimepicker({ stepInMinutes: 30, onDateChange: action('onDateChange') }))

1 change: 1 addition & 0 deletions utilities/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ export const LOOKUP = 'SLDSLookup';
export const MEDIA_OBJECT = 'SLDSMediaObject';
export const MENU_DROPDOWN = 'SLDSMenuDropdown';
export const SPINNER = 'SLDSSpinner';
export const TIME_PICKER = 'SLDSTimepicker';