summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOliver <oliver@mohlin.dev>2025-04-10 11:07:34 +0200
committerSebastian Holmin <sebastian.holmin@mullvad.net>2025-05-28 13:25:30 +0200
commit169545fff5aaa5942e51e566068804e0808f4aab (patch)
tree51dbbaff0d7467a4cd21d0bc8c52600d1c69bdba
parent7e116c128fe9ed156509b26c8c3b8407a4335dcd (diff)
downloadmullvadvpn-169545fff5aaa5942e51e566068804e0808f4aab.tar.xz
mullvadvpn-169545fff5aaa5942e51e566068804e0808f4aab.zip
Add context to Animate
-rw-r--r--desktop/packages/mullvad-vpn/src/renderer/lib/components/animate/AnimateContext.tsx33
1 files changed, 33 insertions, 0 deletions
diff --git a/desktop/packages/mullvad-vpn/src/renderer/lib/components/animate/AnimateContext.tsx b/desktop/packages/mullvad-vpn/src/renderer/lib/components/animate/AnimateContext.tsx
new file mode 100644
index 0000000000..e9a41e8079
--- /dev/null
+++ b/desktop/packages/mullvad-vpn/src/renderer/lib/components/animate/AnimateContext.tsx
@@ -0,0 +1,33 @@
+import React from 'react';
+
+interface AnimateContextProps {
+ present?: boolean;
+ initial?: boolean;
+ show: boolean;
+ setShow: React.Dispatch<React.SetStateAction<boolean>>;
+}
+
+const AnimateContext = React.createContext<AnimateContextProps | undefined>(undefined);
+
+export const useAnimateContext = (): AnimateContextProps => {
+ const context = React.useContext(AnimateContext);
+ if (!context) {
+ throw new Error('useButtonContext must be used within a ButtonProvider');
+ }
+ return context;
+};
+
+interface AnimateProviderProps {
+ present?: boolean;
+ initial?: boolean;
+ children: React.ReactNode;
+}
+
+export const AnimateProvider = ({ present, initial, children }: AnimateProviderProps) => {
+ const [show, setShow] = React.useState<boolean>(present || false);
+ return (
+ <AnimateContext.Provider value={{ present, initial, show, setShow }}>
+ {children}
+ </AnimateContext.Provider>
+ );
+};