-
Notifications
You must be signed in to change notification settings - Fork 429
Add SLDS Slider #1317
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
Add SLDS Slider #1317
Conversation
Conflicts: package-lock.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome first time contribution!!! I left some notes on the code. npm run lint:fix
should fix the lint issues.
|
||
render () { | ||
return ( | ||
<Slider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a good idea for code examples to be spaces, so this is a good call, but please convert all to tabs for consistency.
} | ||
}); | ||
|
||
export default Example; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove min-max-step.jsx
and min-max.jsx
since they are in base.
import Slider from '~/components/slider'; | ||
|
||
const Example = createReactClass({ | ||
displayName: 'IconExample', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update displayName
.
|
||
import { SLIDER } from '../../utilities/constants'; | ||
|
||
const propTypes = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please sort alphabetically.
components/slider/index.jsx
Outdated
* Text that is visually hidden but read aloud by screenreaders to tell the user what the Slider is for. | ||
* If the Slider has a visible label, you can omit the <code>assistiveText</code> prop and use the <code>label</code> prop. | ||
*/ | ||
assistiveText: PropTypes.object, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please list out label
key/value pair.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* The ability to style sliders with CSS varies across browsers. Using this component ensures sliders look the same everywhere. | ||
*/ | ||
class Slider extends React.Component { | ||
static displayName = SLIDER; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pull in from constants file like
import { ACCORDION } from '../../utilities/constants';
components/slider/index.jsx
Outdated
} | ||
|
||
handleChange = (event) => { | ||
this.setState(({ value: event.target.value })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we need state. The value should be the value directly from the props and not the DOM event, so this can be controlled. The examples will need a state container around them then though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@interactivellama just to clarify, the user should be the one in charge of making sure that span.slds-slider__value is up to date with the current slider value(as per implementation note https://www.lightningdesignsystem.com/components/slider/)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be a controlled component, the user should be triggering an onChange
event that passes the value up to a state container (or Redux in an app) that then passes it down as the props.value
. You can see this in other examples, for instance, a controlled <Input/>
textbox. The keyPress fires of the change event that then changes the value and loops it back in. This allows the component to be a functional stateless components.
components/slider/index.jsx
Outdated
id={this.getId()} | ||
name={this.props.name} | ||
className="slds-slider__range" | ||
value={this.state.value} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace with props.value
.
components/slider/index.jsx
Outdated
className="slds-slider__value" | ||
aria-hidden="true" | ||
> | ||
{this.state.value} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace with props.value
.
components/slider/index.jsx
Outdated
*/ | ||
disabled: PropTypes.bool, | ||
/** | ||
* Size of the slider. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should mention this is only horizontal size.
- Updates to match implementation guidelines. - Added state component wrapper to show updating the value. - Removed unneeded documentation. - Added defaultValue prop.
@interactivellama should be good. Let me know if I missed anything. |
Resolved missing aria attribute in snapshot testing.
components/slider/index.jsx
Outdated
/** | ||
* Message to display when the Slider is in an error state. When this is present, also visually highlights the component as in error. | ||
* This event fires whenever the user has modified the data of the control. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* This event fires whenever the user has modified the data of the control. event, { value: [string] }
is passed in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry. That's exactly what you did. The tests though seem to not get an object, but a straight number. The test probably just needs updating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@interactivellama can you clarify which prop you're referring to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to follow the combobox implementation, passing an object with key of value.
Thanks for the contribution! Before we can merge this, we need @dlferro to sign the Salesforce.com Contributor License Agreement. |
This adds the SLDS Slider component to the component library.
Fixes #1314
@interactivellama
Pull Request Review checklist (do not remove)
last-slds-markup-review
inpackage.json
and push.last-accessibility-review
, topackage.json
and push.npm run local-update
within locally cloned site repo to confirm the site will function correctly at the next release.