Skip to content

Commit 15972d8

Browse files
committed
docs: add disabled handle pushable example
1 parent 4e23930 commit 15972d8

1 file changed

Lines changed: 39 additions & 7 deletions

File tree

docs/examples/disabled-handle.tsx

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ const EditableWithDisabled = () => {
4444
))}
4545
</div>
4646
<p style={{ marginTop: 8, color: '#999', fontSize: 12 }}>
47-
Try: Click track to add handle • Drag handle to edge to delete • Toggle checkboxes to disable handles
47+
Try: Click track to add handle • Drag handle to edge to delete • Toggle checkboxes to
48+
disable handles
4849
</p>
4950
</div>
5051
);
@@ -82,11 +83,35 @@ const DisabledHandleAsBoundary = () => {
8283

8384
return (
8485
<div>
85-
<Slider range value={value} onChange={(v) => setValue(v as number[])} disabled={[false, true, false]} />
86+
<Slider
87+
range
88+
value={value}
89+
onChange={(v) => setValue(v as number[])}
90+
disabled={[false, true, false]}
91+
/>
92+
<p style={{ marginTop: 8, color: '#999' }}>
93+
Middle handle (50) is disabled and acts as a boundary. First handle cannot go beyond 50,
94+
third handle cannot go below 50. Disabled handle has gray border and not-allowed cursor.
95+
</p>
96+
</div>
97+
);
98+
};
99+
100+
const PushableWithDisabledHandle = () => {
101+
const [value, setValue] = useState<number[]>([20, 40, 60, 80]);
102+
103+
return (
104+
<div>
105+
<Slider
106+
range
107+
value={value}
108+
onChange={(v) => setValue(v as number[])}
109+
disabled={[false, true, false, false]}
110+
pushable={10}
111+
/>
86112
<p style={{ marginTop: 8, color: '#999' }}>
87-
Middle handle (50) is disabled and acts as a boundary.
88-
First handle cannot go beyond 50, third handle cannot go below 50.
89-
Disabled handle has gray border and not-allowed cursor.
113+
Second handle (40) is disabled. Drag the first handle toward it or push the last two handles
114+
together: enabled handles keep at least 10 apart without crossing the disabled handle.
90115
</p>
91116
</div>
92117
);
@@ -103,7 +128,7 @@ const SingleSlider = () => {
103128
<Slider value={value2} onChange={(v) => setValue2(v as number)} disabled={false} />
104129
</div>
105130
);
106-
}
131+
};
107132

108133
export default () => (
109134
<div>
@@ -113,14 +138,21 @@ export default () => (
113138
</div>
114139
<div style={style}>
115140
<h3>Disabled Handle + Draggable Track</h3>
116-
<p>Toggle checkboxes to disable/enable specific handles. Drag the track area to move the range.</p>
141+
<p>
142+
Toggle checkboxes to disable/enable specific handles. Drag the track area to move the range.
143+
</p>
117144
<BasicDisabledHandle />
118145
</div>
119146

120147
<div style={style}>
121148
<h3>Disabled Handle as Boundary</h3>
122149
<DisabledHandleAsBoundary />
123150
</div>
151+
152+
<div style={style}>
153+
<h3>Disabled Handle + Pushable</h3>
154+
<PushableWithDisabledHandle />
155+
</div>
124156
<div>
125157
<div style={style}>
126158
<h3>Editable + Disabled Array</h3>

0 commit comments

Comments
 (0)