Skip to content

Commit 0084e12

Browse files
committed
Add a button to scroll to current time marker
1 parent e5340b9 commit 0084e12

File tree

4 files changed

+38
-15
lines changed

4 files changed

+38
-15
lines changed

src/app/conf/2025/schedule/_components/filters.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,18 @@ export function ResetFiltersButton({
9797
}) {
9898
const hasFilters = Object.values(filters).flat().length > 0
9999

100+
if (!hasFilters) {
101+
return null
102+
}
103+
100104
return (
101105
<Button
102106
variant="tertiary"
103107
title="Reset filters"
104108
onClick={onReset}
105109
disabled={!hasFilters}
106110
className={clsx(
107-
"h-fit items-center gap-x-2 bg-neu-100 !p-2 text-neu-700 transition-opacity hover:bg-neu-200/80 hover:text-neu-900 disabled:opacity-0",
111+
"h-fit items-center gap-x-2 bg-neu-100 !p-2 text-neu-700 transition-opacity hover:bg-neu-200/80 hover:text-neu-900",
108112
className,
109113
)}
110114
>

src/app/conf/2025/schedule/_components/schedule-list.tsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
} from "./filters"
1919
import { formatBlockTime } from "./format-block-time"
2020
import { useCurrentTimeMarker } from "./use-current-time-marker"
21+
import { Button } from "@/app/conf/_design-system/button"
2122

2223
export interface FiltersConfig
2324
extends Partial<
@@ -139,23 +140,32 @@ export function ScheduleList({
139140
const firstDayIsDayZero = Object.keys(firstDay).length < 3
140141
const startIndex = firstDayIsDayZero ? 0 : 1
141142

142-
const getTimeMarker = useCurrentTimeMarker()
143+
const { getTimeMarker } = useCurrentTimeMarker()
143144

144145
return (
145146
<>
146147
<div className="flex justify-between gap-1 max-lg:flex-col">
147148
<BookmarkOnSched year={year} />
148-
<ResetFiltersButton
149-
filters={filtersState}
150-
onReset={() =>
151-
setFiltersState(
152-
FilterStates.initial(
153-
Object.keys(filterFields) as (keyof ScheduleSession)[],
154-
),
155-
)
156-
}
157-
className="max-lg:mb-4 max-lg:w-fit max-lg:self-end"
158-
/>
149+
<div className="flex gap-2">
150+
<Button
151+
href="#current-time-marker"
152+
variant="tertiary"
153+
className="hidden h-fit items-center gap-x-2 bg-neu-100 !p-2 text-neu-700 transition-opacity hover:bg-neu-200/80 hover:text-neu-900 disabled:opacity-0 [body:has(#current-time-marker)_&]:flex"
154+
>
155+
Scroll to current block
156+
</Button>
157+
<ResetFiltersButton
158+
filters={filtersState}
159+
onReset={() =>
160+
setFiltersState(
161+
FilterStates.initial(
162+
Object.keys(filterFields) as (keyof ScheduleSession)[],
163+
),
164+
)
165+
}
166+
className="max-lg:mb-4 max-lg:w-fit max-lg:self-end"
167+
/>
168+
</div>
159169
</div>
160170
{showFilter && (
161171
<Filters

src/app/conf/2025/schedule/_components/use-current-time-marker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ export function useCurrentTimeMarker() {
4141
}
4242
}
4343

44-
return getTimeMarker
44+
return { getTimeMarker }
4545
}

src/app/conf/_design-system/anchor.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,16 @@ export const Anchor = forwardRef(function Anchor(
2626
return isInternal(props) ? (
2727
<NextLink {...props} ref={ref} />
2828
) : (
29-
<a ref={ref} rel="noopener noreferrer" target="_blank" {...props} />
29+
<a
30+
ref={ref}
31+
{...(!props.href.startsWith("#")
32+
? {
33+
rel: "noopener noreferrer",
34+
target: "_blank",
35+
}
36+
: {})}
37+
{...props}
38+
/>
3039
)
3140
}) as (props: AnchorProps) => ReactElement
3241

0 commit comments

Comments
 (0)