Skip to content

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

Merged
merged 6 commits into from
Apr 11, 2018
Merged

Add SLDS Slider #1317

merged 6 commits into from
Apr 11, 2018

Conversation

dlferro
Copy link
Contributor

@dlferro dlferro commented Apr 2, 2018

This adds the SLDS Slider component to the component library.

Fixes #1314

@interactivellama


Pull Request Review checklist (do not remove)

  • Review the appropriate Storybook stories. Open http://localhost:9001/.
  • Review tests are passing in the browser. Open http://localhost:8001/.
  • Review markup conforms to SLDS by looking at snapshot strings.
  • Add year-first date and commit SHA to last-slds-markup-review in package.json and push.
  • Request a review of the deployed Heroku app by the Salesforce UX Accessibility Team.
  • Add year-first review date, and commit SHA, last-accessibility-review, to package.json and push.
  • While the contributor's branch is checked out, run npm run local-update within locally cloned site repo to confirm the site will function correctly at the next release.

@dlferro dlferro changed the title Slider Added SLDS Slider Apr 2, 2018
@interactivellama interactivellama self-requested a review April 2, 2018 19:29
Copy link
Contributor

@interactivellama interactivellama left a 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
Copy link
Contributor

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;
Copy link
Contributor

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',
Copy link
Contributor

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 = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sort alphabetically.

* 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,
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be PropTypes.shape so that it can be undefined.

screen shot 2018-04-03 at 6 23 58 pm

* 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;
Copy link
Contributor

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';

}

handleChange = (event) => {
this.setState(({ value: event.target.value }));
Copy link
Contributor

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.

Copy link
Contributor Author

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/)?

Copy link
Contributor

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.

id={this.getId()}
name={this.props.name}
className="slds-slider__range"
value={this.state.value}
Copy link
Contributor

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.

className="slds-slider__value"
aria-hidden="true"
>
{this.state.value}
Copy link
Contributor

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.

*/
disabled: PropTypes.bool,
/**
* Size of the slider.
Copy link
Contributor

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.
@dlferro
Copy link
Contributor Author

dlferro commented Apr 6, 2018

@interactivellama should be good. Let me know if I missed anything.

dlferro added 2 commits April 9, 2018 09:57
Resolved missing aria attribute in snapshot testing.
/**
* 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.
Copy link
Contributor

@interactivellama interactivellama Apr 10, 2018

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.

See https://github.com/salesforce/design-system-react/blob/master/components/combobox/combobox.jsx#L427

Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

@interactivellama interactivellama temporarily deployed to design-system-react-co-pr-1317 April 10, 2018 17:30 Inactive
@interactivellama interactivellama merged commit 3a4f467 into salesforce:master Apr 11, 2018
@interactivellama interactivellama changed the title Added SLDS Slider Add SLDS Slider Apr 17, 2018
@dlferro dlferro deleted the slider branch June 19, 2018 23:27
@salesforce-cla
Copy link

salesforce-cla bot commented Aug 6, 2020

Thanks for the contribution! Before we can merge this, we need @dlferro to sign the Salesforce.com Contributor License Agreement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Slider Component
2 participants