From 1b5c47c50d99b736e8a75843de53065712336f3a Mon Sep 17 00:00:00 2001 From: danielterletzkiy Date: Sun, 23 Jul 2023 02:31:32 +0200 Subject: [PATCH] WIP changed hardcoded non-dynamic colors to css variables --- src/App.vue | 32 ++++++++++- src/VuelizePlugin.ts | 33 +++-------- src/components/DWrapper.vue | 56 +++++++++++------- src/components/app/toolbar/DToolbar.vue | 5 +- src/components/card/DCard.vue | 11 +--- src/components/root/DRoot.vue | 58 +++++++++++++++---- src/composables/Color.composable.ts | 58 +++++++++++++++++++ src/mixins/DefaultProps.ts | 24 ++++---- src/store/ThemeStore.ts | 73 ++++++++++++++++-------- src/styles/index.scss | 11 +--- src/types/Theme.ts | 76 +++++++++++++++++++++++++ src/types/Vuelize.ts | 32 ----------- 12 files changed, 324 insertions(+), 145 deletions(-) create mode 100644 src/composables/Color.composable.ts create mode 100644 src/types/Theme.ts diff --git a/src/App.vue b/src/App.vue index 80e15e9..0d746a3 100644 --- a/src/App.vue +++ b/src/App.vue @@ -5,6 +5,9 @@ import DCardTitle from "./components/card/text/DCardTitle.vue"; import DNotificationWrapper from "./components/notification/DNotificationWrapper.vue"; import DNavigationBar from "./components/app/navigation/DNavigationBar.vue"; import {ref} from "vue"; +import DButton from "./components/button/DButton.vue"; +import {ThemeColorProperty} from "./types/Theme"; +import DCard from "./components/card/DCard.vue"; const navOpen = ref(false); @@ -13,7 +16,7 @@ const navOpen = ref(false); diff --git a/src/VuelizePlugin.ts b/src/VuelizePlugin.ts index d61361c..f7d78da 100644 --- a/src/VuelizePlugin.ts +++ b/src/VuelizePlugin.ts @@ -2,14 +2,14 @@ import {ref} from 'vue'; import type {Plugin, App} from "vue"; import type {Ref} from "vue"; import {createPinia} from "pinia"; -import {ThemeStore} from './store/ThemeStore' +import {useVuelizeTheme} from './store/ThemeStore' import importAll from "./ComponentImport"; import {State} from "./types/Vuelize"; import Notification from "./components/notification/Notification"; // @ts-ignore no ripple types available import VWave from "v-wave"; -import Unicon from 'vue3-unicons' +//import Unicon from 'vue3-unicons' import 'v3-transitions/dist/style.css' import ClickOutside from "./directive/ClickOutside"; @@ -21,7 +21,7 @@ class VuelizePlugin implements Vuelize { constructor(app: App) { this.app = app; - this.theme = ThemeStore(); + this.theme = useVuelizeTheme(); this.notifications.value; } @@ -30,31 +30,13 @@ class VuelizePlugin implements Vuelize { } getColor(color: string, tint?: number | string | undefined): string { - let colorOut: string; - if (this.theme.dark) { - colorOut = this.theme.themes.dark[color as keyof Theme.Dark]; - } else { - colorOut = this.theme.themes.light[color as keyof Theme.Light]; - } - if (!colorOut) { - colorOut = color; - } + let colorOut: string = "unset"; - if (tint && ['currentColor', 'transparent'].indexOf(colorOut) === -1) { - try { - if (typeof tint === "string") { - tint = parseInt(tint) - } - colorOut = this.#tintColor(colorOut, tint); - } catch (e) { - console.warn(e) - } - } return colorOut; } getColorContrast(color: string, tint?: number | string | undefined): string { - try { + /*try { let hexColor = this.getColor(color, tint); if (hexColor.slice(0, 1) === '#') { hexColor = hexColor.slice(1); @@ -74,7 +56,8 @@ class VuelizePlugin implements Vuelize { return (yiq > 160) ? 'rgba(0,0,0,0.75)' : 'rgba(255,255,255,0.85)'; } catch (e) { return this.getColor('error') - } + }*/ + return "test" } #tintColor = function adjust(color: string, amount: number): string { @@ -93,7 +76,7 @@ export const Vuelize: Plugin = { duration: 0.2, finalOpacity: 0.2 }); - app.use(Unicon); + //app.use(Unicon); app.config.globalProperties.$vuelize = new VuelizePlugin(app); app.provide('vuelize', app.config.globalProperties.$vuelize); diff --git a/src/components/DWrapper.vue b/src/components/DWrapper.vue index ebbd71e..5b82e54 100644 --- a/src/components/DWrapper.vue +++ b/src/components/DWrapper.vue @@ -1,20 +1,28 @@ diff --git a/src/components/root/DRoot.vue b/src/components/root/DRoot.vue index 7591b43..7aeeba8 100644 --- a/src/components/root/DRoot.vue +++ b/src/components/root/DRoot.vue @@ -1,17 +1,17 @@