improve menu active dash

This commit is contained in:
SrGooglo 2024-09-13 16:09:05 +00:00
parent 08f0c37988
commit 9146839dec
7 changed files with 70 additions and 44 deletions

View File

@ -9,7 +9,7 @@ import Drawer from "@layouts/components/drawer"
import { Icons } from "@components/Icons" import { Icons } from "@components/Icons"
import GenerateSidebarMenuItems from "@utils/generateSidebarMenuItems" import GenerateMenuItems from "@utils/generateMenuItems"
import TopMenuItems from "@config/sidebar/TopItems" import TopMenuItems from "@config/sidebar/TopItems"
import BottomMenuItems from "@config/sidebar/BottomItems" import BottomMenuItems from "@config/sidebar/BottomItems"
@ -75,8 +75,8 @@ export default class Sidebar extends React.Component {
visible: false, visible: false,
expanded: false, expanded: false,
topItems: GenerateSidebarMenuItems(TopMenuItems), topItems: GenerateMenuItems(TopMenuItems),
bottomItems: GenerateSidebarMenuItems(BottomMenuItems), bottomItems: GenerateMenuItems(BottomMenuItems),
selectedMenuItem: null, selectedMenuItem: null,
navigationRender: null, navigationRender: null,
@ -432,6 +432,6 @@ export default class Sidebar extends React.Component {
</AnimatePresence> </AnimatePresence>
<Drawer /> <Drawer />
</div > </div>
} }
} }

View File

@ -172,6 +172,8 @@
} }
.ant-menu-item { .ant-menu-item {
position: relative;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;

View File

@ -1,13 +1,14 @@
import React from "react" import React from "react"
import * as antd from "antd" import * as antd from "antd"
import classnames from "classnames" import classnames from "classnames"
import { Translation } from "react-i18next"
import { motion, AnimatePresence } from "framer-motion" import { motion, AnimatePresence } from "framer-motion"
import { Icons } from "@components/Icons" import { Icons } from "@components/Icons"
import FollowButton from "@components/FollowButton" import FollowButton from "@components/FollowButton"
import UserCard from "@components/UserCard" import UserCard from "@components/UserCard"
import GenerateMenuItems from "@utils/generateMenuItems"
import { SessionModel, UserModel, FollowsModel } from "@models" import { SessionModel, UserModel, FollowsModel } from "@models"
import DetailsTab from "./tabs/details" import DetailsTab from "./tabs/details"
@ -225,43 +226,29 @@ export default class Account extends React.Component {
mode={app.isMobile ? "horizontal" : "vertical"} mode={app.isMobile ? "horizontal" : "vertical"}
selectedKeys={[this.state.tabActiveKey]} selectedKeys={[this.state.tabActiveKey]}
onClick={(e) => this.handlePageTransition(e.key)} onClick={(e) => this.handlePageTransition(e.key)}
> items={GenerateMenuItems([
<antd.Menu.Item {
key="posts" id: "posts",
icon={<Icons.BookOpen />} label: "Posts",
> icon: "BookOpen",
<Translation> },
{t => t("Posts")} {
</Translation> id: "music",
</antd.Menu.Item> label: "Music",
icon: "MdAlbum",
<antd.Menu.Item },
key="music" {
icon={<Icons.MdAlbum />} id: "followers",
> label: "Followers",
<Translation> icon: "Users",
{t => t("Music")} },
</Translation> {
</antd.Menu.Item> id: "details",
label: "Details",
<antd.Menu.Item icon: "Info",
key="followers" }
icon={<Icons.Users />} ])}
> />
<Translation>
{t => t("Followers")}
</Translation>
</antd.Menu.Item>
<antd.Menu.Item
key="details"
icon={<Icons.Info />}
>
<Translation>
{t => t("Details")}
</Translation>
</antd.Menu.Item>
</antd.Menu>
</div> </div>
</div> </div>
</div> </div>

View File

@ -191,7 +191,7 @@
justify-content: flex-start; justify-content: flex-start;
padding: 5px 10px !important; padding: 5px 15px !important;
svg { svg {
margin: 0 !important; margin: 0 !important;

View File

@ -235,6 +235,32 @@
p { p {
color: var(--background-color-contrast); color: var(--background-color-contrast);
} }
// active dash
&::before {
content: '';
display: block;
position: absolute;
top: auto;
left: 5px;
transition: all 150ms ease-in-out;
background-color: var(--colorPrimary);
width: @menu-selected-item-dash-width;
border-radius: @menu-selected-item-dash-border-radius;
// by default set opacity & height to 0
opacity: 0;
height: 0;
}
.ant-menu-title-content {
transition: @transition-ease-inout !important;
}
} }
} }
@ -272,6 +298,12 @@
&::after { &::after {
opacity: 0; opacity: 0;
} }
&::before {
opacity: 1;
height: @menu-selected-item-dash-height;
}
} }
.ant-menu-item:active { .ant-menu-item:active {
@ -312,7 +344,6 @@
border-radius: 12px; border-radius: 12px;
outline: 1px solid var(--border-color) !important; outline: 1px solid var(--border-color) !important;
background-color: var(--background-color-primary) !important; background-color: var(--background-color-primary) !important;
} }
.ant-notification-notice { .ant-notification-notice {

View File

@ -13,6 +13,10 @@
@default-object-padding: 10px; @default-object-padding: 10px;
@menu-selected-item-dash-width: 3px;
@menu-selected-item-dash-height: 50%;
@menu-selected-item-dash-border-radius: 12px;
// Mobile // Mobile
@top_bar_height: 52px; @top_bar_height: 52px;
@top_bar_padding: 10px; @top_bar_padding: 10px;

View File

@ -1,3 +1,5 @@
import React from "react"
import { Translation } from "react-i18next" import { Translation } from "react-i18next"
import { createIconRender } from "@components/Icons" import { createIconRender } from "@components/Icons"