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

refactor(theme): [color-picker] refactor color-picker theme vars #2243

Merged
merged 2 commits into from
Oct 12, 2024
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
6 changes: 3 additions & 3 deletions examples/sites/demos/pc/app/color-picker/size.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { test, expect } from '@playwright/test'
test('测试尺寸', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('color-picker#size')
await expect(page.locator('.tiny-color-picker.tiny-color-picker--large')).toHaveCSS('width', '64px')
await expect(page.locator('.tiny-color-picker.tiny-color-picker--medium')).toHaveCSS('width', '48px')
await expect(page.locator('.tiny-color-picker.tiny-color-picker--small')).toHaveCSS('width', '36px')
await expect(page.locator('.tiny-color-picker.tiny-color-picker--large')).toHaveCSS('width', '48px')
await expect(page.locator('.tiny-color-picker.tiny-color-picker--medium')).toHaveCSS('width', '40px')
await expect(page.locator('.tiny-color-picker.tiny-color-picker--small')).toHaveCSS('width', '28px')
await expect(page.locator('.tiny-color-picker.tiny-color-picker--mini')).toHaveCSS('width', '24px')
})
127 changes: 14 additions & 113 deletions packages/theme/src/color-picker/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
@color-picker-prefix-cls: ~'@{css-prefix}color-picker';

.@{color-picker-prefix-cls} {
.component-css-vars-color-picker();
.inject-ColorPicker-vars();

position: relative;
width: 32px;
height: 32px;
border-radius: var(--ti-color-picker-border-radius-sm);
border: var(--ti-color-picker-border-weight) solid var(--ti-color-picker-border-color);
border-radius: var(--tv-ColorPicker-border-radius-xs);
border: 1px solid var(--tv-ColorPicker-border-color);
box-sizing: content-box;
padding: var(--ti-color-picker-padding-vertical) var(--ti-color-picker-padding-horizontal);
padding: var(--tv-ColorPicker-padding-y) var(--tv-ColorPicker-padding-x);
cursor: pointer;

&__inner {
Expand All @@ -21,125 +21,26 @@
height: 100%;
align-items: center;
justify-content: center;
border-radius: var(--ti-color-picker-border-radius-sm);
background: var(--ti-color-picker-bg-color);
border-radius: var(--tv-ColorPicker-border-radius-xs);
}

&__wrapper {
display: flex;
flex-direction: column;
position: absolute;
max-width: 300px;
z-index: var(--ti-color-picker__select__wrapper-zindex);
margin-top: var(--ti-color-picker-spacing);
background: var(--ti-color-picker__wrapper-bg);
gap: var(--ti-color-picker-spacing);
padding: var(--ti-color-picker-spacing-2x);
box-shadow: var(--ti-color-picker-shadow);

&__tools {
display: flex;

.tiny-input {
flex: 1 0 0;
}

.tiny-button-group {
flex: 0 0 auto;
}
}

&__inner {
display: flex;
gap: 12px;
&__color-select {
width: 280px;
height: 180px;
position: relative;

.white {
background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0));
}

.black {
background: linear-gradient(to top, #000, rgba(0, 0, 0, 0));
}

.white,
.black {
position: absolute;
inset: 0;
}

.cursor {
position: absolute;
width: 12px;
height: 12px;
border-radius: 100%;
border: 1px solid white;
background: rgba(0, 0, 0, .15);
box-shadow: inset 0 0 1px 1px #0000004d, 0 0 1px 2px #0006;
}
}

&__hue-select {
position: relative;
width: 18px;
border-radius: var(--ti-color-picker-border-radius-xs);
background: linear-gradient(to bottom, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);

div {
position: absolute;
top: 0;
width: 100%;
height: 4px;
background: #fff;
box-shadow: 0 0 2px rgba(0, 0, 0, .6);
border-radius: 1px;
}
}
}

&__alpha {
position: relative;
width: 100%;
height: 20px;
border-radius: var(--ti-color-picker-border-radius-xs);
margin-top: var(--ti-color-picker-spacing-2x);
&__slider {
width: 100%;
height: 100%;
}

&__thumb {
width: 4px;
height: 100%;
position: absolute;
top: 0;
left: 0;
background: #fff;
box-shadow: 0 0 2px rgba(0, 0, 0, .6);
border-radius: 1px;
}
}
}
&--large {
width: var(--ti-color-picker-size-large-width);
height: var(--ti-color-picker-size-large-height);
width: var(--tv-ColorPicker-size-large-width);
height: var(--tv-ColorPicker-size-large-height);
}

&--small {
width: var(--ti-color-picker-size-small-width);
height: var(--ti-color-picker-size-small-height);
width: var(--tv-ColorPicker-size-small-width);
height: var(--tv-ColorPicker-size-small-height);
}

&--medium {
width: var(--ti-color-picker-size-medium-width);
height: var(--ti-color-picker-size-medium-height);
width: var(--tv-ColorPicker-size-medium-width);
height: var(--tv-ColorPicker-size-medium-height);
}

&--mini {
width: var(--ti-color-picker-size-mini-width);
height: var(--ti-color-picker-size-mini-height);
width: var(--tv-ColorPicker-size-mini-width);
height: var(--tv-ColorPicker-size-mini-height);
}
}
}
46 changes: 17 additions & 29 deletions packages/theme/src/color-picker/vars.less
Original file line number Diff line number Diff line change
@@ -1,46 +1,34 @@
.component-css-vars-color-picker() {
// 默认按钮背景色(hide)
--ti-color-picker-bg-color: var(--ti-common-color-transparent, transparent);
.inject-ColorPicker-vars() {
// 按钮边框色
--ti-color-picker-border-color: var(--ti-base-color-common-2, #808080);
// 按钮边框厚度
--ti-color-picker-border-weight: var(--ti-common-border-weight-normal, 1px);
// 没用(hide)
--ti-color-picker-border-radius-xs: var(--ti-common-border-radius-normal, 6px);
--tv-ColorPicker-border-color: var(--tv-color-border-ghost);
// 按钮边框圆角
--ti-color-picker-border-radius-sm: var(--ti-common-border-radius-1, 2px);
// 没用(hide)
--ti-color-picker-border-radius: var(--ti-common-border-radius-2, 4px);
--tv-ColorPicker-border-radius-md: var(--tv-border-radius-md);
// 按钮边框小圆角
--tv-ColorPicker-border-radius-xs: var(--tv-border-radius-xs);
// 按钮垂直内边距
--ti-color-picker-padding-vertical: var(--ti-common-space-base, 4px);
--tv-ColorPicker-padding-y: var(--tv-space-sm);
// 按钮水平内边距
--ti-color-picker-padding-horizontal: var(--ti-common-space-base, 4px);
// 没用(hide)
--ti-color-picker-spacing-2x: var(--ti-common-space-2x, 8px);
// 没用(hide)
--ti-color-picker-shadow: var(--ti-common-shadow-2-down, 0 2px 8px 0 rgba(0, 0, 0, 0.2));
// 没用(hide)
--ti-color-picker__select__wrapper-zindex: 1000;
--tv-ColorPicker-padding-x: var(--tv-space-sm);
// 没用(hide)
--ti-color-picker__wrapper-bg: var(--ti-common-color-bg-white-emphasize, #f0f0f0);
--tv-ColorPicker-spacing-2x: var(--tv-space-md);

// 超大尺寸高度
--ti-color-picker-size-large-height: var(--ti-common-size-16x, 64px);
--tv-ColorPicker-size-large-height: var(--tv-size-height-xl);
// 超大尺寸宽度
--ti-color-picker-size-large-width: var(--ti-common-size-16x, 64px);
--tv-ColorPicker-size-large-width: var(--tv-size-height-xl);

// 中等尺寸高度
--ti-color-picker-size-medium-height: var(--ti-common-size-12x, 48px);
--tv-ColorPicker-size-medium-height: var(--tv-size-height-lg);
// 中等尺寸最小宽度
--ti-color-picker-size-medium-width: var(--ti-common-size-12x, 48px);
--tv-ColorPicker-size-medium-width: var(--tv-size-height-lg);

// 小型高度
--ti-color-picker-size-small-height: var(--ti-common-size-9x, 36px);
--tv-ColorPicker-size-small-height: var(--tv-size-height-sm);
// 小尺寸宽度
--ti-color-picker-size-small-width: var(--ti-common-size-9x, 36px);
--tv-ColorPicker-size-small-width: var(--tv-size-height-sm);

// 迷你尺寸按钮高度
--ti-color-picker-size-mini-height: var(--ti-common-size-6x, 24px);
--tv-ColorPicker-size-mini-height: var(--tv-size-height-xs);
// 迷你尺寸宽度
--ti-color-picker-size-mini-width: var(--ti-common-size-6x, 24px);
}
--tv-ColorPicker-size-mini-width: var(--tv-size-height-xs);
}
Loading
Loading