diff options
author | 2023-04-19 21:38:59 +0200 | |
---|---|---|
committer | 2023-04-19 22:33:22 +0200 | |
commit | c45bce36f985a550d7bfad744099b601cb61e449 (patch) | |
tree | 2c5e186db857776a06879dce7529b5396de214b1 /src/ui/theme | |
parent | df989e24b3937876f094301e33762677d604888a (diff) | |
download | it-tools-c45bce36f985a550d7bfad744099b601cb61e449.tar.gz it-tools-c45bce36f985a550d7bfad744099b601cb61e449.tar.zst it-tools-c45bce36f985a550d7bfad744099b601cb61e449.zip |
refactor(ui): getting ride of naive ui buttons
Diffstat (limited to 'src/ui/theme')
-rw-r--r-- | src/ui/theme/theme.models.ts | 13 | ||||
-rw-r--r-- | src/ui/theme/theme.store.ts | 20 | ||||
-rw-r--r-- | src/ui/theme/themes.ts | 37 |
3 files changed, 70 insertions, 0 deletions
diff --git a/src/ui/theme/theme.models.ts b/src/ui/theme/theme.models.ts new file mode 100644 index 0000000..850afe9 --- /dev/null +++ b/src/ui/theme/theme.models.ts @@ -0,0 +1,13 @@ +import { useThemeStore } from './theme.store'; + +export { defineThemes }; + +function defineThemes<Theme>(themes: { light: Theme; dark: Theme }) { + return { + themes, + useTheme() { + const themeStore = useThemeStore(); + return computed(() => themes[themeStore.themeType]); + }, + }; +} diff --git a/src/ui/theme/theme.store.ts b/src/ui/theme/theme.store.ts new file mode 100644 index 0000000..e2457fc --- /dev/null +++ b/src/ui/theme/theme.store.ts @@ -0,0 +1,20 @@ +import { defineStore } from 'pinia'; + +export const useThemeStore = defineStore('ui-theme', { + state: () => ({ + themeType: useStorage<'dark' | 'light'>('ui-store:theme-type', 'dark') as Ref<'dark' | 'light'>, + }), + getters: { + isDarkTheme(): boolean { + return this.themeType === 'dark'; + }, + isLightTheme(): boolean { + return this.themeType === 'light'; + }, + }, + actions: { + toggleTheme() { + this.themeType = this.isDarkTheme ? 'light' : 'dark'; + }, + }, +}); diff --git a/src/ui/theme/themes.ts b/src/ui/theme/themes.ts new file mode 100644 index 0000000..94c87f6 --- /dev/null +++ b/src/ui/theme/themes.ts @@ -0,0 +1,37 @@ +import { defineThemes } from './theme.models'; + +export const { themes: appThemes, useTheme: useAppTheme } = defineThemes({ + light: { + text: { + baseColor: 'rgb(51, 54, 57)', + }, + + primary: { + color: '#18a058', + colorHover: '#1ea54c', + colorPressed: '#0C7A43', + }, + + warning: { + color: '#f59e0b', + colorHover: '#f59e0b', + colorPressed: '#f59e0b', + }, + }, + dark: { + text: { + baseColor: 'rgba(255, 255, 255, 0.82)', + }, + + primary: { + color: '#1ea54c', + colorHover: '#36AD6A', + colorPressed: '#0C7A43', + }, + warning: { + color: '#f59e0b', + colorHover: '#f59e0b', + colorPressed: '#f59e0b', + }, + }, +}); |