Extract delete team alert into a file
Also, to support this: * Added `Destructive` class to Button * Added `primaryActionClassName` prop to Alert
This commit is contained in:
parent
7c3f03f20e
commit
c365f857b0
4 changed files with 51 additions and 1 deletions
|
|
@ -30,6 +30,7 @@
|
||||||
.description {
|
.description {
|
||||||
font-size: $font-regular;
|
font-size: $font-regular;
|
||||||
line-height: 1.4;
|
line-height: 1.4;
|
||||||
|
white-space: pre-line;
|
||||||
|
|
||||||
strong {
|
strong {
|
||||||
font-weight: $bold;
|
font-weight: $bold;
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ interface Props {
|
||||||
message: string | React.ReactNode
|
message: string | React.ReactNode
|
||||||
primaryAction?: () => void
|
primaryAction?: () => void
|
||||||
primaryActionText?: string
|
primaryActionText?: string
|
||||||
|
primaryActionClassName?: string
|
||||||
cancelAction: () => void
|
cancelAction: () => void
|
||||||
cancelActionText: string
|
cancelActionText: string
|
||||||
}
|
}
|
||||||
|
|
@ -22,7 +23,10 @@ const Alert = (props: Props) => {
|
||||||
<AlertDialog.Portal>
|
<AlertDialog.Portal>
|
||||||
<AlertDialog.Overlay className="Overlay" onClick={props.cancelAction} />
|
<AlertDialog.Overlay className="Overlay" onClick={props.cancelAction} />
|
||||||
<div className="AlertWrapper">
|
<div className="AlertWrapper">
|
||||||
<AlertDialog.Content className="Alert">
|
<AlertDialog.Content
|
||||||
|
className="Alert"
|
||||||
|
onEscapeKeyDown={props.cancelAction}
|
||||||
|
>
|
||||||
{props.title ? (
|
{props.title ? (
|
||||||
<AlertDialog.Title>{props.title}</AlertDialog.Title>
|
<AlertDialog.Title>{props.title}</AlertDialog.Title>
|
||||||
) : (
|
) : (
|
||||||
|
|
@ -42,6 +46,7 @@ const Alert = (props: Props) => {
|
||||||
{props.primaryAction ? (
|
{props.primaryAction ? (
|
||||||
<AlertDialog.Action asChild>
|
<AlertDialog.Action asChild>
|
||||||
<Button
|
<Button
|
||||||
|
className={props.primaryActionClassName}
|
||||||
contained={true}
|
contained={true}
|
||||||
onClick={props.primaryAction}
|
onClick={props.primaryAction}
|
||||||
text={props.primaryActionText}
|
text={props.primaryActionText}
|
||||||
|
|
|
||||||
|
|
@ -166,6 +166,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.Destructive {
|
||||||
|
background: $error;
|
||||||
|
color: white;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: darken($error, 15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.Accessory {
|
.Accessory {
|
||||||
$dimension: $unit-2x;
|
$dimension: $unit-2x;
|
||||||
|
|
||||||
|
|
|
||||||
35
components/dialogs/DeleteTeamAlert/index.tsx
Normal file
35
components/dialogs/DeleteTeamAlert/index.tsx
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
import React from 'react'
|
||||||
|
import { useTranslation } from 'next-i18next'
|
||||||
|
import Alert from '~components/common/Alert'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
open: boolean
|
||||||
|
deleteCallback: () => void
|
||||||
|
onOpenChange: (open: boolean) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
const DeleteTeamAlert = ({ open, deleteCallback, onOpenChange }: Props) => {
|
||||||
|
const { t } = useTranslation('common')
|
||||||
|
|
||||||
|
function deleteParty() {
|
||||||
|
deleteCallback()
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
onOpenChange(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Alert
|
||||||
|
open={open}
|
||||||
|
primaryAction={deleteParty}
|
||||||
|
primaryActionClassName="Destructive"
|
||||||
|
primaryActionText={t('modals.delete_team.buttons.confirm')}
|
||||||
|
cancelAction={close}
|
||||||
|
cancelActionText={t('modals.delete_team.buttons.cancel')}
|
||||||
|
message={t('modals.delete_team.description')}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DeleteTeamAlert
|
||||||
Loading…
Reference in a new issue