From 59151f0b3f5d89fe20fd3fa044eb461e7c170c55 Mon Sep 17 00:00:00 2001 From: Wan Qi Chen <495709+wa0x6e@users.noreply.github.com> Date: Mon, 13 Jan 2025 18:14:52 +0400 Subject: [PATCH] feat: add `theme` to skin --- src/graphql/helpers.ts | 11 +++++++---- src/graphql/schema.gql | 1 + src/helpers/schema.sql | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/graphql/helpers.ts b/src/graphql/helpers.ts index 41e9dc71..bb74afe1 100644 --- a/src/graphql/helpers.ts +++ b/src/graphql/helpers.ts @@ -45,7 +45,8 @@ const SKIN_SETTINGS = [ 'border_color', 'heading_color', 'header_color', - 'primary_color' + 'primary_color', + 'theme' ]; export function checkLimits(args: any = {}, type) { @@ -73,10 +74,12 @@ export function checkLimits(args: any = {}, type) { } function formatSkinSettings(result) { - return SKIN_SETTINGS.reduce((acc, color) => { - if (!result[color]) return acc; + return SKIN_SETTINGS.reduce((acc, colorName) => { + if (!result[colorName]) return acc; - acc[color] = `#${result[color]}`; + acc[colorName] = `${colorName.includes('_color') ? '#' : ''}${ + result[colorName] + }`; return acc; }, {}); } diff --git a/src/graphql/schema.gql b/src/graphql/schema.gql index 98de16b2..768f6201 100644 --- a/src/graphql/schema.gql +++ b/src/graphql/schema.gql @@ -662,4 +662,5 @@ type SkinSettings { heading_color: String header_color: String primary_color: String + theme: String } diff --git a/src/helpers/schema.sql b/src/helpers/schema.sql index f0759288..ad7bc9d0 100644 --- a/src/helpers/schema.sql +++ b/src/helpers/schema.sql @@ -202,5 +202,6 @@ CREATE TABLE skins ( heading_color VARCHAR(6) DEFAULT NULL, primary_color VARCHAR(6) DEFAULT NULL, header_color VARCHAR(6) DEFAULT NULL, + theme VARCHAR(5) NOT NULL DEFAULT 'light', PRIMARY KEY (id) );