-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Update design of collapsible in sidebar menu. No longer uses collap…
…sible. - Breaking: Remove `indent` prop on SidebarMenuLink. Indentation is now done automatically by SidebarMenuCollapsible.
- Loading branch information
1 parent
74da771
commit 6151845
Showing
8 changed files
with
130 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 77 additions & 30 deletions
107
packages/panels/src/components/sidebar-menu/SidebarMenuCollapsible.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,100 @@ | ||
import * as React from "react"; | ||
import { ReactNode, useState } from "react"; | ||
import { Collapsible } from "../collapsible/Collapsible"; | ||
import { Box, Column, Indent } from "@stenajs-webui/core"; | ||
import { Box, Indent, Row, Space, Text } from "@stenajs-webui/core"; | ||
import { IconDefinition } from "@fortawesome/fontawesome-svg-core"; | ||
import styles from "./SidebarMenuCollapsible.module.css"; | ||
import { Icon } from "@stenajs-webui/elements"; | ||
import contentStyles from "./SidebarMenuContent.module.css"; | ||
import cx from "classnames"; | ||
import { faChevronUp } from "@fortawesome/free-solid-svg-icons/faChevronUp"; | ||
import { faChevronDown } from "@fortawesome/free-solid-svg-icons"; | ||
import { cssColor } from "@stenajs-webui/theme"; | ||
import { SidebarMenuCollapsibleGroupBox } from "./SidebarMenuCollapsibleGroupBox"; | ||
|
||
export interface SidebarMenuCollapsibleProps { | ||
label: string; | ||
collapsed?: boolean; | ||
leftIcon?: IconDefinition; | ||
children?: ReactNode; | ||
className?: string; | ||
initialExpand?: boolean; | ||
indent?: number | boolean; | ||
} | ||
|
||
export const SidebarMenuCollapsible: React.FC<SidebarMenuCollapsibleProps> = ({ | ||
children, | ||
label, | ||
leftIcon, | ||
className, | ||
initialExpand = false, | ||
indent, | ||
}) => { | ||
const [collapsed, setCollapsed] = useState<boolean>(false); | ||
const [expanded, setExpanded] = useState<boolean>(initialExpand); | ||
|
||
const innerClassName = cx( | ||
contentStyles.button, | ||
expanded ? contentStyles.selected : undefined, | ||
className | ||
); | ||
|
||
const innerStyle = { | ||
height: "var(--swui-sidebar-menu-item-height)", | ||
}; | ||
|
||
return ( | ||
<Box background={"var(--current-background-color)"}> | ||
<Collapsible | ||
className={styles.sidebarMenuCollapsible} | ||
label={label} | ||
collapsed={collapsed} | ||
onClick={() => setCollapsed(!collapsed)} | ||
contentLeft={ | ||
leftIcon ? ( | ||
<Box | ||
width={"var(--swui-sidebar-menu-item-height)"} | ||
alignItems={"center"} | ||
justifyContent={"center"} | ||
> | ||
<Icon | ||
icon={leftIcon} | ||
size={16} | ||
color={"var(--current-text-color)"} | ||
data-hover={true} | ||
/> | ||
</Box> | ||
) : ( | ||
<Indent num={1} /> | ||
) | ||
} | ||
> | ||
<Column flex={1}>{children}</Column> | ||
</Collapsible> | ||
<Box indent={1} width={"100%"}> | ||
<Box | ||
width={"100%"} | ||
borderRadius={"99rem"} | ||
overflow={"hidden"} | ||
justifyContent={"space-between"} | ||
> | ||
<button | ||
className={innerClassName} | ||
style={innerStyle} | ||
onClick={() => setExpanded(!expanded)} | ||
> | ||
<Row justifyContent={"space-between"}> | ||
<Row> | ||
{leftIcon ? ( | ||
<Box | ||
width={"var(--swui-sidebar-menu-item-height)"} | ||
alignItems={"center"} | ||
justifyContent={"center"} | ||
> | ||
<Icon | ||
icon={leftIcon} | ||
size={16} | ||
color={"var(--current-text-color)"} | ||
data-hover={true} | ||
/> | ||
</Box> | ||
) : ( | ||
<Indent num={1} /> | ||
)} | ||
<Text variant={"bold"}>{label}</Text> | ||
</Row> | ||
<Row> | ||
<Icon | ||
icon={expanded ? faChevronUp : faChevronDown} | ||
size={12} | ||
color={cssColor("--lhds-color-blue-600")} | ||
/> | ||
<Indent /> | ||
</Row> | ||
</Row> | ||
</button> | ||
</Box> | ||
</Box> | ||
|
||
{expanded && ( | ||
<Indent> | ||
<Space /> | ||
<SidebarMenuCollapsibleGroupBox indent={indent}> | ||
{children} | ||
</SidebarMenuCollapsibleGroupBox> | ||
</Indent> | ||
)} | ||
</Box> | ||
); | ||
}; |
9 changes: 9 additions & 0 deletions
9
packages/panels/src/components/sidebar-menu/SidebarMenuCollapsibleGroupBox.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.sidebarMenuCollapsibleGroupBox { | ||
background: var(--lhds-color-ui-200); | ||
border-radius: var(--swui-border-radius); | ||
gap: var(--swui-metrics-space); | ||
display: flex; | ||
flex-direction: column; | ||
padding-top: var(--swui-metrics-space); | ||
padding-bottom: var(--swui-metrics-space); | ||
} |
16 changes: 16 additions & 0 deletions
16
packages/panels/src/components/sidebar-menu/SidebarMenuCollapsibleGroupBox.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as React from "react"; | ||
import styles from "./SidebarMenuCollapsibleGroupBox.module.css"; | ||
import { ReactNode } from "react"; | ||
|
||
export interface SidebarMenuCollapsibleGroupLineProps { | ||
children?: ReactNode; | ||
indent?: number | boolean; | ||
} | ||
|
||
export const SidebarMenuCollapsibleGroupBox: React.FC< | ||
SidebarMenuCollapsibleGroupLineProps | ||
> = ({ children }) => { | ||
return ( | ||
<div className={styles.sidebarMenuCollapsibleGroupBox}>{children}</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters