Skip to content

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

TypeScript

fix(core): use overlay hover treatment for Thumbnail, unify on --color-overlay-hover (#4346)

Kenton Quatman4c46f53f3ae6
diff --git a/.changeset/thumbnail-card-hover-overlay.md b/.changeset/thumbnail-card-hover-overlay.md
new file mode 100644
index 0000000000..c6a4bb65fc
--- /dev/null
+++ b/.changeset/thumbnail-card-hover-overlay.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[fix] Thumbnail: replace the hover box-shadow on interactive tiles with the same `::after` overlay treatment ClickableCard and SelectableCard use. All three now tint on hover with `--color-overlay-hover` (and `--color-overlay-pressed` on press), so interactive feedback is consistent across the card family.
+
+@kentonquatman
diff --git a/packages/core/src/ClickableCard/ClickableCard.tsx b/packages/core/src/ClickableCard/ClickableCard.tsx
index d4958cfa71..fdbcb821ff 100644
--- a/packages/core/src/ClickableCard/ClickableCard.tsx
+++ b/packages/core/src/ClickableCard/ClickableCard.tsx
@@ -79,13 +79,13 @@ const styles = stylex.create({
backgroundColor: 'transparent',
},
':active::after': {
- backgroundColor: 'color-mix(in srgb, currentColor 10%, transparent)',
+ backgroundColor: colorVars['--color-overlay-pressed'],
},
},
hoverOnPointer: {
'@media (hover: hover)': {
':hover::after': {
- backgroundColor: 'color-mix(in srgb, currentColor 5%, transparent)',
+ backgroundColor: colorVars['--color-overlay-hover'],
},
},
},
diff --git a/packages/core/src/SelectableCard/SelectableCard.tsx b/packages/core/src/SelectableCard/SelectableCard.tsx
index bfed3465b4..c33cb1266e 100644
--- a/packages/core/src/SelectableCard/SelectableCard.tsx
+++ b/packages/core/src/SelectableCard/SelectableCard.tsx
@@ -79,13 +79,13 @@ const styles = stylex.create({
backgroundColor: 'transparent',
},
':active::after': {
- backgroundColor: 'color-mix(in srgb, currentColor 10%, transparent)',
+ backgroundColor: colorVars['--color-overlay-pressed'],
},
},
hoverOnPointer: {
'@media (hover: hover)': {
':hover::after': {
- backgroundColor: 'color-mix(in srgb, currentColor 5%, transparent)',
+ backgroundColor: colorVars['--color-overlay-hover'],
},
},
},
diff --git a/packages/core/src/Thumbnail/Thumbnail.doc.mjs b/packages/core/src/Thumbnail/Thumbnail.doc.mjs
index a8ca26fb28..f2778c1259 100644
--- a/packages/core/src/Thumbnail/Thumbnail.doc.mjs
+++ b/packages/core/src/Thumbnail/Thumbnail.doc.mjs
@@ -31,7 +31,7 @@ export const docs = {
{
name: 'onClick',
type: '(e: React.MouseEvent) => void',
- description: 'Click handler. Adds button semantics and hover shadow.',
+ description: 'Click handler. Adds button semantics and a hover overlay.',
},
{
name: 'isLoading',
@@ -77,7 +77,7 @@ export const docs = {
bestPractices: [
{guidance: true, description: 'Always provide a label prop with the file name so the thumbnail and its remove button are accessible to screen readers and show a tooltip on hover.'},
{guidance: true, description: 'Use isLoading without a src to show a skeleton during initial upload, and isLoading with a src to show a spinner overlay once a preview URL is available.'},
- {guidance: true, description: 'Pair onClick with a lightbox or detail view so users can inspect the full image; the thumbnail adds button semantics and a hover shadow automatically.'},
+ {guidance: true, description: 'Pair onClick with a lightbox or detail view so users can inspect the full image; the thumbnail adds button semantics and a hover overlay automatically.'},
{guidance: false, description: "Don't use Thumbnail for non-image file types like PDFs or spreadsheets; use a file attachment component with an appropriate icon instead."},
{guidance: false, description: "Don't omit alt text when a src is provided; screen readers need a description of the image content, not just the file name from label."},
],
@@ -98,7 +98,7 @@ export const docsZh = {
alt: '\u56FE\u7247\u7684\u66FF\u4EE3\u6587\u672C\u3002\u7701\u7565\u65F6\u56FE\u7247\u4F1A\u88AB\u663E\u5F0F\u6807\u8BB0\u4E3A\u88C5\u9970\u6027\uFF08alt=""\u3001role="presentation"\u3001aria-hidden\uFF09\u5E76\u5BF9\u5C4F\u5E55\u9605\u8BFB\u5668\u9690\u85CF\uFF1B\u82E5 alt \u548C label \u5747\u672A\u8BBE\u7F6E\uFF0C\u5F00\u53D1\u73AF\u5883\u4F1A\u53D1\u51FA\u8B66\u544A\u3002',
label: '\u65E0\u969C\u788D\u6807\u7B7E\uFF08\u5982\u6587\u4EF6\u540D\uFF09\u3002\u60AC\u505C\u65F6\u4EE5\u63D0\u793A\u5DE5\u5177\u663E\u793A\u3002',
onRemove: '\u8986\u76D6\u5C42\u79FB\u9664\u6309\u94AE\u7684\u56DE\u8C03\u3002',
- onClick: '\u70B9\u51FB\u5904\u7406\u5668\u3002\u6DFB\u52A0\u6309\u94AE\u8BED\u4E49\u548C\u60AC\u505C\u9634\u5F71\u3002',
+ onClick: '\u70B9\u51FB\u5904\u7406\u5668\u3002\u6DFB\u52A0\u6309\u94AE\u8BED\u4E49\u548C\u60AC\u505C\u8986\u76D6\u5C42\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',
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',
@@ -112,7 +112,7 @@ export const docsZh = {
bestPractices: [
{guidance: true, description: '\u59CB\u7EC8\u63D0\u4F9B label \u5C5E\u6027\u5E76\u586B\u5199\u6587\u4EF6\u540D\uFF0C\u4EE5\u4FBF\u5C4F\u5E55\u9605\u8BFB\u5668\u80FD\u591F\u8BC6\u522B\u7F29\u7565\u56FE\u53CA\u5176\u79FB\u9664\u6309\u94AE\uFF0C\u5E76\u5728\u60AC\u505C\u65F6\u663E\u793A\u63D0\u793A\u3002'},
{guidance: true, description: '\u4E0A\u4F20\u521D\u671F\u4F7F\u7528\u4E0D\u5E26 src \u7684 isLoading \u663E\u793A\u9AA8\u67B6\u5C4F\uFF1B\u83B7\u5F97\u9884\u89C8 URL \u540E\u4F7F\u7528\u5E26 src \u7684 isLoading \u663E\u793A\u65CB\u8F6C\u52A0\u8F7D\u8986\u76D6\u5C42\u3002'},
- {guidance: true, description: '\u5C06 onClick \u4E0E\u706F\u7BB1\u6216\u8BE6\u60C5\u89C6\u56FE\u914D\u5BF9\uFF0C\u4EE5\u4FBF\u7528\u6237\u67E5\u770B\u5B8C\u6574\u56FE\u7247\u2014\u2014\u7EC4\u4EF6\u4F1A\u81EA\u52A8\u6DFB\u52A0\u6309\u94AE\u8BED\u4E49\u548C\u60AC\u505C\u9634\u5F71\u3002'},
+ {guidance: true, description: '\u5C06 onClick \u4E0E\u706F\u7BB1\u6216\u8BE6\u60C5\u89C6\u56FE\u914D\u5BF9\uFF0C\u4EE5\u4FBF\u7528\u6237\u67E5\u770B\u5B8C\u6574\u56FE\u7247\u2014\u2014\u7EC4\u4EF6\u4F1A\u81EA\u52A8\u6DFB\u52A0\u6309\u94AE\u8BED\u4E49\u548C\u60AC\u505C\u8986\u76D6\u5C42\u3002'},
{guidance: false, description: '\u5BF9 PDF \u6216\u7535\u5B50\u8868\u683C\u7B49\u975E\u56FE\u7247\u6587\u4EF6\u7C7B\u578B\u4F7F\u7528 Thumbnail\u2014\u2014\u5E94\u4F7F\u7528\u5E26\u6709\u76F8\u5E94\u56FE\u6807\u7684\u6587\u4EF6\u9644\u4EF6\u7EC4\u4EF6\u3002'},
{guidance: false, description: '\u63D0\u4F9B src \u65F6\u7701\u7565 alt \u6587\u672C\u2014\u2014\u5C4F\u5E55\u9605\u8BFB\u5668\u9700\u8981\u56FE\u7247\u5185\u5BB9\u7684\u63CF\u8FF0\uFF0C\u800C\u4E0D\u4EC5\u662F label \u4E2D\u7684\u6587\u4EF6\u540D\u3002'},
],
@@ -128,7 +128,7 @@ export const docsDense = {
bestPractices: [
{guidance: true, description: 'Always set label (file name) for a11y; powers screen reader announce + hover tooltip.'},
{guidance: true, description: 'isLoading w/o src \u2192 skeleton; isLoading w/ src \u2192 spinner overlay. Two distinct loading states.'},
- {guidance: true, description: 'onClick adds button semantics + hover shadow; pair with lightbox for full preview.'},
+ {guidance: true, description: 'onClick adds button semantics + hover overlay; pair with lightbox for full preview.'},
{guidance: false, description: "Don't use for non-image files (PDF, xlsx); use file attachment component with icon instead."},
{guidance: false, description: "Don't omit alt when src present; screen readers need image content description, not just label."},
],
@@ -138,7 +138,7 @@ export const docsDense = {
alt: 'Alt text for image. Omitted → explicitly decorative (alt="" + role="presentation" + aria-hidden); dev warn when src set with no alt and no label.',
label: 'Accessible label (file name). Tooltip on hover, aria-label.',
onRemove: '(e) => void. Overlaid remove button callback.',
- onClick: '(e) => void. Adds button semantics + hover shadow.',
+ onClick: '(e) => void. Adds button semantics + hover overlay.',
isLoading: 'Skeleton (no src) or upload overlay (with src). Default: false.',
isDisabled: 'Disabled state. Default: false.',
xstyle: 'stylex.create() for layout.',
diff --git a/packages/core/src/Thumbnail/Thumbnail.tsx b/packages/core/src/Thumbnail/Thumbnail.tsx
index 88aba7c895..3faef893b1 100644
--- a/packages/core/src/Thumbnail/Thumbnail.tsx
+++ b/packages/core/src/Thumbnail/Thumbnail.tsx
@@ -30,7 +30,6 @@ import {
colorVars,
radiusVars,
spacingVars,
- shadowVars,
durationVars,
easeVars,
} from '../theme/tokens.stylex';
@@ -147,22 +146,6 @@ const styles = stylex.create({
},
interactive: {
cursor: 'pointer',
- transitionProperty: 'opacity, box-shadow',
- transitionDuration: durationVars['--duration-fast'],
- transitionTimingFunction: easeVars['--ease-standard'],
- boxShadow: {
- default: 'none',
- ':hover': {
- '@media (hover: hover)': shadowVars['--shadow-med'],
- },
- },
- opacity: {
- default: 1,
- ':hover': {
- '@media (hover: hover)': 0.85,
- },
- ':active': 0.75,
- },
outline: {
default: null,
':has(:focus-visible)': `2px solid ${colorVars['--color-accent']}`,
@@ -172,6 +155,33 @@ const styles = stylex.create({
':has(:focus-visible)': '2px',
},
},
+ // Hover/pressed overlay — the exact same treatment as ClickableCard and
+ // SelectableCard. A transparent `::after` tints on hover/press instead of
+ // shifting shadow or opacity. Guarded by @media (hover: hover) so touch
+ // devices don't show a stuck hover state; active/pressed works everywhere.
+ overlay: {
+ '::after': {
+ content: '""',
+ position: 'absolute',
+ inset: 0,
+ borderRadius: 'inherit',
+ pointerEvents: 'none',
+ transitionProperty: 'background-color',
+ transitionDuration: durationVars['--duration-fast'],
+ transitionTimingFunction: easeVars['--ease-standard'],
+ backgroundColor: 'transparent',
+ },
+ ':active::after': {
+ backgroundColor: colorVars['--color-overlay-pressed'],
+ },
+ },
+ hoverOnPointer: {
+ '@media (hover: hover)': {
+ ':hover::after': {
+ backgroundColor: colorVars['--color-overlay-hover'],
+ },
+ },
+ },
interactiveButton: {
all: 'unset',
cursor: 'pointer',
@@ -356,6 +366,8 @@ export function Thumbnail({
{...stylex.props(
styles.imageContainer,
isInteractive && styles.interactive,
+ isInteractive && styles.overlay,
+ isInteractive && styles.hoverOnPointer,
)}>
{isInteractive ? (
<button