From 3bc31b3e3f33a38146acc63d8da2e16a98a403fb Mon Sep 17 00:00:00 2001 From: Glen Huang Date: Fri, 19 Sep 2025 22:09:59 +0800 Subject: [PATCH 1/2] ui: use css modules for sidebar components --- .../src/components/Sidebar/SidebarHeader.css | 93 ------------- .../Sidebar/SidebarHeader.module.css | 89 +++++++++++++ .../src/components/Sidebar/SidebarHeader.tsx | 22 ++-- .../ui/src/components/Sidebar/SidebarPane.css | 123 ------------------ .../components/Sidebar/SidebarPane.module.css | 120 +++++++++++++++++ .../Sidebar/SidebarPane.stories.tsx | 2 +- .../ui/src/components/Sidebar/SidebarPane.tsx | 23 ++-- .../src/components/Sidebar/SidebarSection.css | 15 --- .../Sidebar/SidebarSection.module.css | 12 ++ .../src/components/Sidebar/SidebarSection.tsx | 16 ++- .../components/Sidebar/SidebarSectionForm.tsx | 68 +++++----- 11 files changed, 280 insertions(+), 303 deletions(-) delete mode 100644 pkgs/clan-app/ui/src/components/Sidebar/SidebarHeader.css create mode 100644 pkgs/clan-app/ui/src/components/Sidebar/SidebarHeader.module.css delete mode 100644 pkgs/clan-app/ui/src/components/Sidebar/SidebarPane.css create mode 100644 pkgs/clan-app/ui/src/components/Sidebar/SidebarPane.module.css delete mode 100644 pkgs/clan-app/ui/src/components/Sidebar/SidebarSection.css create mode 100644 pkgs/clan-app/ui/src/components/Sidebar/SidebarSection.module.css diff --git a/pkgs/clan-app/ui/src/components/Sidebar/SidebarHeader.css b/pkgs/clan-app/ui/src/components/Sidebar/SidebarHeader.css deleted file mode 100644 index 92ffc7ae1..000000000 --- a/pkgs/clan-app/ui/src/components/Sidebar/SidebarHeader.css +++ /dev/null @@ -1,93 +0,0 @@ -div.sidebar-header { - @apply flex items-center justify-center w-full px-1 py-1; - @apply border border-inv-3 rounded-md rounded-bl-none rounded-br-none; - - background: linear-gradient( - 90deg, - theme(colors.bg.inv.2) 0%, - theme(colors.bg.inv.3) 0% - ); - - & > .dropdown-trigger { - @apply flex items-center justify-between flex-grow px-1 py-1; - @apply rounded-tl-md rounded-tr-md; - @apply border border-transparent border-b-0; - - transition: all 250ms ease-in-out; - - div.clan-label { - @apply flex items-center gap-2 justify-start; - - & > .clan-icon { - @apply flex justify-center items-center; - @apply rounded-full bg-inv-4 w-7 h-7; - } - } - - .icon[data-icon-name="CaretDown"] { - transition: transform 300ms cubic-bezier(0.87, 0, 0.13, 1); - } - - &[data-expanded] { - @apply bg-def-1 border-def-2; - - .icon[data-icon-name="CaretDown"] { - transform: rotate(180deg); - } - } - } -} - -.sidebar-dropdown-content { - @apply flex flex-col w-full px-2 py-1.5 z-10 gap-3; - @apply bg-def-1 rounded-bl-md rounded-br-md; - @apply border border-def-2; - - animation: sidebarNavContentHide 250ms ease-in forwards; - - .dropdown-item { - @apply flex items-center justify-start w-full px-1.5 py-2 gap-2 rounded; - - &:hover { - @apply bg-def-acc-2 cursor-pointer; - } - } - - .dropdown-group { - @apply flex flex-col gap-2; - @apply px-1; - - .dropdown-group-label { - @apply flex items-baseline justify-between w-full; - } - - .dropdown-group-items { - @apply rounded px-1 py-1.5 bg-def-2; - } - } -} - -.sidebar-dropdown-content[data-expanded] { - animation: sidebarNavContentShow 250ms ease-out; -} - -@keyframes sidebarNavContentShow { - from { - opacity: 0; - transform: scale(0.96); - } - to { - opacity: 1; - transform: scale(1); - } -} -@keyframes sidebarNavContentHide { - from { - opacity: 1; - transform: scale(1); - } - to { - opacity: 0; - transform: scale(0.96); - } -} diff --git a/pkgs/clan-app/ui/src/components/Sidebar/SidebarHeader.module.css b/pkgs/clan-app/ui/src/components/Sidebar/SidebarHeader.module.css new file mode 100644 index 000000000..087704ed5 --- /dev/null +++ b/pkgs/clan-app/ui/src/components/Sidebar/SidebarHeader.module.css @@ -0,0 +1,89 @@ +.sidebarHeader { + @apply flex items-center justify-center w-full px-1 py-1; + @apply border border-inv-3 rounded-md rounded-bl-none rounded-br-none; + + background: linear-gradient( + 90deg, + theme(colors.bg.inv.2) 0%, + theme(colors.bg.inv.3) 0% + ); +} + +.dropDownTrigger { + @apply flex items-center justify-between flex-grow px-1 py-1; + @apply rounded-tl-md rounded-tr-md; + @apply border border-transparent border-b-0; + + transition: all 250ms ease-in-out; + + .icon[data-icon-name="CaretDown"] { + transition: transform 300ms cubic-bezier(0.87, 0, 0.13, 1); + } + + &[data-expanded] { + @apply bg-def-1 border-def-2; + + .icon[data-icon-name="CaretDown"] { + transform: rotate(180deg); + } + } +} + +.clanLabel { + @apply flex items-center gap-2 justify-start; +} +.clanIcon { + @apply flex justify-center items-center; + @apply rounded-full bg-inv-4 w-7 h-7; +} + +.dropDownContent { + @apply flex flex-col w-full px-2 py-1.5 z-10 gap-3; + @apply bg-def-1 rounded-bl-md rounded-br-md; + @apply border border-def-2; + + animation: sidebarNavContentHide 250ms ease-in forwards; +} +.dropDownContent[data-expanded] { + animation: sidebarNavContentShow 250ms ease-out; +} + +.dropdownItem { + @apply flex items-center justify-start w-full px-1.5 py-2 gap-2 rounded; + + &:hover { + @apply bg-def-acc-2 cursor-pointer; + } +} + +.dropdownGroup { + @apply flex flex-col gap-2; + @apply px-1; +} +.dropdownGroupLabel { + @apply flex items-baseline justify-between w-full; +} +.dropdownGroupItems { + @apply rounded px-1 py-1.5 bg-def-2; +} + +@keyframes sidebarNavContentShow { + from { + opacity: 0; + transform: scale(0.96); + } + to { + opacity: 1; + transform: scale(1); + } +} +@keyframes sidebarNavContentHide { + from { + opacity: 1; + transform: scale(1); + } + to { + opacity: 0; + transform: scale(0.96); + } +} diff --git a/pkgs/clan-app/ui/src/components/Sidebar/SidebarHeader.tsx b/pkgs/clan-app/ui/src/components/Sidebar/SidebarHeader.tsx index 756e76412..89eb01463 100644 --- a/pkgs/clan-app/ui/src/components/Sidebar/SidebarHeader.tsx +++ b/pkgs/clan-app/ui/src/components/Sidebar/SidebarHeader.tsx @@ -1,4 +1,4 @@ -import "./SidebarHeader.css"; +import styles from "./SidebarHeader.module.css"; import Icon from "@/src/components/Icon/Icon"; import { DropdownMenu } from "@kobalte/core/dropdown-menu"; import { useNavigate } from "@solidjs/router"; @@ -30,7 +30,7 @@ export const SidebarHeader = () => { .sort((a, b) => a.details.name.localeCompare(b.details.name)); return ( -