Skip to content

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

TypeScript

fix(FileInput): use color-mix for hover shadow and XDSInputClearButton (#2449)

Cindy Zhangf7235f60a931
diff --git a/packages/core/src/FileInput/XDSFileInput.tsx b/packages/core/src/FileInput/XDSFileInput.tsx
index 6f9cea9e6e..1e920a3ce0 100644
--- a/packages/core/src/FileInput/XDSFileInput.tsx
+++ b/packages/core/src/FileInput/XDSFileInput.tsx
@@ -36,7 +36,12 @@ import {
durationVars,
easeVars,
} from '../theme/tokens.stylex';
-import {XDSField, type XDSInputStatus, type XDSInputStatusType} from '../Field';
+import {
+ XDSField,
+ XDSInputClearButton,
+ type XDSInputStatus,
+ type XDSInputStatusType,
+} from '../Field';
import {XDSIcon, type XDSIconName} from '../Icon';
import {XDSSpinner} from '../Spinner';
@@ -137,7 +142,7 @@ const styles = stylex.create({
boxShadow: {
default: null,
':hover': {
- '@media (hover: hover)': `inset 0 0 0 2px ${String(colorVars['--color-accent'])}33`,
+ '@media (hover: hover)': `inset 0 0 0 2px color-mix(in srgb, ${colorVars['--color-accent']} 20%, transparent)`,
},
},
},
@@ -176,7 +181,7 @@ const styles = stylex.create({
boxShadow: {
default: 'none',
':hover:not(:focus-within)': {
- '@media (hover: hover)': `inset 0 0 0 2px ${String(colorVars['--color-accent'])}33`,
+ '@media (hover: hover)': `inset 0 0 0 2px color-mix(in srgb, ${colorVars['--color-accent']} 20%, transparent)`,
},
},
cursor: 'pointer',
@@ -224,24 +229,6 @@ const styles = stylex.create({
flex: 1,
minWidth: 0,
},
- clearButton: {
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
- padding: 0,
- margin: 0,
- borderWidth: 0,
- borderStyle: 'none',
- backgroundColor: 'transparent',
- cursor: 'pointer',
- borderRadius: radiusVars['--radius-element'],
- outline: {
- default: 'none',
- ':focus-visible': `${borderVars['--border-width']} solid ${colorVars['--color-accent']}`,
- },
- outlineOffset: 1,
- flexShrink: 0,
- },
fileNameDropzone: {
textAlign: 'center',
whiteSpace: 'normal',
@@ -707,13 +694,7 @@ export function XDSFileInput({
/>
{isDropzone ? renderDropzoneContent() : renderCompactContent()}
{hasFiles && !isDisabled && !isLoading && (
- <button
- type="button"
- onClick={handleClear}
- aria-label={`Clear ${label}`}
- {...stylex.props(styles.clearButton)}>
- <XDSIcon icon="close" size="sm" color="secondary" />
- </button>
+ <XDSInputClearButton label={`Clear ${label}`} onClick={handleClear} />
)}
</div>
<div