-
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.
Add support for custom sidebar item ordering
Sidebar icons are now rendered dynamically
- Loading branch information
1 parent
e31bbed
commit 5831b63
Showing
2 changed files
with
25 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,29 @@ | ||
import { useCallback } from "react"; | ||
import { SidebarButton } from "./SidebarButton" | ||
|
||
export default function SidebarIcons(props: {dispatch: React.Dispatch<any>, view: string, state:any}){ | ||
export type SidebarItem = "notes" | "favorites" | "search" | "notebooks" | "tags" | "todos" | "settings" | "spacer"; | ||
|
||
const ICON_MAP={ | ||
"notes": "stickies", | ||
"favorites": "star", | ||
"search": "search", | ||
"notebooks": "journals", | ||
"tags": "tags", | ||
"todos": "check-all", | ||
"settings": "gear", | ||
"spacer": "" | ||
} | ||
|
||
const DEFAULT_ITEMS:SidebarItem[] = ["notes", "favorites", "search", "notebooks", "tags", "todos", "spacer", "settings"] | ||
|
||
export default function SidebarIcons(props: {dispatch: React.Dispatch<any>, view: string, state:any,items?:SidebarItem[]}){ | ||
const isActive = (view:string)=>{return view===props.view && props.state.paneVisible} | ||
|
||
return <div className="flex flex-col flex-shrink-0 w-16 bg-bg1 items-center select-none gap-2 rounded-2xl p-2"> | ||
<SidebarButton onClick={()=>{props.dispatch("notes")}} icon="stickies" active={isActive("notes")}></SidebarButton> | ||
<SidebarButton onClick={()=>{props.dispatch("favorites")}} icon="star" active={isActive("favorites")}></SidebarButton> | ||
<SidebarButton onClick={()=>{props.dispatch("search")}} icon="search" active={isActive("search")}></SidebarButton> | ||
<SidebarButton onClick={()=>{props.dispatch("notebooks")}} icon="journals" active={isActive("notebooks")}></SidebarButton> | ||
<SidebarButton onClick={()=>{props.dispatch("tags")}} icon="tags" active={isActive("tags")}></SidebarButton> | ||
<SidebarButton onClick={()=>{props.dispatch("todos")}} icon="check-all" active={isActive("todos")}></SidebarButton> | ||
<div className="flex-grow"></div> | ||
<SidebarButton onClick={()=>{props.dispatch("settings")}} icon="gear" active={isActive("settings")}></SidebarButton> | ||
{(props.items || DEFAULT_ITEMS).map((i)=>{ | ||
if(i==="spacer") return <div className="flex-grow"></div> | ||
return <SidebarButton onClick={()=>{props.dispatch(i)}} icon={ICON_MAP[i]} key={i} active={isActive(i)}></SidebarButton> | ||
})} | ||
</div> | ||
} | ||
} | ||
|