From d8c7156082ba7beb08ebc0a0944a7229febb32a3 Mon Sep 17 00:00:00 2001 From: Enzo Vieira Date: Wed, 29 Nov 2023 22:35:55 +0000 Subject: [PATCH 1/4] feat: add smoothing scroll when linking to anchor --- components/Schedule/Table/Block/index.jsx | 2 +- styles/globals.css | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/Schedule/Table/Block/index.jsx b/components/Schedule/Table/Block/index.jsx index 8a2e6eec..95612803 100644 --- a/components/Schedule/Table/Block/index.jsx +++ b/components/Schedule/Table/Block/index.jsx @@ -21,7 +21,7 @@ function BlockItem({ const block = (
{coffeeBreak && ( diff --git a/styles/globals.css b/styles/globals.css index b9ae2344..2303209f 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -6,6 +6,7 @@ html { overflow-x: hidden; height: 100%; + scroll-behavior: smooth; } body { From bf77f66e822329a2d604e170042319076dd8a969 Mon Sep 17 00:00:00 2001 From: Enzo Vieira Date: Thu, 30 Nov 2023 19:14:02 +0000 Subject: [PATCH 2/4] fix: smooth scroll on schedule page when date change --- components/Schedule/Table/index.jsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/components/Schedule/Table/index.jsx b/components/Schedule/Table/index.jsx index d10b1824..79ba7735 100644 --- a/components/Schedule/Table/index.jsx +++ b/components/Schedule/Table/index.jsx @@ -2,6 +2,7 @@ import Block from "./Block"; import { isSelected } from "../Day/Filters"; import schedule from "/data/schedule.json"; +import { useEffect } from "react"; function filterElem(filters) { return function (elem) { @@ -62,6 +63,23 @@ export default function Table({ filters, detailed, }) { + useEffect(() => { + if (!(typeof window === "undefined")) { + const targetElement = document?.getElementById(hash); + if (!targetElement) return; + + const elementPosition = targetElement.getBoundingClientRect().top; + + const scroll = () => { + window.scrollTo({ + top: elementPosition, + }); + }; + + requestAnimationFrame(scroll); + } + }, [hash]); + const obj = schedule.find((obj) => obj.date == date); if (obj === undefined || obj.activities === undefined) { From b4e77ac5f2abdf67ce770c6ad3da6bdbd7fb7a37 Mon Sep 17 00:00:00 2001 From: Enzo Vieira Date: Thu, 30 Nov 2023 19:34:22 +0000 Subject: [PATCH 3/4] feat(speakers): add smooth scroll to speakers page --- components/Schedule/Table/Block/index.jsx | 14 +++++++-- .../components/Schedule/Table/Block/index.jsx | 2 +- layout/Speakers/components/Schedule/index.jsx | 30 +++++++++++++++++++ 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/components/Schedule/Table/Block/index.jsx b/components/Schedule/Table/Block/index.jsx index 95612803..3af2f654 100644 --- a/components/Schedule/Table/Block/index.jsx +++ b/components/Schedule/Table/Block/index.jsx @@ -1,11 +1,11 @@ import styles from "./style.module.css"; import Image from "next/image"; import Link from "next/link"; -import { useEffect } from "react"; function BlockItem({ id, coffeeBreak, + date, startTime, endTime, activityType, @@ -46,7 +46,16 @@ function BlockItem({ > {author && (
  • - + {author}
  • @@ -127,6 +136,7 @@ export default function Block({ date, detailed, elems }) { id={`${date}-${elem.id}`} focused={elem.focused} detailed={detailed} + date={date} {...elem.activity} /> ))} diff --git a/layout/Speakers/components/Schedule/Table/Block/index.jsx b/layout/Speakers/components/Schedule/Table/Block/index.jsx index 34af5668..f468860a 100644 --- a/layout/Speakers/components/Schedule/Table/Block/index.jsx +++ b/layout/Speakers/components/Schedule/Table/Block/index.jsx @@ -25,7 +25,7 @@ export default function Block({ const [showSpeaker, setShowSpeaker] = useState(true); return ( -
    +
    { + if (typeof window === "undefined") return; + + const { date, speaker } = router.query; + if (date) { + updateDate(date); + } + + if (speaker) { + const targetElement = document?.getElementById(speaker); + if (!targetElement) return; + + const elementPosition = targetElement.getBoundingClientRect().top; + + const scroll = () => { + window.scrollTo({ + top: elementPosition, + behavior: "smooth", + }); + }; + + requestAnimationFrame(scroll); + } + }, [router.query, date]); + const previous_day = () => { const new_date = addDate(date, -1); if (!isAfter(min_date, new_date) && !isAfter(new_date, max_date)) From 1d5bc995b3f9d9e8ad6e44405795389c885788af Mon Sep 17 00:00:00 2001 From: Enzo Vieira Date: Thu, 30 Nov 2023 19:53:16 +0000 Subject: [PATCH 4/4] fix(Block): create a unique link for each author --- components/Schedule/Table/Block/index.jsx | 38 +++++++++++++---------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/components/Schedule/Table/Block/index.jsx b/components/Schedule/Table/Block/index.jsx index 3af2f654..45c9ca06 100644 --- a/components/Schedule/Table/Block/index.jsx +++ b/components/Schedule/Table/Block/index.jsx @@ -44,22 +44,28 @@ function BlockItem({
      - {author && ( -
    • - - {author} - -
    • - )} + {author && + author.split(" & ").map((uniqueAuthor, uniqueAuthorIndex) => ( +
    • + + {uniqueAuthor} + + + {/* Separates each author name with a ' & ' */} + {uniqueAuthorIndex < author.split(" & ").length - 1 && ( +  &  + )} +
    • + ))}
    {description && (