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

refactor(site): Redesign dialogs#6237

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
BrunoQuaresma merged 1 commit intomainfrombq/refactor-dialogs
Feb 16, 2023
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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
import { action } from "@storybook/addon-actions"
import { ComponentMeta, Story } from "@storybook/react"
import { ConfirmDialog, ConfirmDialogProps } from "./ConfirmDialog"

Expand All@@ -7,9 +8,11 @@ export default {
argTypes: {
onClose: {
action: "onClose",
defaultValue: action("onClose"),
},
onConfirm: {
action: "onConfirm",
defaultValue: action("onConfirm"),
},
open: {
control: "boolean",
Expand Down
49 changes: 22 additions & 27 deletionssite/src/components/Dialogs/ConfirmDialog/ConfirmDialog.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
import DialogActions from "@material-ui/core/DialogActions"
import { alpha, makeStyles } from "@material-ui/core/styles"
import Typography from "@material-ui/core/Typography"
import { makeStyles } from "@material-ui/core/styles"
import { ReactNode, FC, PropsWithChildren } from "react"
import {
Dialog,
Expand DownExpand Up@@ -61,25 +60,35 @@ const useStyles = makeStyles((theme) => ({
"& .MuiPaper-root": {
background: theme.palette.background.paper,
border: `1px solid ${theme.palette.divider}`,
width: "100%",
maxWidth: theme.spacing(55),
},
"& .MuiDialogActions-spacing": {
padding: `0 ${theme.spacing(3.75)}px ${theme.spacing(3.75)}px`,
padding: `0 ${theme.spacing(5)}px ${theme.spacing(5)}px`,
},
},
dialogContent: {
color: theme.palette.text.secondary,
padding: theme.spacing(6),
textAlign: "center",
padding: theme.spacing(5),
},
titleText: {
marginBottom: theme.spacing(3),
dialogTitle: {
margin: 0,
marginBottom: theme.spacing(2),
color: theme.palette.text.primary,
fontWeight: 400,
fontSize: theme.spacing(2.5),
},
description: {
color:alpha(theme.palette.text.secondary, 0.75),
dialogDescription: {
color: theme.palette.text.secondary,
lineHeight: "160%",
fontSize: 16,

"& strong": {
color: alpha(theme.palette.text.secondary, 0.95),
color: theme.palette.text.primary,
},

"& p": {
margin: theme.spacing(1, 0),
},
},
}))
Expand DownExpand Up@@ -110,25 +119,11 @@ export const ConfirmDialog: FC<PropsWithChildren<ConfirmDialogProps>> = ({
}

return (
<Dialog
className={styles.dialogWrapper}
maxWidth="sm"
onClose={onClose}
open={open}
>
<Dialog className={styles.dialogWrapper} onClose={onClose} open={open}>
<div className={styles.dialogContent}>
<Typography className={styles.titleText} variant="h3">
{title}
</Typography>

<h3 className={styles.dialogTitle}>{title}</h3>
{description && (
<Typography
component={typeof description === "string" ? "p" : "div"}
className={styles.description}
variant="body2"
>
{description}
</Typography>
<div className={styles.dialogDescription}>{description}</div>
)}
</div>

Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
import { action } from "@storybook/addon-actions"
import { ComponentMeta, Story } from "@storybook/react"
import { DeleteDialog, DeleteDialogProps } from "./DeleteDialog"

Expand All@@ -7,9 +8,11 @@ export default {
argTypes: {
onCancel: {
action: "onClose",
defaultValue: action("onClose"),
},
onConfirm: {
action: "onConfirm",
defaultValue: action("onConfirm"),
},
open: {
control: "boolean",
Expand Down
48 changes: 26 additions & 22 deletionssite/src/components/Dialogs/DeleteDialog/DeleteDialog.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
import FormHelperText from "@material-ui/core/FormHelperText"
import makeStyles from "@material-ui/core/styles/makeStyles"
import TextField from "@material-ui/core/TextField"
import Typography from "@material-ui/core/Typography"
import { Maybe } from "components/Conditionals/Maybe"
import { Stack } from "components/Stack/Stack"
import { ChangeEvent, useState, PropsWithChildren, FC } from "react"
import { useTranslation } from "react-i18next"
import { ConfirmDialog } from "../ConfirmDialog/ConfirmDialog"
Expand DownExpand Up@@ -34,30 +31,33 @@ export const DeleteDialog: FC<PropsWithChildren<DeleteDialogProps>> = ({
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
setNameValue(event.target.value)
}
const hasError = nameValue.length > 0 && !confirmed

const content = (
<>
<Typography>{t("deleteDialog.intro", { entity })}</Typography>
<p>{t("deleteDialog.intro", { entity })}</p>
<Maybe condition={info !== undefined}>
<Typography className={styles.warning}>{info}</Typography>
<p className={styles.warning}>{info}</p>
</Maybe>
<Typography>{t("deleteDialog.confirm", { entity })}</Typography>
<Stack spacing={1}>
<TextField
name="confirmation"
autoComplete="off"
id="confirmation"
placeholder={name}
value={nameValue}
onChange={handleChange}
label={t("deleteDialog.confirmLabel", { entity })}
/>
<Maybe condition={nameValue.length > 0 && !confirmed}>
<FormHelperText error>
{t("deleteDialog.incorrectName", { entity })}
</FormHelperText>
</Maybe>
</Stack>
<p>{t("deleteDialog.confirm", { entity })}</p>

<TextField
fullWidth
InputLabelProps={{
shrink: true,
}}
autoFocus
className={styles.textField}
name="confirmation"
autoComplete="off"
id="confirmation"
placeholder={name}
value={nameValue}
onChange={handleChange}
label={t("deleteDialog.confirmLabel", { entity })}
error={hasError}
helperText={hasError && t("deleteDialog.incorrectName", { entity })}
/>
</>
)

Expand All@@ -80,4 +80,8 @@ const useStyles = makeStyles((theme) => ({
warning: {
color: theme.palette.warning.light,
},

textField: {
marginTop: theme.spacing(3),
},
}))
125 changes: 9 additions & 116 deletionssite/src/components/Dialogs/Dialog.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
import MuiDialog, {
DialogProps as MuiDialogProps,
} from "@material-ui/core/Dialog"
import { alpha, darken,lighten,makeStyles } from "@material-ui/core/styles"
import { alpha, darken, makeStyles } from "@material-ui/core/styles"
import * as React from "react"
import { colors } from "theme/colors"
import { combineClasses } from "../../util/combineClasses"
import {
LoadingButton,
Expand DownExpand Up@@ -42,7 +43,6 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
cancelText = "Cancel",
confirmText = "Confirm",
confirmLoading = false,
confirmDialog,
disabled = false,
onCancel,
onConfirm,
Expand All@@ -54,29 +54,24 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
<>
{onCancel && (
<LoadingButton
className={combineClasses({
[styles.dialogButton]: true,
[styles.cancelButton]: true,
[styles.confirmDialogCancelButton]: confirmDialog,
})}
disabled={confirmLoading}
onClick={onCancel}
variant="outlined"
fullWidth
>
{cancelText}
</LoadingButton>
)}
{onConfirm && (
<LoadingButton
fullWidth
variant="contained"
onClick={onConfirm}
color={typeToColor(type)}
loading={confirmLoading}
disabled={disabled}
type="submit"
className={combineClasses({
[styles.dialogButton]: true,
[styles.submitButton]: true,
[styles.errorButton]: type === "delete",
[styles.successButton]: type === "success",
})}
Expand All@@ -88,119 +83,17 @@ export const DialogActionButtons: React.FC<DialogActionButtonsProps> = ({
)
}

interface StyleProps {
type: ConfirmDialogType
}

const useButtonStyles = makeStyles((theme) => ({
dialogButton: {
borderRadius: theme.shape.borderRadius,
fontSize: theme.typography.h6.fontSize,
fontWeight: theme.typography.h5.fontWeight,
padding: `${theme.spacing(0.75)}px ${theme.spacing(2)}px`,
width: "100%",
boxShadow: "none",
},
cancelButton: {
background: alpha(theme.palette.primary.main, 0.1),
color: theme.palette.primary.main,

"&:hover": {
background: alpha(theme.palette.primary.main, 0.3),
},
},
confirmDialogCancelButton: (props: StyleProps) => {
const color =
props.type === "info"
? theme.palette.primary.contrastText
: theme.palette.error.contrastText
return {
background: alpha(color, 0.15),
color,

"&:hover": {
background: alpha(color, 0.3),
},

"&.Mui-disabled": {
background: alpha(color, 0.15),
color: alpha(color, 0.5),
},
}
},
submitButton: {
// Override disabled to keep background color, change loading spinner to contrast color
"&.Mui-disabled": {
"&.MuiButton-containedPrimary": {
background: theme.palette.primary.dark,

"& .MuiCircularProgress-root": {
color: theme.palette.primary.contrastText,
},
},

"&.CdrButton-error.MuiButton-contained": {
background: darken(theme.palette.error.main, 0.3),

"& .MuiCircularProgress-root": {
color: theme.palette.error.contrastText,
},
},
},
},
errorButton: {
"&.MuiButton-contained": {
backgroundColor: lighten(theme.palette.error.dark, 0.15),
color: theme.palette.error.contrastText,
"&:hover": {
backgroundColor: theme.palette.error.dark,
"@media (hover: none)": {
backgroundColor: "transparent",
},
"&.Mui-disabled": {
backgroundColor: "transparent",
},
},
"&.Mui-disabled": {
backgroundColor: theme.palette.action.disabledBackground,
color: alpha(theme.palette.text.disabled, 0.5),
},
},

"&.MuiButton-outlined": {
color: theme.palette.error.main,
borderColor: theme.palette.error.main,
"&:hover": {
backgroundColor: alpha(
theme.palette.error.main,
theme.palette.action.hoverOpacity,
),
"@media (hover: none)": {
backgroundColor: "transparent",
},
"&.Mui-disabled": {
backgroundColor: "transparent",
},
},
"&.Mui-disabled": {
color: alpha(theme.palette.text.disabled, 0.5),
borderColor: theme.palette.action.disabled,
},
},

"&.MuiButton-text": {
color: theme.palette.error.main,
backgroundColor: colors.red[10],
borderColor: colors.red[9],
color: theme.palette.text.primary,
"&:hover": {
backgroundColor: alpha(
theme.palette.error.main,
theme.palette.action.hoverOpacity,
),
"@media (hover: none)": {
backgroundColor: "transparent",
},
backgroundColor: colors.red[9],
},
"&.Mui-disabled": {
color: alpha(theme.palette.text.disabled,0.5),
opacity:0.5,
},
},
},
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
import { action } from "@storybook/addon-actions"
import { Story } from "@storybook/react"
import { MockUser } from "../../../testHelpers/renderHelpers"
import {
Expand All@@ -9,8 +10,8 @@ export default {
title: "components/Dialogs/ResetPasswordDialog",
component: ResetPasswordDialog,
argTypes: {
onClose: { action: "onClose" },
onConfirm: { action: "onConfirm" },
onClose: { action: "onClose", defaultValue: action("onClose") },
onConfirm: { action: "onConfirm", defaultValue: action("onConfirm") },
},
}

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp