From da853a914c8499aaf7532bf172f74d2717366a4e Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 20 Jul 2022 23:54:12 +0200 Subject: [PATCH] feat: styling --- src/components/tasks/gantt-chart.vue | 110 +++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 6 deletions(-) diff --git a/src/components/tasks/gantt-chart.vue b/src/components/tasks/gantt-chart.vue index 22fd8d2d..0e982728 100644 --- a/src/components/tasks/gantt-chart.vue +++ b/src/components/tasks/gantt-chart.vue @@ -12,6 +12,16 @@ font="'Open Sans', sans-serif" :width="ganttChartWidth + 'px'" > + parse(props.dateFrom, 'yyyy-LL-dd', new Date())) +const dateToDate = computed(() => parse(props.dateTo, 'yyyy-LL-dd', new Date())) + const DAY_WIDTH_PIXELS = 30 const ganttChartWidth = computed(() => { - const from = parse(props.dateFrom, 'yyyy-LL-dd', new Date()) - const to = parse(props.dateTo, 'yyyy-LL-dd', new Date()) - const dateDiff = Math.floor((to - from) / (1000 * 60 * 60 * 24)) + const dateDiff = Math.floor((dateToDate.value - dateFromDate.value) / (1000 * 60 * 60 * 24)) return dateDiff * DAY_WIDTH_PIXELS }) @@ -98,6 +109,8 @@ const defaultEndDate = format(new Date((new Date()).setDate((new Date()).getDate // A computed won't work directly. function mapGanttBars() { ganttBars.value = [] + const black = 'var(--grey-800)' + tasks.value.forEach(t => ganttBars.value.push([{ startDate: t.startDate ? format(t.startDate, dateFormat) : defaultStartDate, endDate: t.endDate ? format(t.endDate, dateFormat) : defaultEndDate, @@ -106,8 +119,9 @@ function mapGanttBars() { label: t.title, hasHandles: true, style: { - color: colorIsDark(t.getHexColor()) ? 'black' : 'white', - backgroundColor: t.getHexColor(), + color: t.startDate ? (colorIsDark(t.getHexColor()) ? black : 'white') : black, + backgroundColor: t.startDate ? t.getHexColor() : 'var(--grey-100)', + border: t.startDate ? '': '2px dashed var(--grey-300)', }, }, }])) @@ -205,12 +219,96 @@ function openTask(e) { state: {backdropView: router.currentRoute.value.fullPath}, }) } + +function weekdayFromTimeLabel(label: string): string { + const parsed = parse(label, 'dd.MMM', dateFromDate.value) + return format(parsed, 'E') +} + +function dayIsToday(label: string): boolean { + const parsed = parse(label, 'dd.MMM', dateFromDate.value) + const today = new Date() + return parsed.getDate() === today.getDate() && + parsed.getMonth() === today.getMonth() && + parsed.getFullYear() === today.getFullYear() +} -