Skip to content

Commit d92aa4d

Browse files
committed
feat: theme switcher devtool
1 parent 2a51173 commit d92aa4d

File tree

3 files changed

+43
-8
lines changed

3 files changed

+43
-8
lines changed

frontend/app/assets/styles/main.css

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@
2525
--color-border-default: rgb(40 37 33 / 0.15);
2626

2727
/* Border radius */
28-
--radius-list: 24px;
29-
--radius-list-inset: 20px;
30-
--radius-navigation: 32px;
31-
--radius-navigation-inset: 28px;
32-
--radius-card: 48px;
33-
--radius-button-large: 26px;
34-
--radius-button-medium: 22px;
35-
--radius-button-small: 18px;
28+
--radius-multiplier: 1;
29+
--radius-list: calc(24px * var(--radius-multiplier));
30+
--radius-list-inset: calc(20px * var(--radius-multiplier));
31+
--radius-navigation: calc(32px * var(--radius-multiplier));
32+
--radius-navigation-inset: calc(28px * var(--radius-multiplier));
33+
--radius-card: calc(48px * var(--radius-multiplier));
34+
--radius-button-large: calc(26px * var(--radius-multiplier));
35+
--radius-button-medium: calc(22px * var(--radius-multiplier));
36+
--radius-button-small: calc(18px * var(--radius-multiplier));
3637

3738
/* Spacing */
3839
--spacing-default: 20px;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<script setup lang="ts">
2+
import { onKeyDown } from '@vueuse/core'
3+
4+
const themes = [
5+
{ color: '#A2D3C2', rounding: 1 },
6+
{ color: '#5448C8', rounding: 0.5 },
7+
{ color: '#F6D8AE', rounding: 0 },
8+
]
9+
function setTheme(theme: number) {
10+
const themeData = themes[theme]
11+
if (!themeData) return
12+
13+
// Set dynamic project theme color
14+
document.documentElement.style.setProperty(
15+
'--color-accent-base',
16+
themeData.color,
17+
)
18+
19+
// Calculate and set the on-accent contrast color
20+
const contrastColor = getContrastColor(themeData.color)
21+
document.documentElement.style.setProperty('--color-on-accent', contrastColor)
22+
23+
// Set rounding
24+
document.documentElement.style.setProperty(
25+
'--radius-multiplier',
26+
themeData.rounding.toString(),
27+
)
28+
}
29+
30+
onKeyDown('1', () => setTheme(0))
31+
onKeyDown('2', () => setTheme(1))
32+
onKeyDown('3', () => setTheme(2))
33+
</script>

frontend/app/layouts/default.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ const { left, height, width, top } = useElementBounding(activeMenuItem)
8888

8989
<template>
9090
<div class="text-default relative mx-auto h-full w-full max-w-xl">
91+
<ThemePresetSwitcher />
9192
<div class="h-full">
9293
<slot />
9394
</div>

0 commit comments

Comments
 (0)