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(action-menu): [action-menu] modify variable names and add refactor styles #2224

Merged
merged 3 commits into from
Sep 30, 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
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
<template>
<tiny-action-menu :options="options"> </tiny-action-menu>
<div>
<tiny-action-menu :options="options"> </tiny-action-menu>
<br />
<tiny-action-menu :options="options1"> </tiny-action-menu>
<br />
<tiny-action-menu :options="options1" mode="card"> </tiny-action-menu>
</div>
</template>

<script setup>
import { ref } from 'vue'
import { ActionMenu as TinyActionMenu } from '@opentiny/vue'
import { iconWebPlus, iconSuccessful, iconCloseSquare } from '@opentiny/vue-icon'

const options = ref([
{
Expand All @@ -28,4 +35,27 @@ const options = ref([
]
}
])

const options1 = ref([
{
label: '远程登陆',
icon: iconWebPlus()
},
{
label: '开机',
icon: iconSuccessful(),
disabled: true
},
{
label: '关机',
icon: iconCloseSquare()
},
{
label: '重启'
},
{
label: '网络设置',
children: [{ label: '更改安全组' }, { label: '切换VPC', divided: true }]
}
])
</script>
5 changes: 4 additions & 1 deletion examples/sites/demos/pc/app/action-menu/disabled.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ test('禁用', async ({ page }) => {

const wrap = page.locator('#disabled')
const actionMenu = wrap.locator('.tiny-action-menu')
const disabledItem = actionMenu.locator('.tiny-dropdown-item.tiny-dropdown-menu__item').filter({ hasText: '开机' })
const disabledItem = actionMenu
.nth(0)
.locator('.tiny-dropdown-item.tiny-dropdown-menu__item')
.filter({ hasText: '开机' })

await expect(disabledItem).toHaveClass(/is-disabled/)
await expect(disabledItem).toHaveCSS('cursor', 'not-allowed')
Expand Down
31 changes: 30 additions & 1 deletion examples/sites/demos/pc/app/action-menu/disabled.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<template>
<tiny-action-menu :options="options"> </tiny-action-menu>
<div>
<tiny-action-menu :options="options"> </tiny-action-menu>
<br />
<tiny-action-menu :options="options1"> </tiny-action-menu>
<br />
<tiny-action-menu :options="options1" mode="card"> </tiny-action-menu>
</div>
</template>

<script>
import { ActionMenu } from '@opentiny/vue'
import { iconWebPlus, iconSuccessful, iconCloseSquare } from '@opentiny/vue-icon'

export default {
components: {
Expand Down Expand Up @@ -33,6 +40,28 @@ export default {
{ label: '切换VPC', divided: true }
]
}
],
options1: [
{
label: '远程登陆',
icon: iconWebPlus()
},
{
label: '开机',
icon: iconSuccessful(),
disabled: true
},
{
label: '关机',
icon: iconCloseSquare()
},
{
label: '重启'
},
{
label: '网络设置',
children: [{ label: '更改安全组' }, { label: '切换VPC', divided: true }]
}
]
}
}
Expand Down
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> {{ data.name }}</span>
<span style="vertical-align: middle"> {{ 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> {{ data.name }}</span>
<span style="vertical-align: middle"> {{ data.name }}</span>
</template>
</tiny-action-menu>
</template>
Expand Down
115 changes: 36 additions & 79 deletions packages/theme/src/action-menu/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,115 +20,72 @@
.@{action-menu-prefix-cls} {
.component-css-vars-action-menu();

.@{dropdown-prefix-cls} {
.@{dropdown-prefix-cls}-trigger {
.tiny-svg {
margin-right: var(--ti-action-menu-more-icon-margin-right);
}
}
}
font-size: var(--tv-ActionMenu-font-size);

font-size: var(--ti-action-menu-font-size);
font-weight: var(--ti-action-menu-font-weight);
color: var(--ti-action-menu-text-color);
.tiny-svg {
font-size: var(--tv-ActionMenu-icon-size);
}

&__wrap {
display: flex;

&.@{action-menu-prefix-cls}__card-mode {
.@{action-menu-prefix-cls}__item {
.tiny-svg {
fill: var(--ti-action-menu-item-card-text-color);
}

.@{dropdown-prefix-cls} {
.@{dropdown-prefix-cls}-trigger {
&:hover {
.tiny-svg {
fill: var(--ti-action-menu-item-card-text-color);
}
}
}
}
}
}

.@{action-menu-prefix-cls}__item {
display: flex;
justify-content: space-between;
align-items: center;

.tiny-svg {
fill: var(--ti-action-menu-text-color); // TINY-TODO :没有使用--ti-base-color-brand-7的图标色
margin: var(--ti-action-menu-item-svg-margin-top) var(--ti-action-menu-item-svg-margin-right)
var(--ti-action-menu-item-svg-margin-bottom) var(--ti-action-menu-item-svg-margin-left);
}

&:not(:has(.tiny-dropdown)) {
.tiny-svg {
width: var(--ti-action-menu-more-icon-width);
height: var(--ti-action-menu-more-icon-height);
}
}

&:not(.is-disabled):hover {
&.@{action-menu-prefix-cls}__item-visable {
.@{dropdown-item-prefix-cls} {
background-color: var(--ti-action-menu-item-hover-bg-color);

> .tiny-dropdown-item__wrap {
> .tiny-dropdown-item__content {
.tiny-svg {
fill: var(--ti-action-menu-item-hover-icon-color);
}
}
}
}
}
}

// 默认
&.@{action-menu-prefix-cls}__item-visable {
.@{dropdown-item-prefix-cls} {
.@{dropdown-item-prefix-cls}__wrap {
color: var(--ti-action-menu-text-color);
color: var(--tv-ActionMenu-text-color);
margin: 0px;
height: auto;

&:hover {
background-color: var(--ti-action-menu-item-hover-bg-color);
text-decoration: var(--ti-action-menu-hover-text-decoration);
color: var(--ti-action-menu-item-hover-text-color);
.tiny-svg {
fill: var(--tv-ActionMenu-icon-color);
}
}
}

&.@{action-menu-prefix-cls}__card-item {
// 悬浮
&:not(.is-disabled):hover {
.@{dropdown-item-prefix-cls}__wrap {
color: var(--ti-action-menu-item-card-text-color);

.tiny-svg {
fill: var(--ti-action-menu-item-card-text-color);
}

&:hover {
color: var(--ti-action-menu-item-card-hover-text-color);
}
text-decoration: underline;
}
}

// 禁用
&.is-disabled {
.@{dropdown-item-prefix-cls}__wrap {
color: var(--ti-action-menu-item-disabled-text-color);
.tiny-dropdown-item__content {
color: var(--tv-ActionMenu-text-color-disabled);

.tiny-svg {
fill: var(--tv-ActionMenu-icon-color-disabled);
}
}
}
}
}
}

.@{action-menu-prefix-cls}__item-line {
position: relative;
width: var(--ti-action-menu-item-line-width);
height: 12px;
background: var(--ti-action-menu-item-line-bg-color);
display: inline-block;
/* card 类型 */
&.@{action-menu-prefix-cls}__card-mode {
.tiny-svg {
fill: var(--tv-ActionMenu-icon-color-card);
}

.@{action-menu-prefix-cls}__item {
&.@{action-menu-prefix-cls}__item-visable {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Correct the spelling of 'visable' to 'visible'.

The class name &.@{action-menu-prefix-cls}__item-visable contains a typo. It should be &.@{action-menu-prefix-cls}__item-visible to maintain consistency and prevent potential issues in styling.

Apply this diff to fix the typo:

-&.@{action-menu-prefix-cls}__item-visable {
+&.@{action-menu-prefix-cls}__item-visible {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
&.@{action-menu-prefix-cls}__item-visable {
&.@{action-menu-prefix-cls}__item-visible {

.@{dropdown-item-prefix-cls}__wrap {
color: var(--tv-ActionMenu-text-color-card);

.tiny-svg {
fill: var(--tv-ActionMenu-icon-color-card);
}
}
}
}
}
}
Expand Down
55 changes: 17 additions & 38 deletions packages/theme/src/action-menu/vars.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,21 @@
*/

.component-css-vars-action-menu() {
// 按钮文本字重
--ti-action-menu-font-weight: var(--ti-common-font-weight-normal, 400);
// 按钮文本装饰
--ti-action-menu-hover-text-decoration: underline;
// 更多...图标的宽度
--ti-action-menu-more-icon-width: var(--ti-common-size-4x, 16px);
// 更多...图标的高度
--ti-action-menu-more-icon-height: var(--ti-common-size-4x, 16px);
// 更多...图标的右边外边距
--ti-action-menu-more-icon-margin-right: var(--ti-common-space-0, 0px);
// 下拉触发源文本颜色
--ti-action-menu-text-color: var(--ti-common-color-text-link, #1476ff);
// 下拉触发源文本禁用色
--ti-action-menu-item-disabled-text-color: var(--ti-common-color-text-disabled, #c2c2c2);
// 下拉触发源文本字号
--ti-action-menu-font-size: var(--ti-common-font-size-base, 14px);
// 分割线颜色
--ti-action-menu-item-line-bg-color: transparent;
// 分割线宽度
--ti-action-menu-item-line-width: var(--ti-common-space-0, 0px);
// 下拉菜单项悬浮背景色
--ti-action-menu-item-hover-bg-color: transparent;
// 下拉菜单项文本悬浮色
--ti-action-menu-item-hover-text-color: var(--ti-common-color-text-link, #1476ff);
// 下拉菜单项图标悬浮色
--ti-action-menu-item-hover-icon-color: var(--ti-common-color-text-link-hover, #1476ff); // 没有这个颜色的图标色
// 下拉菜单项图标顶部内边距
--ti-action-menu-item-svg-margin-top: 0px;
// 下拉菜单项图标右侧内边距
--ti-action-menu-item-svg-margin-right: var(--ti-common-space-base, 4px);
// 下拉菜单项图标底部部内边距
--ti-action-menu-item-svg-margin-bottom: var(--ti-common-space-0, 0px);
// 下拉菜单项图标左侧内边距
--ti-action-menu-item-svg-margin-left: var(--ti-common-space-0, 0px);
// 下拉菜单卡片模式字体颜色
--ti-action-menu-item-card-text-color: var(--ti-common-color-text-primary, #191919);
// 下拉菜单卡片模式字体颜色
--ti-action-menu-item-card-hover-text-color: var(--ti-common-color-text-primary, #191919);
// 文本字号
--tv-ActionMenu-font-size: var(--tv-font-size-md, 14px);
// 文本色(默认)
--tv-ActionMenu-text-color: var(--tv-color-text-link, #1476ff);
// 文本色(card 类型)
--tv-ActionMenu-text-color-card: var(--tv-color-text, #191919);
// 文本禁用色
--tv-ActionMenu-text-color-disabled: var(--tv-color-text-disabled, #c2c2c2);

// 图标尺寸
--tv-ActionMenu-icon-size: var(--tv-icon-size, 16px);
// 图标色(默认)
--tv-ActionMenu-icon-color: var(--tv-color-icon-link, #1476ff);
// 图标色( card 类型)
--tv-ActionMenu-icon-color-card: var(--tv-color-icon-control);
// 图标禁用色
--tv-ActionMenu-icon-color-disabled: var(--tv-color-icon-disabled, #c2c2c2);
}
Loading