-
-
Notifications
You must be signed in to change notification settings - Fork 777
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support slider editable (#1006)
* refactor: update logic * feat: click to add * chore: click to move * feat: key to delete * chore: support drag to remove * chore: drag to delete * chore: dragable * chore: editable only * chore: good for dragging remove check * chore: fix save * test: fix test case * chore: adjust range * test: add test case * test: coverage
- Loading branch information
Showing
12 changed files
with
421 additions
and
131 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: Multiple | ||
nav: | ||
title: Demo | ||
path: /demo | ||
--- | ||
|
||
<code src="../examples/editable.tsx"></code> |
This file contains 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* eslint react/no-multi-comp: 0, no-console: 0 */ | ||
import Slider from 'rc-slider'; | ||
import React from 'react'; | ||
import '../../assets/index.less'; | ||
|
||
const style: React.CSSProperties = { | ||
width: 400, | ||
margin: 50, | ||
}; | ||
|
||
export default () => { | ||
const [value, setValue] = React.useState([0, 50, 80]); | ||
|
||
return ( | ||
<div> | ||
<div style={style}> | ||
<Slider | ||
// range | ||
range={{ | ||
editable: true, | ||
}} | ||
track={false} | ||
min={0} | ||
max={100} | ||
value={value} | ||
// defaultValue={null} | ||
onChange={(nextValue) => { | ||
console.error('Change:', nextValue); | ||
setValue(nextValue as any); | ||
}} | ||
onChangeComplete={(nextValue) => { | ||
console.log('Complete', nextValue); | ||
}} | ||
styles={{ | ||
rail: { | ||
background: `linear-gradient(to right, blue, red)`, | ||
}, | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.