Skip to content

Commit abdcbcb

Browse files
committed
website: update example.
1 parent a03d275 commit abdcbcb

File tree

1 file changed

+78
-1
lines changed

1 file changed

+78
-1
lines changed

website/src/pages/home/index.tsx

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
import { useContext } from 'react';
2-
import { Colorful, Sketch, Block, Circle, Compact, Wheel, Github, Material, Chrome } from '@uiw/react-color';
2+
import {
3+
Colorful,
4+
Sketch,
5+
Block,
6+
Circle,
7+
Compact,
8+
Wheel,
9+
Github,
10+
Material,
11+
Chrome,
12+
Saturation,
13+
Alpha,
14+
ShadeSlider,
15+
Hue,
16+
Swatch,
17+
Slider,
18+
} from '@uiw/react-color';
319
import { hsvaToHex } from '@uiw/react-color';
420
import Markdown from '../../components/Markdown';
521
import { Context } from '../../Store';
@@ -126,6 +142,67 @@ function Example() {
126142
<Title>{`<Block color="${hsvaToHex(hsva)}" />`}</Title>
127143
</div>
128144
</div>
145+
<div style={{ display: 'flex', gap: '20px', justifyContent: 'space-between', paddingTop: 40 }}>
146+
<Saturation
147+
hsva={hsva}
148+
onChange={(color) => {
149+
dispatch!({ hsva: { ...hsva, ...color } });
150+
}}
151+
/>
152+
<div style={{ flex: 1, display: 'flex', gap: '20px', flexDirection: 'column' }}>
153+
<Hue
154+
hue={hsva.h}
155+
onChange={(newHue) => {
156+
dispatch!({ hsva: { ...hsva, ...newHue } });
157+
}}
158+
/>
159+
<Alpha
160+
hsva={hsva}
161+
onChange={(newAlpha) => {
162+
dispatch!({ hsva: { ...hsva, ...newAlpha } });
163+
}}
164+
/>
165+
<ShadeSlider
166+
hsva={hsva}
167+
onChange={(newShade) => {
168+
dispatch!({ hsva: { ...hsva, ...newShade } });
169+
}}
170+
/>
171+
<Slider
172+
color={hsva}
173+
onChange={(color) => {
174+
dispatch!({ hsva: { ...hsva, ...color.hsv } });
175+
}}
176+
customColorShades={[
177+
{ color: '#000000', lightness: [50, 40, 30, 20, 10] },
178+
{ color: '#ffffff', lightness: [95, 90, 80, 70, 60] },
179+
]}
180+
/>
181+
<Swatch
182+
colors={[
183+
'#D0021B',
184+
'#F5A623',
185+
'#f8e61b',
186+
'#8B572A',
187+
'#7ED321',
188+
'#417505',
189+
'#BD10E0',
190+
'#9013FE',
191+
'#4A90E2',
192+
'#50E3C2',
193+
'#B8E986',
194+
'#000000',
195+
'#4A4A4A',
196+
'#9B9B9B',
197+
'#FFFFFF',
198+
]}
199+
color={hsvaToHex(hsva)}
200+
onChange={(hsva) => {
201+
dispatch!({ hsva: { ...hsva, ...hsva } });
202+
}}
203+
/>
204+
</div>
205+
</div>
129206
</div>
130207
);
131208
}

0 commit comments

Comments
 (0)