-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add compression utils * define a template for the theme CSS * API endpoint to GET themes * DB migration scripts + CRUD queries + cache invalidation * add `BUILD_TIME` static for proper theme default timestamp * themes API endpoints + types def + OpenAPI docs * include theme fetch in `app.html` and create first template for TS API types
- Loading branch information
Showing
26 changed files
with
1,057 additions
and
59 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,19 @@ | ||
export interface ThemeCss { | ||
text: number[], | ||
textHigh: number[], | ||
bg: number[], | ||
bgHigh: number[], | ||
action: number[], | ||
accent: number[], | ||
error: number[], | ||
btnText: string, | ||
themeSun: string, | ||
themeMoon: string, | ||
} | ||
|
||
export interface ThemeRequestResponse { | ||
clientId: string, | ||
light: ThemeCss, | ||
dark: ThemeCss, | ||
borderRadius: string, | ||
} |
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,31 @@ | ||
const isDev = process.env.DEV_MODE === 'true'; | ||
|
||
const langDefault = 'en'; | ||
const themeDefault = 'body{--text:208 10 40;--text-high:208 20 20;--bg:228 2 98;--bg-high:228 8 84;--action:34 100 59;--accent:246 60 53;--error:15 100 37;--btn-text:white;--theme-sun:hsla(var(--action), .7);--theme-moon:hsla(var(--accent), .85);--border-radius:5px;}.theme-dark{--text:228 2 70;--text-high:228 8 90;--bg:208 90 4;--bg-high:208 30 19;--action:34 100 59;--accent:246 60 53;--error:15 100 37;--btn-text:hsl(var(--bg));--theme-sun:hsla(var(--action), .7);--theme-moon:hsla(var(--accent), .85);}@media (prefers-color-scheme: dark){body{--text:228 2 70;--text-high:228 8 90;--bg:208 90 4;--bg-high:208 30 19;--action:34 100 59;--accent:246 60 53;--error:15 100 37;--btn-text:hsl(var(--bg));--theme-sun:hsla(var(--action), .7);--theme-moon:hsla(var(--accent), .85);}.theme-light{--text:208 10 40;--text-high:208 20 20;--bg:228 2 98;--bg-high:228 8 84;--action:34 100 59;--accent:246 60 53;--error:15 100 37;--btn-text:white;--theme-sun:hsla(var(--action), .7);--theme-moon:hsla(var(--accent), .85);}}'; | ||
|
||
/** | ||
* This hook only runs during local dev and compiling into static HTML. | ||
* Proxy values in `vite.config.js` have a higher priority. | ||
* | ||
* We can use it to fix "error" popping up because of for instance invalid CSS | ||
* values inside `app.html`, which will be used in production for SSR. | ||
* | ||
* @type {import('@sveltejs/kit').Handle} | ||
*/ | ||
export async function handle({event, resolve}) { | ||
let path = event.url.pathname; | ||
|
||
if (path === '/auth/v1/theme/%7B%7Bclient_id%7D%7D') { | ||
return new Response(themeDefault); | ||
} | ||
|
||
return resolve(event, { | ||
transformPageChunk: ({html}) => { | ||
if (isDev) { | ||
return html.replace('%lang%', langDefault); | ||
} else { | ||
return html.replace('%lang%', '{{lang}}'); | ||
} | ||
} | ||
}); | ||
} |
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
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,14 @@ | ||
CREATE TABLE themes | ||
( | ||
client_id TEXT NOT NULL | ||
CONSTRAINT themes_pk | ||
PRIMARY KEY | ||
CONSTRAINT themes_clients_id_fk | ||
REFERENCES clients | ||
ON UPDATE CASCADE ON DELETE CASCADE, | ||
last_update INTEGER NOT NULL, | ||
version INTEGER NOT NULL, | ||
light BLOB NOT NULL, | ||
dark BLOB NOT NULL, | ||
border_radius TEXT NOT NULL | ||
) STRICT; |
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,14 @@ | ||
CREATE TABLE themes | ||
( | ||
client_id VARCHAR NOT NULL | ||
CONSTRAINT themes_pk | ||
PRIMARY KEY | ||
CONSTRAINT themes_clients_id_fk | ||
REFERENCES clients | ||
ON UPDATE CASCADE ON DELETE CASCADE, | ||
last_update BIGINT NOT NULL, | ||
version INT NOT NULL, | ||
light BYTEA NOT NULL, | ||
dark BYTEA NOT NULL, | ||
border_radius VARCHAR NOT NULL | ||
); |
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.