Skip to content

Commit 6282289

Browse files
Merge pull request #80 from linked-planet/dev
timeTableUtil - fixed start and end slot detection
2 parents 239128e + 240d31b commit 6282289

File tree

5 files changed

+48
-36
lines changed

5 files changed

+48
-36
lines changed

library/src/components/timetable/timeTableUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ export function getStartAndEndSlot(
561561
}
562562
}
563563
if (startSlot === -1) {
564-
startSlot = 0
564+
startSlot = slotsArray.length - 1
565565
}
566566

567567
let endSlot = slotsArray.findIndex((slot) => slot.isAfter(item.endDate))

package-lock.json

Lines changed: 21 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@
117117
"@atlaskit/code": "^15.6.6",
118118
"@atlaskit/css-reset": "^6.11.2",
119119
"@atlaskit/lozenge": "^11.12.2",
120-
"@atlaskit/pagination": "^14.9.5",
120+
"@atlaskit/pagination": "^14.10.0",
121121
"@atlaskit/side-navigation": "^3.6.3",
122122
"@atlaskit/table-tree": "^10.0.6",
123123
"@atlaskit/tag": "^12.6.6",
124124
"@atlaskit/tag-group": "^10.6.1",
125125
"@atlaskit/textarea": "^5.6.4",
126-
"@atlaskit/textfield": "^6.5.5",
126+
"@atlaskit/textfield": "^6.6.0",
127127
"@atlaskit/theme": "^14.0.1",
128128
"@babel/generator": "^7.26.2",
129129
"@babel/parser": "^7.26.2",
@@ -159,7 +159,7 @@
159159
"tailwindcss": "^3.4.15",
160160
"typescript": "^5.7.2",
161161
"typescript-plugin-css-modules": "^5.1.0",
162-
"vite": "^6.0.0",
162+
"vite": "^6.0.1",
163163
"vite-plugin-dts": "^4.3.0",
164164
"vitest": "^2.1.6"
165165
},

showcase/public/showcase-sources.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9717,7 +9717,7 @@ export default function UtilsShowCase(props: ShowcaseProps) {
97179717
)
97189718
}
97199719

9720-
import React, { useState } from "react"
9720+
import { useState } from "react"
97219721
import { AppLayout, Checkbox, PageLayout } from "@linked-planet/ui-kit-ts"
97229722

97239723
import "@atlaskit/css-reset" // sets base styles of AK
@@ -9735,7 +9735,7 @@ export default function AppLayoutExample() {
97359735
const [mainFixedHeight, setMainFixedHeight] = useState(true)
97369736

97379737
return (
9738-
<AppLayout.Container>
9738+
<AppLayout.Container useBanner>
97399739
<AppLayout.Banner
97409740
sticky={bannerSticky}
97419741
className="flex justify-between gap-4 border-2 border-solid px-4 py-2"

showcase/src/components/showcase/wrapper/TimeTableShowcase.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const exampleEntries: TimeTableTypes.TimeTableEntry<
4444
},
4545
items: [],
4646
},
47-
{
47+
/*{
4848
group: {
4949
id: "group-1",
5050
title: "Group 1",
@@ -343,7 +343,7 @@ const exampleEntries: TimeTableTypes.TimeTableEntry<
343343
title: "Item 7-1",
344344
},
345345
],
346-
},
346+
},*/
347347
]
348348

349349
function createTestItems(
@@ -419,8 +419,8 @@ function createMoreTestGroups(
419419
return newGroups
420420
}
421421

422-
const startDateInitial = dayjs().startOf("day").add(-1, "day").add(8, "hours")
423-
const endDateInitial = dayjs().startOf("day").add(5, "days").add(23, "hours")
422+
const startDateInitial = dayjs().startOf("day").add(-1, "day")
423+
const endDateInitial = dayjs().startOf("day").add(6, "days")
424424

425425
function TestCustomHeaderRowTimeSlot<
426426
G extends TimeTableTypes.TimeTableGroup,
@@ -435,10 +435,13 @@ function TestCustomHeaderRowTimeSlot<
435435
entries,
436436
tableCellRef,
437437
}: TimeTableTypes.CustomHeaderRowTimeSlotProps<G, I>) {
438-
const groupItems = entries[1].items
438+
const groupItems = entries[0].items
439+
if (!groupItems.length) {
440+
return null
441+
}
439442

440443
const groupItemsOfCell: I[] = []
441-
const startAndEndInSlow: {
444+
const startAndEndInSlot: {
442445
status: "in" | "before" | "after"
443446
startSlot: number
444447
endSlot: number
@@ -454,12 +457,15 @@ function TestCustomHeaderRowTimeSlot<
454457
)
455458
if (slotsArray[startAndEnd.startSlot] === timeSlot) {
456459
groupItemsOfCell.push(item)
457-
startAndEndInSlow.push(startAndEnd)
460+
startAndEndInSlot.push(startAndEnd)
458461
}
459462
}
463+
if (!groupItemsOfCell.length) {
464+
return null
465+
}
460466

461467
const leftAndWidths = groupItemsOfCell.map((it, i) => {
462-
const startAndEnd = startAndEndInSlow[i]
468+
const startAndEnd = startAndEndInSlot[i]
463469
if (startAndEnd.status === "before" || startAndEnd.status === "after") {
464470
return null
465471
}
@@ -474,6 +480,10 @@ function TestCustomHeaderRowTimeSlot<
474480
)
475481
})
476482

483+
if (entries[0].items.length) {
484+
console.log("LEFT", entries[0].items, leftAndWidths, startAndEndInSlot)
485+
}
486+
477487
const cellWidth = tableCellRef.current?.offsetWidth ?? 70
478488

479489
const ret = leftAndWidths.map((it, i) =>
@@ -506,7 +516,7 @@ function CustomHeaderRowHeader<
506516
}: TimeTableTypes.CustomHeaderRowHeaderProps<G, I>) {
507517
return (
508518
<div className="bg-surface-pressed">
509-
{entries[1].group.title} has {entries.length} entries
519+
{entries[0].group.title} has {entries.length} entries
510520
</div>
511521
)
512522
}
@@ -647,6 +657,7 @@ function Example() {
647657
)
648658

649659
useEffect(() => {
660+
/*requestMoreEntriesCB()
650661
requestMoreEntriesCB()
651662
requestMoreEntriesCB()
652663
requestMoreEntriesCB()
@@ -658,8 +669,7 @@ function Example() {
658669
requestMoreEntriesCB()
659670
requestMoreEntriesCB()
660671
requestMoreEntriesCB()
661-
requestMoreEntriesCB()
662-
requestMoreEntriesCB()
672+
requestMoreEntriesCB()*/
663673
/*requestMoreEntriesCB()
664674
requestMoreEntriesCB()
665675
requestMoreEntriesCB()

0 commit comments

Comments
 (0)