-
Notifications
You must be signed in to change notification settings - Fork 31
Onboarding v4: design feedback round 2 #2440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c4ae2b7
63a4b96
8d8e58b
b59639f
b908a49
e16f0be
131f4b0
093bf0f
f0abb5e
25615c8
fee4e6d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,6 +74,8 @@ function DuckPlayerDefault({ advance }) { | |
| const videosRef = useRef(/** @type {Record<DPTarget, HTMLVideoElement | null>} */ ({ with: null, without: null })); | ||
|
|
||
| const [state, setState] = useState(/** @type {DPState} */ ({ target: 'with', phase: 'initial', reverse: false })); | ||
| const stateRef = useRef(state); | ||
| stateRef.current = state; | ||
|
|
||
| /** @type {(target: DPTarget) => DPTarget} */ | ||
| const flip = (target) => (target === 'with' ? 'without' : 'with'); | ||
|
|
@@ -90,9 +92,11 @@ function DuckPlayerDefault({ advance }) { | |
| } | ||
| video.currentTime = 0; | ||
| try { | ||
| /** @type {Promise<void>} */ | ||
| const frameReady = new Promise((resolve) => video.requestVideoFrameCallback(() => resolve())); | ||
| await video.play(); | ||
| await frameReady; | ||
| } catch (error) { | ||
| // Ignore errors - we can assume that our browsers support playback | ||
| console.error(error); | ||
| } | ||
| }; | ||
|
|
@@ -102,20 +106,20 @@ function DuckPlayerDefault({ advance }) { | |
| if (video) video.currentTime = 0; | ||
| }; | ||
|
|
||
| // Auto-play after bubble entry animation (400ms delay + 267ms duration = 667ms) | ||
| // Auto-play after bottom bubble entry animation (650ms delay + 267ms duration = 917ms) | ||
| useEffect(() => { | ||
| const id = setTimeout( | ||
| () => { | ||
| play(videoFor('with')); | ||
| setState((prev) => ({ ...prev, phase: isReducedMotion ? 'settled' : 'playing' })); | ||
| }, | ||
| isReducedMotion ? 0 : 667, | ||
| isReducedMotion ? 0 : 917, | ||
| ); | ||
| return () => clearTimeout(id); | ||
| }, []); // exclude isReducedMotion from deps — must not re-fire if reduced motion changes after mount | ||
|
|
||
| const toggle = () => { | ||
| const { target, phase, reverse } = state; | ||
| const toggle = async () => { | ||
| const { target, phase, reverse } = stateRef.current; | ||
| if (phase === 'initial') { | ||
| // Queue or cancel a reverse so auto-play will switch to "without" once the "with" video ends | ||
| setState({ target, phase, reverse: !reverse }); | ||
|
|
@@ -124,18 +128,19 @@ function DuckPlayerDefault({ advance }) { | |
| if (!reverse) reset(videoFor(flip(target))); | ||
| setState({ target, phase: 'playing', reverse: !reverse }); | ||
| } else { | ||
| // Settled: switch to the other video | ||
| // Settled: play the other video, wait for its first frame, then switch visibility | ||
| const next = flip(target); | ||
| play(videoFor(next)); | ||
| await play(videoFor(next)); | ||
| setState({ target: next, phase: isReducedMotion ? 'settled' : 'playing', reverse: false }); | ||
| } | ||
| }; | ||
|
|
||
| const end = () => { | ||
| if (state.reverse) { | ||
| // A reverse was queued — play the other video now | ||
noisysocks marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Async toggle/end creates state machine race conditionMedium Severity Making Additional Locations (1) |
||
| const next = flip(state.target); | ||
| play(videoFor(next)); | ||
| const end = async () => { | ||
| const { reverse, target } = stateRef.current; | ||
| if (reverse) { | ||
| // A reverse was queued — play the other video, wait for its first frame, then switch | ||
| const next = flip(target); | ||
| await play(videoFor(next)); | ||
| setState({ target: next, phase: 'playing', reverse: false }); | ||
| } else { | ||
| // No reverse — just settle on the current video | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,8 @@ | |
| position: absolute; | ||
| top: 0; | ||
| left: 0; | ||
| visibility: hidden; | ||
| opacity: 0; | ||
| pointer-events: none; | ||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,9 @@ import { useFlip } from '../hooks/useFlip'; | |
| import cn from 'classnames'; | ||
| import styles from './MakeDefaultContent.module.css'; | ||
|
|
||
| /** @type {string|null} */ | ||
| const bubbleFadeInDelayOverride = new URLSearchParams(window.location.search).get('bubbleFadeInDelay'); | ||
|
|
||
| /** | ||
| * Top bubble content for the makeDefaultSingle step. | ||
| * Shows title (changes after user makes default), comparison table, and Skip/Make Default buttons. | ||
|
|
@@ -78,6 +81,11 @@ export function MakeDefaultContent({ advance, updateSystemValue }) { | |
| })(); | ||
| }; | ||
|
|
||
| const defaultBubbleDelay = 400; | ||
| const defaultOffset = 250; | ||
| const parsedOffset = bubbleFadeInDelayOverride ? Number.parseInt(bubbleFadeInDelayOverride, 10) : defaultOffset; | ||
| const staggerDelay = defaultBubbleDelay + (Number.isNaN(parsedOffset) ? defaultOffset : parsedOffset); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicated stagger delay calculation risks future divergenceLow Severity The stagger delay calculation — parsing Additional Locations (1) |
||
|
|
||
| return ( | ||
| <Container class={styles.root}> | ||
| <div class={styles.titleContainer}> | ||
|
|
@@ -95,17 +103,19 @@ export function MakeDefaultContent({ advance, updateSystemValue }) { | |
| /> | ||
| </div> | ||
|
|
||
| <ComparisonTable /> | ||
| <div class={styles.content} style={{ '--stagger-delay': `${staggerDelay}ms` }}> | ||
| <ComparisonTable /> | ||
|
|
||
| <div class={styles.actions}> | ||
| {skipButtonMounted && ( | ||
| <Button buttonRef={skipButtonRef} class={styles.skipButton} variant="secondary" onClick={advance}> | ||
| {t('skipButton')} | ||
| <div class={styles.actions}> | ||
| {skipButtonMounted && ( | ||
| <Button buttonRef={skipButtonRef} class={styles.skipButton} variant="secondary" onClick={advance}> | ||
| {t('skipButton')} | ||
| </Button> | ||
| )} | ||
| <Button buttonRef={primaryButtonRef} disabled={isPending} onClick={showSkipButton ? enableDefaultBrowser : advance}> | ||
| {showSkipButton ? t('makeDefaultButton') : t('nextButton')} | ||
| </Button> | ||
| )} | ||
| <Button buttonRef={primaryButtonRef} disabled={isPending} onClick={showSkipButton ? enableDefaultBrowser : advance}> | ||
| {showSkipButton ? t('makeDefaultButton') : t('nextButton')} | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| </Container> | ||
| ); | ||
|
|
||


Uh oh!
There was an error while loading. Please reload this page.