FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

add onFormatChange handler by jschuler · Pull Request #3477 · patternfly/patternfly-react · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (2) .snap  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
    • Slider.js
    • Slider.stories.js
      • Slider.test.js.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Slider extends React.Component {
};

onFormatChange = format => {
this.setState({ tooltipFormat: format });
this.setState({ tooltipFormat: format }, this.props.onFormatChange(format));
};

formatter = value => `${value} ${this.state.tooltipFormat}`;
Expand Down Expand Up @@ -103,6 +103,7 @@ Slider.propTypes = {
value: PropTypes.oneOfType([PropTypes.array, PropTypes.number]),
toolTip: PropTypes.bool,
onSlide: PropTypes.func,
onFormatChange: PropTypes.func,
label: PropTypes.string,
labelClass: PropTypes.string,
icon: PropTypes.object,
Expand All @@ -121,6 +122,7 @@ Slider.defaultProps = {
step: 1,
toolTip: false,
onSlide: noop,
onFormatChange: noop,
label: null,
labelClass: null,
input: false,
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ SliderStories.addDecorator(
})
);

const onSlide = value => {
action(`onSlide: ${value}`)();
};

const onFormatChange = value => {
action(`onFormatChange: ${value}`)();
};

SliderStories.add('Slider', () => (
<div>
<p>
Expand All @@ -31,7 +39,7 @@ SliderStories.add('Slider', () => (
<br />

<div className="container">
<Slider id="slider-one" min={0} max={100} showBoundaries step={1} value={50} tooltip="show" />
<Slider id="slider-one" min={0} max={100} showBoundaries step={1} value={50} tooltip="show" onSlide={onSlide} />

<br />
<br />
Expand All @@ -46,6 +54,7 @@ SliderStories.add('Slider', () => (
tooltip="show"
ticks={[1, 2, 3, 4, 5]}
ticks_labels={['1', '2', '3', '4', '5']}
onSlide={onSlide}
/>

<br />
Expand All @@ -67,6 +76,7 @@ SliderStories.add('Slider', () => (
tooltip="show"
ticks={[1, 2, 3, 4, 5]}
ticks_labels={['1', '2', '3', '4', '5']}
onSlide={onSlide}
/>
</Col>
</FormGroup>
Expand All @@ -89,7 +99,7 @@ SliderStories.add('Slider', () => (

<FormGroup>
<Col sm={10}>
<Slider label="Size" id="size" min={0} max={100} tooltip="show" showBoundaries input inputFormat="GB" />
<Slider label="Size" id="size" min={0} max={100} tooltip="show" showBoundaries input inputFormat="GB" onSlide={onSlide} />
</Col>
</FormGroup>

Expand All @@ -106,13 +116,24 @@ SliderStories.add('Slider', () => (

<br />

<Slider id="slider-pf" min={0} max={100} tooltip="show" showBoundaries input inputFormat="GB" />
<Slider id="slider-pf" min={0} max={100} tooltip="show" showBoundaries input inputFormat="GB" onSlide={onSlide} />

<br />
<br />
<br />

<Slider id="slider-pf" min={0} max={100} tooltip="show" showBoundaries input dropdownList={['MB', 'GB']} dropup />
<Slider
id="slider-pf"
min={0}
max={100}
tooltip="show"
showBoundaries
input
dropdownList={['MB', 'GB']}
dropup
onSlide={onSlide}
onFormatChange={onFormatChange}
/>
</div>
</div>
)).add('onSlide function', () => <Slider id="slider-pf" min={0} max={5} onSlide={action('onSlide was called')} />);
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ exports[`Slider match snapshot 1`] = `
labelClass={null}
max={100}
min={0}
onFormatChange={[Function]}
onSlide={[Function]}
orientation="horizontal"
reversed={false}
Expand All @@ -48,6 +49,7 @@ exports[`Slider match snapshot 1`] = `
labelClass={null}
max={100}
min={0}
onFormatChange={[Function]}
onSlide={[Function]}
orientation="horizontal"
sliderClass={null}
Expand Down

Back | FazBrowse Home | New Git URL