Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions app/components/studio/hero-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ const EAGER_PHOTOS = 4;
const tiltedRows = css({
display: 'flex',
flexDirection: 'column',
gap: '6',
w: '[108%]',
ml: '[-4%]',
py: '6',
// With the row padding, 24px around and between the rows.
py: '3',
transform: 'rotate(-3deg)',
// Still rows sit flat and inside the screen.
_motionReduce: { w: 'full', ml: '0', transform: 'none' },
Expand All @@ -50,7 +50,8 @@ const rowsFrame = css({
'[linear-gradient(90deg, transparent 0, black 12%, black 88%, transparent 100%)]',
_motionReduce: { maskImage: '[none]' },
});
const rowList = css({ display: 'flex', gap: '5', pr: '5' });
// The row clips its overflow: the padding leaves room for a lifted card.
const rowList = css({ display: 'flex', gap: '5', pr: '5', py: '3' });
const staticList = css({
display: 'flex',
flexWrap: 'wrap',
Expand All @@ -70,6 +71,11 @@ const memberCard = css({
bg: 'gray.100',
borderRadius: '2xl',
textAlign: 'center',
// The card lifts and tilts a little more on hover (mockup `equipe`). No
// shadow: the row clips its overflow, so it would be cut off.
transitionProperty: 'common',
transitionDuration: 'slow',
_motionSafe: { _hover: { transform: 'translateY(-6px) rotate(-1deg)' } },
});
const cardName = text({ variant: 'display-md-black' });
const cardRole = text({ variant: 'small', color: 'muted' });
Expand Down Expand Up @@ -188,6 +194,8 @@ export function HeroSection({ members }: HeroSectionProps) {
<MarqueeTrack
direction={row.direction}
paused={paused}
// The rows are tilted: a GPU layer would blur them.
painted
renderCopy={({ hidden, className }) => (
<MemberCards
members={row.members}
Expand Down
30 changes: 27 additions & 3 deletions app/components/studio/studio-marquee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,32 @@ import { useTranslation } from 'react-i18next';
import { css, cx } from '@ocobo/styled-system/css';
import { button } from '@ocobo/styled-system/recipes';

/** Copies per track: the `marquee-ultra-slow` keyframes move by a third. */
/**
* Copies per track: the `marquee-ultra-slow` and `marquee-ultra-slow-painted`
* keyframes move by a third.
*/
const COPIES = [0, 1, 2] as const;

const TRACK_CLASS = 'studio-marquee-track';

const track = css({
display: 'flex',
w: 'max',
animation: 'marquee-ultra-slow',
// No motion: the one visible copy fits the width and wraps.
_motionReduce: { animation: '[none]', w: 'full' },
});
// One move per track. The GPU slides the default one.
const slidingTrack = css({ animation: 'marquee-ultra-slow' });
// The repainted one, for a track under a rotated parent. `left` takes its
// percentage from the parent, so a wrapper as wide as the track sits between.
const paintedTrack = css({
position: 'relative',
animation: 'marquee-ultra-slow-painted',
});
const paintedFrame = css({
w: 'max',
_motionReduce: { w: 'full' },
});
// Static literals per direction and state: Panda drops runtime values.
const directionStyles = {
left: css({ animationDirection: 'normal' }),
Expand Down Expand Up @@ -55,6 +69,12 @@ export const marqueeWrapWhenStill = css({
type MarqueeTrackProps = {
direction: 'left' | 'right';
paused: boolean;
/**
* Repaints the row at each frame instead of sliding it on the GPU. Use it
* under a rotated parent: the GPU would draw the row flat, then rotate and
* shift it between pixels, which blurs text and photos.
*/
painted?: boolean;
/**
* Renders one copy of the content. The copies after the first are hidden
* from assistive tech and under reduced motion: they take `className`.
Expand All @@ -69,13 +89,15 @@ type MarqueeTrackProps = {
export function MarqueeTrack({
direction,
paused,
painted = false,
renderCopy,
}: MarqueeTrackProps) {
return (
const row = (
<div
className={cx(
TRACK_CLASS,
track,
painted ? paintedTrack : slidingTrack,
directionStyles[direction],
paused && pausedStyle,
)}
Expand All @@ -89,6 +111,8 @@ export function MarqueeTrack({
))}
</div>
);

return painted ? <div className={paintedFrame}>{row}</div> : row;
}

const pauseStyles = cx(
Expand Down
8 changes: 8 additions & 0 deletions preset/keyframes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ export const keyframes = defineKeyframes({
'0%': { transform: 'translateX(0)' },
'100%': { transform: 'translateX(-33.33%)' },
},
// Same move through `left`, which the browser repaints each frame instead
// of sliding a GPU layer. Under a rotated parent, a GPU layer is drawn flat
// then resampled, which blurs its text and photos (studio hero).
'marquee-ultra-slow-painted': {
'0%': { left: '0' },
// An exact third: a rounded one jumps a fraction of a pixel each loop.
'100%': { left: 'calc(-100% / 3)' },
},
'blueprint-in': {
from: { opacity: '0', transform: 'scaleX(0)' },
to: { opacity: '1', transform: 'scaleX(1)' },
Expand Down
3 changes: 3 additions & 0 deletions preset/tokens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ export const tokens = defineTokens({
'marquee-ultra-slow': {
value: 'marquee-ultra-slow 90s linear infinite',
},
'marquee-ultra-slow-painted': {
value: 'marquee-ultra-slow-painted 90s linear infinite',
},
'blueprint-in': {
value: 'blueprint-in 1s cubic-bezier(0.2, 0.8, 0.2, 1) forwards',
},
Expand Down
Loading