-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
177 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
import { Icon } from "astro-icon"; | ||
import "./CircleIcon.style.scss"; | ||
const { icon, colorSet, size } = Astro.props; | ||
--- | ||
|
||
<div class={`circle-icon ${colorSet} ${size}`}> | ||
<Icon name={icon} /> | ||
</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
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,10 +1,19 @@ | ||
export interface SidebarItem { | ||
title: string; | ||
path?: string; | ||
children?: SidebarItem[]; | ||
} | ||
|
||
export interface SidebarItemGroup { | ||
title: string; | ||
path?: string; | ||
icon?: string; | ||
color?: string; | ||
children?: SidebarItem[]; | ||
} | ||
|
||
export interface SidebarItemProps { | ||
item: SidebarItem; | ||
depth: number; | ||
color: string; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,63 @@ | ||
import "./Sidebar.style.scss"; | ||
import { useState } from "react"; | ||
import { CircleIcon } from "../../core"; | ||
import type { SidebarItemProps } from "./Sidebar.model"; | ||
|
||
export default function SidebarItem(props: SidebarItemProps) { | ||
const [open, setOpen] = useState<boolean>(false); | ||
|
||
return props.item.children ? ( | ||
<div className={open ? "sidebar-item open" : "sidebar-item"}> | ||
<div className="sidebar-title"> | ||
<span>{props.item.title}</span> | ||
<button className="menu-down" onClick={() => setOpen(!open)}> | ||
{open ? ( | ||
<i className="fa fa-chevron-up"></i> | ||
) : ( | ||
<i className="fa fa-chevron-down"></i> | ||
)} | ||
</button> | ||
</div> | ||
<div className="sidebar-content"> | ||
{/* TODO: don't hardcode this */} | ||
<div style={{ marginBottom: "0.5rem" }}></div> | ||
{props.item.children.map((child, index) => ( | ||
<SidebarItem key={index} item={child} /> | ||
))} | ||
return ( | ||
<> | ||
<div | ||
className={`sidebar-item ${open && "open"} ${props.color}-item-hover`} | ||
> | ||
<div className="sidebar-title"> | ||
{/* for group headings, display an icons and special style */} | ||
{props.depth === 0 ? ( | ||
<a href={props.item.path || "#"} className="sidebar-item plain"> | ||
<div className="sidebar-title-container"> | ||
<CircleIcon | ||
icon={props.item.icon} | ||
size="size-small" | ||
colorSet={`${props.item.colorSet}-card`} | ||
/> | ||
<span>{props.item.title}</span> | ||
</div> | ||
</a> | ||
) : null} | ||
|
||
{/* for items at depth === 1, they should display inline with group headings */} | ||
{props.depth !== 0 ? ( | ||
<a href={props.item.path || "#"} className="sidebar-item plain"> | ||
<div className="sidebar-title-container"> | ||
<div className={`sidebar-depth-${props.depth}`} /> | ||
<span className="sidebar-sub-item">{props.item.title}</span> | ||
</div> | ||
</a> | ||
) : null} | ||
|
||
{/* if you have children, display a dropdown arrow */} | ||
{props.item.children ? ( | ||
<button className="menu-down" onClick={() => setOpen(!open)}> | ||
<i className={`fa fa-chevron-${open ? "up" : "down"}`} /> | ||
</button> | ||
) : null} | ||
</div> | ||
</div> | ||
</div> | ||
) : ( | ||
<a href={props.item.path || "#"} className="sidebar-item plain"> | ||
{props.item.title} | ||
</a> | ||
|
||
{/* if you have children, display children */} | ||
{props.item.children ? ( | ||
<div className={`sidebar-content ${open ? "open" : null}`}> | ||
{props.item.children.map((child, index) => ( | ||
<SidebarItem | ||
key={index} | ||
item={child} | ||
depth={props.depth + 1} | ||
color={props.color} | ||
/> | ||
))} | ||
</div> | ||
) : null} | ||
</> | ||
); | ||
} |
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