mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-08 22:45:47 +00:00
* feat(www): wip break everything * feat(www): wip chunks * feat(www): wip chunk mode * feat: lift mode * feat: update chunks * fix: resize in lift mode * fix: hasLiftMode * fix: types * fix: toolbar Thanks @mrnbpt * chore: format check * feat: add tracking for enable_lift_mode * chore: format write * docs: add changelog
22 lines
493 B
TypeScript
22 lines
493 B
TypeScript
import { useAtom } from "jotai"
|
|
import { atomWithStorage } from "jotai/utils"
|
|
|
|
const configAtom = atomWithStorage<string[]>("lift-mode", [])
|
|
|
|
export function useLiftMode(name: string) {
|
|
const [chunks, setChunks] = useAtom(configAtom)
|
|
|
|
function toggleLiftMode(name: string) {
|
|
setChunks((prev) => {
|
|
return prev.includes(name)
|
|
? prev.filter((n) => n !== name)
|
|
: [...prev, name]
|
|
})
|
|
}
|
|
|
|
return {
|
|
isLiftMode: chunks.includes(name),
|
|
toggleLiftMode,
|
|
}
|
|
}
|