Skip to content

Commit

Permalink
refactor(admin/menu): 添加二级菜单动画
Browse files Browse the repository at this point in the history
  • Loading branch information
caixw committed Jan 14, 2025
1 parent a494977 commit 49b8c71
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions admin/src/animation.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
display: block;
visibility: hidden;
opacity: 0;

/* 两个属性同时发生变化,但是 visibility 没有过渡动画,等待时间到之后直接改变其属性。 */
transition: visibility 0s var(--transition-duration), opacity var(--transition-duration) linear;
}

Expand Down
2 changes: 1 addition & 1 deletion admin/src/components/tree/menu/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default function (props: Props): JSX.Element {
<li class="item">
{p.item.label}
<Icon class="expand" icon="chevron_right" />
<menu classList={{'c--menu':true,'hidden':true,[props.direction!]:true}}>
<menu classList={{'c--menu':true,'opacity-0':true,[props.direction!]:true}}>
<All items={p.item.items as Array<Item>} />
</menu>
</li>
Expand Down
24 changes: 18 additions & 6 deletions admin/src/components/tree/menu/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
.expand {
@apply ml-auto flex items-center;
}
}

.item:hover {
>.c--menu {
@apply absolute top-0 flex-col flex;
}

>.c--menu.left {
@apply right-[100%];
Expand All @@ -39,6 +33,24 @@
}
}

.item:hover {
>.c--menu {
@apply absolute top-0 flex-col flex;

opacity: 1;
visibility: visible;
transition: opacity var(--transition-duration) linear;
}
}

.opacity-0 {
@apply absolute top-0 flex-col flex;

visibility: hidden;
opacity: 0;
transition: visibility 0s var(--transition-duration), opacity var(--transition-duration) linear;
}

.group {
@apply text-[var(--fg-low)] cursor-default px-2;
}
Expand Down

0 comments on commit 49b8c71

Please sign in to comment.