mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 13:05:09 +00:00
fix
This commit is contained in:
40
napcat.webui/src/components/ColorPicker.tsx
Normal file
40
napcat.webui/src/components/ColorPicker.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@heroui/popover'
|
||||
import React from 'react'
|
||||
import { ColorResult, SketchPicker } from 'react-color'
|
||||
|
||||
// 假定 heroui 提供的 Popover组件
|
||||
|
||||
interface ColorPickerProps {
|
||||
color: string
|
||||
onChange: (color: string) => void
|
||||
}
|
||||
|
||||
const ColorPicker: React.FC<ColorPickerProps> = ({ color, onChange }) => {
|
||||
const handleChange = (colorResult: ColorResult) => {
|
||||
const hsl = colorResult.hsl
|
||||
const color = `${hsl.h} ${hsl.s}% ${hsl.l}%`
|
||||
onChange(color)
|
||||
}
|
||||
|
||||
return (
|
||||
<Popover>
|
||||
<PopoverTrigger>
|
||||
<div
|
||||
style={{
|
||||
background: color,
|
||||
width: 36,
|
||||
height: 14,
|
||||
borderRadius: 2,
|
||||
cursor: 'pointer',
|
||||
border: '1px solid #ddd'
|
||||
}}
|
||||
/>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent>
|
||||
<SketchPicker color={color} onChange={handleChange} />
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
)
|
||||
}
|
||||
|
||||
export default ColorPicker
|
||||
Reference in New Issue
Block a user