mirror of
https://github.com/randyjc/Rahoot.git
synced 2026-03-13 20:15:35 +01:00
adding theming to client and bug fixes
This commit is contained in:
29
packages/web/src/server/theme.ts
Normal file
29
packages/web/src/server/theme.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import Config from "@rahoot/socket/services/config"
|
||||
|
||||
export type ThemeSettings = {
|
||||
brandName: string
|
||||
backgroundUrl: string | null
|
||||
}
|
||||
|
||||
export const getTheme = (): ThemeSettings => {
|
||||
const theme = Config.theme()
|
||||
return {
|
||||
brandName: theme.brandName || "Rahoot",
|
||||
backgroundUrl:
|
||||
typeof theme.backgroundUrl === "string" && theme.backgroundUrl.length > 0
|
||||
? theme.backgroundUrl
|
||||
: null,
|
||||
}
|
||||
}
|
||||
|
||||
export const saveTheme = (payload: Partial<ThemeSettings>): ThemeSettings => {
|
||||
const current = getTheme()
|
||||
const merged = {
|
||||
brandName: payload.brandName ?? current.brandName,
|
||||
backgroundUrl:
|
||||
payload.backgroundUrl === undefined
|
||||
? current.backgroundUrl
|
||||
: payload.backgroundUrl,
|
||||
}
|
||||
return Config.saveTheme(merged)
|
||||
}
|
||||
Reference in New Issue
Block a user