mirror of
https://github.com/CorentinTh/it-tools.git
synced 2025-04-28 02:26:15 -04:00
refactor(ui): getting ride of naive ui buttons
This commit is contained in:
parent
df989e24b3
commit
c45bce36f9
44 changed files with 738 additions and 204 deletions
13
src/ui/theme/theme.models.ts
Normal file
13
src/ui/theme/theme.models.ts
Normal file
|
@ -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]);
|
||||
},
|
||||
};
|
||||
}
|
20
src/ui/theme/theme.store.ts
Normal file
20
src/ui/theme/theme.store.ts
Normal file
|
@ -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';
|
||||
},
|
||||
},
|
||||
});
|
37
src/ui/theme/themes.ts
Normal file
37
src/ui/theme/themes.ts
Normal file
|
@ -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',
|
||||
},
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue