diff --git a/resources/js/Components/Common/Reporting/ReportingChart.vue b/resources/js/Components/Common/Reporting/ReportingChart.vue
index 14ef04b8..db2b6563 100644
--- a/resources/js/Components/Common/Reporting/ReportingChart.vue
+++ b/resources/js/Components/Common/Reporting/ReportingChart.vue
@@ -17,7 +17,7 @@ import {
TooltipComponent,
} from 'echarts/components';
import type { AggregatedTimeEntries, Organization } from '@/packages/api/src';
-import { useCssVar } from '@vueuse/core';
+import { useCssVariable } from '@/utils/useCssVariable';
use([
CanvasRenderer,
@@ -47,8 +47,10 @@ const xAxisLabels = computed(() => {
formatDate(el.key ?? '', organization?.value?.date_format)
);
});
-const accentColor = useCssVar('--theme-color-chart', null, { observe: true });
-const labelColor = useCssVar('--color-text-secondary', null, { observe: true });
+const accentColor = useCssVariable('--theme-color-chart');
+const labelColor = useCssVariable('--color-text-secondary');
+const markLineColor = useCssVariable('--color-border-secondary');
+const splitLineColor = useCssVariable('--color-border-tertiary');
const seriesData = computed(() => {
return props?.groupedData?.map((el) => {
@@ -111,7 +113,7 @@ const option = computed(() => ({
data: xAxisLabels.value,
markLine: {
lineStyle: {
- color: 'rgba(125,156,188,0.1)',
+ color: markLineColor.value,
type: 'dashed',
},
},
@@ -135,9 +137,13 @@ const option = computed(() => ({
},
yAxis: {
type: 'value',
+ axisLabel: {
+ color: labelColor.value,
+ fontFamily: 'Outfit, sans-serif',
+ },
splitLine: {
lineStyle: {
- color: 'rgba(125,156,188,0.2)', // Set desired color here
+ color: splitLineColor.value,
},
},
},
diff --git a/resources/js/Components/Common/Reporting/ReportingPieChart.vue b/resources/js/Components/Common/Reporting/ReportingPieChart.vue
index 63994c12..88ba8c56 100644
--- a/resources/js/Components/Common/Reporting/ReportingPieChart.vue
+++ b/resources/js/Components/Common/Reporting/ReportingPieChart.vue
@@ -11,7 +11,7 @@ import {
TooltipComponent,
} from 'echarts/components';
import { formatHumanReadableDuration } from '@/packages/ui/src/utils/time';
-import { useCssVar } from '@vueuse/core';
+import { useCssVariable } from '@/utils/useCssVariable';
import type { Organization } from '@/packages/api/src';
use([
@@ -36,7 +36,7 @@ type ReportingChartDataEntry = {
const props = defineProps<{
data: ReportingChartDataEntry | null;
}>();
-const labelColor = useCssVar('--color-text-secondary', null, { observe: true });
+const labelColor = useCssVariable('--color-text-secondary');
const seriesData = computed(() => {
return props.data?.map((el) => {
diff --git a/resources/js/Components/Dashboard/ActivityGraphCard.vue b/resources/js/Components/Dashboard/ActivityGraphCard.vue
index 30ac01fd..d80a4d82 100644
--- a/resources/js/Components/Dashboard/ActivityGraphCard.vue
+++ b/resources/js/Components/Dashboard/ActivityGraphCard.vue
@@ -19,7 +19,7 @@ import {
formatHumanReadableDuration,
getDayJsInstance,
} from '@/packages/ui/src/utils/time';
-import { useCssVar } from '@vueuse/core';
+import { useCssVariable } from '@/utils/useCssVariable';
import { useQuery } from '@tanstack/vue-query';
import { getCurrentOrganizationId } from '@/utils/useUser';
import { api, type Organization } from '@/packages/api/src';
@@ -64,12 +64,9 @@ const max = computed(() => {
}
});
-const backgroundColor = useCssVar('--color-card-background', null, {
- observe: true,
-});
-const itemBackgroundColor = useCssVar('--color-bg-tertiary', null, {
- observe: true,
-});
+const backgroundColor = useCssVariable('--theme-color-card-background');
+const itemBackgroundColor = useCssVariable('--color-bg-tertiary');
+const borderColor = useCssVariable('--color-border');
const option = computed(() => {
return {
@@ -120,7 +117,7 @@ const option = computed(() => {
[],
itemStyle: {
borderRadius: 5,
- borderColor: 'rgba(255,255,255,0.05)',
+ borderColor: borderColor.value,
borderWidth: 1,
},
tooltip: {
diff --git a/resources/js/Components/Dashboard/DayOverviewCardChart.vue b/resources/js/Components/Dashboard/DayOverviewCardChart.vue
index 0de64a41..5eefac6f 100644
--- a/resources/js/Components/Dashboard/DayOverviewCardChart.vue
+++ b/resources/js/Components/Dashboard/DayOverviewCardChart.vue
@@ -1,13 +1,14 @@
diff --git a/resources/js/Components/Dashboard/ProjectsChartCard.vue b/resources/js/Components/Dashboard/ProjectsChartCard.vue
index d1d0a190..81519091 100644
--- a/resources/js/Components/Dashboard/ProjectsChartCard.vue
+++ b/resources/js/Components/Dashboard/ProjectsChartCard.vue
@@ -11,7 +11,7 @@ import {
TooltipComponent,
} from 'echarts/components';
import { formatHumanReadableDuration } from '@/packages/ui/src/utils/time';
-import { useCssVar } from "@vueuse/core";
+import { useCssVariable } from '@/utils/useCssVariable';
import type { Organization } from "@/packages/api/src";
use([
@@ -24,7 +24,7 @@ use([
]);
provide(THEME_KEY, 'dark');
-const labelColor = useCssVar('--color-text-secondary', null, { observe: true });
+const labelColor = useCssVariable('--color-text-secondary');
const props = defineProps<{
weeklyProjectOverview: {
diff --git a/resources/js/Components/Dashboard/ThisWeekOverview.vue b/resources/js/Components/Dashboard/ThisWeekOverview.vue
index f9a1e9e3..a67105b8 100644
--- a/resources/js/Components/Dashboard/ThisWeekOverview.vue
+++ b/resources/js/Components/Dashboard/ThisWeekOverview.vue
@@ -18,7 +18,7 @@ import ProjectsChartCard from '@/Components/Dashboard/ProjectsChartCard.vue';
import { formatHumanReadableDuration } from '@/packages/ui/src/utils/time';
import { formatCents } from '@/packages/ui/src/utils/money';
import { getWeekStart } from '@/packages/ui/src/utils/settings';
-import { useCssVar } from '@vueuse/core';
+import { useCssVariable } from '@/utils/useCssVariable';
import { getOrganizationCurrencyString } from '@/utils/money';
import { useQuery } from '@tanstack/vue-query';
import { getCurrentOrganizationId } from '@/utils/useUser';
@@ -60,7 +60,7 @@ const weekdays = computed(() => {
}
});
-const accentColor = useCssVar('--theme-color-chart', null, { observe: true });
+const accentColor = useCssVariable('--theme-color-chart');
// Get the organization ID using the utility function
const organizationId = computed(() => getCurrentOrganizationId());
@@ -176,10 +176,8 @@ const seriesData = computed(() => {
});
});
-const markLineColor = useCssVar('--color-border-secondary', null, {
- observe: true,
-});
-const labelColor = useCssVar('--color-text-secondary', null, { observe: true });
+const markLineColor = useCssVariable('--color-border-secondary');
+const labelColor = useCssVariable('--color-text-secondary');
const option = computed(() => {
return {
tooltip: {
@@ -215,6 +213,10 @@ const option = computed(() => {
},
yAxis: {
type: 'value',
+ axisLabel: {
+ color: labelColor.value,
+ fontFamily: 'Outfit, sans-serif',
+ },
splitLine: {
lineStyle: {
color: markLineColor.value,
diff --git a/resources/js/utils/theme.ts b/resources/js/utils/theme.ts
index 8f813b13..2f5a987d 100644
--- a/resources/js/utils/theme.ts
+++ b/resources/js/utils/theme.ts
@@ -3,13 +3,6 @@ import { computed, watch } from "vue";
type themeOption = "system" | "light" | "dark";
const themeSetting = useStorage("theme", "system");
-// reload page when themeSettingChanges
-watch(
- themeSetting,
- () => {
- location.reload();
- }
-)
const preferredColor = usePreferredColorScheme();
const theme = computed(() => {
if(themeSetting.value === "system"){
diff --git a/resources/js/utils/useCssVariable.ts b/resources/js/utils/useCssVariable.ts
new file mode 100644
index 00000000..be16ad55
--- /dev/null
+++ b/resources/js/utils/useCssVariable.ts
@@ -0,0 +1,49 @@
+import { ref, onMounted, onUnmounted } from 'vue'
+
+export function useCssVariable(variableName: string) {
+ const value = ref('')
+ let observer: MutationObserver | null = null
+ let mediaQuery: MediaQueryList | null = null
+
+ const updateValue = () => {
+ const computedStyle = getComputedStyle(document.documentElement)
+ const cssValue = computedStyle.getPropertyValue(variableName).trim()
+ value.value = cssValue
+ }
+
+ onMounted(() => {
+ // Initialize with current value
+ updateValue()
+
+ // Watch for class changes on document.documentElement (where theme classes are applied)
+ observer = new MutationObserver((mutations) => {
+ mutations.forEach((mutation) => {
+ if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
+ updateValue()
+ }
+ })
+ })
+
+ observer.observe(document.documentElement, {
+ attributes: true,
+ attributeFilter: ['class']
+ })
+
+ // Also watch for system color scheme changes
+ if (window.matchMedia) {
+ mediaQuery = window.matchMedia('(prefers-color-scheme: dark)')
+ mediaQuery.addEventListener('change', updateValue)
+ }
+ })
+
+ onUnmounted(() => {
+ if (observer) {
+ observer.disconnect()
+ }
+ if (mediaQuery) {
+ mediaQuery.removeEventListener('change', updateValue)
+ }
+ })
+
+ return value
+}
\ No newline at end of file