From e0f3ad20be3a8dda5d1a8e911807b01a5dc9e921 Mon Sep 17 00:00:00 2001 From: CrisGrud Date: Mon, 4 Mar 2024 14:59:00 +0100 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20[TimeLine]Changed=20?= =?UTF-8?q?StartLine=20Display?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: #207 --- src/KonvaTimeline/index.stories.tsx | 31 +++++++++++++++++++++++++-- src/tasks/utils/tasks.ts | 2 +- src/timeline/index.tsx | 33 ++++++++++++++++++----------- 3 files changed, 51 insertions(+), 15 deletions(-) diff --git a/src/KonvaTimeline/index.stories.tsx b/src/KonvaTimeline/index.stories.tsx index 4aab93e..84498a6 100644 --- a/src/KonvaTimeline/index.stories.tsx +++ b/src/KonvaTimeline/index.stories.tsx @@ -132,7 +132,34 @@ export const NonPreciseRange: Story = { resourceId: "1", time: { start: 1697632200000, - end: 1697639400000, + end: 1697739400000, + }, + }, + { + id: "4", + label: "Task4", + resourceId: "3", + time: { + start: 1697802666000, + end: 1697939066000, + }, + }, + { + id: "3", + label: "Task3", + resourceId: "1", + time: { + start: 1697925606000, + end: 1698091206000, + }, + }, + { + id: "2", + label: "Task2", + resourceId: "2", + time: { + start: 1697691606000, + end: 1697818006000, }, }, ], @@ -157,7 +184,7 @@ export const CompletedPercentage: Story = { resourceId: "2", completedPercentage: 28, time: { - start: 1698047900000, + start: 1698357600000, end: 1698557900000, }, }, diff --git a/src/tasks/utils/tasks.ts b/src/tasks/utils/tasks.ts index 5c54921..c653d0d 100644 --- a/src/tasks/utils/tasks.ts +++ b/src/tasks/utils/tasks.ts @@ -94,7 +94,7 @@ export const validateTasks = ( return false; } - if (taskEnd < range.start || taskStart > range.end) { + if (taskStart < range.start || taskEnd > range.end) { errors.push({ entity: "task", level: "warn", message: "Outside range", refId: taskId }); return false; } diff --git a/src/timeline/index.tsx b/src/timeline/index.tsx index 2cdc0ac..66a51d7 100644 --- a/src/timeline/index.tsx +++ b/src/timeline/index.tsx @@ -167,6 +167,13 @@ const Timeline: FC = () => { [scrollbarSize, themeColor, timelineCommonStyle] ); + const startOffset = useMemo(() => { + if (externalRangeInMillis.start === +interval.start!) { + return false; + } + return true; + }, [externalRangeInMillis, interval]); + const xOfStart = useMemo(() => { const timeStart = DateTime.fromMillis(externalRangeInMillis.start); const startOffsetInUnit = timeStart.diff(interval.start!).as(resolution.unit); @@ -184,7 +191,7 @@ const Timeline: FC = () => { }, [fullTimelineWidth, xOfEnd]); const marginOffset = useMemo(() => { - return columnWidth * 0.01; + return columnWidth * 0.015; }, [columnWidth]); const gridStageWrapperStyle = useMemo( @@ -308,17 +315,19 @@ const Timeline: FC = () => { onTaskEvent={setExistTask} /> )} - - - - + {startOffset && ( + + + + + )} {newTask && ( Date: Mon, 4 Mar 2024 14:59:37 +0100 Subject: [PATCH 2/2] =?UTF-8?q?docs:=20=E2=9C=8F=EF=B8=8F=20changelog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: #207 --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ff53e7..0d2b440 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,8 @@ # [1.34.0](https://github.com/melfore/konva-timeline/compare/v1.33.2...v1.34.0) (2024-03-04) - ### Features -* 🎸 [TimeLine]Reported start-end range ([df79cb0](https://github.com/melfore/konva-timeline/commit/df79cb0e5623b6abaf452a30def1180bf7a88da0)), closes [#202](https://github.com/melfore/konva-timeline/issues/202) +- 🎸 [TimeLine]Reported start-end range ([df79cb0](https://github.com/melfore/konva-timeline/commit/df79cb0e5623b6abaf452a30def1180bf7a88da0)), closes [#202](https://github.com/melfore/konva-timeline/issues/202) ## [1.33.2](https://github.com/melfore/konva-timeline/compare/v1.33.1...v1.33.2) (2024-02-29)