Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Update to slider v1.0.0, fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ns065186 committed Oct 20, 2023
1 parent fbdda7c commit 0f8eeca
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ import React, { useState } from 'react';
import Slider from 'terra-slider';

const SliderWithOnChangeCallback = () => {
const [value, setValue] = useState('');
const [value, setValue] = useState('');

const handleChange = (event) => {
setValue(event.target.value)
}
const message = value? `Updated Slider value is: ${value}`: "Change the value of Slider to trigger callback";
return(
const handleChange = (event) => {
setValue(event.target.value);
};
const message = value ? `Updated Slider value is: ${value}` : 'Change the value of Slider to trigger callback';

return (
<div>
<Slider
<Slider
minimumValue={0}
maximumValue={100}
labelText="Zoom"
value={20}
onChange={handleChange}
/>
<p>{message}</p>
/>
<p>{message}</p>
</div>
)
};
);
};

export default SliderWithOnChangeCallback;
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ import React, { useState } from 'react';
import Slider from 'terra-slider';

const SliderWithOnChangeCallback = () => {
const [value, setValue] = useState('');
const [value, setValue] = useState('');

const handleChange = (event) => {
setValue(event.target.value)
}
const message = value? `Updated Slider value is: ${value}`: "Change the value of Slider to trigger callback";
return(
const handleChange = (event) => {
setValue(event.target.value);
};
const message = value ? `Updated Slider value is: ${value}` : 'Change the value of Slider to trigger callback';

return (
<div>
<Slider
<Slider
minimumValue={0}
maximumValue={100}
labelText="Zoom"
value={20}
onChange={handleChange}
/>
<p>{message}</p>
/>
<p>{message}</p>
</div>
)
};
);
};

export default SliderWithOnChangeCallback;
export default SliderWithOnChangeCallback;
8 changes: 0 additions & 8 deletions packages/terra-slider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,9 @@
[![NPM version](https://badgen.net/npm/v/terra-slider)](https://www.npmjs.com/package/terra-slider)
[![Build Status](https://badgen.net/travis/cerner/terra-framework)](https://travis-ci.com/cerner/terra-framework)

---
### Notice

> Terra Slider is currently under alpha release. There may be breaking changes between releases until it is stable with the 1.0 release.
---

Terra Slider component provides users a way to select a value from a given range by sliding a thumb along a bar to track the value.

- [Terra Slider](#terra-slider)
- [Notice](#notice)
- [Getting Started](#getting-started)
- [Peer Dependencies](#peer-dependencies)
- [LICENSE](#license)
Expand Down
2 changes: 1 addition & 1 deletion packages/terra-slider/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "terra-slider",
"main": "lib/Slider.js",
"version": "0.1.0",
"version": "1.0.0",
"description": "Terra Slider component provides users a way to select a value from a given range by sliding a thumb along a bar to track the value.",
"repository": {
"type": "git",
Expand Down
8 changes: 4 additions & 4 deletions packages/terra-slider/src/Slider.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
}

.slider-max-label {
margin-right: var(--terra-slider-max-label-margin-right, 0rem);
margin-left: var(--terra-slider-max-label-margin-left, 0.5rem);
margin-right: var(--terra-slider-max-label-margin-right, 0rem);
}

.input-range {
Expand All @@ -52,7 +52,7 @@
/* Hides the slider so that custom slider can be made */
-webkit-appearance: none; /* stylelint-disable-line property-no-vendor-prefix, plugin/no-unsupported-browser-features */
background: linear-gradient(to right, var(--terra-slider-track-selected-range, #007cc3) 0%, var(--terra-slider-track-selected-range, #007cc3) var(--terra-slider-progress-status, 50%), var(--terra-slider-track-unselected-range, #d3d4d5) var(--terra-slider-progress-status, 50%), var(--terra-slider-track-unselected-range, #d3d4d5) 100%);
border-radius: var(--terra-slider-track-border-radius, 0.214rem);
border-radius: var(--terra-slider-track-border-radius, 0.214rem);
height: var(--terra-slider-track-height, 0.43rem);
}

Expand Down Expand Up @@ -103,7 +103,7 @@
.input-range::-ms-track {
-webkit-appearance: none; /* stylelint-disable-line property-no-vendor-prefix, plugin/no-unsupported-browser-features */
background: linear-gradient(to right, var(--terra-slider-track-selected-range, #007cc3) 0%, var(--terra-slider-track-selected-range, #007cc3) var(--terra-slider-progress-status, 50%), var(--terra-slider-track-unselected-range, #d3d4d5) var(--terra-slider-progress-status, 50%), var(--terra-slider-track-unselected-range, #d3d4d5) 100%);
border-radius: var(--terra-slider-track-border-radius, 0.214rem);
border-radius: var(--terra-slider-track-border-radius, 0.214rem);
height: var(--terra-slider-track-height, 0.43rem);
}

Expand Down Expand Up @@ -153,7 +153,7 @@
.input-range::-moz-range-track {
-moz-appearance: none; /* stylelint-disable-line property-no-vendor-prefix, plugin/no-unsupported-browser-features */
background: linear-gradient(to right, var(--terra-slider-track-selected-range, #007cc3) 0%, var(--terra-slider-track-selected-range, #007cc3) var(--terra-slider-progress-status, 50%), var(--terra-slider-track-unselected-range, #d3d4d5) var(--terra-slider-progress-status, 50%), var(--terra-slider-track-unselected-range, #d3d4d5) 100%);
border-radius: var(--terra-slider-track-border-radius, 0.214rem);
border-radius: var(--terra-slider-track-border-radius, 0.214rem);
height: var(--terra-slider-track-height, 0.43rem);
}

Expand Down
4 changes: 1 addition & 3 deletions packages/terra-slider/tests/jest/Slider.test.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React from 'react';
import Slider from '../../src/Slider';

const mockOnChange = jest.fn();

describe('Slider', () => {
it('should render a default slider with proper required props', () => {
const wrapper = shallow(
Expand Down Expand Up @@ -37,7 +35,7 @@ describe('Slider', () => {
<Slider isDisabled minimumValue={0} maximumValue={100} labelText="testLabel" value={50} />,
);
expect(wrapper.find('input').prop('value')).toEqual(50);
wrapper.setProps({value: 30});
wrapper.setProps({ value: 30 });
wrapper.update();
expect(wrapper.find('input').prop('value')).toEqual(30);
});
Expand Down

0 comments on commit 0f8eeca

Please sign in to comment.