From 098da283544018356bf6457bd1e98056ff839bac Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=B1=E7=9C=A0=E5=84=80=E5=BC=8F?= <854085467@qq.com>
Date: Sun, 30 Jan 2022 20:29:16 +0800
Subject: [PATCH] =?UTF-8?q?menu=20=E7=BB=84=E4=BB=B6=E6=96=B0=E5=A2=9E=20i?=
=?UTF-8?q?nverted=20=E5=B1=9E=E6=80=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
example/docs/zh-CN/components/menu.md | 43 ++++++++++++++++++++++++++-
src/component/menu/index.less | 31 +++++++++++++++----
src/component/menu/index.vue | 6 ++--
src/theme/index.less | 3 +-
4 files changed, 72 insertions(+), 11 deletions(-)
diff --git a/example/docs/zh-CN/components/menu.md b/example/docs/zh-CN/components/menu.md
index 2fd61d0c..fdfae402 100644
--- a/example/docs/zh-CN/components/menu.md
+++ b/example/docs/zh-CN/components/menu.md
@@ -82,6 +82,47 @@ export default {
:::
+::: title 反转样式
+:::
+
+::: demo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+:::
+
::: title 切换主题
:::
@@ -123,7 +164,6 @@ export default {
:::
-
::: title 菜单插槽
:::
@@ -179,6 +219,7 @@ export default {
| v-model:selectedKey | 选中项 | -- |
| v-model:openKeys | 打开项 | -- |
| theme | 菜单主题 | `dark` `light` |
+| inverted | 特殊的激活样式 | `true` `false` |
:::
diff --git a/src/component/menu/index.less b/src/component/menu/index.less
index 2c0bf7c1..e1ce8600 100644
--- a/src/component/menu/index.less
+++ b/src/component/menu/index.less
@@ -4,8 +4,8 @@
}
.layui-nav .layui-show.layui-anim-upbit .layui-nav-item {
- display: block;
height: 40px;
+ display: block;
line-height: 40px;
}
@@ -164,8 +164,8 @@
.layui-nav-tree .layui-nav-item > a {
position: relative;
- height: 42px;
- line-height: 42px;
+ height: 40px;
+ line-height: 40px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
@@ -190,10 +190,8 @@
background-color: #009688;
}
-.layui-nav-tree .layui-nav-child dd.layui-this,
-.layui-nav-tree .layui-nav-child dd.layui-this a,
.layui-nav-tree .layui-this,
-.layui-nav-tree .layui-this > a,
+.layui-nav-tree .layui-nav-child dd.layui-this,
.layui-nav-tree .layui-this > a:hover {
background-color: #009688;
color: #fff;
@@ -281,6 +279,27 @@
}
}
+.layui-nav-tree {
+ padding-top: 5px;
+ padding-bottom: 5px;
+}
+
.layui-nav-tree .layui-this * {
color: white!important;
+}
+
+.layui-nav-tree.inverted .layui-this,
+.layui-nav-tree.inverted .layui-this:hover {
+ border-radius: 4px;
+ margin: 0px 6px;
+ width: auto;
+}
+
+.layui-nav-tree.inverted .layui-this > a,
+.layui-nav-tree.inverted .layui-this:hover > a {
+ border-radius: 4px;
+}
+
+.layui-nav-tree.inverted .layui-this > a{
+ padding: 5px 24px 5px 24px;
}
\ No newline at end of file
diff --git a/src/component/menu/index.vue b/src/component/menu/index.vue
index 7be79781..4077f061 100644
--- a/src/component/menu/index.vue
+++ b/src/component/menu/index.vue
@@ -1,5 +1,5 @@
-
@@ -13,6 +13,7 @@ export interface LayMenuProps {
openKeys?: string[];
tree?: boolean;
theme?: string;
+ inverted?: boolean;
}
const emit = defineEmits(["update:selectedKey", "update:openKeys"]);
@@ -21,7 +22,8 @@ const props = withDefaults(defineProps(), {
selectedKey: "",
openKeys: () => [],
tree: false,
- theme: 'dark'
+ theme: 'dark',
+ inverted: false
});
const isTree = computed(() => props.tree);
diff --git a/src/theme/index.less b/src/theme/index.less
index b5677abc..2a118a93 100644
--- a/src/theme/index.less
+++ b/src/theme/index.less
@@ -1967,8 +1967,7 @@ a cite {
.layui-keyboard-list li,
.layui-menu li,
.layui-menu-body-title a:hover,
-.layui-menu-body-title > .layui-icon:hover,
-.layui-nav .layui-nav-item a {
+.layui-menu-body-title > .layui-icon:hover {
transition: all 0.3s;
}