Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Update success confirmation dialog and snackbar#2005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
AbhineetJain merged 4 commits intomainfromabhineetjain/1984-success-dialog-alert
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletionssite/src/components/ConfirmDialog/ConfirmDialog.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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",
}
32 changes: 14 additions & 18 deletionssite/src/components/ConfirmDialog/ConfirmDialog.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,10 @@ const CONFIRM_DIALOG_DEFAULTS: Record<ConfirmDialogType, ConfirmDialogTypeConfig
confirmText: "OK",
hideCancel: true,
},
success: {
confirmText: "OK",
hideCancel: true,
},
}

export interface ConfirmDialogProps extends Omit<DialogActionButtonsProps, "color" | "confirmDialog" | "onCancel"> {
Expand All@@ -41,40 +45,32 @@ export interface ConfirmDialogProps extends Omit<DialogActionButtonsProps, "colo
readonly title: string
}

interface StyleProps {
type: ConfirmDialogType
}

const useStyles = makeStyles((theme) => ({
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),
},
}),
},
}))

/**
Expand Down
61 changes: 56 additions & 5 deletionssite/src/components/Dialog/Dialog.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -126,11 +126,12 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
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}
</LoadingButton>
Expand DownExpand Up@@ -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<OutlinedInputProps, "className" | "fullWidth" | "labelWidth" | "startAdornment">
Expand Down
2 changes: 1 addition & 1 deletionsite/src/components/Dialog/types.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
export type ConfirmDialogType = "delete" | "info"
export type ConfirmDialogType = "delete" | "info" | "success"
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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.",
}
23 changes: 10 additions & 13 deletionssite/src/components/EnterpriseSnackbar/EnterpriseSnackbar.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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 */
Expand DownExpand Up@@ -45,7 +45,7 @@ export const EnterpriseSnackbar: FC<EnterpriseSnackbarProps> = ({
<div className={styles.actionWrapper}>
{action}
<IconButton onClick={onClose} className={styles.iconButton}>
<CloseIcon className={variant === "info" ?styles.closeIcon : styles.closeIconError} />
<CloseIcon className={styles.closeIcon} />
</IconButton>
</div>
}
Expand All@@ -55,6 +55,7 @@ export const EnterpriseSnackbar: FC<EnterpriseSnackbarProps> = ({
[styles.snackbarContent]: true,
[styles.snackbarContentInfo]: variant === "info",
[styles.snackbarContentError]: variant === "error",
[styles.snackbarContentSuccess]: variant === "success",
}),
}}
onClose={onClose}
Expand All@@ -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}`,
Expand All@@ -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,
},
}))
12 changes: 11 additions & 1 deletionsite/src/components/GlobalSnackbar/GlobalSnackbar.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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<boolean>(false)
Expand DownExpand Up@@ -63,7 +73,7 @@ export const GlobalSnackbar: React.FC = () => {
return (
<EnterpriseSnackbar
open={open}
variant={notification.msgType === MsgType.Error ? "error" : "info"}
variant={variantFromMsgType(notification.msgType)}
message={
<div className={styles.messageWrapper}>
{notification.msgType === MsgType.Error && <ErrorIcon className={styles.errorIcon} />}
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp