-
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.
Merge branch 'master' into feature/blur-effect
- Loading branch information
Showing
36 changed files
with
595 additions
and
205 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 |
---|---|---|
@@ -1 +1 @@ | ||
nodejs 18.15.0 | ||
nodejs 18.19.0 |
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
File renamed without changes.
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
File renamed without changes.
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,42 @@ | ||
import { style } from "@vanilla-extract/css"; | ||
|
||
const MENU_BORDER_RADIUS = 8; | ||
const MENU_ITEM_BORDER_RADIUS = 6; | ||
|
||
export const menuIndicator = style({ | ||
display: "flex", | ||
flexFlow: "row", | ||
gap: 4, | ||
color: "#fff", | ||
fontSize: 14, | ||
alignItems: "center", | ||
position: "relative", | ||
}); | ||
|
||
export const itemFrame = style({ | ||
position: "absolute", | ||
top: "100%", | ||
left: -8, | ||
// TODO regularize z-index values | ||
zIndex: 20, | ||
}); | ||
|
||
export const itemWrapper = style({ | ||
color: "#fff", | ||
boxShadow: "rgba(0, 0, 0, 0.55) 0px 10px 34px", | ||
backgroundColor: "#333", | ||
border: "1px solid #5c5c5c", | ||
borderRadius: MENU_BORDER_RADIUS, | ||
overflow: "hidden", | ||
padding: "6px", | ||
whiteSpace: "nowrap", | ||
}); | ||
|
||
export const item = style({ | ||
padding: "4px 8px", | ||
borderRadius: MENU_ITEM_BORDER_RADIUS, | ||
userSelect: "none", | ||
":hover": { | ||
backgroundColor: "rgb(22 116 218)", | ||
}, | ||
}); |
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,42 @@ | ||
"use client"; | ||
import { useCallback, useContext } from "react"; | ||
|
||
import type { MenuItem } from "../../contexts/MenuBarContext"; | ||
import { menuBarContext } from "../../contexts/MenuBarContext"; | ||
import { useOutsideClick } from "../../hooks"; | ||
import * as css from "./Menu.css"; | ||
|
||
interface Props { | ||
menuId: string; | ||
name: string | React.ReactNode; | ||
menuItems: MenuItem[]; | ||
} | ||
|
||
export const Menu = (props: Props) => { | ||
const { menuId, name, menuItems } = props; | ||
const { openedMenuId, openMenu, closeMenu } = useContext(menuBarContext); | ||
const ref = useOutsideClick<HTMLDivElement>(() => closeMenu()); | ||
|
||
const handleClick = useCallback(() => { | ||
if (openedMenuId !== menuId) { | ||
openMenu(menuId); | ||
} else { | ||
closeMenu(); | ||
} | ||
}, [openedMenuId, menuId, closeMenu, openMenu]); | ||
|
||
return ( | ||
<div className={css.menuIndicator} ref={ref}> | ||
<p onClick={handleClick}>{name}</p> | ||
<div className={css.itemFrame} style={{ visibility: openedMenuId === menuId ? "visible" : "hidden" }}> | ||
<ul className={css.itemWrapper}> | ||
{menuItems.map((menuItem) => ( | ||
<li key={`${menuItem.type}-${menuItem.name}`} className={css.item} onClick={menuItem.onClick}> | ||
{menuItem.name} | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,33 @@ | ||
"use client"; | ||
import { format } from "date-fns"; | ||
import { useMemo } from "react"; | ||
import { useCallback, useState } from "react"; | ||
|
||
import { useClock } from "../../hooks"; | ||
import { menuBarContext } from "../../contexts/MenuBarContext"; | ||
import type { IMenuBarContext } from "../../contexts/MenuBarContext"; | ||
import * as css from "./MenuBar.css"; | ||
|
||
export const MenuBar = () => { | ||
const time = useClock(); | ||
const clock = useMemo(() => format(time, "E MMM d") + "\u00A0\u00A0" + format(time, "h:mm a"), [time]); | ||
interface Props { | ||
leftMenu: React.ReactNode; | ||
rightMenu: React.ReactNode; | ||
} | ||
|
||
export const MenuBar = (props: Props) => { | ||
const { leftMenu, rightMenu } = props; | ||
const [openedMenuId, setOpenedMenuId] = useState<string | null>(null); | ||
|
||
const openMenu = useCallback((menuId: string) => setOpenedMenuId(menuId), []); | ||
const closeMenu = useCallback(() => setOpenedMenuId(null), []); | ||
const value: IMenuBarContext = { openedMenuId, openMenu, closeMenu }; | ||
|
||
return ( | ||
<nav className={css.container}> | ||
<div className={css.menuWrapper}> | ||
</div> | ||
<div className={css.rightMenuWrapper}> | ||
<p className={css.clock}>{clock}</p> | ||
</div> | ||
</nav> | ||
<menuBarContext.Provider value={value}> | ||
<nav className={css.container}> | ||
<div className={css.wrapper}> | ||
{leftMenu} | ||
</div> | ||
<div className={css.rightMenuWrapper}> | ||
{rightMenu} | ||
</div> | ||
</nav> | ||
</menuBarContext.Provider> | ||
); | ||
}; |
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 { style } from "@vanilla-extract/css"; | ||
|
||
import { menuIndicator } from "../Menu/Menu.css"; | ||
|
||
export const batteryIndicator = style([menuIndicator, { | ||
fontSize: 12, | ||
}]); |
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,78 @@ | ||
"use client"; | ||
import { format } from "date-fns"; | ||
import { useContext, useEffect, useMemo, useState } from "react"; | ||
import { IoBatteryCharging, IoBatteryFull, IoBatteryHalf, IoCodeSlash } from "react-icons/io5"; | ||
|
||
import { LockContext } from "@/contexts/LockContext"; | ||
import { useClock } from "@/hooks"; | ||
|
||
import { Menu } from "../Menu"; | ||
import { menuIndicator } from "../Menu/Menu.css"; | ||
import * as css from "./Menus.css"; | ||
|
||
export const PortfolioMenu = () => { | ||
const { lock } = useContext(LockContext); | ||
return ( | ||
<Menu | ||
menuId="menu-portfolio" | ||
name={<IoCodeSlash size={24} />} | ||
menuItems={[ | ||
{ | ||
id: "about-this-site", | ||
name: "About This Site", | ||
type: "default", | ||
checked: false, | ||
disabled: false, | ||
onClick: () => {}, | ||
}, | ||
{ | ||
id: "lock-screen", | ||
name: "Lock Screen", | ||
type: "default", | ||
checked: false, | ||
disabled: false, | ||
onClick: lock, | ||
} | ||
]} | ||
/> | ||
); | ||
}; | ||
|
||
export const ClockIndicator = () => { | ||
const time = useClock(); | ||
const clock = useMemo(() => format(time, "E MMM d") + "\u00A0\u00A0" + format(time, "h:mm a"), [time]); | ||
|
||
return <p className={menuIndicator}>{clock}</p>; | ||
}; | ||
|
||
export const BatteryIndicator = () => { | ||
const [battery, setBattery] = useState<Battery>({ | ||
charging: false, | ||
chargingTime: 0, | ||
dischargingTime: 0, | ||
level: 1, | ||
}); | ||
const batteryPercent = useMemo(() => (battery.level * 100).toString() + "%", [battery]); | ||
const batteryIcon = useMemo(() => { | ||
if (battery.charging) { | ||
return <IoBatteryCharging size={22} />; | ||
} | ||
|
||
if (battery.level !== 1) { | ||
return <IoBatteryHalf size={22} />; | ||
} | ||
|
||
return <IoBatteryFull size={22} />; | ||
}, [battery]); | ||
|
||
useEffect(() => { | ||
window.navigator.getBattery?.().then((battery) => setBattery(battery)); | ||
}, []); | ||
|
||
return ( | ||
<p className={css.batteryIndicator}> | ||
{batteryPercent} | ||
{batteryIcon} | ||
</p> | ||
); | ||
}; |
File renamed without changes.
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
File renamed without changes.
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,51 @@ | ||
import { style, styleVariants } from "@vanilla-extract/css"; | ||
|
||
export const container = style({ | ||
position: "relative", | ||
}); | ||
|
||
export const selected = style({ | ||
display: "flex", | ||
alignItems: "center", | ||
fontSize: 14, | ||
padding: "4px 6px", | ||
borderRadius: 6, | ||
userSelect: "none", | ||
transition: "all .15s ease-in-out", | ||
":hover": { | ||
backgroundColor: "rgba(104, 100, 100, 1)", | ||
}, | ||
":after": { | ||
backgroundColor: "rgb(104, 100, 100)", | ||
}, | ||
selectors: { | ||
"&:hover::after": { | ||
backgroundColor: "rgb(22, 100, 220)", | ||
}, | ||
}, | ||
}); | ||
|
||
export const selectedExpandIndicator = style({ | ||
marginLeft: 4, | ||
}); | ||
|
||
export const baseOptions = style({ | ||
position: "absolute", | ||
top: "calc(100% + 4px)", | ||
left: 0, | ||
right: 0, | ||
selectors: { | ||
"&:nth-child(n+1)": { | ||
marginTop: 4, | ||
}, | ||
}, | ||
}); | ||
|
||
export const options = styleVariants({ | ||
closed: [baseOptions, { display: "none" }], | ||
opened: [baseOptions], | ||
}); | ||
|
||
export const option = style({ | ||
fontSize: 14, | ||
}); |
Oops, something went wrong.