From fa7f0e2fc0d2550f5e0cec4579f71eb0d294c06b Mon Sep 17 00:00:00 2001 From: enes Date: Tue, 3 Sep 2024 13:38:55 +0200 Subject: [PATCH 1/8] refactor(create): move add counterpart below, select role to toggle, remove duplicate code --- src/pages/create/index.tsx | 244 +++++++++++++------------------------ 1 file changed, 86 insertions(+), 158 deletions(-) diff --git a/src/pages/create/index.tsx b/src/pages/create/index.tsx index f1cfbd0..d3ed57a 100644 --- a/src/pages/create/index.tsx +++ b/src/pages/create/index.tsx @@ -1,13 +1,4 @@ -import { - Button, - FormHelperText, - ListItemIcon, - ListItemText, - MenuItem, - Select, - TextField, - Tooltip -} from '@mui/material' +import { Button, FormHelperText, TextField, Tooltip } from '@mui/material' import type { Identifier, XYCoord } from 'dnd-core' import saveAs from 'file-saver' import JSZip from 'jszip' @@ -932,9 +923,18 @@ export const CreatePage = () => { } right={
+
+ +
setUserInput(e.target.value)} onKeyDown={handleInputKeyDown} @@ -950,42 +950,26 @@ export const CreatePage = () => { } }} /> - + +
- -
- -
- @@ -1088,8 +1061,8 @@ const DisplayUser = ({ {users .filter((user) => user.role === UserRole.signer) .map((user, index) => ( - {users .filter((user) => user.role === UserRole.viewer) - .map((user, index) => { - const userMeta = metadata[user.pubkey] + .map((user) => { return ( -
-
- -
- - - - +
+
) })} @@ -1179,23 +1096,26 @@ interface DragItem { type: string } -type SignerRowProps = { +type CounterpartProps = { userMeta: ProfileMetadata user: User - index: number - moveSigner: (dragIndex: number, hoverIndex: number) => void handleUserRoleChange: (role: UserRole, pubkey: string) => void handleRemoveUser: (pubkey: string) => void } -const SignerRow = ({ +type SignerCounterpartProps = CounterpartProps & { + index: number + moveSigner: (dragIndex: number, hoverIndex: number) => void +} + +const SignerCounterpart = ({ userMeta, user, index, moveSigner, handleUserRoleChange, handleRemoveUser -}: SignerRowProps) => { +}: SignerCounterpartProps) => { const ref = useRef(null) const [{ handlerId }, drop] = useDrop< @@ -1280,6 +1200,24 @@ const SignerRow = ({ ref={ref} > + +
+ ) +} + +const Counterpart = ({ + userMeta, + user, + handleUserRoleChange, + handleRemoveUser +}: CounterpartProps) => { + return ( + <>
- - + + + -
+ ) } -- 2.34.1 From 5caa7f22823e7cdbdee262a88fd7fb4bf9f9da8a Mon Sep 17 00:00:00 2001 From: enes Date: Wed, 4 Sep 2024 17:35:54 +0200 Subject: [PATCH 2/8] refactor: update add counterparty design --- src/pages/create/index.tsx | 44 ++++++++++++++---------------- src/pages/create/style.module.scss | 21 +++++++++++++- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/pages/create/index.tsx b/src/pages/create/index.tsx index d3ed57a..0a15f2c 100644 --- a/src/pages/create/index.tsx +++ b/src/pages/create/index.tsx @@ -932,24 +932,25 @@ export const CreatePage = () => { moveSigner={moveSigner} /> -
- setUserInput(e.target.value)} - onKeyDown={handleInputKeyDown} - error={!!error} - fullWidth - sx={{ - fontSize: '16px', - '& .MuiInputBase-input': { - padding: '7px 14px' - }, - '& .MuiOutlinedInput-notchedOutline': { - display: 'none' - } - }} - /> +
+
+ setUserInput(e.target.value)} + onKeyDown={handleInputKeyDown} + error={!!error} + sx={{ + fontSize: '16px', + '& .MuiInputBase-input': { + padding: '7px 14px' + }, + '& .MuiOutlinedInput-notchedOutline': { + display: 'none' + } + }} + /> +
@@ -942,15 +930,6 @@ export const CreatePage = () => { onChange={(e) => setUserInput(e.target.value)} onKeyDown={handleInputKeyDown} error={!!error} - sx={{ - fontSize: '16px', - '& .MuiInputBase-input': { - padding: '7px 14px' - }, - '& .MuiOutlinedInput-notchedOutline': { - display: 'none' - } - }} />
@@ -1005,11 +978,7 @@ export const CreatePage = () => { {drawTool.active ? ( ) : ( - + Coming soon )} @@ -1057,7 +1026,7 @@ const DisplayUser = ({ }: DisplayUsersProps) => { return ( <> - + {users .filter((user) => user.role === UserRole.signer) .map((user, index) => ( @@ -1237,18 +1206,10 @@ const Counterpart = ({ user.pubkey ) } - sx={{ - minWidth: '34px', - height: '34px', - padding: 0, - color: 'var(--primary-main)', - '&:hover': { - color: 'white' - } - }} + className={styles.counterpartRowToggleButton} + data-variant="primary" > @@ -1256,17 +1217,10 @@ const Counterpart = ({ diff --git a/src/pages/create/style.module.scss b/src/pages/create/style.module.scss index 4652a64..a7dd7f2 100644 --- a/src/pages/create/style.module.scss +++ b/src/pages/create/style.module.scss @@ -42,6 +42,7 @@ } button { + min-width: 44px; color: $primary-main; } @@ -89,6 +90,16 @@ &:focus-within { outline-color: $primary-main; } + + // Override default MUI input styles only inside inputWrapepr + :global { + .MuiInputBase-input { + padding: 7px 14px; + } + .MuiOutlinedInput-notchedOutline { + display: none; + } + } } .addCounterpart { @@ -101,11 +112,21 @@ > .inputWrapper { flex-shrink: 1; } + + button { + min-width: 44px; + padding: 11px 12px; + } } .users { flex-shrink: 0; max-height: 33vh; + + .counterpartToggleButton { + min-width: 44px; + padding: 11px 12px; + } } .user { @@ -120,6 +141,22 @@ a:hover { text-decoration: none; } + + // Higher specificify to override default button styles + .counterpartRowToggleButton { + min-width: 34px; + height: 34px; + padding: 0; + } +} + +.counterpartRowToggleButton { + &[data-variant='primary'] { + color: $primary-main; + } + &[data-variant='secondary'] { + color: rgba(0, 0, 0, 0.35); + } } .avatar { @@ -199,3 +236,7 @@ cursor: not-allowed; } } + +.comingSoonPlaceholder { + font-size: 10px; +} -- 2.34.1