Skip to content

Commit

Permalink
Update slider story
Browse files Browse the repository at this point in the history
  • Loading branch information
keianhzo committed Jan 10, 2022
1 parent 27457cb commit 16edc4d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
9 changes: 8 additions & 1 deletion src/react-components/input/Slider.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { forwardRef, memo, useImperativeHandle, useRef } from "react";
import React, { forwardRef, memo, useEffect, useImperativeHandle, useRef } from "react";
import { useState, useCallback } from "react";
import PropTypes from "prop-types";
import classNames from "classnames";
Expand Down Expand Up @@ -43,6 +43,13 @@ export const Slider = memo(
}
}));

useEffect(
() => {
updateValue(displayValue);
},
[updateValue, displayValue]
);

return (
<div className={classNames(styles.numberWithRange, className)}>
<div className={classNames(styles.rangeSlider)} disabled={disabled}>
Expand Down
21 changes: 2 additions & 19 deletions src/react-components/input/Slider.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,7 @@ const Template = args => (
export const Base = Template.bind({});
Base.argTypes = {
onChange: { action: "changed" },
value: {
table: {
disable: true
}
}
};
Base.args = {
min: 0,
max: 8,
step: 1,
defaultValue: 4,
disabled: false
};

export const Controlled = Template.bind({});
Controlled.argTypes = {
onChange: { action: "changed" },
value: {
defaultValue: {
control: {
type: "range",
min: 0,
Expand All @@ -42,7 +25,7 @@ Controlled.argTypes = {
}
}
};
Controlled.args = {
Base.args = {
min: 0,
max: 8,
step: 1,
Expand Down

0 comments on commit 16edc4d

Please sign in to comment.