diff --git a/site/src/components/ConfirmDialog/ConfirmDialog.stories.tsx b/site/src/components/ConfirmDialog/ConfirmDialog.stories.tsx index 9c32bd7610dcf..694d131eed99c 100644 --- a/site/src/components/ConfirmDialog/ConfirmDialog.stories.tsx +++ b/site/src/components/ConfirmDialog/ConfirmDialog.stories.tsx @@ -36,3 +36,24 @@ InfoDialog.args = { hideCancel: true, type: "info", } + +export const InfoDialogWithCancel = Template.bind({}) +InfoDialogWithCancel.args = { + description: "Information can be cool!", + hideCancel: false, + type: "info", +} + +export const SuccessDialog = Template.bind({}) +SuccessDialog.args = { + description: "I am successful.", + hideCancel: true, + type: "success", +} + +export const SuccessDialogWithCancel = Template.bind({}) +SuccessDialogWithCancel.args = { + description: "I may be successful.", + hideCancel: false, + type: "success", +} diff --git a/site/src/components/ConfirmDialog/ConfirmDialog.tsx b/site/src/components/ConfirmDialog/ConfirmDialog.tsx index f7933dd12e9b7..fec223afbd2bb 100644 --- a/site/src/components/ConfirmDialog/ConfirmDialog.tsx +++ b/site/src/components/ConfirmDialog/ConfirmDialog.tsx @@ -19,6 +19,10 @@ const CONFIRM_DIALOG_DEFAULTS: Record { @@ -41,40 +45,32 @@ export interface ConfirmDialogProps extends Omit ({ - dialogWrapper: (props: StyleProps) => ({ + dialogWrapper: { "& .MuiPaper-root": { - background: props.type === "info" ? theme.palette.primary.main : theme.palette.background.paper, + background: theme.palette.background.paper, border: `1px solid ${theme.palette.divider}`, }, "& .MuiDialogActions-spacing": { padding: `0 ${theme.spacing(3.75)}px ${theme.spacing(3.75)}px`, }, - }), - dialogContent: (props: StyleProps) => ({ - color: props.type === "info" ? theme.palette.primary.contrastText : theme.palette.text.secondary, + }, + dialogContent: { + color: theme.palette.text.secondary, padding: theme.spacing(6), textAlign: "center", - }), + }, titleText: { marginBottom: theme.spacing(3), }, - description: (props: StyleProps) => ({ - color: - props.type === "info" ? fade(theme.palette.primary.contrastText, 0.75) : fade(theme.palette.text.secondary, 0.75), + description: { + color: fade(theme.palette.text.secondary, 0.75), lineHeight: "160%", "& strong": { - color: - props.type === "info" - ? fade(theme.palette.primary.contrastText, 0.95) - : fade(theme.palette.text.secondary, 0.95), + color: fade(theme.palette.text.secondary, 0.95), }, - }), + }, })) /** diff --git a/site/src/components/Dialog/Dialog.tsx b/site/src/components/Dialog/Dialog.tsx index aa222ad4a1985..411a34c2d8e0a 100644 --- a/site/src/components/Dialog/Dialog.tsx +++ b/site/src/components/Dialog/Dialog.tsx @@ -126,11 +126,12 @@ export const DialogActionButtons: React.FC = ({ color={typeToColor(type)} loading={confirmLoading} type="submit" - className={combineClasses([ - styles.dialogButton, - styles.submitButton, - type === "delete" ? styles.errorButton : "", - ])} + className={combineClasses({ + [styles.dialogButton]: true, + [styles.submitButton]: true, + [styles.errorButton]: type === "delete", + [styles.successButton]: type === "success", + })} > {confirmText} @@ -246,6 +247,56 @@ const useButtonStyles = makeStyles((theme) => ({ }, }, }, + successButton: { + "&.MuiButton-contained": { + backgroundColor: theme.palette.success.main, + color: theme.palette.primary.contrastText, + "&:hover": { + backgroundColor: darken(theme.palette.success.main, 0.3), + "@media (hover: none)": { + backgroundColor: "transparent", + }, + "&.Mui-disabled": { + backgroundColor: "transparent", + }, + }, + "&.Mui-disabled": { + backgroundColor: theme.palette.action.disabledBackground, + color: fade(theme.palette.text.disabled, 0.5), + }, + }, + + "&.MuiButton-outlined": { + color: theme.palette.success.main, + borderColor: theme.palette.success.main, + "&:hover": { + backgroundColor: fade(theme.palette.success.main, theme.palette.action.hoverOpacity), + "@media (hover: none)": { + backgroundColor: "transparent", + }, + "&.Mui-disabled": { + backgroundColor: "transparent", + }, + }, + "&.Mui-disabled": { + color: fade(theme.palette.text.disabled, 0.5), + borderColor: theme.palette.action.disabled, + }, + }, + + "&.MuiButton-text": { + color: theme.palette.success.main, + "&:hover": { + backgroundColor: fade(theme.palette.success.main, theme.palette.action.hoverOpacity), + "@media (hover: none)": { + backgroundColor: "transparent", + }, + }, + "&.Mui-disabled": { + color: fade(theme.palette.text.disabled, 0.5), + }, + }, + }, })) export type DialogSearchProps = Omit diff --git a/site/src/components/Dialog/types.ts b/site/src/components/Dialog/types.ts index bc827e0b6e4b6..a2909db8258e5 100644 --- a/site/src/components/Dialog/types.ts +++ b/site/src/components/Dialog/types.ts @@ -1 +1 @@ -export type ConfirmDialogType = "delete" | "info" +export type ConfirmDialogType = "delete" | "info" | "success" diff --git a/site/src/components/EnterpriseSnackbar/EnterpriseSnackbar.stories.tsx b/site/src/components/EnterpriseSnackbar/EnterpriseSnackbar.stories.tsx index 2565cab09fc28..751f8544d4e79 100644 --- a/site/src/components/EnterpriseSnackbar/EnterpriseSnackbar.stories.tsx +++ b/site/src/components/EnterpriseSnackbar/EnterpriseSnackbar.stories.tsx @@ -21,3 +21,10 @@ Info.args = { open: true, message: "Hey, something happened.", } + +export const Success = Template.bind({}) +Success.args = { + variant: "success", + open: true, + message: "Hey, something good happened.", +} diff --git a/site/src/components/EnterpriseSnackbar/EnterpriseSnackbar.tsx b/site/src/components/EnterpriseSnackbar/EnterpriseSnackbar.tsx index 5740ac3088d1a..03ce89c375624 100644 --- a/site/src/components/EnterpriseSnackbar/EnterpriseSnackbar.tsx +++ b/site/src/components/EnterpriseSnackbar/EnterpriseSnackbar.tsx @@ -5,7 +5,7 @@ import CloseIcon from "@material-ui/icons/Close" import { FC } from "react" import { combineClasses } from "../../util/combineClasses" -type EnterpriseSnackbarVariant = "error" | "info" +type EnterpriseSnackbarVariant = "error" | "info" | "success" export interface EnterpriseSnackbarProps extends MuiSnackbarProps { /** Called when the snackbar should close, either from timeout or clicking close */ @@ -45,7 +45,7 @@ export const EnterpriseSnackbar: FC = ({
{action} - +
} @@ -55,6 +55,7 @@ export const EnterpriseSnackbar: FC = ({ [styles.snackbarContent]: true, [styles.snackbarContentInfo]: variant === "info", [styles.snackbarContentError]: variant === "error", + [styles.snackbarContentSuccess]: variant === "success", }), }} onClose={onClose} @@ -73,12 +74,7 @@ const useStyles = makeStyles((theme) => ({ closeIcon: { width: 25, height: 25, - color: theme.palette.info.contrastText, - }, - closeIconError: { - width: 25, - height: 25, - color: theme.palette.error.contrastText, + color: theme.palette.primary.contrastText, }, snackbarContent: { border: `1px solid ${theme.palette.divider}`, @@ -87,16 +83,17 @@ const useStyles = makeStyles((theme) => ({ padding: `${theme.spacing(1)}px ${theme.spacing(3)}px ${theme.spacing(1)}px ${theme.spacing(2)}px`, boxShadow: theme.shadows[6], alignItems: "inherit", + backgroundColor: theme.palette.background.paper, + color: theme.palette.text.secondary, }, snackbarContentInfo: { - backgroundColor: theme.palette.info.main, - // Use primary color as a highlight + // Use success color as a highlight borderLeftColor: theme.palette.primary.main, - color: theme.palette.info.contrastText, }, snackbarContentError: { - backgroundColor: theme.palette.background.paper, borderLeftColor: theme.palette.error.main, - color: theme.palette.text.secondary, + }, + snackbarContentSuccess: { + borderLeftColor: theme.palette.success.main, }, })) diff --git a/site/src/components/GlobalSnackbar/GlobalSnackbar.tsx b/site/src/components/GlobalSnackbar/GlobalSnackbar.tsx index 873572848da76..e2dd795f806ce 100644 --- a/site/src/components/GlobalSnackbar/GlobalSnackbar.tsx +++ b/site/src/components/GlobalSnackbar/GlobalSnackbar.tsx @@ -15,6 +15,16 @@ import { SnackbarEventType, } from "./utils" +const variantFromMsgType = (type: MsgType) => { + if (type === MsgType.Error) { + return "error" + } else if (type === MsgType.Success) { + return "success" + } else { + return "info" + } +} + export const GlobalSnackbar: React.FC = () => { const styles = useStyles() const [open, setOpen] = useState(false) @@ -63,7 +73,7 @@ export const GlobalSnackbar: React.FC = () => { return ( {notification.msgType === MsgType.Error && } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy