Skip to content

Commit

Permalink
Adapt chip styling (#2879)
Browse files Browse the repository at this point in the history
Hover styling is not consistent with the design in every variant; please implement it as per the design.

- Fix hover styling of all variants
- Add new variant with white background and no border (variant="filled" and color="info") and add it to story

Co-authored-by: Julia Wegmayr <[email protected]>
Co-authored-by: Johannes Obermair <[email protected]>
  • Loading branch information
3 people authored Dec 5, 2024
1 parent 6eba5ab commit 22f3d40
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 9 deletions.
8 changes: 8 additions & 0 deletions .changeset/clever-jobs-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@comet/admin-theme": minor
---

Adapt `Chip` styling to align with Comet DXP design

- Fix hover styling
- Add new styling for `<Chip variant="filled" color="info">`
22 changes: 13 additions & 9 deletions packages/admin/admin-theme/src/componentsTheme/MuiChip.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Clear } from "@comet/admin-icons";
import { chipClasses } from "@mui/material";

import { mergeOverrideStyles } from "../utils/mergeOverrideStyles";
import { GetMuiComponentTheme } from "./getComponentsTheme";
Expand Down Expand Up @@ -98,18 +97,23 @@ export const getMuiChip: GetMuiComponentTheme<"MuiChip"> = (component, { palette
},
filledDefault: {
backgroundColor: palette.grey["100"],
"&.MuiChip-clickable": {
"&:hover": {
backgroundColor: palette.grey["200"],
},
},
},
filledInfo: {
backgroundColor: "#fff",
"&.MuiChip-clickable": {
"&:hover": {
backgroundColor: palette.grey["50"],
},
},
},
outlinedDefault: {
borderColor: palette.grey["100"],
},
clickableColorDefault: {
[`&.${chipClasses.filled}:hover`]: {
backgroundColor: palette.grey["200"],
},
[`&.${chipClasses.outlined}:hover`]: {
backgroundColor: palette.grey["50"],
},
},
}),
defaultProps: {
deleteIcon: <Clear />,
Expand Down
49 changes: 49 additions & 0 deletions storybook/src/admin/mui/Chip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,30 @@ export const _Chip = {
/>
</Grid>
</Grid>
<Grid container spacing={2} mb={5}>
<Grid item>
<Chip variant="filled" color="info" label="Normal" />
</Grid>
<Grid item>
<Chip variant="filled" color="info" clickable label="Clickable" />
</Grid>
<Grid item>
<Chip variant="filled" color="info" icon={<ChevronDown />} clickable label="With Icon" />
</Grid>
<Grid item>
<Chip variant="filled" color="info" label="Disabled" disabled />
</Grid>
<Grid item>
<Chip
variant="filled"
color="info"
label="Deletable"
onDelete={() => {
console.log("Delete");
}}
/>
</Grid>
</Grid>
</Box>
<Typography variant="h4" gutterBottom>
Small size Chips
Expand Down Expand Up @@ -374,6 +398,31 @@ export const _Chip = {
/>
</Grid>
</Grid>
<Grid container spacing={2} mb={5}>
<Grid item>
<Chip size="small" variant="filled" color="info" label="Normal" />
</Grid>
<Grid item>
<Chip size="small" variant="filled" color="info" clickable label="Clickable" />
</Grid>
<Grid item>
<Chip size="small" variant="filled" color="info" icon={<ChevronDown />} clickable label="With Icon" />
</Grid>
<Grid item>
<Chip size="small" variant="filled" color="info" label="Disabled" disabled />
</Grid>
<Grid item>
<Chip
size="small"
variant="filled"
color="info"
label="Deletable"
onDelete={() => {
console.log("Delete");
}}
/>
</Grid>
</Grid>
</Box>
</CardContent>
</Card>
Expand Down

0 comments on commit 22f3d40

Please sign in to comment.