-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: upgrade color and add custom color panel (#129)
* feat: upgrade tdesign and add dynamic color panel * feat: upgrade tdesign and add dynamic color panel
- Loading branch information
Showing
29 changed files
with
191 additions
and
5,260 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 was deleted.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -1,25 +1,67 @@ | ||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
import { defaultColor } from 'configs/color'; | ||
import { Popup, ColorPickerPanel } from 'tdesign-react'; | ||
import Style from './RadioColor.module.less'; | ||
|
||
interface IProps { | ||
defaultValue?: number | string; | ||
onChange: (color: string) => void; | ||
} | ||
|
||
const RadioColor = (props: IProps) => ( | ||
<div className={Style.panel}> | ||
{defaultColor.map((color, index) => ( | ||
<div | ||
key={index} | ||
onClick={() => props?.onChange(color)} | ||
className={Style.box} | ||
style={{ borderColor: props.defaultValue === color ? color : 'transparent' }} | ||
const RadioColor = (props: IProps) => { | ||
const [isColoPickerDisplay, onPopupVisibleChange] = useState(false); | ||
|
||
return ( | ||
<div className={Style.panel}> | ||
{defaultColor.map((color, index) => ( | ||
<div | ||
key={index} | ||
onClick={() => props?.onChange(color)} | ||
className={Style.box} | ||
style={{ borderColor: props.defaultValue === color && !isColoPickerDisplay ? color : 'transparent' }} | ||
> | ||
<div className={Style.item} style={{ backgroundColor: color }} /> | ||
</div> | ||
))} | ||
|
||
<Popup | ||
trigger='click' | ||
placement='bottom-right' | ||
expandAnimation | ||
visible={isColoPickerDisplay} | ||
onVisibleChange={(v) => onPopupVisibleChange(v)} | ||
overlayInnerStyle={{ padding: 0 }} | ||
content={ | ||
<ColorPickerPanel | ||
onChange={(v) => props?.onChange(v)} | ||
colorModes={['monochrome']} | ||
format='HEX' | ||
swatchColors={[]} | ||
defaultValue={props.defaultValue as string} | ||
/> | ||
} | ||
> | ||
<div className={Style.item} style={{ backgroundColor: color }} /> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
<div | ||
key='dynamic' | ||
className={Style.box} | ||
style={{ | ||
borderColor: | ||
isColoPickerDisplay || defaultColor.indexOf(props.defaultValue as string) === -1 | ||
? (props.defaultValue as string) | ||
: 'transparent', | ||
}} | ||
> | ||
<div | ||
className={Style.item} | ||
style={{ | ||
background: | ||
'conic-gradient(from 90deg at 50% 50%, #FF0000 -19.41deg, #FF0000 18.76deg, #FF8A00 59.32deg, #FFE600 99.87deg, #14FF00 141.65deg, #00A3FF 177.72deg, #0500FF 220.23deg, #AD00FF 260.13deg, #FF00C7 300.69deg, #FF0000 340.59deg, #FF0000 378.76deg)', | ||
}} | ||
/> | ||
</div> | ||
</Popup> | ||
</div> | ||
); | ||
}; | ||
|
||
export default React.memo(RadioColor); |
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
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
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.