From 124eb9a6eacc5a8f10dc82595a60963cf1999196 Mon Sep 17 00:00:00 2001 From: cv <34649812+cpvalente@users.noreply.github.com> Date: Thu, 31 Aug 2023 21:28:50 +0200 Subject: [PATCH] style: recompose layout --- apps/client/src/common/utils/debounce.ts | 12 +++++++++ .../features/operator/Operator.module.scss | 3 ++- .../client/src/features/operator/Operator.tsx | 25 +++++++++++-------- .../follow-button/FollowButton.module.scss | 11 ++------ .../operator/status-bar/StatusBar.module.scss | 17 +++++++------ .../operator/status-bar/StatusBar.tsx | 20 +++++++-------- apps/client/src/theme/_v2Styles.scss | 1 + 7 files changed, 50 insertions(+), 39 deletions(-) create mode 100644 apps/client/src/common/utils/debounce.ts diff --git a/apps/client/src/common/utils/debounce.ts b/apps/client/src/common/utils/debounce.ts new file mode 100644 index 000000000..4b15d83d4 --- /dev/null +++ b/apps/client/src/common/utils/debounce.ts @@ -0,0 +1,12 @@ +export function debounce(callback: () => void, wait: number) { + let timeout: NodeJS.Timeout | null; + return () => { + if (timeout) { + return; + } + timeout = setTimeout(() => { + timeout = null; + callback(); + }, wait); + }; +} diff --git a/apps/client/src/features/operator/Operator.module.scss b/apps/client/src/features/operator/Operator.module.scss index 2974e5f02..87716b92e 100644 --- a/apps/client/src/features/operator/Operator.module.scss +++ b/apps/client/src/features/operator/Operator.module.scss @@ -11,6 +11,7 @@ .operatorEvents { width: 100vw; height: 100vh; + padding-top: 0.25rem; overflow: auto; display: flex; @@ -19,7 +20,7 @@ } .spacer { - min-height: 80vh; + min-height: 95vh; } @mixin block() { diff --git a/apps/client/src/features/operator/Operator.tsx b/apps/client/src/features/operator/Operator.tsx index 91b210382..5012af38a 100644 --- a/apps/client/src/features/operator/Operator.tsx +++ b/apps/client/src/features/operator/Operator.tsx @@ -65,8 +65,10 @@ export default function Operator() { const handleScroll = () => { if (selectedRef && scrollRef) { const selectedRect = selectedRef.current?.getBoundingClientRect(); - if (selectedRect) { - const hasScrolledOutOfThreshold = selectedRect.top < 0 || selectedRect.top > selectedOffset; + const scrollerRect = scrollRef.current?.getBoundingClientRect(); + if (selectedRect && scrollerRect) { + const distanceFromTop = selectedRect.top - scrollerRect.top; + const hasScrolledOutOfThreshold = distanceFromTop < -8 || distanceFromTop > selectedOffset; setLockAutoScroll(hasScrolledOutOfThreshold); } } @@ -100,6 +102,16 @@ export default function Operator() { + +
{data.map((entry) => { if (entry.type === SupportedEvent.Event) { @@ -136,15 +148,6 @@ export default function Operator() {
-
); } diff --git a/apps/client/src/features/operator/follow-button/FollowButton.module.scss b/apps/client/src/features/operator/follow-button/FollowButton.module.scss index cbbdd2240..0ff82c0e0 100644 --- a/apps/client/src/features/operator/follow-button/FollowButton.module.scss +++ b/apps/client/src/features/operator/follow-button/FollowButton.module.scss @@ -3,7 +3,7 @@ .followButton { position: relative; - bottom: 100px; + bottom: 10rem; margin: 0 auto; z-index: 1; @@ -25,12 +25,5 @@ .hidden { transition: bottom 1s; - bottom: -0; -} - -// tablet -@media (min-width: $min-tablet) { - .followButton { - bottom: 150px; - } + bottom: -50px; } diff --git a/apps/client/src/features/operator/status-bar/StatusBar.module.scss b/apps/client/src/features/operator/status-bar/StatusBar.module.scss index d17ee2a62..8143e31c7 100644 --- a/apps/client/src/features/operator/status-bar/StatusBar.module.scss +++ b/apps/client/src/features/operator/status-bar/StatusBar.module.scss @@ -9,15 +9,15 @@ } .statusBar { - position: absolute; - bottom: 0; + position: sticky; + top: 0; width: 100%; background-color: $gray-1350; z-index: 2; padding: 0.5rem 1rem; - border-top: 1px solid $white-10; - box-shadow: $large-bottom-drawer-shadow; + border-bottom: 1px solid $white-10; + box-shadow: $large-top-drawer-shadow; display: grid; grid-template-areas: @@ -50,9 +50,10 @@ .title { grid-area: title; - font-size: 1.5rem; - padding-left: 0.5rem; + font-size: 1rem; + padding-left: 0.25rem; display: none; + line-height: 1.25em; } .startTime { @@ -80,8 +81,8 @@ @media (min-width: $min-tablet) { .statusBar { grid-template-areas: - "playback timer1B timer2B timer3B" - "title timer1A timer2A timer3A"; + "playback timer1B timer2A timer3A" + "title title timer2B timer3B"; row-gap: 0.25rem; column-gap: 2rem; } diff --git a/apps/client/src/features/operator/status-bar/StatusBar.tsx b/apps/client/src/features/operator/status-bar/StatusBar.tsx index dc29e2817..cb75b770f 100644 --- a/apps/client/src/features/operator/status-bar/StatusBar.tsx +++ b/apps/client/src/features/operator/status-bar/StatusBar.tsx @@ -63,16 +63,6 @@ export default function StatusBar(props: StatusBarProps) { return (
- {projectTitle} -
- Scheduled start - {getTimeStart()} -
-
- Scheduled end - {getTimeEnd()} -
- {PlaybackIconComponent}
Time now @@ -86,6 +76,16 @@ export default function StatusBar(props: StatusBarProps) { Running timer {runningTime}
+ + {projectTitle} +
+ Scheduled start + {getTimeStart()} +
+
+ Scheduled end + {getTimeEnd()} +
); } diff --git a/apps/client/src/theme/_v2Styles.scss b/apps/client/src/theme/_v2Styles.scss index b812ae78c..adc90326b 100644 --- a/apps/client/src/theme/_v2Styles.scss +++ b/apps/client/src/theme/_v2Styles.scss @@ -37,6 +37,7 @@ $bg-container-onlight: $gray-100; $box-shadow-l1: rgba(0, 0, 0, 0.15) 0 3px 3px 0; $box-shadow-l2: rgba(0, 0, 0, 0.15) 0 3px 3px 0; $large-bottom-drawer-shadow: rgba(0, 0, 0, 0.35) 0 3px 6px 6px; +$large-top-drawer-shadow: rgba(0, 0, 0, 0.35) 0 1px 6px 3px; $modal-note-color: $gray-700;