From 614ee1b133c85df2ab0a470921a87f7406f57a11 Mon Sep 17 00:00:00 2001 From: Aaron Cook Date: Thu, 27 Oct 2022 16:19:01 +0200 Subject: [PATCH] feat: creation info widget (#960) * feat: creation info widget * fix: Remove demo page Co-authored-by: Usame Algan --- public/images/common/lightbulb.svg | 10 +++ .../create-safe/InfoWidget/index.tsx | 86 +++++++++++++++++++ .../create-safe/InfoWidget/styles.module.css | 30 +++++++ src/styles/colors.ts | 2 +- src/styles/vars.css | 2 +- 5 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 public/images/common/lightbulb.svg create mode 100644 src/components/create-safe/InfoWidget/index.tsx create mode 100644 src/components/create-safe/InfoWidget/styles.module.css diff --git a/public/images/common/lightbulb.svg b/public/images/common/lightbulb.svg new file mode 100644 index 0000000000..1dbf872f3d --- /dev/null +++ b/public/images/common/lightbulb.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/components/create-safe/InfoWidget/index.tsx b/src/components/create-safe/InfoWidget/index.tsx new file mode 100644 index 0000000000..cfaf826abb --- /dev/null +++ b/src/components/create-safe/InfoWidget/index.tsx @@ -0,0 +1,86 @@ +import { Box, Button, Card, CardActions, CardContent, CardHeader, SvgIcon, Typography } from '@mui/material' +import ChevronLeftIcon from '@mui/icons-material/ChevronLeft' +import { useState } from 'react' +import type { AlertColor } from '@mui/material' +import type { ReactElement } from 'react' + +import LightbulbIcon from '@/public/images/common/lightbulb.svg' + +import css from './styles.module.css' + +type Props = { + title: string + steps: { title: string; text: string }[] + variant: AlertColor +} + +const InfoWidget = ({ title, steps, variant }: Props): ReactElement | null => { + const [activeStep, setActiveStep] = useState(0) + const [dismissed, setDismissed] = useState(false) + + const isFirst = activeStep === 0 + const isLast = activeStep === steps.length - 1 + + const isMultiStep = steps.length > 1 + + const onPrev = () => { + if (!isFirst) { + setActiveStep((prev) => prev - 1) + } + } + + const onNext = () => { + if (isLast) { + setDismissed(true) + } else { + setActiveStep((prev) => prev + 1) + } + } + + if (dismissed) { + return null + } + + return ( + palette[variant]?.background }}> + + palette[variant]?.main, + }} + > + + {title} + + {isMultiStep && ( + + {activeStep + 1} of {steps.length} + + )} + + } + /> + + {steps[activeStep].title} + {steps[activeStep].text} + + + {isMultiStep && !isFirst && ( + + )} + + + + ) +} + +export default InfoWidget diff --git a/src/components/create-safe/InfoWidget/styles.module.css b/src/components/create-safe/InfoWidget/styles.module.css new file mode 100644 index 0000000000..cef51fb000 --- /dev/null +++ b/src/components/create-safe/InfoWidget/styles.module.css @@ -0,0 +1,30 @@ +.header { + padding-bottom: 0px; +} + +.headerWrapper { + display: flex; + justify-content: space-between; + align-items: center; +} + +.title { + font-weight: 700; + padding: calc(var(--space-1) / 2) var(--space-1); + border-radius: 6px; + display: flex; + align-items: center; +} + +.lightbulb { + margin-right: calc(var(--space-1) / 2); +} + +.count { + color: var(--color-text-secondary); +} + +.actions { + display: flex; + justify-content: flex-end; +} diff --git a/src/styles/colors.ts b/src/styles/colors.ts index 3897cf1d6b..bc368b427b 100644 --- a/src/styles/colors.ts +++ b/src/styles/colors.ts @@ -42,7 +42,7 @@ const palette = { dark: '#CD674E', main: '#FF8061', light: '#FFB7A6', - background: '#EFFFF4', + background: '#FFF0ED', }, background: { default: '#F4F4F4', diff --git a/src/styles/vars.css b/src/styles/vars.css index 38043f17b3..32b7bf4bb7 100644 --- a/src/styles/vars.css +++ b/src/styles/vars.css @@ -29,7 +29,7 @@ --color-warning-dark: #cd674e; --color-warning-main: #ff8061; --color-warning-light: #ffb7a6; - --color-warning-background: #effff4; + --color-warning-background: #fff0ed; --color-background-default: #f4f4f4; --color-background-main: #f4f4f4; --color-background-paper: #ffffff;