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
24 changes: 16 additions & 8 deletions app/components/ClientCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ASSETS_BASE_URL } from '~/config/assets';

import { OptimizedImage } from './ui/optimized-image';

import { usePrefersReducedMotion } from '~/hooks/use-prefers-reduced-motion';
import { useWindowSize } from '~/hooks/useWindowSize';

const items = [
Expand Down Expand Up @@ -91,6 +92,9 @@ const ClientCarousel: React.FunctionComponent<{
}> = ({ shouldDisplayTitle }) => {
const { t } = useTranslation('common');
const browserWidth = useWindowSize();
// The CSS reduced motion rule cannot reach framer-motion: the logos stand
// still at their start position instead of looping.
const reducedMotion = usePrefersReducedMotion();

const slideWidth = useMemo(
() => (itemWidth * items.length + itemGap * (items.length + 1)) * 2,
Expand Down Expand Up @@ -144,14 +148,18 @@ const ClientCarousel: React.FunctionComponent<{
w: 'auto',
px: '4',
})}
animate={{
x: [0, -delta + 'px'],
transition: {
ease: 'linear',
duration: delta / 15,
repeat: Infinity,
},
}}
animate={
reducedMotion
? { x: 0, transition: { duration: 0 } }
: {
x: [0, -delta + 'px'],
transition: {
ease: 'linear',
duration: delta / 15,
repeat: Infinity,
},
}
}
>
{duplicateItems.map((item, i) => (
<li
Expand Down
10 changes: 8 additions & 2 deletions app/components/about/data-illustration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import { css, cx } from '@ocobo/styled-system/css';
import { flex } from '@ocobo/styled-system/patterns';
import { card, text } from '@ocobo/styled-system/recipes';

// Under reduced motion the cursor rests on the loop's first frame: without
// it, the SVG `transform` attributes apply and the arrow is clipped (#316).
const cursorAtRest = css({
_motionReduce: { transform: 'translate(430px, 430px) rotate(-10deg)' },
});

export const DataIllustration = () => {
const { t } = useTranslation('about');

Expand Down Expand Up @@ -138,7 +144,7 @@ export const DataIllustration = () => {

<g
transform="translate(485, 460)"
className={css({ animation: 'float-cursor' })}
className={cx(css({ animation: 'float-cursor' }), cursorAtRest)}
>
<circle
cx="0"
Expand All @@ -165,7 +171,7 @@ export const DataIllustration = () => {
transform="translate(470, 455) scale(1.2)"
d="M0,0 L25,40 L10,35 L0,55 Z"
fill="currentColor"
className={css({ animation: 'float-cursor' })}
className={cx(css({ animation: 'float-cursor' }), cursorAtRest)}
/>
</svg>
</div>
Expand Down
2 changes: 2 additions & 0 deletions app/components/navbar-v2/nav-disclosure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ export function NavDisclosure({
<div
id={panelId}
data-state={isOpen ? 'open' : 'closed'}
// Keeps its fade under reduced motion: out of the global rule.
data-motion-own=""
// Visibility, not `hidden`, so the panel can fade out. `inert` takes
// a closing panel out of reach at once: no pointer, focus or reader.
style={{ visibility: isOpen ? 'visible' : 'hidden' }}
Expand Down
1 change: 1 addition & 0 deletions docs/development/j1-route-review-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ These come from the preset and show up everywhere. Check them once on Home, then
| Decorative blurs: 32px and 48px both become 40px (`2xl`) (#217) | |
| Transitions that used `ease` or `ease-in-out` take the Panda default curve, cubic-bezier(0.4, 0, 0.2, 1); durations unchanged. Includes every `button` hover and its arrow (#217) | |
| Transitions written for one or two properties now use the `colors` or `common` preset, which animates a wider property set (team member card, team photo corners, contact inputs and button, design system tokens block) (#217) | |
| Under reduced motion (`prefers-reduced-motion: reduce`), animations last 0ms and transitions are instant: nothing loops or floats, entrance content shows at once, loops rest on their element's own style. Transition delays stay. The navbar panel keeps its fade through `data-motion-own`. About us: the illustration cursor rests on its first frame. With reduced motion off, nothing changes (#316) | |

## Routes

Expand Down
22 changes: 22 additions & 0 deletions preset/global-css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,28 @@ export const globalCss = defineGlobalStyles({
textDecoration: 'none',
},

// Reduced motion (#316). The v1 illustrations loop and float without
// reading the visitor setting. Under `prefers-reduced-motion: reduce`,
// animations last 0ms and run once: entrance animations, which all fill
// `forwards`, show their end frame at once, so content that starts at
// `opacity: 0` still shows; loops rest on the element's own style.
// Transitions are instant. Transition delays stay: a delay moves nothing,
// and the page dimming on navigation relies on one to skip fast loads.
// `!important` is required: in the base layer it wins over the atomic
// utilities, where the animations are declared, and over inline styles.
// A 0ms transition never fires `transitionend`: do not wait on it.
// An element that sets its own reduced motion behaviour, such as a fade,
// opts out with the `data-motion-own` attribute (its children do not).
'*:not([data-motion-own]), *:not([data-motion-own])::before, *:not([data-motion-own])::after':
{
_motionReduce: {
animationDuration: 'instant !important',
animationDelay: 'instant !important',
animationIterationCount: '1 !important',
transitionDuration: 'instant !important',
},
},

'::selection': {
backgroundColor: 'yellow',
color: 'dark',
Expand Down
8 changes: 0 additions & 8 deletions preset/keyframes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ export const keyframes = defineKeyframes({
from: { height: 'var(--height)' }, // Ark UI provides --height CSS variable
to: { height: 0 },
},
slide: {
'0%': { left: 0 },
'100%': { left: '-100%' },
},
scaleProgress: {
'0%': { transform: 'scaleX(0)' },
'100%': { transform: 'scaleX(1)' },
},
'float-cursor': {
'0%, 100%': { transform: 'translate(430px, 430px) rotate(-10deg)' },
'50%': { transform: 'translate(440px, 420px) rotate(-5deg)' },
Expand Down
Loading