-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(release): automatic release v0.1.0
- Loading branch information
Showing
71 changed files
with
3,617 additions
and
658 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
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
89 changes: 89 additions & 0 deletions
89
apps/nextjs/src/app/[locale]/_client-providers/mantine.tsx
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,89 @@ | ||
"use client"; | ||
|
||
import { useState } from "react"; | ||
import type { PropsWithChildren } from "react"; | ||
import type { MantineColorScheme, MantineColorSchemeManager } from "@mantine/core"; | ||
import { createTheme, isMantineColorScheme, MantineProvider } from "@mantine/core"; | ||
|
||
import { clientApi } from "@homarr/api/client"; | ||
import { useSession } from "@homarr/auth/client"; | ||
|
||
export const CustomMantineProvider = ({ children }: PropsWithChildren) => { | ||
const manager = useColorSchemeManager(); | ||
|
||
return ( | ||
<MantineProvider | ||
defaultColorScheme="auto" | ||
colorSchemeManager={manager} | ||
theme={createTheme({ | ||
primaryColor: "red", | ||
autoContrast: true, | ||
})} | ||
> | ||
{children} | ||
</MantineProvider> | ||
); | ||
}; | ||
|
||
function useColorSchemeManager(): MantineColorSchemeManager { | ||
const key = "homarr-color-scheme"; | ||
const { data: session } = useSession(); | ||
const [sessionColorScheme, setSessionColorScheme] = useState<MantineColorScheme | undefined>( | ||
session?.user.colorScheme, | ||
); | ||
const { mutate: mutateColorScheme } = clientApi.user.changeColorScheme.useMutation({ | ||
onSuccess: (_, variables) => { | ||
setSessionColorScheme(variables.colorScheme); | ||
}, | ||
}); | ||
|
||
let handleStorageEvent: (event: StorageEvent) => void; | ||
|
||
return { | ||
get: (defaultValue) => { | ||
if (typeof window === "undefined") { | ||
return defaultValue; | ||
} | ||
|
||
if (sessionColorScheme) { | ||
return sessionColorScheme; | ||
} | ||
|
||
try { | ||
return (window.localStorage.getItem(key) as MantineColorScheme | undefined) ?? defaultValue; | ||
} catch { | ||
return defaultValue; | ||
} | ||
}, | ||
|
||
set: (value) => { | ||
try { | ||
if (session) { | ||
mutateColorScheme({ colorScheme: value }); | ||
} | ||
window.localStorage.setItem(key, value); | ||
} catch (error) { | ||
console.warn("[@mantine/core] Local storage color scheme manager was unable to save color scheme.", error); | ||
} | ||
}, | ||
|
||
subscribe: (onUpdate) => { | ||
handleStorageEvent = (event) => { | ||
if (session) return; // Ignore updates when session is available as we are using session color scheme | ||
if (event.storageArea === window.localStorage && event.key === key && isMantineColorScheme(event.newValue)) { | ||
onUpdate(event.newValue); | ||
} | ||
}; | ||
|
||
window.addEventListener("storage", handleStorageEvent); | ||
}, | ||
|
||
unsubscribe: () => { | ||
window.removeEventListener("storage", handleStorageEvent); | ||
}, | ||
|
||
clear: () => { | ||
window.localStorage.removeItem(key); | ||
}, | ||
}; | ||
} |
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,10 @@ | ||
"use client"; | ||
|
||
import dynamic from "next/dynamic"; | ||
|
||
export const ClientSideTerminalComponent = dynamic( | ||
() => import("./terminal").then(({ TerminalComponent }) => TerminalComponent), | ||
{ | ||
ssr: false, | ||
}, | ||
); |
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
Oops, something went wrong.