An open-source, self-hosted system for apps built with web technologies.
Validate extended Surface theme
zohayrslileh2483dfc215f6
diff --git a/scripts/verify-theme.mjs b/scripts/verify-theme.mjsindex c3e6223..32c8270 100644--- a/scripts/verify-theme.mjs+++ b/scripts/verify-theme.mjs@@ -10,26 +10,58 @@ const expected = {radius: 10,surface: {grain: 0.04,+ grainAmount: 1,animation: 0,backdrop: 0,- opacity: 1+ opacity: 1,+ distortion: 0,+ waves: 0,+ ripples: 0,+ saturation: 1,+ brightness: 1}}assert.deepEqual(themeSchema.parse({}), expected)-const configured = themeSchema.parse({ background: "black", surface: { grain: 0.9, animation: 16, backdrop: 24, opacity: 0 } })+const configured = themeSchema.parse({+ background: "black",+ surface: {+ grain: 0.9,+ grainAmount: 0.5,+ animation: 16,+ backdrop: 24,+ opacity: 0,+ distortion: 140,+ waves: 40,+ ripples: 40,+ saturation: 2.6,+ brightness: 1.12+ }+})assert.equal(configured.background, "black")assert.deepEqual(configured.surface, {grain: 0.9,+ grainAmount: 0.5,animation: 16,backdrop: 24,- opacity: 0+ opacity: 0,+ distortion: 140,+ waves: 40,+ ripples: 40,+ saturation: 2.6,+ brightness: 1.12})assert.throws(() => themeSchema.parse({ surface: { color: "black" } }))assert.throws(() => themeSchema.parse({ glass: {} }))assert.throws(() => themeSchema.parse({ surface: { grain: 1.01 } }))+assert.throws(() => themeSchema.parse({ surface: { grainAmount: -0.01 } }))assert.throws(() => themeSchema.parse({ surface: { animation: 17 } }))assert.throws(() => themeSchema.parse({ surface: { backdrop: 25 } }))+assert.throws(() => themeSchema.parse({ surface: { distortion: 141 } }))+assert.throws(() => themeSchema.parse({ surface: { waves: 41 } }))+assert.throws(() => themeSchema.parse({ surface: { ripples: 41 } }))+assert.throws(() => themeSchema.parse({ surface: { saturation: 0.99 } }))+assert.throws(() => themeSchema.parse({ surface: { brightness: 1.13 } }))const store = new Keyv()const manager = await ThemeManager.open(store)diff --git a/source/server/core/theme-manager.ts b/source/server/core/theme-manager.tsindex c285c88..a870c88 100644--- a/source/server/core/theme-manager.ts+++ b/source/server/core/theme-manager.ts@@ -13,9 +13,15 @@ export const themeSchema: z.ZodType<ThemeProperties> = z.strictObject({radius: bounded(themeLimits.radius).default(standardTheme.radius),surface: z.strictObject({grain: bounded(themeLimits.surface.grain).default(standardTheme.surface.grain),+ grainAmount: bounded(themeLimits.surface.grainAmount).default(standardTheme.surface.grainAmount),animation: bounded(themeLimits.surface.animation).default(standardTheme.surface.animation),backdrop: bounded(themeLimits.surface.backdrop).default(standardTheme.surface.backdrop),- opacity: bounded(themeLimits.surface.opacity).default(standardTheme.surface.opacity)+ opacity: bounded(themeLimits.surface.opacity).default(standardTheme.surface.opacity),+ distortion: bounded(themeLimits.surface.distortion).default(standardTheme.surface.distortion),+ waves: bounded(themeLimits.surface.waves).default(standardTheme.surface.waves),+ ripples: bounded(themeLimits.surface.ripples).default(standardTheme.surface.ripples),+ saturation: bounded(themeLimits.surface.saturation).default(standardTheme.surface.saturation),+ brightness: bounded(themeLimits.surface.brightness).default(standardTheme.surface.brightness)}).default(standardTheme.surface)})