Skip to content

Commit

Permalink
feat(color-picker): update usePopup demo
Browse files Browse the repository at this point in the history
  • Loading branch information
slatejack committed Jan 23, 2025
1 parent 5ae9d5c commit 345208d
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/color-picker/_example/usePopup.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import React, { useState } from 'react';
import { ColorObject, ColorPicker, ColorPickerTrigger } from 'tdesign-mobile-react';
import { ColorObject, ColorPicker, ColorPickerTrigger, Popup } from 'tdesign-mobile-react';
import Button from 'tdesign-mobile-react/button';

export default function () {
const [visible, setVisible] = useState<boolean>(false);
const onChange = (value: string) => {
console.log('change', value);
};
const onClose = (target: ColorPickerTrigger) => {
console.log('close', target);
setVisible(false);
const onClose = (visible: boolean, target: ColorPickerTrigger) => {
console.log('close', visible, target);
if (!visible) {
setVisible(false);
}
};
const onPaletteBarChange = (e: { color: ColorObject }) => {
console.log('onPaletteBarChange', e.color);
Expand All @@ -19,15 +21,11 @@ export default function () {
};
return (
<>
<ColorPicker
usePopup
enableAlpha
visible={visible}
type="multiple"
onChange={onChange}
onClose={onClose}
onPaletteBarChange={onPaletteBarChange}
/>
<Popup showOverlay placement="bottom" visible={visible} onVisibleChange={onClose}>
{visible ? (
<ColorPicker enableAlpha fixed type="multiple" onChange={onChange} onPaletteBarChange={onPaletteBarChange} />
) : null}
</Popup>
<div className="row">
<Button block size="large" variant="outline" theme="primary" onClick={handlePopup}>
弹窗形式的颜色选择器
Expand Down

0 comments on commit 345208d

Please sign in to comment.