Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(colorpicker): remove swatchs panel default title #1810

Merged
merged 6 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 19 additions & 24 deletions src/color-picker/components/panel/swatches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,7 @@ export interface TdColorSwathcesProps extends TdColorBaseProps {
}

const Swatches = (props: TdColorSwathcesProps) => {
const {
baseClassName,
colors = [],
title = '系统色彩',
editable = false,
onChange,
disabled,
onSetColor,
handleAddColor,
} = props;
const { baseClassName, colors = [], editable = false, title, onChange, disabled, onSetColor, handleAddColor } = props;
const { DeleteIcon, AddIcon } = useGlobalIcon({ DeleteIcon: TdDeleteIcon, AddIcon: TdAddIcon });
const swatchesClass = `${baseClassName}__swatches`;
const { STATUS: statusClassNames } = useCommonClassName();
Expand All @@ -44,21 +35,25 @@ const Swatches = (props: TdColorSwathcesProps) => {

return (
<div className={swatchesClass}>
<h3 className={`${swatchesClass}--title`}>
<span>{title}</span>
{editable && (
<div className={`${swatchesClass}--actions`}>
<span role="button" className={`${baseClassName}__icon`} onClick={() => handleAddColor()}>
<AddIcon />
</span>
{colors.length > 0 ? (
<span role="button" className={`${baseClassName}__icon`} onClick={() => handleRemoveColor()}>
<DeleteIcon />
{title ? (
<h3 className={`${swatchesClass}--title`}>
<span>{title}</span>
{editable && (
<div className={`${swatchesClass}--actions`}>
<span role="button" className={`${baseClassName}__icon`} onClick={() => handleAddColor()}>
<AddIcon />
</span>
) : null}
</div>
)}
</h3>
{colors.length > 0 ? (
<span role="button" className={`${baseClassName}__icon`} onClick={() => handleRemoveColor()}>
<DeleteIcon />
</span>
) : null}
</div>
)}
</h3>
) : (
<></>
)}
<ul className={classnames(`${swatchesClass}--items`, 'narrow-scrollbar')}>
{colors.map((color) => (
<li
Expand Down