From 80c151ca6c4a76a5f912505672eee471f77a3bba 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 | 111 +++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 7 deletions(-) diff --git a/src/components/tasks/gantt-chart.vue b/src/components/tasks/gantt-chart.vue index 22fd8d2dc1..ff06a76e0e 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)', }, }, }])) @@ -198,19 +212,102 @@ async function createTask() { } function openTask(e) { - console.log('open', e.bar.ganttBarConfig.id) router.push({ name: 'task.detail', params: {id: e.bar.ganttBarConfig.id}, 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() +} -