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

Feature/color picker #1346

Merged
merged 21 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9b4ad2f
feat(color-picker): 新增渐变预览, 新增最近使用颜色添加操作
S-mohan Apr 6, 2022
6d8cc74
feat(color-picker): 新增渐变预览, 改进增加最近使用色交互
S-mohan Apr 6, 2022
df8d007
Merge branch 'Tencent:develop' into feature/color-picker
S-mohan Apr 7, 2022
7ee9236
Merge branch 'Tencent:develop' into feature/color-picker
S-mohan Apr 8, 2022
4356bff
style(color-picker): 抽离公共逻辑文件
S-mohan Apr 8, 2022
d76096a
fix(color-picker): color-picker, 子目录增加style相关代码
S-mohan Apr 8, 2022
b0f8819
Merge branch 'develop' into feature/color-picker
S-mohan May 10, 2022
fee729a
fix(color-picker): fix: https://github.com/Tencent/tdesign-vue-next/i…
S-mohan May 10, 2022
b0cc7ac
style(color-picker): 删除demo文件中测试demo
S-mohan May 10, 2022
6a9c266
test(color-picker): update test files
S-mohan May 10, 2022
b0604e1
Merge remote-tracking branch 'upstream/develop' into feature/color-pi…
S-mohan May 20, 2022
bb2aaf5
feat(color-picker): 使用common中的常量, 删除无用的代码, 样式BEM
S-mohan May 20, 2022
35ec679
fix: color-picker panel 点击关闭的问题
S-mohan May 27, 2022
56a45e9
Merge branch 'Tencent:develop' into feature/color-picker
S-mohan May 27, 2022
82c7560
test: update test file
S-mohan May 27, 2022
b539f71
Merge branch 'develop' into feature/color-picker
S-mohan May 27, 2022
d744d03
test: update test file
S-mohan May 27, 2022
18959fe
Merge branch 'Tencent:develop' into feature/color-picker
S-mohan Jun 16, 2022
d96ec6f
Merge remote-tracking branch 'upstream/develop' into feature/color-pi…
S-mohan Aug 4, 2022
c59564f
style(color-picker): update color-picker style
S-mohan Aug 4, 2022
2076dc1
style(color-picker): 运用最新的color-picker样式
S-mohan Aug 4, 2022
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
1 change: 1 addition & 0 deletions src/color-picker/panel/alpha.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default defineComponent({
rail-style={this.railStyle}
max-value={100}
disabled={this.disabled}
type="alpha"
/>
);
},
Expand Down
3 changes: 2 additions & 1 deletion src/color-picker/panel/format/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export default defineComponent({
<div class={`${baseClassName}__format`}>
<div class={`${baseClassName}__format--item`}>
<TSelect
autoWidth={true}
size="small"
class={`${baseClassName}__format-mode-select`}
{...selectInputProps}
popupProps={{
overlayClassName: `${baseClassName}__select-options`,
Expand Down
2 changes: 2 additions & 0 deletions src/color-picker/panel/format/inputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default defineComponent({
<TInput
{...inputProps}
align="center"
size="small"
disabled={this.disabled}
v-model={this.modelValue[config.key]}
maxlength={this.format === 'HEX' ? 9 : undefined}
Expand All @@ -136,6 +137,7 @@ export default defineComponent({
<TInputNumber
{...inputProps}
align="center"
size="small"
disabled={this.disabled}
v-model={this.modelValue[config.key]}
title={this.modelValue[config.key]}
Expand Down
16 changes: 3 additions & 13 deletions src/color-picker/panel/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ export default defineComponent({
setup(props) {
const baseClassName = useBaseClassName();
const modeValue = ref(props.mode);
const handleClosePopup = () => {
props.togglePopup?.(false);
};
const handleModeChange = (v: string) => props.onModeChange(v);
watch(
() => props.mode,
Expand All @@ -39,10 +36,12 @@ export default defineComponent({
baseClassName,
modeValue,
handleModeChange,
handleClosePopup,
};
},
render() {
if (this.colorModes?.length === 1) {
return null;
}
const { baseClassName } = this;
return (
<div class={`${baseClassName}__head`}>
Expand All @@ -64,15 +63,6 @@ export default defineComponent({
</TRadioGroup>
)}
</div>
{this.closeBtn ? (
<span
role="button"
class={[`${baseClassName}__icon`, `${baseClassName}__close`]}
onClick={this.handleClosePopup}
>
<CloseIcon />
</span>
) : null}
</div>
);
},
Expand Down
1 change: 1 addition & 0 deletions src/color-picker/panel/hue.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default defineComponent({
value={this.color.hue}
onChange={this.onChange}
disabled={this.disabled}
type="hue"
/>
);
},
Expand Down
30 changes: 21 additions & 9 deletions src/color-picker/panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,19 +311,31 @@ export default defineComponent({
);
};

const isGradient = this.mode === 'linear-gradient';
return (
<div
class={[`${baseClassName}__panel`, this.disabled ? statusClassNames.disabled : false]}
onClick={(e) => e.stopPropagation()}
>
<div class={[`${baseClassName}__panel`, this.disabled ? statusClassNames.disabled : false]}>
<PanelHeader {...this.$props} mode={this.mode} onModeChange={this.handleModeChange} />
<div class={[`${baseClassName}__body`]}>
{this.mode === 'linear-gradient' ? (
<LinearGradient {...baseProps} onChange={this.handleGradientChange} />
) : null}
{isGradient ? <LinearGradient {...baseProps} onChange={this.handleGradientChange} /> : null}

<SaturationPanel {...baseProps} onChange={this.handleSatAndValueChange} />
<HueSlider {...baseProps} onChange={this.handleHueChange} />
{this.enableAlpha ? <AlphaSlider {...baseProps} onChange={this.handleAlphaChange} /> : null}

<div class={[`${baseClassName}__sliders-wrapper`]}>
<div class={[`${baseClassName}__sliders`]}>
<HueSlider {...baseProps} onChange={this.handleHueChange} />
{this.enableAlpha ? <AlphaSlider {...baseProps} onChange={this.handleAlphaChange} /> : null}
</div>

<div class={[`${baseClassName}__sliders-preview`, `${baseClassName}--bg-alpha`]}>
<span
class={`${baseClassName}__sliders-preview-inner`}
style={{
background: isGradient ? this.color.linearGradient : this.color.rgba,
}}
/>
</div>
</div>

<FormatPanel
{...this.$props}
color={this.color}
Expand Down
1 change: 1 addition & 0 deletions src/color-picker/panel/linear-gradient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ export default defineComponent({
</div>
<div class={`${baseClassName}__gradient-degree`} title={`${degree}deg`}>
<TInputNumber
size="small"
theme="normal"
min={0}
max={360}
Expand Down
18 changes: 14 additions & 4 deletions src/color-picker/panel/slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export default defineComponent({
railStyle: {
type: Object as PropType<any>,
},
type: {
type: String as PropType<'hue' | 'alpha'>,
default: 'hue',
},
},
setup(props) {
const baseClassName = useBaseClassName();
Expand Down Expand Up @@ -87,11 +91,17 @@ export default defineComponent({
};
},
render() {
const { baseClassName, className, railStyle, styles } = this;
const { baseClassName, className, railStyle, styles, type, color } = this;
const paddingStyle = {
background: `linear-gradient(90deg, rgba(0,0,0,.0) 0%, rgba(0,0,0,.0) 93%, ${color.rgb} 93%, ${color.rgb} 100%)`,
};
return (
<div class={[`${baseClassName}__slider`, className]} ref="refPanel">
<div class={`${baseClassName}__rail`} style={railStyle}></div>
<span class={[`${baseClassName}__thumb`]} role="slider" tabindex={0} ref="refThumb" style={styles}></span>
<div class={[`${baseClassName}__slider-wrapper`, `${baseClassName}__slider-wrapper--${type}-type`]}>
{type === 'alpha' && <div className={`${baseClassName}__slider-padding`} style={paddingStyle} />}
<div class={[`${baseClassName}__slider`, className]} ref="refPanel">
<div class={`${baseClassName}__rail`} style={railStyle}></div>
<span class={[`${baseClassName}__thumb`]} role="slider" tabindex={0} ref="refThumb" style={styles}></span>
</div>
</div>
);
},
Expand Down
Loading