From fe1caa2644d79cd6b9f66970c4e10bb67038e488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E4=BC=9F=E5=BC=BA?= Date: Tue, 16 May 2023 17:40:49 +0800 Subject: [PATCH] feat: sidebar navs highlight --- .../explore/sidebar/app-nav-item/index.tsx | 9 ++-- .../sidebar/app-nav-item/style.module.css | 2 +- web/app/components/explore/sidebar/index.tsx | 49 ++++++++++++------- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/web/app/components/explore/sidebar/app-nav-item/index.tsx b/web/app/components/explore/sidebar/app-nav-item/index.tsx index 351ed1f703..caae2f80de 100644 --- a/web/app/components/explore/sidebar/app-nav-item/index.tsx +++ b/web/app/components/explore/sidebar/app-nav-item/index.tsx @@ -1,5 +1,4 @@ 'use client' -import { useSelectedLayoutSegment } from 'next/navigation' import cn from 'classnames' import Link from 'next/link' @@ -8,14 +7,14 @@ import s from './style.module.css' export default function NavLink({ name, id, + isSelected, }: { name: string id: string + isSelected: boolean }) { - const segment = useSelectedLayoutSegment() const url = `/explore/installed/${id}` - const isActive = id === segment?.toLowerCase() - + return ( diff --git a/web/app/components/explore/sidebar/app-nav-item/style.module.css b/web/app/components/explore/sidebar/app-nav-item/style.module.css index e22d930383..f10b0d11ba 100644 --- a/web/app/components/explore/sidebar/app-nav-item/style.module.css +++ b/web/app/components/explore/sidebar/app-nav-item/style.module.css @@ -1,4 +1,4 @@ -.item:hover, +/* .item:hover, */ .item.active { border: 0.5px solid #EAECF0; box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05); diff --git a/web/app/components/explore/sidebar/index.tsx b/web/app/components/explore/sidebar/index.tsx index 6ebe35b00d..886dc00ff6 100644 --- a/web/app/components/explore/sidebar/index.tsx +++ b/web/app/components/explore/sidebar/index.tsx @@ -1,6 +1,9 @@ 'use client' import React, { FC } from 'react' import { useTranslation } from 'react-i18next' +import cn from 'classnames' +import { useSelectedLayoutSegments } from 'next/navigation' +import Link from 'next/link' import Item from './app-nav-item' const list = [ @@ -14,36 +17,48 @@ const list = [ } ] -const DiscoveryIcon = () => ( +const SelectedDiscoveryIcon = () => ( ) +const DiscoveryIcon = () => ( + + + +) + const SideBar: FC = () => { const { t } = useTranslation() + const segments = useSelectedLayoutSegments() + const lastSegment = segments.slice(-1)[0] + const isDiscoverySelected = lastSegment === 'apps' return ( -
+
-
- -
{t('explore.sidebar.discovery')}
-
+ {isDiscoverySelected ? : } +
{t('explore.sidebar.discovery')}
+
-
-
{t('explore.sidebar.workspace')}
-
- {list.map(({id, name}) => { - return ( - - ) - })} + {list.length > 0 && ( +
+
{t('explore.sidebar.workspace')}
+
+ {list.map(({id, name}) => { + return ( + + ) + })} +
-
+ )}
) }