From 3cf8bcf5655b34cf9494799dbbffbb92d15ce561 Mon Sep 17 00:00:00 2001 From: iamacook Date: Tue, 25 Oct 2022 08:59:53 +0200 Subject: [PATCH 1/6] feat: new creation design + step 1 --- src/components/open/CardActions/index.tsx | 10 ++ .../open/CardActions/styles.module.css | 3 + src/components/open/CardContent/index.tsx | 10 ++ .../open/CardContent/styles.module.css | 5 + src/components/open/CardHeader/index.tsx | 22 +++ .../open/CardHeader/styles.module.css | 17 +++ src/components/open/CreateSafe/index.tsx | 55 +++++++ .../open/CreateSafe/styles.module.css | 7 + .../OverviewWidget/index.tsx | 0 .../OverviewWidget/styles.module.css | 0 src/components/open/steps/Step1/index.tsx | 138 ++++++++++++++++++ .../open/steps/Step1/styles.module.css | 24 +++ src/config/routes.ts | 1 + src/pages/demo.tsx | 17 +++ 14 files changed, 309 insertions(+) create mode 100644 src/components/open/CardActions/index.tsx create mode 100644 src/components/open/CardActions/styles.module.css create mode 100644 src/components/open/CardContent/index.tsx create mode 100644 src/components/open/CardContent/styles.module.css create mode 100644 src/components/open/CardHeader/index.tsx create mode 100644 src/components/open/CardHeader/styles.module.css create mode 100644 src/components/open/CreateSafe/index.tsx create mode 100644 src/components/open/CreateSafe/styles.module.css rename src/components/{create-safe => open}/OverviewWidget/index.tsx (100%) rename src/components/{create-safe => open}/OverviewWidget/styles.module.css (100%) create mode 100644 src/components/open/steps/Step1/index.tsx create mode 100644 src/components/open/steps/Step1/styles.module.css create mode 100644 src/pages/demo.tsx diff --git a/src/components/open/CardActions/index.tsx b/src/components/open/CardActions/index.tsx new file mode 100644 index 0000000000..c381746004 --- /dev/null +++ b/src/components/open/CardActions/index.tsx @@ -0,0 +1,10 @@ +import { CardActions } from '@mui/material' +import type { CardActionsProps } from '@mui/material' + +import css from './styles.module.css' + +const CreateSafeCardActions = (props: CardActionsProps) => { + return +} + +export default CreateSafeCardActions diff --git a/src/components/open/CardActions/styles.module.css b/src/components/open/CardActions/styles.module.css new file mode 100644 index 0000000000..90bb38b53f --- /dev/null +++ b/src/components/open/CardActions/styles.module.css @@ -0,0 +1,3 @@ +.actions { + padding: var(--space-3) 52px; +} diff --git a/src/components/open/CardContent/index.tsx b/src/components/open/CardContent/index.tsx new file mode 100644 index 0000000000..dd86289c48 --- /dev/null +++ b/src/components/open/CardContent/index.tsx @@ -0,0 +1,10 @@ +import { CardContent } from '@mui/material' +import type { CardContentProps } from '@mui/material' + +import css from './styles.module.css' + +const CreateSafeCardContent = (props: CardContentProps) => { + return +} + +export default CreateSafeCardContent diff --git a/src/components/open/CardContent/styles.module.css b/src/components/open/CardContent/styles.module.css new file mode 100644 index 0000000000..ed6e28fea8 --- /dev/null +++ b/src/components/open/CardContent/styles.module.css @@ -0,0 +1,5 @@ +.content { + padding: var(--space-3) 52px; + border-top: 1px solid var(--color-border-light); + border-bottom: 1px solid var(--color-border-light); +} diff --git a/src/components/open/CardHeader/index.tsx b/src/components/open/CardHeader/index.tsx new file mode 100644 index 0000000000..a3f4b47b70 --- /dev/null +++ b/src/components/open/CardHeader/index.tsx @@ -0,0 +1,22 @@ +import { CardHeader, Avatar, Typography } from '@mui/material' +import type { CardHeaderProps } from '@mui/material' + +import css from './styles.module.css' + +const CreateSafeCardHeader = ({ step, ...props }: CardHeaderProps & { step: number }) => { + return ( + + {step} + + } + className={css.header} + {...props} + /> + ) +} + +export default CreateSafeCardHeader diff --git a/src/components/open/CardHeader/styles.module.css b/src/components/open/CardHeader/styles.module.css new file mode 100644 index 0000000000..be95a226f1 --- /dev/null +++ b/src/components/open/CardHeader/styles.module.css @@ -0,0 +1,17 @@ +.header { + padding: var(--space-3) var(--space-2); +} + +.header :global .MuiCardHeader-title { + font-weight: 700; +} + +.header :global .MuiCardHeader-subheader { + color: var(--color-text-primary); +} + +.avatar { + background-color: var(--color-primary-main); + height: 20px; + width: 20px; +} diff --git a/src/components/open/CreateSafe/index.tsx b/src/components/open/CreateSafe/index.tsx new file mode 100644 index 0000000000..6522b43015 --- /dev/null +++ b/src/components/open/CreateSafe/index.tsx @@ -0,0 +1,55 @@ +import { Button, Typography, Grid } from '@mui/material' +import ChevronLeftIcon from '@mui/icons-material/ChevronLeft' +import { useRouter } from 'next/router' + +import WalletInfo from '@/components/common/WalletInfo' +import { useCurrentChain } from '@/hooks/useChains' +import useWallet from '@/hooks/wallets/useWallet' +import OverviewWidget from '../OverviewWidget' +import CreateSafeStep1 from '../steps/Step1' + +import css from './styles.module.css' + +const CreateSafe = () => { + const router = useRouter() + + // TODO: These rows are just a demo + const wallet = useWallet() + const chain = useCurrentChain() + const rows = [ + ...(wallet && chain ? [{ title: 'Wallet', component: }] : []), + ] + + const onBack = () => { + router.back() + + // Logic to be handled by stepper hook + } + + // TODO: Improve layout when other widget/responsive design is ready + return ( + + + + + + Create new Safe + + + + + + + + + + + + + + ) +} + +export default CreateSafe diff --git a/src/components/open/CreateSafe/styles.module.css b/src/components/open/CreateSafe/styles.module.css new file mode 100644 index 0000000000..57cc135937 --- /dev/null +++ b/src/components/open/CreateSafe/styles.module.css @@ -0,0 +1,7 @@ +.back { + margin: var(--space-4) 0; +} + +.title { + padding-bottom: var(--space-2); +} diff --git a/src/components/create-safe/OverviewWidget/index.tsx b/src/components/open/OverviewWidget/index.tsx similarity index 100% rename from src/components/create-safe/OverviewWidget/index.tsx rename to src/components/open/OverviewWidget/index.tsx diff --git a/src/components/create-safe/OverviewWidget/styles.module.css b/src/components/open/OverviewWidget/styles.module.css similarity index 100% rename from src/components/create-safe/OverviewWidget/styles.module.css rename to src/components/open/OverviewWidget/styles.module.css diff --git a/src/components/open/steps/Step1/index.tsx b/src/components/open/steps/Step1/index.tsx new file mode 100644 index 0000000000..5d6ce43a31 --- /dev/null +++ b/src/components/open/steps/Step1/index.tsx @@ -0,0 +1,138 @@ +import { + Card, + LinearProgress, + Select, + InputAdornment, + InputLabel, + MenuItem, + TextField, + Tooltip, + SvgIcon, + Typography, + Button, + Link, +} from '@mui/material' +import { useForm } from 'react-hook-form' + +import ChainIndicator from '@/components/common/ChainIndicator' +import useChainId from '@/hooks/useChainId' +import useChains from '@/hooks/useChains' +import { useMnemonicSafeName } from '@/hooks/useMnemonicName' +import InfoIcon from '@/public/images/notifications/info.svg' +import CreateSafeCardContent from '../../CardContent' +import CreateSafeCardHeader from '../../CardHeader' +import CreateSafeCardActions from '../../CardActions' + +import css from './styles.module.css' + +type CreateSafeStep1Form = { + chainId: string + name: string +} + +enum CreateSafeStep1Fields { + chainId = 'chainId', + name = 'name', +} + +const STEP_1_FORM_ID = 'create-safe-step-1-form' + +const CreateSafeStep1 = () => { + const chainId = useChainId() + const { configs } = useChains() + const fallbackName = useMnemonicSafeName() + + const { + handleSubmit, + register, + formState: { errors }, + } = useForm({ + mode: 'all', + defaultValues: { + [CreateSafeStep1Fields.chainId]: chainId || '', + [CreateSafeStep1Fields.name]: '', + }, + }) + + const onSubmit = (data: CreateSafeStep1Form) => { + console.log(data) + } + + return ( + + + + + + +
+ + + + + + + + ), + }} + InputLabelProps={{ + shrink: true, + }} + {...register(CreateSafeStep1Fields.name)} + /> + + + By continuing, you agree to our{' '} + + terms of use + {' '} + and{' '} + + privacy policy + + . + + +
+ + + + +
+ ) +} + +export default CreateSafeStep1 diff --git a/src/components/open/steps/Step1/styles.module.css b/src/components/open/steps/Step1/styles.module.css new file mode 100644 index 0000000000..9aa4f18ffa --- /dev/null +++ b/src/components/open/steps/Step1/styles.module.css @@ -0,0 +1,24 @@ +.card { + border: none; +} + +.form { + display: flex; + flex-direction: column; + gap: var(--space-3); + align-items: flex-start; +} + +.select { + border-radius: 0; + padding-left: var(--space-1); + border-left: 1px solid var(--color-border-main); +} + +.chain { + min-width: 90px; + min-height: var(--space-2); + border-radius: 4px; + font-size: 12px; + font-weight: 700px; +} diff --git a/src/config/routes.ts b/src/config/routes.ts index 28342223ce..9a323bd190 100644 --- a/src/config/routes.ts +++ b/src/config/routes.ts @@ -5,6 +5,7 @@ export const AppRoutes = { load: '/load', index: '/', home: '/home', + demo: '/demo', apps: '/apps', addressBook: '/address-book', balances: { diff --git a/src/pages/demo.tsx b/src/pages/demo.tsx new file mode 100644 index 0000000000..08cd69846d --- /dev/null +++ b/src/pages/demo.tsx @@ -0,0 +1,17 @@ +import type { NextPage } from 'next' +import Head from 'next/head' +import CreateSafe from '@/components/open/CreateSafe' + +const Open: NextPage = () => { + return ( +
+ + Safe – Create Safe + + + +
+ ) +} + +export default Open From ddaf0d9161944059ce3eb1047cd363b5ed8b766d Mon Sep 17 00:00:00 2001 From: iamacook Date: Tue, 25 Oct 2022 09:03:06 +0200 Subject: [PATCH 2/6] fix: widget width --- src/components/open/CreateSafe/index.tsx | 5 ++--- src/components/open/OverviewWidget/styles.module.css | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/open/CreateSafe/index.tsx b/src/components/open/CreateSafe/index.tsx index 6522b43015..1f1dd6da25 100644 --- a/src/components/open/CreateSafe/index.tsx +++ b/src/components/open/CreateSafe/index.tsx @@ -30,7 +30,7 @@ const CreateSafe = () => { return ( - + @@ -38,13 +38,12 @@ const CreateSafe = () => { Create new Safe - - + diff --git a/src/components/open/OverviewWidget/styles.module.css b/src/components/open/OverviewWidget/styles.module.css index 98c0c668fc..c7e87b7dbe 100644 --- a/src/components/open/OverviewWidget/styles.module.css +++ b/src/components/open/OverviewWidget/styles.module.css @@ -1,6 +1,6 @@ .card { border: 1px solid var(--color-border-light); - width: 300px; /* TODO: Remove when added to flow */ + width: 100%; } .header { From 4997dc08fae824bbd23f3f22557decd35fd13447 Mon Sep 17 00:00:00 2001 From: iamacook Date: Tue, 25 Oct 2022 09:33:42 +0200 Subject: [PATCH 3/6] refactor: combine components --- src/components/open/CardActions/index.tsx | 10 ----- .../open/CardActions/styles.module.css | 3 -- src/components/open/CardContent/index.tsx | 10 ----- .../open/CardContent/styles.module.css | 5 --- src/components/open/CardHeader/index.tsx | 22 ---------- src/components/open/StepCard/index.tsx | 41 +++++++++++++++++++ .../styles.module.css | 16 +++++++- src/components/open/steps/Step1/index.tsx | 29 ++++--------- 8 files changed, 65 insertions(+), 71 deletions(-) delete mode 100644 src/components/open/CardActions/index.tsx delete mode 100644 src/components/open/CardActions/styles.module.css delete mode 100644 src/components/open/CardContent/index.tsx delete mode 100644 src/components/open/CardContent/styles.module.css delete mode 100644 src/components/open/CardHeader/index.tsx create mode 100644 src/components/open/StepCard/index.tsx rename src/components/open/{CardHeader => StepCard}/styles.module.css (54%) diff --git a/src/components/open/CardActions/index.tsx b/src/components/open/CardActions/index.tsx deleted file mode 100644 index c381746004..0000000000 --- a/src/components/open/CardActions/index.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { CardActions } from '@mui/material' -import type { CardActionsProps } from '@mui/material' - -import css from './styles.module.css' - -const CreateSafeCardActions = (props: CardActionsProps) => { - return -} - -export default CreateSafeCardActions diff --git a/src/components/open/CardActions/styles.module.css b/src/components/open/CardActions/styles.module.css deleted file mode 100644 index 90bb38b53f..0000000000 --- a/src/components/open/CardActions/styles.module.css +++ /dev/null @@ -1,3 +0,0 @@ -.actions { - padding: var(--space-3) 52px; -} diff --git a/src/components/open/CardContent/index.tsx b/src/components/open/CardContent/index.tsx deleted file mode 100644 index dd86289c48..0000000000 --- a/src/components/open/CardContent/index.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { CardContent } from '@mui/material' -import type { CardContentProps } from '@mui/material' - -import css from './styles.module.css' - -const CreateSafeCardContent = (props: CardContentProps) => { - return -} - -export default CreateSafeCardContent diff --git a/src/components/open/CardContent/styles.module.css b/src/components/open/CardContent/styles.module.css deleted file mode 100644 index ed6e28fea8..0000000000 --- a/src/components/open/CardContent/styles.module.css +++ /dev/null @@ -1,5 +0,0 @@ -.content { - padding: var(--space-3) 52px; - border-top: 1px solid var(--color-border-light); - border-bottom: 1px solid var(--color-border-light); -} diff --git a/src/components/open/CardHeader/index.tsx b/src/components/open/CardHeader/index.tsx deleted file mode 100644 index a3f4b47b70..0000000000 --- a/src/components/open/CardHeader/index.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { CardHeader, Avatar, Typography } from '@mui/material' -import type { CardHeaderProps } from '@mui/material' - -import css from './styles.module.css' - -const CreateSafeCardHeader = ({ step, ...props }: CardHeaderProps & { step: number }) => { - return ( - - {step} - - } - className={css.header} - {...props} - /> - ) -} - -export default CreateSafeCardHeader diff --git a/src/components/open/StepCard/index.tsx b/src/components/open/StepCard/index.tsx new file mode 100644 index 0000000000..2037eb412f --- /dev/null +++ b/src/components/open/StepCard/index.tsx @@ -0,0 +1,41 @@ +import { Card, CardHeader, Avatar, Typography, CardContent, CardActions, LinearProgress } from '@mui/material' +import type { ReactElement } from 'react' + +import css from './styles.module.css' + +const StepCard = ({ + title, + subheader, + content, + actions, +}: { + title: string + subheader: string + content: ReactElement + actions: ReactElement +}): ReactElement => { + // TODO: `step` and `LinearProgress` will be set via stepper hook + const step = 1 + + return ( + + + + {step} + + } + className={css.header} + /> + {content} + {actions} + + ) +} + +export default StepCard diff --git a/src/components/open/CardHeader/styles.module.css b/src/components/open/StepCard/styles.module.css similarity index 54% rename from src/components/open/CardHeader/styles.module.css rename to src/components/open/StepCard/styles.module.css index be95a226f1..8ea2864b08 100644 --- a/src/components/open/CardHeader/styles.module.css +++ b/src/components/open/StepCard/styles.module.css @@ -1,3 +1,7 @@ +.card { + border: none; +} + .header { padding: var(--space-3) var(--space-2); } @@ -10,8 +14,18 @@ color: var(--color-text-primary); } -.avatar { +.step { background-color: var(--color-primary-main); height: 20px; width: 20px; } + +.content { + padding: var(--space-3) 52px; + border-top: 1px solid var(--color-border-light); + border-bottom: 1px solid var(--color-border-light); +} + +.actions { + padding: var(--space-3) 52px; +} diff --git a/src/components/open/steps/Step1/index.tsx b/src/components/open/steps/Step1/index.tsx index 5d6ce43a31..516e103f28 100644 --- a/src/components/open/steps/Step1/index.tsx +++ b/src/components/open/steps/Step1/index.tsx @@ -1,6 +1,4 @@ import { - Card, - LinearProgress, Select, InputAdornment, InputLabel, @@ -19,9 +17,7 @@ import useChainId from '@/hooks/useChainId' import useChains from '@/hooks/useChains' import { useMnemonicSafeName } from '@/hooks/useMnemonicName' import InfoIcon from '@/public/images/notifications/info.svg' -import CreateSafeCardContent from '../../CardContent' -import CreateSafeCardHeader from '../../CardHeader' -import CreateSafeCardActions from '../../CardActions' +import StepCard from '../../StepCard' import css from './styles.module.css' @@ -59,16 +55,10 @@ const CreateSafeStep1 = () => { } return ( - - - - - - + - Network - - } - {...register(CreateSafeStep1Fields.chainId)} - SelectDisplayProps={{ - className: css.select, - }} - defaultValue={chainId} - > - {configs.map((chain) => ( - - - - ))} - + + + Network + + + + +