diff --git a/src/layout/AppFooter.vue b/src/layout/AppFooter.vue index 907c9a6..1c0e9bc 100644 --- a/src/layout/AppFooter.vue +++ b/src/layout/AppFooter.vue @@ -12,7 +12,7 @@ const logoUrl = () => { diff --git a/src/layout/composables/layoutService.js b/src/layout/composables/layoutService.js index ae2a3e0..2dd25d8 100644 --- a/src/layout/composables/layoutService.js +++ b/src/layout/composables/layoutService.js @@ -19,17 +19,17 @@ const layoutState = reactive({ menuHoverActive: false }); -export function useLayoutService() { +export function useLayoutService () { const changeThemeSettings = (theme, darkTheme) => { layoutConfig.theme = theme; layoutConfig.darkTheme = darkTheme; }; - const setScale = (scale) => { + const setScale = scale => { layoutConfig.scale = scale; }; - const setActiveMenuItem = (item) => { + const setActiveMenuItem = item => { layoutConfig.activeMenuItem = item.value || item; }; diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index e24d496..d14c6bd 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -7,10 +7,10 @@ const { isDarkTheme } = useLayoutService(); const products = ref(null); const lineData = reactive({ - labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], + labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], datasets: [ { - label: 'Revenue', + label: 'First Dataset', data: [65, 59, 80, 81, 56, 55, 40], fill: false, backgroundColor: '#2f4860', @@ -18,7 +18,7 @@ const lineData = reactive({ tension: 0.4 }, { - label: 'Sales', + label: 'Second Dataset', data: [28, 48, 40, 19, 86, 27, 90], fill: false, backgroundColor: '#00bb7e', @@ -76,25 +76,25 @@ const applyDarkTheme = () => { plugins: { legend: { labels: { - color: '#495057' + color: '#ebedef' } } }, scales: { x: { ticks: { - color: '#495057' + color: '#ebedef' }, grid: { - color: '#ebedef' + color: 'rgba(160, 167, 181, .3)' } }, y: { ticks: { - color: '#495057' + color: '#ebedef' }, grid: { - color: '#ebedef' + color: 'rgba(160, 167, 181, .3)' } } } diff --git a/src/views/uikit/Chart.vue b/src/views/uikit/Chart.vue index bd89219..9b103d6 100644 --- a/src/views/uikit/Chart.vue +++ b/src/views/uikit/Chart.vue @@ -2,91 +2,17 @@ import { ref, watch } from 'vue'; import { useLayoutService } from '@/layout/composables/layoutService'; -const { isDarkTheme } = useLayoutService(); -const lineData = ref({ - labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], - datasets: [ - { - label: 'First Dataset', - data: [65, 59, 80, 81, 56, 55, 40], - fill: false, - backgroundColor: '#2f4860', - borderColor: '#2f4860', - tension: 0.4 - }, - { - label: 'Second Dataset', - data: [28, 48, 40, 19, 86, 27, 90], - fill: false, - backgroundColor: '#00bb7e', - borderColor: '#00bb7e', - tension: 0.4 - } - ] -}); +const { layoutConfig } = useLayoutService(); +const documentStyle = getComputedStyle(document.documentElement); +let textColor = documentStyle.getPropertyValue('--text-color'); +let textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary'); +let surfaceBorder = documentStyle.getPropertyValue('--surface-border'); -const pieData = ref({ - labels: ['A', 'B', 'C'], - datasets: [ - { - data: [300, 50, 100], - backgroundColor: ['#FF6384', '#36A2EB', '#FFCE56'], - hoverBackgroundColor: ['#FF6384', '#36A2EB', '#FFCE56'] - } - ] -}); - -const polarData = ref({ - datasets: [ - { - data: [11, 16, 7, 3, 14], - backgroundColor: ['#FF6384', '#4BC0C0', '#FFCE56', '#E7E9ED', '#36A2EB'], - label: 'My dataset' - } - ], - labels: ['Red', 'Green', 'Yellow', 'Grey', 'Blue'] -}); -const barData = ref({ - labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], - datasets: [ - { - label: 'My First dataset', - backgroundColor: '#2f4860', - data: [65, 59, 80, 81, 56, 55, 40] - }, - { - label: 'My Second dataset', - backgroundColor: '#00bb7e', - data: [28, 48, 40, 19, 86, 27, 90] - } - ] -}); - -const radarData = ref({ - labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'], - datasets: [ - { - label: 'My First dataset', - backgroundColor: 'rgba(179,181,198,0.2)', - borderColor: 'rgba(179,181,198,1)', - pointBackgroundColor: 'rgba(179,181,198,1)', - pointBorderColor: '#fff', - pointHoverBackgroundColor: '#fff', - pointHoverBorderColor: 'rgba(179,181,198,1)', - data: [65, 59, 90, 81, 56, 55, 40] - }, - { - label: 'My Second dataset', - backgroundColor: 'rgba(255,99,132,0.2)', - borderColor: 'rgba(255,99,132,1)', - pointBackgroundColor: 'rgba(255,99,132,1)', - pointBorderColor: '#fff', - pointHoverBackgroundColor: '#fff', - pointHoverBorderColor: 'rgba(255,99,132,1)', - data: [28, 48, 40, 19, 96, 27, 100] - } - ] -}); +const lineData = ref(null); +const pieData = ref(null); +const polarData = ref(null); +const barData = ref(null); +const radarData = ref(null); const lineOptions = ref(null); const pieOptions = ref(null); @@ -94,204 +20,202 @@ const polarOptions = ref(null); const barOptions = ref(null); const radarOptions = ref(null); -const applyLightTheme = () => { - lineOptions.value = { - plugins: { - legend: { - labels: { - color: '#495057' - } - } - }, - scales: { - x: { - ticks: { - color: '#495057' - }, - grid: { - color: '#ebedef' - } - }, - y: { - ticks: { - color: '#495057' - }, - grid: { - color: '#ebedef' - } - } - } - }; - - barOptions.value = { - plugins: { - legend: { - labels: { - color: '#495057' - } - } - }, - scales: { - x: { - ticks: { - color: '#495057' - }, - grid: { - color: '#ebedef' - } - }, - y: { - ticks: { - color: '#495057' - }, - grid: { - color: '#ebedef' - } - } - } - }; - - pieOptions.value = { - plugins: { - legend: { - labels: { - color: '#495057' - } - } - } - }; - - polarOptions.value = { - plugins: { - legend: { - labels: { - color: '#495057' - } - } - }, - scales: { - r: { - grid: { - color: '#ebedef' - } - } - } - }; - - radarOptions.value = { - plugins: { - legend: { - labels: { - color: '#495057' - } - } - }, - scales: { - r: { - grid: { - color: '#ebedef' - } - } - } - }; +const setColorOptions = () => { + textColor = documentStyle.getPropertyValue('--text-color'); + textColorSecondary = documentStyle.getPropertyValue('--text-color-secondary'); + surfaceBorder = documentStyle.getPropertyValue('--surface-border'); }; -const applyDarkTheme = () => { - lineOptions.value = { +const setChart = () => { + setColorOptions(); + barData.value = { + labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], + datasets: [ + { + label: 'My First dataset', + backgroundColor: documentStyle.getPropertyValue('--primary-500'), + borderColor: documentStyle.getPropertyValue('--primary-500'), + data: [65, 59, 80, 81, 56, 55, 40] + }, + { + label: 'My Second dataset', + backgroundColor: documentStyle.getPropertyValue('--primary-200'), + borderColor: documentStyle.getPropertyValue('--primary-200'), + data: [28, 48, 40, 19, 86, 27, 90] + } + ] + }; + barOptions.value = { plugins: { legend: { labels: { - color: '#ebedef' + fontColor: textColor } } }, scales: { x: { ticks: { - color: '#ebedef' + color: textColorSecondary, + font: { + weight: 500 + } }, grid: { - color: 'rgba(160, 167, 181, .3)' + display: false, + drawBorder: false } }, y: { ticks: { - color: '#ebedef' + color: textColorSecondary }, grid: { - color: 'rgba(160, 167, 181, .3)' + color: surfaceBorder, + drawBorder: false } } } }; - barOptions.value = { - plugins: { - legend: { - labels: { - color: '#ebedef' - } + pieData.value = { + labels: ['A', 'B', 'C'], + datasets: [ + { + data: [540, 325, 702], + backgroundColor: [documentStyle.getPropertyValue('--indigo-500'), documentStyle.getPropertyValue('--purple-500'), documentStyle.getPropertyValue('--teal-500')], + hoverBackgroundColor: [documentStyle.getPropertyValue('--indigo-400'), documentStyle.getPropertyValue('--purple-400'), documentStyle.getPropertyValue('--teal-400')] } - }, - scales: { - x: { - ticks: { - color: '#ebedef' - }, - grid: { - color: 'rgba(160, 167, 181, .3)' - } - }, - y: { - ticks: { - color: '#ebedef' - }, - grid: { - color: 'rgba(160, 167, 181, .3)' - } - } - } + ] }; pieOptions.value = { plugins: { legend: { labels: { - color: '#ebedef' + usePointStyle: true, + color: textColor } } } }; + lineData.value = { + labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], + datasets: [ + { + label: 'First Dataset', + data: [65, 59, 80, 81, 56, 55, 40], + fill: false, + backgroundColor: documentStyle.getPropertyValue('--primary-500'), + borderColor: documentStyle.getPropertyValue('--primary-500'), + tension: 0.4 + }, + { + label: 'Second Dataset', + data: [28, 48, 40, 19, 86, 27, 90], + fill: false, + backgroundColor: documentStyle.getPropertyValue('--primary-200'), + borderColor: documentStyle.getPropertyValue('--primary-200'), + tension: 0.4 + } + ] + }; + + lineOptions.value = { + plugins: { + legend: { + labels: { + fontColor: textColor + } + } + }, + scales: { + x: { + ticks: { + color: textColorSecondary + }, + grid: { + color: surfaceBorder, + drawBorder: false + } + }, + y: { + ticks: { + color: textColorSecondary + }, + grid: { + color: surfaceBorder, + drawBorder: false + } + } + } + }; + + polarData.value = { + datasets: [ + { + data: [11, 16, 7, 3], + backgroundColor: [documentStyle.getPropertyValue('--indigo-500'), documentStyle.getPropertyValue('--purple-500'), documentStyle.getPropertyValue('--teal-500'), documentStyle.getPropertyValue('--orange-500')], + label: 'My dataset' + } + ], + labels: ['Indigo', 'Purple', 'Teal', 'Orange'] + }; + polarOptions.value = { plugins: { legend: { labels: { - color: '#ebedef' + color: textColor } } }, scales: { r: { grid: { - color: 'rgba(160, 167, 181, .3)' + color: surfaceBorder } } } }; + radarData.value = { + labels: ['Eating', 'Drinking', 'Sleeping', 'Designing', 'Coding', 'Cycling', 'Running'], + datasets: [ + { + label: 'My First dataset', + borderColor: documentStyle.getPropertyValue('--indigo-400'), + pointBackgroundColor: documentStyle.getPropertyValue('--indigo-400'), + pointBorderColor: documentStyle.getPropertyValue('--indigo-400'), + pointHoverBackgroundColor: textColor, + pointHoverBorderColor: documentStyle.getPropertyValue('--indigo-400'), + data: [65, 59, 90, 81, 56, 55, 40] + }, + { + label: 'My Second dataset', + borderColor: documentStyle.getPropertyValue('--purple-400'), + pointBackgroundColor: documentStyle.getPropertyValue('--purple-400'), + pointBorderColor: documentStyle.getPropertyValue('--purple-400'), + pointHoverBackgroundColor: textColor, + pointHoverBorderColor: documentStyle.getPropertyValue('--purple-400'), + data: [28, 48, 40, 19, 96, 27, 100] + } + ] + }; + radarOptions.value = { plugins: { legend: { labels: { - color: '#ebedef' + fontColor: textColor } } }, scales: { r: { grid: { - color: 'rgba(160, 167, 181, .3)' + color: textColorSecondary } } } @@ -299,13 +223,11 @@ const applyDarkTheme = () => { }; watch( - isDarkTheme, - (val) => { - if (val) { - applyDarkTheme(); - } else { - applyLightTheme(); - } + layoutConfig.theme, + () => { + setTimeout(() => { + setChart(); + }, 100); }, { immediate: true } ); @@ -313,36 +235,40 @@ watch(