Skip to content

Commit

Permalink
feat(dropdown): [action-menu,dropdown,autocomplete,input] component d…
Browse files Browse the repository at this point in the history
…ark theme adaptation (#3014)

* feat(dropdown): [action-menu,dropdown] component dark theme adaptation

* feat(dialog-select): [dialog-select] modify search icon alignment issue

* feat(autocomplete): [autocomplete] dark theme adaptation

* feat(input): [input] dark theme adaptation

* test(dropdown): [action-menu,dropdown] synchronize modification of test cases
  • Loading branch information
MomoPoppy authored Mar 4, 2025
1 parent 3a57416 commit 694d6f1
Show file tree
Hide file tree
Showing 29 changed files with 114 additions and 89 deletions.
10 changes: 5 additions & 5 deletions examples/sites/demos/pc/app/action-menu/icon-composition-api.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,22 @@ p {
:deep(.tiny-action-menu__wrap) {
.tiny-action-menu__item {
.tiny-dropdown-item__wrap {
color: #191919;
color: var(--tv-color-icon-control);
.tiny-svg {
fill: #191919;
fill: var(--tv-color-icon-control);
}
}
&:hover {
.tiny-dropdown-item__wrap > .tiny-dropdown-item__content .tiny-svg {
fill: #191919;
fill: var(--tv-color-icon-control);
}
}
.tiny-dropdown {
color: #191919;
color: var(--tv-color-icon-control);
.tiny-svg {
fill: #191919;
fill: var(--tv-color-icon-control);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions examples/sites/demos/pc/app/action-menu/icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,22 @@ p {
:deep(.tiny-action-menu__wrap) {
.tiny-action-menu__item {
.tiny-dropdown-item__wrap {
color: #191919;
color: var(--tv-color-icon-control);
.tiny-svg {
fill: #191919;
fill: var(--tv-color-icon-control);
}
}
&:hover {
.tiny-dropdown-item__wrap > .tiny-dropdown-item__content .tiny-svg {
fill: #191919;
fill: var(--tv-color-icon-control);
}
}
.tiny-dropdown {
color: #191919;
color: var(--tv-color-icon-control);
.tiny-svg {
fill: #191919;
fill: var(--tv-color-icon-control);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ const options = ref([

<style>
.custom-action-menu {
background-color: antiquewhite;
background-color: var(--tv-color-bg-3);
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ test('弹框样式', async ({ page }) => {
await visibleItem.last().hover()
await page.waitForTimeout(200)
await expect(dropDownMenu).toHaveClass(/custom-action-menu/)
await expect(dropDownMenu).toHaveCSS('background-color', 'rgb(250, 235, 215)')
await expect(dropDownMenu).toHaveCSS('background-color', 'rgb(255, 255, 255)')
})
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/action-menu/popper-class.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ export default {

<style>
.custom-action-menu {
background-color: antiquewhite;
background-color: var(--tv-color-bg-3);
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<tiny-action-menu :options="options">
<template #item="{ data }">
<tiny-icon-smile></tiny-icon-smile>
<span style="vertical-align: middle"> {{ data.name }}</span>
<span style="vertical-align: middle; margin-left: 4px"> {{ data.name }}</span>
</template>
</tiny-action-menu>
</template>
Expand Down
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/action-menu/slot-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<tiny-action-menu :options="options">
<template #item="{ data }">
<icon-smile></icon-smile>
<span style="vertical-align: middle"> {{ data.name }}</span>
<span style="vertical-align: middle; margin-left: 4px"> {{ data.name }}</span>
</template>
</tiny-action-menu>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<template #prepend>前置内容</template>
<template #append>后置内容</template>
</tiny-autocomplete>
<br />
<br />
<tiny-autocomplete class="fix-slot" v-model="value" placeholder="请输入内容" :fetch-suggestions="querySearch">
<template #prefix>
<tiny-icon-edit />
Expand All @@ -12,6 +14,8 @@
<tiny-icon-association />
</template>
</tiny-autocomplete>
<br />
<br />
<tiny-autocomplete class="default-slot" v-model="value" :fetch-suggestions="querySearch">
<template #default="{ slotScope }">
<div>{{ slotScope.value }}</div>
Expand Down
4 changes: 4 additions & 0 deletions examples/sites/demos/pc/app/autocomplete/slot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<template #prepend>前置内容</template>
<template #append>后置内容</template>
</tiny-autocomplete>
<br />
<br />
<tiny-autocomplete class="fix-slot" v-model="value" :fetch-suggestions="querySearch">
<template #prefix>
<tiny-icon-edit />
Expand All @@ -12,6 +14,8 @@
<tiny-icon-association />
</template>
</tiny-autocomplete>
<br />
<br />
<tiny-autocomplete class="default-slot" v-model="value" :fetch-suggestions="querySearch">
<template #default="{ slotScope }">
<div>{{ slotScope.value }}</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="demo-drop">
<p class="demo-dropdown">场景 1:默认</p>
<tiny-dropdown split-button type="success">
<tiny-dropdown border type="success">
更多菜单(标题很长示例)
<template #dropdown>
<tiny-dropdown-menu>
Expand All @@ -15,7 +15,7 @@
</tiny-dropdown>
<br /><br />
<p class="demo-dropdown">场景 2:设置 inherit-width</p>
<tiny-dropdown split-button type="success" :inherit-width="true">
<tiny-dropdown border type="success" :inherit-width="true">
更多菜单(标题很长示例)
<template #dropdown>
<tiny-dropdown-menu>
Expand Down
4 changes: 2 additions & 2 deletions examples/sites/demos/pc/app/dropdown/inherit-width.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="demo-drop">
<p class="demo-dropdown">场景 1:默认</p>
<tiny-dropdown split-button type="success">
<tiny-dropdown border type="success">
更多菜单(标题很长示例)
<template #dropdown>
<tiny-dropdown-menu>
Expand All @@ -15,7 +15,7 @@
</tiny-dropdown>
<br /><br />
<p class="demo-dropdown">场景 2:设置 inherit-width</p>
<tiny-dropdown split-button type="success" :inherit-width="true">
<tiny-dropdown type="success" border :inherit-width="true">
更多菜单(标题很长示例)
<template #dropdown>
<tiny-dropdown-menu>
Expand Down
18 changes: 12 additions & 6 deletions examples/sites/demos/pc/app/dropdown/show-icon-composition-api.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,20 @@ p {
margin-top: 30px;
}
.tiny-dropdown.only-icon {
:deep(.tiny-dropdown__trigger) {
.tiny-svg {
fill: #191919;
&:hover {
fill: #191919;
.tiny-dropdown {
&.only-icon {
:deep(.tiny-dropdown__trigger) {
.tiny-svg {
fill: var(--tv-color-icon-control);
&:hover {
fill: var(--tv-color-icon-control);
}
}
}
}
:deep(.tiny-dropdown__prefix-inner) {
fill: var(--tv-color-icon-control);
}
}
</style>
18 changes: 12 additions & 6 deletions examples/sites/demos/pc/app/dropdown/show-icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,20 @@ p {
margin-top: 30px;
}
.tiny-dropdown.only-icon {
:deep(.tiny-dropdown__trigger) {
.tiny-svg {
fill: #191919;
&:hover {
fill: #191919;
.tiny-dropdown {
&.only-icon {
:deep(.tiny-dropdown__trigger) {
.tiny-svg {
fill: var(--tv-color-icon-control);
&:hover {
fill: var(--tv-color-icon-control);
}
}
}
}
:deep(.tiny-dropdown__prefix-inner) {
fill: var(--tv-color-icon-control);
}
}
</style>
8 changes: 4 additions & 4 deletions examples/sites/demos/pc/app/dropdown/size-composition-api.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="demo-drop">
<p class="demo-dropdown">默认:</p>
<tiny-dropdown split-button type="primary">
<tiny-dropdown border type="primary">
默认尺寸
<template #dropdown>
<tiny-dropdown-menu>
Expand All @@ -14,7 +14,7 @@
</template>
</tiny-dropdown>
<p class="demo-dropdown">其他尺寸:</p>
<tiny-dropdown size="medium" split-button type="primary">
<tiny-dropdown size="medium" border type="primary">
中等尺寸
<template #dropdown>
<tiny-dropdown-menu>
Expand All @@ -27,7 +27,7 @@
</template>
</tiny-dropdown>

<tiny-dropdown size="small" split-button type="primary">
<tiny-dropdown size="small" border type="primary">
小型尺寸
<template #dropdown>
<tiny-dropdown-menu>
Expand All @@ -40,7 +40,7 @@
</template>
</tiny-dropdown>

<tiny-dropdown size="mini" split-button type="primary">
<tiny-dropdown size="mini" border type="primary">
超小尺寸
<template #dropdown>
<tiny-dropdown-menu>
Expand Down
8 changes: 4 additions & 4 deletions examples/sites/demos/pc/app/dropdown/size.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<div class="demo-drop">
<p class="demo-dropdown">默认:</p>
<tiny-dropdown split-button type="primary">
<tiny-dropdown border type="primary">
默认尺寸
<template #dropdown>
<tiny-dropdown-menu>
Expand All @@ -14,7 +14,7 @@
</template>
</tiny-dropdown>
<p class="demo-dropdown">其他尺寸:</p>
<tiny-dropdown size="medium" split-button type="primary">
<tiny-dropdown size="medium" border type="primary">
中等尺寸
<template #dropdown>
<tiny-dropdown-menu>
Expand All @@ -27,7 +27,7 @@
</template>
</tiny-dropdown>

<tiny-dropdown size="small" split-button type="primary">
<tiny-dropdown size="small" border type="primary">
小型尺寸
<template #dropdown>
<tiny-dropdown-menu>
Expand All @@ -40,7 +40,7 @@
</template>
</tiny-dropdown>

<tiny-dropdown size="mini" split-button type="primary">
<tiny-dropdown size="mini" border type="primary">
超小尺寸
<template #dropdown>
<tiny-dropdown-menu>
Expand Down
35 changes: 18 additions & 17 deletions examples/sites/demos/pc/app/dropdown/split-button.spec.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
import { test, expect } from '@playwright/test'

// 不展示此示例。按钮类型推荐使用 border
test('按钮类型', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('dropdown#split-button')
// await page.goto('dropdown#split-button')

const wrap = page.locator('#split-button')
const dropDown = wrap.locator('.tiny-dropdown').nth(1)
const dropDownMenu = page.locator('body > .tiny-dropdown-menu')
const textBtn = dropDown.locator('button').first()
const dropDownBtn = dropDown.locator('button').nth(1)
// const wrap = page.locator('#split-button')
// const dropDown = wrap.locator('.tiny-dropdown').nth(1)
// const dropDownMenu = page.locator('body > .tiny-dropdown-menu')
// const textBtn = dropDown.locator('button').first()
// const dropDownBtn = dropDown.locator('button').nth(1)

// 是否变成了按钮且按钮样式是否生效
await expect(dropDown.locator('button')).toHaveCount(2)
await expect(textBtn).toHaveCSS('background-color', 'rgb(92, 179, 0)')
await expect(textBtn).toHaveCSS('color', 'rgb(255, 255, 255)')
await expect(dropDownBtn).toHaveCSS('background-color', 'rgb(92, 179, 0)')
await expect(dropDownBtn).toHaveCSS('color', 'rgb(255, 255, 255)')
// await expect(dropDown.locator('button')).toHaveCount(2)
// await expect(textBtn).toHaveCSS('background-color', 'rgb(92, 179, 0)')
// await expect(textBtn).toHaveCSS('color', 'rgb(255, 255, 255)')
// await expect(dropDownBtn).toHaveCSS('background-color', 'rgb(92, 179, 0)')
// await expect(dropDownBtn).toHaveCSS('color', 'rgb(255, 255, 255)')

// 文字悬浮不出现下拉菜单
await page.waitForTimeout(500)
await textBtn.hover()
await expect(dropDownMenu).not.toBeVisible()
await dropDownBtn.hover()
await expect(dropDownMenu).toBeVisible()
// // 文字悬浮不出现下拉菜单
// await page.waitForTimeout(500)
// await textBtn.hover()
// await expect(dropDownMenu).not.toBeVisible()
// await dropDownBtn.hover()
// await expect(dropDownMenu).toBeVisible()
})
14 changes: 0 additions & 14 deletions examples/sites/demos/pc/app/dropdown/webdoc/dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,6 @@ export default {
},
codeFiles: ['show-icon.vue']
},
{
demoId: 'split-button',
name: {
'zh-CN': '按钮类型',
'en-US': 'Button type'
},
desc: {
'zh-CN':
'<p>通过 <code>split-button</code> 属性,设置下拉菜单显示为按钮类型。仅按钮类型时,支持 <code>type</code> 属性设置按钮状态。</p>\n',
'en-US':
'<p>Set the drop-down menu to display as a button type through the <code>split-button</code> attribute. When only button types are used, the <code>type</code> attribute setting button status is supported.</p>\n'
},
codeFiles: ['split-button.vue']
},
{
demoId: 'trigger',
name: {
Expand Down
5 changes: 5 additions & 0 deletions packages/theme/src/action-menu/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
justify-content: space-between;
align-items: center;

.@{dropdown-prefix-cls} {
display: flex;
align-items: center;
}

// 默认
&.@{action-menu-prefix-cls}__item-visible {
.@{dropdown-item-prefix-cls} {
Expand Down
1 change: 1 addition & 0 deletions packages/theme/src/autocomplete/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
&.is-loading &__list-loading {
.tiny-svg {
font-size: var(--tv-Autocomplete-icon-size);
fill: var(--tv-Autocomplete-loading-icon-color);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/theme/src/autocomplete/vars.less
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@
--tv-Autocomplete-li-padding: 5.5px var(--tv-space-xl, 16px);
// 列表项悬浮背景色
--tv-Autocomplete-li-bg-color-hover: var(--tv-color-bg-hover, #f5f5f5);

// 加载图标色
--tv-Autocomplete-loading-icon-color: var(--tv-color-icon-control, #191919);
}
Loading

0 comments on commit 694d6f1

Please sign in to comment.