Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dark mode in dashboard stats & chart #1161

Merged
merged 2 commits into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions resources/scripts/admin/components/charts/LineChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@

<script setup>
import Chart from 'chart.js'
import { ref, reactive, computed, onMounted, watchEffect, inject } from 'vue'
import {
ref,
reactive,
computed,
onMounted,
watchEffect,
inject,
watch,
} from 'vue'
import { useCompanyStore } from '@/scripts/admin/stores/company'
import { useGlobalStore } from '@/scripts/admin/stores/global'

const utils = inject('utils')

Expand Down Expand Up @@ -44,9 +53,11 @@ const props = defineProps({
},
})

const isDarkModeOn = document.documentElement.classList.contains('dark')
let myLineChart = null
const graph = ref(null)
const companyStore = useCompanyStore()
const globalStore = useGlobalStore()
const defaultCurrency = computed(() => {
return companyStore.selectedCompanyCurrency
})
Expand All @@ -60,6 +71,14 @@ watchEffect(() => {
}
})

watch(
() => globalStore.isDarkModeOn,
() => {
myLineChart.reset()
updateColors()
}
)

onMounted(() => {
let context = graph.value.getContext('2d')
let options = reactive({
Expand All @@ -81,6 +100,8 @@ onMounted(() => {
},
})

const salesColor = globalStore.isDarkModeOn ? '#ffffff' : '#040405'

let data = reactive({
labels: props.labels,
datasets: [
Expand All @@ -89,16 +110,16 @@ onMounted(() => {
fill: false,
lineTension: 0.3,
backgroundColor: 'rgba(230, 254, 249)',
borderColor: '#040405',
borderColor: salesColor,
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: '#040405',
pointBorderColor: salesColor,
pointBackgroundColor: '#fff',
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: '#040405',
pointHoverBackgroundColor: salesColor,
pointHoverBorderColor: 'rgba(220,220,220,1)',
pointHoverBorderWidth: 2,
pointRadius: 4,
Expand Down Expand Up @@ -194,4 +215,12 @@ function update() {
lazy: true,
})
}

function updateColors() {
const newColor = globalStore.isDarkModeOn ? '#ffffff' : '#040405'

myLineChart.data.datasets[0].borderColor = newColor
myLineChart.data.datasets[0].pointBorderColor = newColor
myLineChart.data.datasets[0].pointHoverBackgroundColor = newColor
}
</script>
34 changes: 22 additions & 12 deletions resources/scripts/admin/views/dashboard/DashboardChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,23 @@
<div>
<div
v-if="dashboardStore.isDashboardDataLoaded"
class="grid grid-cols-10 mt-8 bg-white rounded shadow"
class="
grid
grid-cols-10
mt-8
bg-white
rounded shadow
dark:text-white
dark:backdrop-blur-xl
dark:shadow-glass
dark:border
dark:bg-opacity-70
dark:border-white/10
dark:bg-gray-800
relative
"
>
<BaseDarkHighlight />
<!-- Chart -->
<div
class="
Expand Down Expand Up @@ -54,6 +69,7 @@
lg:border-t-0 lg:text-right lg:col-span-3
xl:col-span-2
lg:grid-cols-1
dark:border-white/10
"
>
<div class="p-6">
Expand Down Expand Up @@ -96,15 +112,7 @@
</span>
<br />
<span
class="
block
mt-1
text-xl
font-semibold
leading-8
lg:text-2xl
text-red-400
"
class="block mt-1 text-xl font-semibold leading-8 lg:text-2xl text-red-400"
>
<BaseFormatMoney
:amount="dashboardStore.totalExpenses"
Expand All @@ -116,8 +124,10 @@
class="
col-span-3
p-6
border-t border-gray-200 border-solid
border-t
border-gray-200 border-solid
lg:col-span-1
dark:border-white/10
"
>
<span class="text-xs leading-5 lg:text-sm">
Expand All @@ -132,7 +142,7 @@
font-semibold
leading-8
lg:text-2xl
text-primary-500
text-primary-500 dark:text-primary-400
"
>
<BaseFormatMoney
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<BaseContentPlaceholders
class="grid grid-cols-10 mt-8 bg-white rounded shadow"
class="grid grid-cols-10 mt-8 bg-white rounded shadow dark:bg-gray-800"
>
<!-- Chart -->
<div
Expand Down Expand Up @@ -29,6 +29,7 @@
text-center
border-t border-l border-gray-200 border-solid
lg:border-t-0 lg:text-right lg:col-span-3
dark:border-gray-600
xl:col-span-2
lg:grid-cols-1
"
Expand Down Expand Up @@ -77,6 +78,7 @@
col-span-3
p-6
border-t border-gray-200 border-solid
dark:border-gray-600
lg:justify-end lg:items-end lg:col-span-1
"
>
Expand Down
10 changes: 8 additions & 2 deletions resources/scripts/admin/views/dashboard/DashboardStatsItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@
hover:bg-gray-50
xl:p-4
lg:col-span-2
dark:backdrop-blur-xl
dark:shadow-glass
dark:border
dark:border-white/10
dark:bg-gray-800/70
"
:class="{ 'lg:!col-span-3': large }"
:to="route"
>
<div>
<span class="text-xl font-semibold leading-tight text-black xl:text-3xl">
<span class="text-xl font-semibold leading-tight text-black xl:text-3xl dark:text-white">
<slot />
</span>
<span class="block mt-1 text-sm leading-tight text-gray-500 xl:text-lg">
<span class="block mt-1 text-sm leading-tight text-gray-500 xl:text-lg dark:text-gray-300">
{{ label }}
</span>
</div>
<BaseDarkHighlight class="!bg-highlight/[.17] !top-5" />
<div class="flex items-center">
<component :is="iconComponent" class="w-10 h-10 xl:w-12 xl:h-12" />
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<BaseContentPlaceholders
:rounded="true"
class="relative flex justify-between w-full p-3 bg-white rounded shadow lg:col-span-3 xl:p-4"
class="relative flex justify-between w-full p-3 bg-white rounded shadow lg:col-span-3 xl:p-4 dark:bg-gray-800"
>
<div>
<BaseContentPlaceholdersText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
shadow
lg:col-span-2
xl:p-4
dark:bg-gray-800
"
>
<div>
Expand Down
13 changes: 8 additions & 5 deletions resources/scripts/components/icons/dashboard/CustomerIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@
width="50"
height="50"
viewBox="0 0 50 50"
:class="colorClass"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<circle cx="25" cy="25" r="25" fill="#EAF1FB" />
<circle cx="25" cy="25" r="25" :class="bgColor" />
<path
d="M28.2656 23.0547C27.3021 24.0182 26.1302 24.5 24.75 24.5C23.3698 24.5 22.1849 24.0182 21.1953 23.0547C20.2318 22.0651 19.75 20.8802 19.75 19.5C19.75 18.1198 20.2318 16.9479 21.1953 15.9844C22.1849 14.9948 23.3698 14.5 24.75 14.5C26.1302 14.5 27.3021 14.9948 28.2656 15.9844C29.2552 16.9479 29.75 18.1198 29.75 19.5C29.75 20.8802 29.2552 22.0651 28.2656 23.0547ZM28.2656 25.75C29.6979 25.75 30.9219 26.2708 31.9375 27.3125C32.9792 28.3281 33.5 29.5521 33.5 30.9844V32.625C33.5 33.1458 33.3177 33.5885 32.9531 33.9531C32.5885 34.3177 32.1458 34.5 31.625 34.5H17.875C17.3542 34.5 16.9115 34.3177 16.5469 33.9531C16.1823 33.5885 16 33.1458 16 32.625V30.9844C16 29.5521 16.5078 28.3281 17.5234 27.3125C18.5651 26.2708 19.8021 25.75 21.2344 25.75H21.8984C22.8099 26.1667 23.7604 26.375 24.75 26.375C25.7396 26.375 26.6901 26.1667 27.6016 25.75H28.2656Z"
fill="currentColor"
:class="color"
/>
</svg>
</template>

<script setup>
const props = defineProps({
colorClass: {
color: {
type: String,
default: 'text-primary-500',
default: 'fill-primary-500 dark:fill-white',
},
bgColor: {
type: String,
default: 'fill-gray-100 dark:fill-primary-400',
},
})
</script>
Expand Down
16 changes: 15 additions & 1 deletion resources/scripts/components/icons/dashboard/DollarIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,24 @@
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<circle cx="25" cy="25" r="25" fill="#FDE4E5" />
<circle :class="bgColor" cx="25" cy="25" r="25" />
<path
:class="color"
d="M27.2031 23.6016C28.349 23.9401 29.2083 24.6562 29.7812 25.75C30.3802 26.8438 30.4714 27.9766 30.0547 29.1484C29.7422 30.0078 29.2083 30.6979 28.4531 31.2188C27.6979 31.7135 26.8516 31.974 25.9141 32V33.875C25.9141 34.0573 25.849 34.2005 25.7188 34.3047C25.6146 34.4349 25.4714 34.5 25.2891 34.5H24.0391C23.8568 34.5 23.7005 34.4349 23.5703 34.3047C23.4661 34.2005 23.4141 34.0573 23.4141 33.875V32C22.1641 32 21.0443 31.6094 20.0547 30.8281C19.8984 30.6979 19.8073 30.5417 19.7812 30.3594C19.7552 30.1771 19.8203 30.0208 19.9766 29.8906L21.3047 28.5625C21.5651 28.3281 21.8255 28.3021 22.0859 28.4844C22.4766 28.7448 22.9193 28.875 23.4141 28.875H25.9922C26.3307 28.875 26.6042 28.7708 26.8125 28.5625C27.0469 28.3281 27.1641 28.0417 27.1641 27.7031C27.1641 27.1302 26.8906 26.7656 26.3438 26.6094L22.3203 25.4375C21.4349 25.1771 20.6927 24.7083 20.0938 24.0312C19.4948 23.3542 19.1432 22.5729 19.0391 21.6875C18.9349 20.4115 19.2995 19.3177 20.1328 18.4062C20.9922 17.4688 22.0599 17 23.3359 17H23.4141V15.125C23.4141 14.9427 23.4661 14.7995 23.5703 14.6953C23.7005 14.5651 23.8568 14.5 24.0391 14.5H25.2891C25.4714 14.5 25.6146 14.5651 25.7188 14.6953C25.849 14.7995 25.9141 14.9427 25.9141 15.125V17C27.1641 17 28.2839 17.3906 29.2734 18.1719C29.4297 18.3021 29.5208 18.4583 29.5469 18.6406C29.5729 18.8229 29.5078 18.9792 29.3516 19.1094L28.0234 20.4375C27.763 20.6719 27.5026 20.6979 27.2422 20.5156C26.8516 20.2552 26.4089 20.125 25.9141 20.125H23.3359C22.9974 20.125 22.7109 20.2422 22.4766 20.4766C22.2682 20.6849 22.1641 20.9583 22.1641 21.2969C22.1641 21.5312 22.2422 21.7526 22.3984 21.9609C22.5547 22.1693 22.75 22.3125 22.9844 22.3906L27.2031 23.6016Z"
fill="#FB7178"
/>
</svg>
</template>
<script setup>
const props = defineProps({
color: {
type: String,
default: 'fill-red-400 dark:fill-white',
},
bgColor: {
type: String,
default: 'fill-red-100 dark:fill-red-400',
},
})
</script>

13 changes: 8 additions & 5 deletions resources/scripts/components/icons/dashboard/EstimateIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@
viewBox="0 0 50 50"
fill="none"
xmlns="http://www.w3.org/2000/svg"
:class="colorClass"
>
<circle cx="25" cy="25" r="25" fill="#EAF1FB" />
<circle cx="25" cy="25" r="25" :class="bgColor" />
<path
d="M26.75 19.8125C26.75 20.0729 26.8411 20.2943 27.0234 20.4766C27.2057 20.6589 27.4271 20.75 27.6875 20.75H33V33.5625C33 33.8229 32.9089 34.0443 32.7266 34.2266C32.5443 34.4089 32.3229 34.5 32.0625 34.5H18.9375C18.6771 34.5 18.4557 34.4089 18.2734 34.2266C18.0911 34.0443 18 33.8229 18 33.5625V15.4375C18 15.1771 18.0911 14.9557 18.2734 14.7734C18.4557 14.5911 18.6771 14.5 18.9375 14.5H26.75V19.8125ZM33 19.2656V19.5H28V14.5H28.2344C28.4948 14.5 28.7161 14.5911 28.8984 14.7734L32.7266 18.6016C32.9089 18.7839 33 19.0052 33 19.2656Z"
fill="currentColor"
:class="color"
/>
</svg>
</template>

<script setup>
const props = defineProps({
colorClass: {
color: {
type: String,
default: 'text-primary-500',
default: 'fill-primary-500 dark:fill-white',
},
bgColor: {
type: String,
default: 'fill-gray-100 dark:fill-primary-400',
},
})
</script>
13 changes: 8 additions & 5 deletions resources/scripts/components/icons/dashboard/InvoiceIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,24 @@
viewBox="0 0 50 50"
fill="none"
xmlns="http://www.w3.org/2000/svg"
:class="colorClass"
>
<circle cx="25" cy="25" r="25" fill="#EAF1FB" />
<circle cx="25" cy="25" r="25" :class="bgColor" />
<path
d="M28.25 24.5V27H20.75V24.5H28.25ZM31.7266 18.6016C31.9089 18.7839 32 19.0052 32 19.2656V19.5H27V14.5H27.2344C27.4948 14.5 27.7161 14.5911 27.8984 14.7734L31.7266 18.6016ZM25.75 19.8125C25.75 20.0729 25.8411 20.2943 26.0234 20.4766C26.2057 20.6589 26.4271 20.75 26.6875 20.75H32V33.5625C32 33.8229 31.9089 34.0443 31.7266 34.2266C31.5443 34.4089 31.3229 34.5 31.0625 34.5H17.9375C17.6771 34.5 17.4557 34.4089 17.2734 34.2266C17.0911 34.0443 17 33.8229 17 33.5625V15.4375C17 15.1771 17.0911 14.9557 17.2734 14.7734C17.4557 14.5911 17.6771 14.5 17.9375 14.5H25.75V19.8125ZM19.5 17.3125V17.9375C19.5 18.1458 19.6042 18.25 19.8125 18.25H22.9375C23.1458 18.25 23.25 18.1458 23.25 17.9375V17.3125C23.25 17.1042 23.1458 17 22.9375 17H19.8125C19.6042 17 19.5 17.1042 19.5 17.3125ZM19.5 19.8125V20.4375C19.5 20.6458 19.6042 20.75 19.8125 20.75H22.9375C23.1458 20.75 23.25 20.6458 23.25 20.4375V19.8125C23.25 19.6042 23.1458 19.5 22.9375 19.5H19.8125C19.6042 19.5 19.5 19.6042 19.5 19.8125ZM29.5 31.6875V31.0625C29.5 30.8542 29.3958 30.75 29.1875 30.75H26.0625C25.8542 30.75 25.75 30.8542 25.75 31.0625V31.6875C25.75 31.8958 25.8542 32 26.0625 32H29.1875C29.3958 32 29.5 31.8958 29.5 31.6875ZM29.5 23.875C29.5 23.6927 29.4349 23.5495 29.3047 23.4453C29.2005 23.3151 29.0573 23.25 28.875 23.25H20.125C19.9427 23.25 19.7865 23.3151 19.6562 23.4453C19.5521 23.5495 19.5 23.6927 19.5 23.875V27.625C19.5 27.8073 19.5521 27.9635 19.6562 28.0938C19.7865 28.1979 19.9427 28.25 20.125 28.25H28.875C29.0573 28.25 29.2005 28.1979 29.3047 28.0938C29.4349 27.9635 29.5 27.8073 29.5 27.625V23.875Z"
fill="currentColor"
:class="color"
/>
</svg>
</template>

<script setup>
const props = defineProps({
colorClass: {
color: {
type: String,
default: 'text-primary-500',
default: 'fill-primary-500 dark:fill-white',
},
bgColor: {
type: String,
default: 'fill-gray-100 dark:fill-primary-400',
},
})
</script>