diff --git a/changelog.md b/changelog.md index 8b94370f..d2b0273e 100644 --- a/changelog.md +++ b/changelog.md @@ -10,6 +10,7 @@ ### Changed +- Outlined inputs (TextField, Select, Autocomplete) now have a `surface` background, so they stay distinct on container or elevated surfaces. - _Dialog_ now defaults to elevation 16 (`surface.strong`'s tone) instead of MUI's 24, and temporary _Drawer_ to elevation 4 instead of 16, so floating surfaces order Drawer < Menu < Dialog and dialog text keeps more contrast. - **Breaking** _Dialog_'s deprecated `PaperProps` is now ignored. Move it to `slotProps.paper`, e.g. with `npx @mui/codemod@latest deprecations/dialog-props `. If you use MRT, also check `muiEditRowDialogProps` and `muiCreateRowModalProps` by hand, as the codemod won't reach them. diff --git a/src/components/MUI/Inputs/Select.stories.tsx b/src/components/MUI/Inputs/Select.stories.tsx index d75dcfae..d7d0543a 100644 --- a/src/components/MUI/Inputs/Select.stories.tsx +++ b/src/components/MUI/Inputs/Select.stories.tsx @@ -88,6 +88,24 @@ export const FilledAndStandard: Story = { ), }; +export const OnSurfaces: Story = { + name: "On surfaces", + render: (args: SelectArgs) => ( + + {[ + ["Background", "var(--ds-background)"], + ["Surface", "var(--ds-surface)"], + ["Surface container", "var(--ds-surface-container)"], + ["Surface container high", "var(--ds-surface-container-high)"], + ].map(([name, background]) => ( + + {renderSelectWithLabel({ ...args, variant: "outlined", label: name })} + + ))} + + ), +}; + export const States: Story = { render: (args: SelectArgs) => ( diff --git a/src/components/MUI/Inputs/TextField.stories.tsx b/src/components/MUI/Inputs/TextField.stories.tsx index 725027c0..f88b56e7 100644 --- a/src/components/MUI/Inputs/TextField.stories.tsx +++ b/src/components/MUI/Inputs/TextField.stories.tsx @@ -184,6 +184,30 @@ export const States: Story = { }, }; +export const OnSurfaces: Story = { + name: "On surfaces", + render: (_args) => ( + + {[ + ["Background", "var(--ds-background)"], + ["Surface", "var(--ds-surface)"], + ["Surface container", "var(--ds-surface-container)"], + ["Surface container high", "var(--ds-surface-container-high)"], + ].map(([name, background]) => ( + + + + ))} + + ), +}; + export const Validation: Story = { render: (_args) => ( diff --git a/src/themes/DiamondDSTheme.test.ts b/src/themes/DiamondDSTheme.test.ts index 26610117..57c77bdd 100644 --- a/src/themes/DiamondDSTheme.test.ts +++ b/src/themes/DiamondDSTheme.test.ts @@ -787,6 +787,12 @@ describe("DiamondDS component overrides", () => { }); // Rest + expect(styles.backgroundColor).toBe("var(--ds-surface)"); + expect( + styles[ + "&:not(.Mui-disabled):not(.MuiInputBase-readOnly) .MuiOutlinedInput-notchedOutline legend > span" + ], + ).toEqual(expect.objectContaining({ backgroundColor: "inherit" })); expect(styles["& .MuiOutlinedInput-notchedOutline"]).toEqual( expect.objectContaining({ borderColor: "var(--ds-border-emphasis)", diff --git a/src/themes/DiamondDSTheme.ts b/src/themes/DiamondDSTheme.ts index c367f79c..89d8fe65 100644 --- a/src/themes/DiamondDSTheme.ts +++ b/src/themes/DiamondDSTheme.ts @@ -1453,8 +1453,51 @@ const DiamondDSTheme = extendTheme({ const accent = `var(--ds-${tokenName}-accent)`; return { + /** Opaque fill so the field stays distinct on container or elevated surfaces. */ + backgroundColor: "var(--ds-surface)", + "& .MuiOutlinedInput-notchedOutline": { borderColor: "var(--ds-border-emphasis)", + top: -7, + }, + + /** Notch 2px higher and 4px taller than MUI's, so the border line stays put. */ + "& .MuiOutlinedInput-notchedOutline legend": { + height: 15, + }, + + /** + * Fills the notch so the straddling label sits on one tone. Editable + * fields inherit the field background; `background-clip: text` keeps + * the fieldset and legend from painting it over the value. + */ + "& .MuiOutlinedInput-notchedOutline legend > span": { + borderRadius: "4px 4px 0 0", + color: "transparent", + opacity: 1, + }, + + "&:not(.Mui-disabled):not(.MuiInputBase-readOnly) .MuiOutlinedInput-notchedOutline, &:not(.Mui-disabled):not(.MuiInputBase-readOnly) .MuiOutlinedInput-notchedOutline legend": + { + backgroundColor: "inherit", + backgroundClip: "text", + }, + + "&:not(.Mui-disabled):not(.MuiInputBase-readOnly) .MuiOutlinedInput-notchedOutline legend > span": + { + backgroundColor: "inherit", + }, + + /** Washes are translucent, so paint only above the field edge to avoid doubling. */ + "&.MuiInputBase-readOnly:not(.Mui-disabled) .MuiOutlinedInput-notchedOutline legend > span": + { + backgroundColor: "var(--ds-surface-readonly)", + height: 7, + }, + + "&.Mui-disabled .MuiOutlinedInput-notchedOutline legend > span": { + backgroundColor: "var(--ds-surface-disabled)", + height: 7, }, "&:hover:not(.Mui-disabled):not(.Mui-error):not(.Mui-focused):not(.MuiInputBase-readOnly) .MuiOutlinedInput-notchedOutline": @@ -1649,6 +1692,11 @@ const DiamondDSTheme = extendTheme({ color: "var(--ds-on-surface-disabled)", }, + /** 1px below MUI's -9px, for room above the label in the filled notch. */ + "&.MuiInputLabel-outlined.MuiInputLabel-shrink": { + transform: "translate(14px, -8px) scale(0.75)", + }, + "&.Mui-focused": { color: "var(--ds-primary)", },