Skip to content

Commit

Permalink
Merge pull request #117 from melfore/develop
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
luciob committed Oct 17, 2023
2 parents cc5051a + 361acae commit 9f5d6a7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# [1.12.0](https://github.com/melfore/konva-timeline/compare/v1.11.0...v1.12.0) (2023-10-16)


### Features

* 🎸 [Timeline] Added initialDateTime prop to auto scroll ([4500178](https://github.com/melfore/konva-timeline/commit/4500178c5006f52555aa411a33ade89fefb3b10f)), closes [#77](https://github.com/melfore/konva-timeline/issues/77)
- 🎸 [Timeline] Added initialDateTime prop to auto scroll ([4500178](https://github.com/melfore/konva-timeline/commit/4500178c5006f52555aa411a33ade89fefb3b10f)), closes [#77](https://github.com/melfore/konva-timeline/issues/77)

# [1.11.0](https://github.com/melfore/konva-timeline/compare/v1.10.0...v1.11.0) (2023-10-16)

Expand Down
5 changes: 4 additions & 1 deletion src/resources/utils/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export const RESOURCE_TEXT_OFFSET = 12;
* Adds header resource to incoming list of resources
* @param resources the list of all resources
*/
export const addHeaderResource = (resources: Resource[]): Resource[] => [RESOURCE_HEADER, ...resources];
export const addHeaderResource = (resources: Resource[], headerLabel?: string): Resource[] => [
{ ...RESOURCE_HEADER, label: headerLabel || RESOURCE_HEADER.label },
...resources,
];

/**
* Finds resource index given a y coordinate. Used when determining the resource from pointer position.
Expand Down
8 changes: 7 additions & 1 deletion src/timeline/TimelineContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ export type TimelineProviderProps = PropsWithChildren<TimelineInput> & {
* Enables resize operation on tasks
*/
enableResize?: boolean;
/**
* Label to display in header column
*/
headerLabel?: string;
/**
* Initial date time to scroll to
*/
Expand Down Expand Up @@ -67,6 +71,7 @@ type TimelineContextType = Required<
drawRange: InternalTimeRange;
enableDrag: boolean;
enableResize: boolean;
headerLabel?: string;
initialDateTime?: number;
interval: Interval;
onErrors?: (errors: KonvaTimelineError[]) => void;
Expand Down Expand Up @@ -97,6 +102,7 @@ export const TimelineProvider = ({
dragResolution: externalDragResolution,
enableDrag = true,
enableResize = true,
headerLabel,
hideResources = false,
initialDateTime: externalInitialDateTime,
onErrors,
Expand Down Expand Up @@ -212,7 +218,7 @@ export const TimelineProvider = ({
return resData;
}, [externalDragResolution, externalResolution]);

const resources = useMemo(() => addHeaderResource(externalResources), [externalResources]);
const resources = useMemo(() => addHeaderResource(externalResources, headerLabel), [externalResources, headerLabel]);

const rowHeight = useMemo(() => {
logDebug("TimelineProvider", "Calculating rowHeight...");
Expand Down
2 changes: 1 addition & 1 deletion src/utils/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const getValidTime = (date: number | string): number => {
}

if (typeof date === "string") {
const dateTime = DateTime.fromISO(date, { zone: "utc" });
const dateTime = DateTime.fromISO(date);
if (dateTime.toISO() === date) {
return dateTime.toMillis();
}
Expand Down

0 comments on commit 9f5d6a7

Please sign in to comment.