-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(snackbar): remove duplicated alert role (#3443)
* fix: remove duplicate role alert * refactor(snackbar): replaced styled components with useClasses * fix: correctly apply styles * fix: type definition * fix: revert previous, fix type definition in the correct place
- Loading branch information
Showing
11 changed files
with
196 additions
and
288 deletions.
There are no files selected for viewing
51 changes: 32 additions & 19 deletions
51
packages/core/src/components/Snackbar/Snackbar.styles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,41 @@ | ||
import styled from "@emotion/styled"; | ||
import Snackbar, { snackbarClasses } from "@mui/material/Snackbar"; | ||
import { theme } from "@hitachivantara/uikit-styles"; | ||
import { createClasses } from "@core/utils"; | ||
import { snackbarClasses } from "@mui/material"; | ||
|
||
export const StyledSnackbar = styled(Snackbar)({ | ||
[`&.${snackbarClasses.anchorOriginTopRight}`]: { | ||
top: theme.space.xs, | ||
right: theme.space.xs, | ||
export const { useClasses, staticClasses } = createClasses("HvSnackbar", { | ||
root: {}, | ||
anchorOriginTopRight: { | ||
[`&.${snackbarClasses.anchorOriginTopRight}`]: { | ||
top: theme.space.xs, | ||
right: theme.space.xs, | ||
}, | ||
}, | ||
[`&.${snackbarClasses.anchorOriginTopLeft}`]: { | ||
top: theme.space.xs, | ||
left: theme.space.xs, | ||
anchorOriginTopLeft: { | ||
[`&.${snackbarClasses.anchorOriginTopLeft}`]: { | ||
top: theme.space.xs, | ||
left: theme.space.xs, | ||
}, | ||
}, | ||
[`&.${snackbarClasses.anchorOriginTopCenter}`]: { | ||
top: theme.space.xs, | ||
anchorOriginTopCenter: { | ||
[`&.${snackbarClasses.anchorOriginTopCenter}`]: { | ||
top: theme.space.xs, | ||
}, | ||
}, | ||
[`&.${snackbarClasses.anchorOriginBottomCenter}`]: { | ||
bottom: theme.space.xs, | ||
anchorOriginBottomCenter: { | ||
[`&.${snackbarClasses.anchorOriginBottomCenter}`]: { | ||
bottom: theme.space.xs, | ||
}, | ||
}, | ||
[`&.${snackbarClasses.anchorOriginBottomLeft}`]: { | ||
bottom: theme.space.xs, | ||
left: theme.space.xs, | ||
anchorOriginBottomLeft: { | ||
[`&.${snackbarClasses.anchorOriginBottomLeft}`]: { | ||
bottom: theme.space.xs, | ||
left: theme.space.xs, | ||
}, | ||
}, | ||
[`&.${snackbarClasses.anchorOriginBottomRight}`]: { | ||
bottom: theme.space.xs, | ||
right: theme.space.xs, | ||
anchorOriginBottomRight: { | ||
[`&.${snackbarClasses.anchorOriginBottomRight}`]: { | ||
bottom: theme.space.xs, | ||
right: theme.space.xs, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 46 additions & 52 deletions
98
...ges/core/src/components/Snackbar/SnackbarContentWrapper/SnackbarContentWrapper.styles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,49 @@ | ||
import styled from "@emotion/styled"; | ||
import { theme } from "@hitachivantara/uikit-styles"; | ||
import SnackbarContent, { | ||
snackbarContentClasses, | ||
} from "@mui/material/SnackbarContent"; | ||
import { CSSProperties } from "react"; | ||
import { transientOptions } from "@core/utils/transientOptions"; | ||
import { createClasses } from "@core/utils"; | ||
|
||
export const StyledSnackbarContent = styled( | ||
SnackbarContent, | ||
transientOptions | ||
)(({ $variant }: { $variant: string }) => ({ | ||
...($variant === "success" && { | ||
backgroundColor: theme.colors.positive_20, | ||
}), | ||
...($variant === "error" && { | ||
backgroundColor: theme.colors.negative_20, | ||
}), | ||
...($variant === "default" && { | ||
backgroundColor: theme.colors.neutral_20, | ||
}), | ||
...($variant === "warning" && { | ||
backgroundColor: theme.colors.warning_20, | ||
}), | ||
[`&.${snackbarContentClasses.root}`]: { | ||
width: "310px", | ||
minHeight: "52px", | ||
maxHeight: "92px", | ||
padding: theme.space.xs, | ||
boxShadow: "none", | ||
}, | ||
[`& .${snackbarContentClasses.message}`]: { | ||
padding: 0, | ||
width: "100%", | ||
}, | ||
})); | ||
|
||
export const StyledMessageSpan = styled("div")({ | ||
display: "flex", | ||
alignItems: "center", | ||
minHeight: "32px", | ||
}); | ||
|
||
export const StyledMessageText = styled("div")({ | ||
...(theme.typography.body as CSSProperties), | ||
padding: `0 ${theme.space.xs}`, | ||
color: theme.colors.base_dark, | ||
fontFamily: theme.fontFamily.body, | ||
maxHeight: "72px", | ||
wordBreak: "break-word", | ||
}); | ||
|
||
export const StyledAction = styled("div")({ | ||
textAlign: "right", | ||
}); | ||
export const { useClasses, staticClasses } = createClasses( | ||
"HvSnackbar-Content", | ||
{ | ||
root: { | ||
width: "310px", | ||
minHeight: "52px", | ||
maxHeight: "92px", | ||
padding: theme.space.xs, | ||
boxShadow: "none", | ||
}, | ||
success: { | ||
backgroundColor: theme.colors.positive_20, | ||
}, | ||
error: { | ||
backgroundColor: theme.colors.negative_20, | ||
}, | ||
default: { | ||
backgroundColor: theme.colors.neutral_20, | ||
}, | ||
warning: { | ||
backgroundColor: theme.colors.warning_20, | ||
}, | ||
message: { | ||
padding: 0, | ||
width: "100%", | ||
}, | ||
messageSpan: { | ||
display: "flex", | ||
alignItems: "center", | ||
minHeight: "32px", | ||
}, | ||
messageText: { | ||
...(theme.typography.body as CSSProperties), | ||
padding: `0 ${theme.space.xs}`, | ||
color: theme.colors.base_dark, | ||
fontFamily: theme.fontFamily.body, | ||
maxHeight: "72px", | ||
wordBreak: "break-word", | ||
}, | ||
action: { | ||
textAlign: "right", | ||
}, | ||
iconVariant: {}, | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
packages/core/src/components/Snackbar/SnackbarContentWrapper/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1 @@ | ||
export { default as snackbarContentClasses } from "./snackbarContentWrapperClasses"; | ||
export * from "./snackbarContentWrapperClasses"; | ||
export { default as HvSnackbarContent } from "./SnackbarContentWrapper"; | ||
export * from "./SnackbarContentWrapper"; |
Oops, something went wrong.