Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat(thumbnail): remove the elevation prop (#4344)

Kenton Quatman2061d8bfd0d9
diff --git a/.changeset/elevation-prop-configurable-surfaces.md b/.changeset/elevation-prop-configurable-surfaces.md
index 2bd2bd0ab6..c8bb894434 100644
--- a/.changeset/elevation-prop-configurable-surfaces.md
+++ b/.changeset/elevation-prop-configurable-surfaces.md
@@ -2,6 +2,6 @@
'@astryxdesign/core': patch
---
-[feat] Add an `elevation` prop to configurable surfaces — Card, ClickableCard, SelectableCard, Button, IconButton, ButtonGroup, Thumbnail, and Banner take the full `'none' | 'low' | 'med' | 'high'` scale; ChatComposer takes `'none' | 'low'`. Defaults preserve today's appearance (`none` everywhere except ChatComposer's `low`), so nothing changes unless you opt in. (#4146)
+[feat] Add an `elevation` prop to configurable surfaces — Card, ClickableCard, SelectableCard, Button, IconButton, ButtonGroup, and Banner take the full `'none' | 'low' | 'med' | 'high'` scale; ChatComposer takes `'none' | 'low'`. Defaults preserve today's appearance (`none` everywhere except ChatComposer's `low`), so nothing changes unless you opt in. (#4146)
@kentonquatman
diff --git a/apps/storybook/stories/Thumbnail.stories.tsx b/apps/storybook/stories/Thumbnail.stories.tsx
index c3a2a53bde..caac34ef76 100644
--- a/apps/storybook/stories/Thumbnail.stories.tsx
+++ b/apps/storybook/stories/Thumbnail.stories.tsx
@@ -25,11 +25,6 @@ const meta: Meta<typeof Thumbnail> = {
control: 'boolean',
description: 'Whether the thumbnail is disabled',
},
- elevation: {
- control: 'inline-radio',
- options: ['none', 'low', 'med', 'high'],
- description: 'Resting shadow depth',
- },
},
};
diff --git a/packages/cli/docs/elevation.doc.mjs b/packages/cli/docs/elevation.doc.mjs
index 767d5b8945..783bf4f753 100644
--- a/packages/cli/docs/elevation.doc.mjs
+++ b/packages/cli/docs/elevation.doc.mjs
@@ -56,7 +56,7 @@ export const docs = {
[
'low',
'The component is in the normal page flow but should read as distinct from the background. Use for emphasis or to separate the component from the surface behind it — the component still sits on the page, it is not floating over other content.',
- 'A raised Card that needs emphasis, a ChatComposer, a resting Thumbnail',
+ 'A raised Card that needs emphasis, a ChatComposer',
],
[
'med',
@@ -82,11 +82,11 @@ export const docs = {
content: [
{
type: 'prose',
- text: 'Configurable surfaces expose a single `elevation` prop instead of asking consumers to hand-write a box-shadow. It takes the graded enum `none | low | med | high`, narrowed per component to the steps that surface needs: Card, ClickableCard, SelectableCard, Button, IconButton, ButtonGroup, Thumbnail, and Banner expose the full scale, while ChatComposer exposes only `none | low`. `none` is a flat literal (`box-shadow: none`); the other levels map to the `--shadow-*` tokens above, so a surface stays theme-agnostic.',
+ text: 'Configurable surfaces expose a single `elevation` prop instead of asking consumers to hand-write a box-shadow. It takes the graded enum `none | low | med | high`, narrowed per component to the steps that surface needs: Card, ClickableCard, SelectableCard, Button, IconButton, ButtonGroup, and Banner expose the full scale, while ChatComposer exposes only `none | low`. `none` is a flat literal (`box-shadow: none`); the other levels map to the `--shadow-*` tokens above, so a surface stays theme-agnostic.',
},
{
type: 'prose',
- text: 'Prop defaults preserve current appearance: every surface defaults to `none` except ChatComposer, which defaults to `low` to keep its raised look. Set `elevation="none"` to flatten it — the flat composer draws a border with the same rest / hover / focus treatment as a text input. Thumbnail keeps its existing hover-only shadow at the `none` default.',
+ text: 'Prop defaults preserve current appearance: every surface defaults to `none` except ChatComposer, which defaults to `low` to keep its raised look. Set `elevation="none"` to flatten it — the flat composer draws a border with the same rest / hover / focus treatment as a text input.',
},
{
type: 'code',
diff --git a/packages/cli/templates/blocks/components/Thumbnail/ThumbnailElevated.doc.mjs b/packages/cli/templates/blocks/components/Thumbnail/ThumbnailElevated.doc.mjs
deleted file mode 100644
index af530a89f5..0000000000
--- a/packages/cli/templates/blocks/components/Thumbnail/ThumbnailElevated.doc.mjs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-/** @type {import('../../../../../core/src/docs-types').TemplateDoc} */
-export const doc = {
- type: 'block',
- exampleFor: 'Thumbnail',
- name: 'Thumbnail — Elevated',
- displayName: 'Thumbnail — Elevated',
- description:
- 'Image tiles raised at rest with `elevation`. The default keeps the existing hover-only shadow; a set level lifts the tile off the page.',
- isReady: true,
- aspectRatio: 16 / 9,
- componentsUsed: ['Thumbnail', 'Layout', 'Text'],
-};
diff --git a/packages/cli/templates/blocks/components/Thumbnail/ThumbnailElevated.tsx b/packages/cli/templates/blocks/components/Thumbnail/ThumbnailElevated.tsx
deleted file mode 100644
index 08b9bcf5a9..0000000000
--- a/packages/cli/templates/blocks/components/Thumbnail/ThumbnailElevated.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-'use client';
-
-import {Thumbnail} from '@astryxdesign/core/Thumbnail';
-import {Stack} from '@astryxdesign/core/Layout';
-import {Text} from '@astryxdesign/core/Text';
-
-// Demo imagery is inlined as same-origin data URIs so the example is
-// self-contained. Thumbnail's remove-button overlay uses useImageMode, which
-// FETCHES the image to sample pixels (APCA) for contrast — a cross-origin CDN
-// URL without CORS headers cannot be sampled, so contrast detection fails
-// silently in hosted previews.
-const NIGHT_FOREST =
- 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAAAwFBMVEX18+H08uDy8d/y8N/v7t/m5NXl49Tk4tPc3NDX1cnW1cnW1cjW1MjV1MjV1MfR0cXIyLzEw7m8vLC3t68wM0QvM0MvM0IvMkIuMkEtMEErLz8iJjkhJTggJTcgJDcfJDYfIzYeIjUcITMbHzIWHiwYGzIXGjEWGjAWGTAVGS8VGC8UGC4UGC0UFy4TFy0TFywTFi0SFiwRFSsQFSkNFR4QFCoPFCkPFCgPEykOEygOEigNEicNEScMESYIDw8ECgr+gzZIAAABqElEQVR42uWQ61aCQBRGD5GylNBMKS9FZgNdNE0cyUvB+79VM8MoF9Fgplau2j/8nO8c9hqAD0ngDwjeJYH1lrfBWoCtYDboNu/Zv7qQYNap1bpCN1gxFh1dNe5WAsCSc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2slbGBciHZ9hOE2smNpTuxenhieCdeH06E7qTqvYnImWTbbUSPlKL1wHrgTwZ+AWq+3H5MpRkwAAAAAElFTkSuQmCC';
-
-export default function ThumbnailElevated() {
- return (
- <Stack direction="vertical" gap={3}>
- <Text type="supporting" color="secondary">
- Raised tiles — `elevation` lifts an image off the page at rest
- </Text>
- <Stack direction="horizontal" gap={3} vAlign="center">
- <Thumbnail src={NIGHT_FOREST} alt="Forest at night" elevation="low" />
- <Thumbnail src={GOLDEN_SUNSET} alt="Golden sunset" elevation="high" />
- </Stack>
- </Stack>
- );
-}
diff --git a/packages/core/src/Thumbnail/Thumbnail.doc.mjs b/packages/core/src/Thumbnail/Thumbnail.doc.mjs
index f30408c089..850758787c 100644
--- a/packages/core/src/Thumbnail/Thumbnail.doc.mjs
+++ b/packages/core/src/Thumbnail/Thumbnail.doc.mjs
@@ -45,13 +45,6 @@ export const docs = {
description: 'Whether the thumbnail is disabled.',
default: 'false',
},
- {
- name: 'elevation',
- type: "'none' | 'low' | 'med' | 'high'",
- description:
- 'Resting shadow depth. `none` (the default) keeps the existing hover-only shadow; set a level to raise the tile at rest.',
- default: "'none'",
- },
{
name: 'xstyle',
type: 'StyleXStyles',
@@ -108,7 +101,6 @@ export const docsZh = {
onClick: '\u70B9\u51FB\u5904\u7406\u5668\u3002\u6DFB\u52A0\u6309\u94AE\u8BED\u4E49\u548C\u60AC\u505C\u9634\u5F71\u3002',
isLoading: '\u663E\u793A\u9AA8\u67B6\u5C4F\uFF08\u65E0 src\uFF09\u6216\u4E0A\u4F20\u8986\u76D6\u5C42\uFF08\u6709 src\uFF09\u3002',
isDisabled: '\u662F\u5426\u7981\u7528\u7F29\u7565\u56FE\u3002',
- elevation: '\u9759\u6B62\u9634\u5F71\u6DF1\u5EA6\uFF1Anone\uFF08\u9ED8\u8BA4\uFF0C\u4FDD\u7559\u4EC5\u60AC\u505C\u9634\u5F71\uFF09| low | med | high\u3002',
xstyle: '\u7528\u4E8E\u5E03\u5C40\u81EA\u5B9A\u4E49\u7684 StyleX \u6837\u5F0F\u3002\u5FC5\u987B\u662F stylex.create() \u7684\u503C\uFF0C\u800C\u975E\u5185\u8054\u6837\u5F0F\u5BF9\u8C61\u3002',
className: '\u6839\u5143\u7D20\u7684 CSS \u7C7B\u540D\u3002\u5EFA\u8BAE\u4F7F\u7528 xstyle\u3002',
style: '\u6839\u5143\u7D20\u7684\u5185\u8054\u6837\u5F0F\u3002\u5EFA\u8BAE\u4F7F\u7528 xstyle\u3002',
@@ -149,7 +141,6 @@ export const docsDense = {
onClick: '(e) => void. Adds button semantics + hover shadow.',
isLoading: 'Skeleton (no src) or upload overlay (with src). Default: false.',
isDisabled: 'Disabled state. Default: false.',
- elevation: 'Resting shadow depth: none (keeps hover-only shadow) | low | med | high.',
xstyle: 'stylex.create() for layout.',
className: 'CSS class. Prefer xstyle.',
style: 'Inline styles. Prefer xstyle.',
diff --git a/packages/core/src/Thumbnail/Thumbnail.test.tsx b/packages/core/src/Thumbnail/Thumbnail.test.tsx
index 5cf4ab48f2..dece8b3a2a 100644
--- a/packages/core/src/Thumbnail/Thumbnail.test.tsx
+++ b/packages/core/src/Thumbnail/Thumbnail.test.tsx
@@ -163,34 +163,4 @@ describe('Thumbnail', () => {
render(<Thumbnail ref={ref} data-testid="thumb" />);
expect(ref).toHaveBeenCalled();
});
-
- describe('elevation', () => {
- // The elevation class lives on the image container (the shadow surface),
- // which is the root's first element child.
- const imageContainerClass = (
- elevation: 'none' | 'low' | 'med' | 'high',
- ) => {
- const {container} = render(
- <Thumbnail src="/x.png" alt="x" elevation={elevation} />,
- );
- return container.firstElementChild!.firstElementChild!.className;
- };
-
- it('renders a distinct class for each elevation level', () => {
- const classes = new Set([
- imageContainerClass('none'),
- imageContainerClass('low'),
- imageContainerClass('med'),
- imageContainerClass('high'),
- ]);
- expect(classes.size).toBe(4);
- });
-
- it('defaults to flat (elevation none)', () => {
- const {container: def} = render(<Thumbnail src="/x.png" alt="x" />);
- expect(def.firstElementChild!.firstElementChild!.className).toBe(
- imageContainerClass('none'),
- );
- });
- });
});
diff --git a/packages/core/src/Thumbnail/Thumbnail.tsx b/packages/core/src/Thumbnail/Thumbnail.tsx
index e610a34d34..44d8697ccb 100644
--- a/packages/core/src/Thumbnail/Thumbnail.tsx
+++ b/packages/core/src/Thumbnail/Thumbnail.tsx
@@ -43,7 +43,6 @@ import {MediaTheme} from '../theme/MediaTheme';
import {useImageMode} from '../hooks/useImageMode';
import {useDevWarning} from '../hooks/useDevWarning';
import type {BaseProps} from '../BaseProps';
-import type {Elevation} from '../utils/types';
import {mergeProps} from '../utils';
import {themeProps} from '../utils/themeProps';
import {useTranslator} from '../i18n';
@@ -103,12 +102,6 @@ export interface ThumbnailProps extends BaseProps<HTMLDivElement> {
* @default false
*/
isDisabled?: boolean;
- /**
- * Resting elevation — the shadow depth the tile sits at. `none` (the default)
- * keeps the existing hover-only shadow; a set level raises the tile at rest.
- * @default 'none'
- */
- elevation?: Elevation;
/**
* Test ID for testing frameworks.
*/
@@ -135,10 +128,6 @@ const styles = stylex.create({
borderRadius: radiusVars['--radius-element'],
overflow: 'hidden',
backgroundColor: colorVars['--color-neutral'],
- // Resting elevation is set via --_thumbnail-elevation (see elevationStyles).
- // Routing it through a var lets the interactive hover bump (below) override
- // just the resting value without clobbering the elevation prop.
- boxShadow: 'var(--_thumbnail-elevation, none)',
},
image: {
width: '100%',
@@ -167,10 +156,7 @@ const styles = stylex.create({
transitionDuration: durationVars['--duration-fast'],
transitionTimingFunction: easeVars['--ease-standard'],
boxShadow: {
- // Rest at the elevation prop's level (default none); bump to med on hover
- // as before. Reading the var here keeps a set elevation visible at rest
- // instead of being reset to flat.
- default: 'var(--_thumbnail-elevation, none)',
+ default: 'none',
':hover': {
'@media (hover: hover)': shadowVars['--shadow-med'],
},
@@ -227,17 +213,6 @@ const styles = stylex.create({
},
});
-// Resting elevation → shadow token. Sets --_thumbnail-elevation (read by the
-// image container and the interactive hover style) rather than box-shadow
-// directly, so a set resting elevation survives the interactive hover bump.
-// 'none' is the default — the existing hover-only shadow is unchanged.
-const elevationStyles = stylex.create({
- none: {'--_thumbnail-elevation': 'none'},
- low: {'--_thumbnail-elevation': shadowVars['--shadow-low']},
- med: {'--_thumbnail-elevation': shadowVars['--shadow-med']},
- high: {'--_thumbnail-elevation': shadowVars['--shadow-high']},
-});
-
// =============================================================================
// Placeholder icon — a simple image silhouette
// =============================================================================
@@ -283,7 +258,6 @@ export function Thumbnail({
onClick,
isLoading = false,
isDisabled = false,
- elevation = 'none',
xstyle,
className,
style,
@@ -381,7 +355,6 @@ export function Thumbnail({
<div
{...stylex.props(
styles.imageContainer,
- elevationStyles[elevation],
isInteractive && styles.interactive,
)}>
{isInteractive ? (