From cc43aa6710de63146ba34dcddd76bc95860d6122 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 28 Sep 2023 13:47:21 +0530 Subject: [PATCH 01/16] add collapsible button --- .../[district]/components/Content.module.scss | 6 ++ .../components/dashboard-layout.tsx | 9 +-- .../components/dashboard-sidebar.tsx | 50 +++++++++----- .../components/mobile-dashboard-nav.tsx | 66 ++++++++++--------- examples/district/components/icons.tsx | 2 + examples/district/tailwind.config.js | 2 +- 6 files changed, 79 insertions(+), 56 deletions(-) diff --git a/examples/district/app/[locale]/[district]/components/Content.module.scss b/examples/district/app/[locale]/[district]/components/Content.module.scss index ff3dd4bd..9e077d9f 100644 --- a/examples/district/app/[locale]/[district]/components/Content.module.scss +++ b/examples/district/app/[locale]/[district]/components/Content.module.scss @@ -48,3 +48,9 @@ .Collapse { transition: flex-basis var(--duration-300) var(--ease-in-out); } + +.BtnRotate { + & > span { + transform: rotate(180deg); + } +} diff --git a/examples/district/app/[locale]/[district]/components/dashboard-layout.tsx b/examples/district/app/[locale]/[district]/components/dashboard-layout.tsx index c7cc7e10..5813987a 100644 --- a/examples/district/app/[locale]/[district]/components/dashboard-layout.tsx +++ b/examples/district/app/[locale]/[district]/components/dashboard-layout.tsx @@ -17,19 +17,14 @@ export function DashboardLayout({ }: DashboardLayoutProps) { return (
-
- {children} -
+
{children}
); } diff --git a/examples/district/app/[locale]/[district]/components/dashboard-sidebar.tsx b/examples/district/app/[locale]/[district]/components/dashboard-sidebar.tsx index cd61f14f..3effd99d 100644 --- a/examples/district/app/[locale]/[district]/components/dashboard-sidebar.tsx +++ b/examples/district/app/[locale]/[district]/components/dashboard-sidebar.tsx @@ -5,7 +5,8 @@ import { Icons } from '@/components/icons'; import { cn } from '@/lib/utils'; import Link from 'next/link'; import { useParams, usePathname } from 'next/navigation'; -import { Text } from 'opub-ui'; +import { Text, IconButton } from 'opub-ui'; +import React from 'react'; import { SidebarNavItem } from 'types'; interface DashboardNavProps { @@ -13,40 +14,57 @@ interface DashboardNavProps { } export function DashboardSidebar({ items }: DashboardNavProps) { const path = usePathname(); + const [isCollapsed, setIsCollapsed] = React.useState(false); const { district, department } = useParams(); if (items && !items.length) { return null; } - // const sidebarIcon = isCollapsed ? Icons.expand : Icons.collapse; return ( ); diff --git a/examples/district/app/[locale]/[district]/components/mobile-dashboard-nav.tsx b/examples/district/app/[locale]/[district]/components/mobile-dashboard-nav.tsx index dbeecdbf..cd7fa2b0 100644 --- a/examples/district/app/[locale]/[district]/components/mobile-dashboard-nav.tsx +++ b/examples/district/app/[locale]/[district]/components/mobile-dashboard-nav.tsx @@ -47,39 +47,41 @@ export function MobileDashboardNav({ items }: DashboardNavProps) { -
- - Select a department - - setOpen(false)} icon={IconX}> - Close - -
+
+
+ + Select a department + + setOpen(false)} icon={IconX}> + Close + +
- - - No results found. - - - {items.map((item) => { - return ( - - ); - })} - - + + + No results found. + + + {items.map((item) => { + return ( + + ); + })} + + +
); diff --git a/examples/district/components/icons.tsx b/examples/district/components/icons.tsx index 906a3cad..554ad8c7 100644 --- a/examples/district/components/icons.tsx +++ b/examples/district/components/icons.tsx @@ -29,6 +29,7 @@ import { IconSquareRoundedChevronLeftFilled, IconUserCog, IconExternalLink, + IconChevronsLeft, TablerIconsProps, } from '@tabler/icons-react'; @@ -46,6 +47,7 @@ export const Icons: { down: IconChevronDown, right: IconChevronRight, left: IconChevronLeft, + doubleLeft: IconChevronsLeft, leftFilled: IconSquareRoundedChevronLeftFilled, search: IconSearch, notification: IconBellFilled, diff --git a/examples/district/tailwind.config.js b/examples/district/tailwind.config.js index 51bd9a07..4ba7b059 100644 --- a/examples/district/tailwind.config.js +++ b/examples/district/tailwind.config.js @@ -49,7 +49,7 @@ module.exports = { sm: '640px', md: '768px', lg: '1024px', - xl: '1280px', + xl: '1336px', '2xl': '1536px', }, container: { From 6ef6fdd847f2dece1834b559b85cb9959d8e2f1f Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 28 Sep 2023 23:18:36 +0530 Subject: [PATCH 02/16] add collapsible --- .../[district]/components/Content.module.scss | 8 +++++- .../components/dashboard-layout.tsx | 23 ++++++++++++++-- .../components/dashboard-sidebar.tsx | 27 +++++++------------ 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/examples/district/app/[locale]/[district]/components/Content.module.scss b/examples/district/app/[locale]/[district]/components/Content.module.scss index 9e077d9f..cd30ce7c 100644 --- a/examples/district/app/[locale]/[district]/components/Content.module.scss +++ b/examples/district/app/[locale]/[district]/components/Content.module.scss @@ -49,7 +49,13 @@ transition: flex-basis var(--duration-300) var(--ease-in-out); } -.BtnRotate { +.CollapseBtn { + transition: transform var(--duration-300) var(--ease-in-out); +} + +.Collapsed { + transform: translateX(-210px); + & > span { transform: rotate(180deg); } diff --git a/examples/district/app/[locale]/[district]/components/dashboard-layout.tsx b/examples/district/app/[locale]/[district]/components/dashboard-layout.tsx index 5813987a..b9fe8a5e 100644 --- a/examples/district/app/[locale]/[district]/components/dashboard-layout.tsx +++ b/examples/district/app/[locale]/[district]/components/dashboard-layout.tsx @@ -1,10 +1,12 @@ 'use client'; +import { IconButton } from 'opub-ui'; import styles from './Content.module.scss'; import { DashboardSidebar } from './dashboard-sidebar'; import { MobileDashboardNav } from './mobile-dashboard-nav'; import { cn } from '@/lib/utils'; import React from 'react'; +import Icons from '@/components/icons'; interface DashboardLayoutProps { children?: React.ReactNode; @@ -15,11 +17,28 @@ export function DashboardLayout({ children, dashboardConfig, }: DashboardLayoutProps) { + const [isCollapsed, setIsCollapsed] = React.useState(false); + return (
- + setIsCollapsed((e) => !e)} + > + Collapse Sidebar + +
diff --git a/examples/district/app/[locale]/[district]/components/dashboard-sidebar.tsx b/examples/district/app/[locale]/[district]/components/dashboard-sidebar.tsx index 3effd99d..113af31d 100644 --- a/examples/district/app/[locale]/[district]/components/dashboard-sidebar.tsx +++ b/examples/district/app/[locale]/[district]/components/dashboard-sidebar.tsx @@ -11,10 +11,11 @@ import { SidebarNavItem } from 'types'; interface DashboardNavProps { items: SidebarNavItem[]; + isCollapsed: boolean; } -export function DashboardSidebar({ items }: DashboardNavProps) { +export function DashboardSidebar({ items, isCollapsed }: DashboardNavProps) { const path = usePathname(); - const [isCollapsed, setIsCollapsed] = React.useState(false); + // const [isCollapsed, setIsCollapsed] = React.useState(false); const { district, department } = useParams(); if (items && !items.length) { @@ -24,8 +25,8 @@ export function DashboardSidebar({ items }: DashboardNavProps) { return (