Skip to content

Commit ea354ee

Browse files
committed
Add motion and shadow css utilities.
1 parent d86c46e commit ea354ee

5 files changed

Lines changed: 108 additions & 62 deletions

File tree

‎frontend/purestack.studio/guides/utility-css-classes.mdx‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ For grid children, `justify-self-start`, `justify-self-center`, `justify-self-en
190190
| `position-static`, `position-relative`, `position-absolute`, `position-fixed`, `position-sticky` | Set CSS positioning. |
191191
| `ws-normal`, `ws-nowrap`, `ws-pre-wrap` | Set `white-space`. |
192192
| `cursor-pointer`, `col-resize` | Set pointer or column-resize cursor. |
193-
| `bg-none`, `box-shadow-none` | Remove a background or box shadow. |
193+
| `bg-none` | Remove a background. |
194194

195195
`auto-fit` is a specialized width utility that sets `width: 1%`; it is not a CSS Grid `auto-fit` track rule. Use it only when that width behavior is intended.
196196

@@ -210,6 +210,33 @@ Append `-hover` to a border width, style, or color utility for its hover-only ve
210210

211211
Opacity classes are `opacity-0`, `opacity-25`, `opacity-50`, `opacity-75`, and `opacity-1`, for `0`, `0.25`, `0.5`, `0.75`, and full opacity. Each also has a `-hover` form, such as `opacity-1-hover`. The value `1` means fully opaque, not one percent.
212212

213+
## Shadows and hover motion
214+
215+
Shadow classes read the theme's effect tokens, so depth follows the skin and its presets. Each has a `-hover` form, and `box-shadow-none` removes a shadow, including a component's own.
216+
217+
| Class | Effect |
218+
| --- | --- |
219+
| `box-shadow-panel`, `box-shadow-panel-strong` | The panel shadow and its stronger form. |
220+
| `box-shadow-soft`, `box-shadow-strong` | A soft or a deep neutral shadow. |
221+
| `box-shadow-interactive` | A small shadow for controls. |
222+
| `box-shadow-floating` | A lifted card. |
223+
| `box-shadow-accent` | A glow tinted with the accent color. |
224+
| `box-shadow-inset` | A recessed surface. |
225+
226+
| Class | Effect |
227+
| --- | --- |
228+
| `lift-1`, `lift-2` | Raise an element by `2px` or `4px`. Use the `-hover` form for hover feedback. |
229+
| `nudge-hover` | On hover, slides a row's children inward by `0.5rem`. |
230+
| `transition` | Animates background, border color, shadow, color, and transform changes. |
231+
232+
Combine them for hover feedback without custom CSS. Transitions and the nudge stop when the visitor prefers reduced motion:
233+
234+
```mdx
235+
<a href="/guide/" class="b-1 b-subtle b-tone-hover rounded-lg p-4 transition lift-2-hover box-shadow-floating-hover">
236+
Read the guide
237+
</a>
238+
```
239+
213240
## Semantic tone classes
214241

215242
Tone classes let plain markup use the same palette roles as components. `tone--info` selects a palette; `tone-fill-surface`, `tone-border-surface`, and `tone-text-surface` paint from it. The [Semantic tone classes guide](/guides/semantic-tones/) has a visual gallery of every tone, side-by-side role comparisons, and interactive state examples.

‎packages/ts-ssg/sample-content/home.css‎

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,7 @@
9292
gap: 1.4rem;
9393
}
9494
.wp-home-links a {
95-
color: var(--ps-current-text-subtle);
9695
font-size: 0.84rem;
97-
font-weight: 700;
98-
white-space: nowrap;
99-
}
100-
.wp-home-links a:hover {
101-
color: var(--ps-current-tone);
10296
}
10397

10498
/* Hero. */
@@ -123,25 +117,14 @@
123117
padding: 0.85rem 1.15rem;
124118
font-size: 0.94rem;
125119
line-height: 1.2;
126-
/* The BtnLink variant sets the theme radius; Waypoint buttons are rounder. */
127-
border-radius: 0.65rem !important;
128120
font-weight: 750;
129121
}
130-
.wp-cta:hover {
131-
transform: translateY(-2px);
132-
}
133122
/* Trim the icon's side bearing so the arrow sits like a text glyph. */
134123
.wp-cta .icon {
135124
width: 1.2rem;
136125
height: 1.2rem;
137126
margin-inline: -0.17rem;
138127
}
139-
.wp-cta-primary {
140-
box-shadow: 0 12px 28px rgba(18, 64, 91, 0.2);
141-
}
142-
.wp-cta-primary:hover {
143-
box-shadow: 0 16px 32px rgba(18, 64, 91, 0.27);
144-
}
145128
.wp-disclosure {
146129
margin: 1.35rem 0 0;
147130
font-size: 0.78rem;
@@ -299,13 +282,6 @@
299282
.wp-step {
300283
gap: 1.35rem;
301284
padding: 1.5rem 0.3rem;
302-
transition:
303-
padding 0.2s ease,
304-
background 0.2s ease;
305-
}
306-
.wp-step:hover {
307-
padding-left: 0.9rem;
308-
background: var(--ps-current-surface-rest-background);
309285
}
310286
.wp-step-number {
311287
padding-top: 0.25rem;
@@ -419,17 +395,8 @@
419395
.wp-explore-card {
420396
min-height: 11.5rem;
421397
padding: 1.6rem;
422-
border-radius: 0.9rem;
423-
transition:
424-
transform 0.2s ease,
425-
border-color 0.2s ease,
426-
box-shadow 0.2s ease;
427398
--wp-kicker-size: 0.62rem;
428399
}
429-
.wp-explore-card:hover {
430-
transform: translateY(-4px);
431-
box-shadow: 0 16px 28px rgba(16, 60, 83, 0.11);
432-
}
433400
.wp-explore-card strong {
434401
margin-top: 1.4rem;
435402
font-size: 1.45rem;
@@ -538,11 +505,4 @@
538505
gap: clamp(2.5rem, 8vw, 8rem);
539506
}
540507
}
541-
@media (prefers-reduced-motion: reduce) {
542-
.wp-cta,
543-
.wp-step,
544-
.wp-explore-card {
545-
transition: none;
546-
}
547-
}
548508
}

‎packages/ts-ssg/sample-content/index.mdx‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ nav:
1818
<Flex container="nav" align="center" justify="between" class="wp-home-nav gap-6 bb-1 b-subtle" aria-label="Explore Waypoint">
1919
<span class="wp-kicker tone-text ws-nowrap hidden-md">Explore Waypoint</span>
2020
<Flex align="center" class="wp-home-links">
21-
<a href="/platform/">Platform</a>
22-
<a href="/workspace/">Workspace</a>
23-
<a href="/pricing/">Plans</a>
24-
<a href="/guide/">Starter guide</a>
21+
<a href="/platform/" class="text-subtle mb-0 tone-text-hover fw-700 ws-nowrap">Platform</a>
22+
<a href="/workspace/" class="text-subtle mb-0 tone-text-hover fw-700 ws-nowrap">Workspace</a>
23+
<a href="/pricing/" class="text-subtle mb-0 tone-text-hover fw-700 ws-nowrap">Plans</a>
24+
<a href="/guide/" class="text-subtle mb-0 tone-text-hover fw-700 ws-nowrap">Starter guide</a>
2525
</Flex>
2626
</Flex>
2727
<Grid container="section" columns="1" columnsLg="minmax(0, 0.83fr) minmax(0, 1.17fr)" alignItems="center" class="wp-hero" aria-labelledby="wp-hero-title">
@@ -30,8 +30,8 @@ nav:
3030
<h1 id="wp-hero-title" class="wp-display">Make every next step <span class="tone-text">clear.</span></h1>
3131
<p class="wp-hero-lead text-subtle">A shared home for plans, progress, and decisions. Give your team the context to move forward together.</p>
3232
<Flex direction="column" directionSm="row" wrap="true" class="wp-actions">
33-
<BtnLink href="/workspace/" icon="lucide:arrow-up-right" iconPosition="end" class="wp-cta wp-cta-primary">Explore the workspace</BtnLink>
34-
<BtnLink href="/guide/getting-started/" icon="lucide:arrow-right" iconPosition="end" variant="surface" class="wp-cta">Adapt this starter</BtnLink>
33+
<BtnLink href="/workspace/" icon="lucide:arrow-up-right" iconPosition="end" class="wp-cta box-shadow-accent lift-1-hover">Explore the workspace</BtnLink>
34+
<BtnLink href="/guide/getting-started/" icon="lucide:arrow-right" iconPosition="end" variant="surface" class="wp-cta lift-1-hover">Adapt this starter</BtnLink>
3535
</Flex>
3636
<p class="wp-disclosure text-subtle">An illustrative product and workspace, built with PureStack.</p>
3737
</div>
@@ -93,9 +93,9 @@ nav:
9393
titleClass="wp-section-title"
9494
subtitleClass="wp-section-lead"/>
9595
<div class="bt-1 b-subtle">
96-
<Grid container="a" href="/platform/" columns="2rem minmax(0, 1fr) 1.2rem" alignItems="start" class="wp-step bb-1 b-subtle"><span class="wp-step-number tone-text">01</span><Flex container="span" direction="column" class="wp-step-copy"><strong>Set the direction</strong><small>Give every initiative a purpose, owner, and meaningful milestones.</small></Flex><Icon name="lucide:arrow-up-right" class="wp-arrow tone-text" aria-hidden="true"/></Grid>
97-
<Grid container="a" href="/workspace/" columns="2rem minmax(0, 1fr) 1.2rem" alignItems="start" class="wp-step bb-1 b-subtle"><span class="wp-step-number tone-text">02</span><Flex container="span" direction="column" class="wp-step-copy"><strong>See the progress</strong><small>Bring updates, status, and the next review into one shared view.</small></Flex><Icon name="lucide:arrow-up-right" class="wp-arrow tone-text" aria-hidden="true"/></Grid>
98-
<Grid container="a" href="/journal/weekly-review/" columns="2rem minmax(0, 1fr) 1.2rem" alignItems="start" class="wp-step bb-1 b-subtle"><span class="wp-step-number tone-text">03</span><Flex container="span" direction="column" class="wp-step-copy"><strong>Share the learning</strong><small>Turn the week's work into a short, useful story for everyone.</small></Flex><Icon name="lucide:arrow-up-right" class="wp-arrow tone-text" aria-hidden="true"/></Grid>
96+
<Grid container="a" href="/platform/" columns="2rem minmax(0, 1fr) 1.2rem" alignItems="start" class="wp-step bb-1 b-subtle transition nudge-hover tone-fill-glass-hover"><span class="wp-step-number tone-text">01</span><Flex container="span" direction="column" class="wp-step-copy"><strong>Set the direction</strong><small>Give every initiative a purpose, owner, and meaningful milestones.</small></Flex><Icon name="lucide:arrow-up-right" class="wp-arrow tone-text" aria-hidden="true"/></Grid>
97+
<Grid container="a" href="/workspace/" columns="2rem minmax(0, 1fr) 1.2rem" alignItems="start" class="wp-step bb-1 b-subtle transition nudge-hover tone-fill-glass-hover"><span class="wp-step-number tone-text">02</span><Flex container="span" direction="column" class="wp-step-copy"><strong>See the progress</strong><small>Bring updates, status, and the next review into one shared view.</small></Flex><Icon name="lucide:arrow-up-right" class="wp-arrow tone-text" aria-hidden="true"/></Grid>
98+
<Grid container="a" href="/journal/weekly-review/" columns="2rem minmax(0, 1fr) 1.2rem" alignItems="start" class="wp-step bb-1 b-subtle transition nudge-hover tone-fill-glass-hover"><span class="wp-step-number tone-text">03</span><Flex container="span" direction="column" class="wp-step-copy"><strong>Share the learning</strong><small>Turn the week's work into a short, useful story for everyone.</small></Flex><Icon name="lucide:arrow-up-right" class="wp-arrow tone-text" aria-hidden="true"/></Grid>
9999
</div>
100100
</Grid>
101101
<Panel tone="accent" variant="spotlight" class="wp-brief theme--dark rounded-lg" aria-labelledby="wp-brief-title">
@@ -132,9 +132,9 @@ nav:
132132
<p class="wp-explore-summary text-subtle">One visual language can carry a product story, a working preview, and the guide behind it.</p>
133133
</Flex>
134134
<Grid columns="1" columnsMd="3" class="gap-4">
135-
<Flex container="a" href="/platform/" direction="column" class="wp-explore-card position-relative gap-0 b-1 b-subtle b-tone-hover tone-fill-surface"><span class="wp-kicker tone-text">01 / THE STORY</span><strong>Platform</strong><span>Discover the workflow and how it supports a team.</span><Icon name="lucide:arrow-up-right" class="wp-arrow position-absolute tone-text" aria-hidden="true"/></Flex>
136-
<Flex container="a" href="/workspace/" direction="column" class="wp-explore-card position-relative gap-0 b-1 b-subtle b-tone-hover tone-fill-surface"><span class="wp-kicker tone-text">02 / THE PRODUCT</span><strong>Workspace</strong><span>Explore project status, charts, and decisions in context.</span><Icon name="lucide:arrow-up-right" class="wp-arrow position-absolute tone-text" aria-hidden="true"/></Flex>
137-
<Flex container="a" href="/guide/" direction="column" class="wp-explore-card position-relative gap-0 b-1 b-subtle b-tone-hover tone-fill-surface"><span class="wp-kicker tone-text">03 / THE FOUNDATION</span><strong>Starter guide</strong><span>Find the files, components, and settings to make it yours.</span><Icon name="lucide:arrow-up-right" class="wp-arrow position-absolute tone-text" aria-hidden="true"/></Flex>
135+
<Flex container="a" href="/platform/" direction="column" class="wp-explore-card position-relative gap-0 b-1 rounded-lg b-subtle b-tone-hover tone-fill-surface transition lift-2-hover box-shadow-floating-hover"><span class="wp-kicker tone-text">01 / THE STORY</span><strong>Platform</strong><span>Discover the workflow and how it supports a team.</span><Icon name="lucide:arrow-up-right" class="wp-arrow position-absolute tone-text" aria-hidden="true"/></Flex>
136+
<Flex container="a" href="/workspace/" direction="column" class="wp-explore-card position-relative gap-0 b-1 rounded-lg b-subtle b-tone-hover tone-fill-surface transition lift-2-hover box-shadow-floating-hover"><span class="wp-kicker tone-text">02 / THE PRODUCT</span><strong>Workspace</strong><span>Explore project status, charts, and decisions in context.</span><Icon name="lucide:arrow-up-right" class="wp-arrow position-absolute tone-text" aria-hidden="true"/></Flex>
137+
<Flex container="a" href="/guide/" direction="column" class="wp-explore-card position-relative gap-0 b-1 rounded-lg b-subtle b-tone-hover tone-fill-surface transition lift-2-hover box-shadow-floating-hover"><span class="wp-kicker tone-text">03 / THE FOUNDATION</span><strong>Starter guide</strong><span>Find the files, components, and settings to make it yours.</span><Icon name="lucide:arrow-up-right" class="wp-arrow position-absolute tone-text" aria-hidden="true"/></Flex>
138138
</Grid>
139139
<p class="wp-explore-more text-subtle">Looking for the plan layout? <a href="/pricing/" class="wp-inline-link tone-text underline-hover">Explore example pricing <Icon name="lucide:arrow-right" aria-hidden="true"/></a></p>
140140
</section>
@@ -147,6 +147,6 @@ nav:
147147
eyebrowClass="wp-eyebrow"
148148
titleClass="wp-section-title wp-title-wide wp-final-title"
149149
subtitleClass="wp-final-lead"/>
150-
<BtnLink href="/guide/getting-started/" icon="lucide:arrow-up-right" iconPosition="end" class="wp-cta wp-cta-primary flex-none">Read the getting started guide</BtnLink>
150+
<BtnLink href="/guide/getting-started/" icon="lucide:arrow-up-right" iconPosition="end" class="wp-cta box-shadow-accent lift-1-hover flex-none">Read the getting started guide</BtnLink>
151151
</Flex>
152152
</div>

‎packages/ts-style/src/semanticPresets.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ function spotlightLight(current: ThemePaletteCurrent, reach: string) {
4242
return `radial-gradient(circle at var(${SPOTLIGHT_FROM_VAR}, ${SPOTLIGHT_FROM['top-left']}), ${current.spotlight.light} 0%, transparent ${reach})`
4343
}
4444

45-
function glassVeil(current: ThemePaletteCurrent) {
46-
return `color-mix(in srgb, ${current.spotlight.light} 45%, transparent)`
45+
function glass(current: ThemePaletteCurrent) {
46+
const veil = `color-mix(in srgb, ${current.spotlight.light} 45%, transparent)`
47+
return `${spotlightLight(current, '75%')}, linear-gradient(${veil}, ${veil})`
4748
}
4849

4950
function createSpotlightOrigins(styleBuilder: StyleBuilder, theme: string) {
@@ -200,9 +201,8 @@ function createFills(
200201
// Glass lets the field behind show through, lifted by a veil and lit by
201202
// the same light, so cards sit on a spotlight without a second color.
202203
'tone-fill-glass': {
203-
rest: {
204-
background: `${spotlightLight(current, '75%')}, linear-gradient(${glassVeil(current)}, ${glassVeil(current)})`,
205-
},
204+
rest: { background: glass(current) },
205+
hover: { background: glass(current) },
206206
},
207207
'tone-fill-surface': {
208208
all: true,

‎packages/ts-style/src/utilities.ts‎

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ export function registerUtilityStyles() {
6969
applyFontSizeUtilities(theme, palette)
7070
applyFontWeightUtilities(theme)
7171
applyLineHeightUtilities(theme)
72-
applyShadowUtilities(theme)
72+
applyShadowUtilities(theme, palette)
73+
applyMotionUtilities(theme)
7374
})
7475
}
7576

@@ -347,8 +348,66 @@ function applyRadiusUtility(theme: string, name: string, value: string) {
347348
.borderBottomLeftRadius(radius)
348349
}
349350

350-
function applyShadowUtilities(theme: string) {
351-
styleBuilder.select('.box-shadow-none', theme).boxShadow(force('none'))
351+
/** Shadows read the theme's effect tokens, so depth follows the skin. */
352+
const SHADOW_UTILITIES = {
353+
panel: 'panelShadow',
354+
'panel-strong': 'panelShadowStrong',
355+
soft: 'softShadow',
356+
interactive: 'interactiveShadow',
357+
floating: 'floatingShadow',
358+
strong: 'strongShadow',
359+
accent: 'accentShadow',
360+
inset: 'insetShadow',
361+
} as const satisfies Record<string, keyof ThemePalette['effect']>
362+
363+
function applyShadowUtilities(theme: string, palette: ThemePalette) {
364+
styleBuilder
365+
.select(withHover('box-shadow-none'), theme)
366+
.boxShadow(force('none'))
367+
for (const [name, effect] of Object.entries(SHADOW_UTILITIES)) {
368+
styleBuilder
369+
.select(withHover(`box-shadow-${name}`), theme)
370+
.boxShadow(force(palette.effect[effect]))
371+
}
372+
}
373+
374+
const LIFT_UTILITIES = {
375+
1: '-2px',
376+
2: '-4px',
377+
} as const
378+
379+
const MOTION = '180ms ease'
380+
381+
/**
382+
* Motion for hover feedback. lift-* raises an element, nudge-hover slides a
383+
* row's content inward, and transition animates the paint and position
384+
* changes the other utilities make. All of it stops for reduced motion.
385+
*/
386+
function applyMotionUtilities(theme: string) {
387+
for (const [name, offset] of Object.entries(LIFT_UTILITIES)) {
388+
styleBuilder
389+
.select(withHover(`lift-${name}`), theme)
390+
.transform(force(`translateY(${offset})`))
391+
}
392+
393+
styleBuilder
394+
.select('.transition', theme)
395+
.transition(
396+
['background', 'border-color', 'box-shadow', 'color', 'transform']
397+
.map((property) => `${property} ${MOTION}`)
398+
.join(', '),
399+
)
400+
styleBuilder
401+
.select('.nudge-hover > *', theme)
402+
.transition(`transform ${MOTION}`)
403+
styleBuilder
404+
.select('.nudge-hover:hover > *', theme)
405+
.transform('translateX(0.5rem)')
406+
407+
styleBuilder
408+
.select('.transition, .nudge-hover > *', theme)
409+
.media('prefers-reduced-motion: reduce')
410+
.transition(force('none'))
352411
}
353412

354413
function force(val: string) {

0 commit comments

Comments
 (0)