-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): embed drawer with zustand
- Loading branch information
1 parent
213157a
commit 36d807b
Showing
6 changed files
with
106 additions
and
38 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
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
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,13 +1,28 @@ | ||
import { atom, useAtom } from "jotai"; | ||
import { create } from "zustand"; | ||
|
||
type Embed = { | ||
embedLink: string; | ||
embedId: string; | ||
name: string; | ||
isOpen: boolean; | ||
embedLink: string; | ||
}; | ||
|
||
const embedAtom = atom<Embed>({ name: "", embedLink: "", isOpen: false }); | ||
type EmbedStore = Embed & { | ||
isOpen: boolean; | ||
onOpen: (value: Embed) => void; | ||
onClose: () => void; | ||
}; | ||
|
||
export function useEmbed() { | ||
return useAtom(embedAtom); | ||
} | ||
export const useEmbed = create<EmbedStore>((set, get) => ({ | ||
embedId: "", | ||
embedLink: "", | ||
name: "", | ||
isOpen: false, | ||
onOpen: (value) => | ||
set({ | ||
isOpen: true, | ||
embedId: value.embedId, | ||
embedLink: value.embedLink, | ||
name: value.name, | ||
}), | ||
onClose: () => set({ embedId: "", embedLink: "", name: "", isOpen: false }), | ||
})); |