-
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.
Comment out backend methods and old layout Create a prototype sidebar with working state management and transitions
- Loading branch information
1 parent
e8a7faa
commit e31bbed
Showing
10 changed files
with
206 additions
and
42 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Sidebar } from "./components/sidebar/Sidebar"; | ||
|
||
export default function MainLayout(){ | ||
return <div className="absolute left-0 right-0 bottom-0 top-0 flex flex-row bg-base p-2"> | ||
<Sidebar></Sidebar> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Icon(props: {icon: string, size?: number, color?: string}){ | ||
return <i className={`bi-${props.icon} select-none`} | ||
style={{ | ||
"fontSize": (props.size==null ? "16px" : `${props.size}px`), | ||
"color": props.color == null ? "rgb(var(--text))" : props.color | ||
}}></i> | ||
} |
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,34 @@ | ||
import { useEffect, useReducer, useRef, useState } from "react"; | ||
import SidebarIcons from "./SidebarIcons"; | ||
|
||
interface SidebarState{ | ||
paneVisible: boolean, | ||
view: string | ||
} | ||
|
||
/** | ||
* | ||
* @param state | ||
* @param action New view name | ||
* @returns | ||
*/ | ||
function reducer(state:SidebarState, action:string){ | ||
const newstate = {...state}; | ||
if(action === state.view) newstate.paneVisible=!state.paneVisible; | ||
else newstate.paneVisible=true | ||
newstate.view=action; | ||
return newstate; | ||
} | ||
|
||
export function Sidebar(){ | ||
const [state, dispatch] = useReducer(reducer, {paneVisible: false, view: "notes"}) | ||
|
||
const sidebarRef = useRef<HTMLDivElement>(null); | ||
useEffect(()=>{ | ||
sidebarRef.current?.style.setProperty("width",state.paneVisible ? "320px" : "64px") | ||
},[state.paneVisible]) | ||
return <div ref={sidebarRef} className="flex duration-100 transition-all flex-row bg-bg2 gap-2 rounded-2xl"> | ||
<SidebarIcons dispatch={dispatch} view={state.view} state={state}></SidebarIcons> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { CSSProperties } from "react" | ||
import Icon from "../Icon" | ||
|
||
const ACTIVE_STYLE:CSSProperties = { | ||
"background": "rgb(var(--primary))" | ||
} | ||
|
||
export function SidebarButton(props:SidebarButtonProps){ | ||
return <div style={props.active ? ACTIVE_STYLE : {}} | ||
className={`w-12 h-12 flex justify-center items-center rounded-lg select-none | ||
${props.active ? "hover:brightness-125 active:brightness-150" : "hover:bg-widget-hover active:bg-widget-active" } | ||
transition-all duration-100`} onClick={props.onClick}> | ||
<Icon icon={props.icon} size={24}></Icon> | ||
</div> | ||
} | ||
|
||
export interface SidebarButtonProps{ | ||
icon: string, | ||
onClick: ()=>void, | ||
active?: boolean | ||
} |
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,15 @@ | ||
import { SidebarButton } from "./SidebarButton" | ||
|
||
export default function SidebarIcons(props: {dispatch: React.Dispatch<any>, view: string, state:any}){ | ||
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> | ||
</div> | ||
} |
Oops, something went wrong.