Skip to content

Commit

Permalink
ui: remove account name and improve some UI components (#65)
Browse files Browse the repository at this point in the history
* chore: update MetaMask provider

* chore: remove dead code

* fix: remove account name

* chore: fix linting errors

* chore: remove unused file

* feat: multiple small UI improvements

* feat: update accounts list on account deletion

* ui: fix work-break of `CopyableItemValue`

* ui: fix paddings and margins
  • Loading branch information
danroc authored Sep 14, 2023
1 parent 89e2444 commit 09087a8
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 241 deletions.
2 changes: 1 addition & 1 deletion packages/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@metamask/keyring-api": "^0.2.3",
"@metamask/providers": "^11.0.0",
"@metamask/providers": "^12.0.0",
"@mui/icons-material": "^5.14.0",
"@mui/material": "^5.14.0",
"@types/uuid": "^9.0.1",
Expand Down
3 changes: 2 additions & 1 deletion packages/site/src/components/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ const AccordionItem = styled.div`
border: 1px solid #eaeaea;
border-radius: 4px;
margin-bottom: 20px;
padding: 8px;
width: 100%;
`;

const AccordionHeader = styled.div`
margin: 16px;
margin: 8px;
font-weight: bold;
cursor: pointer;
display: flex;
Expand Down
4 changes: 1 addition & 3 deletions packages/site/src/components/Buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ const ActionButton = styled.button`
background-color: #0376c9;
border-radius: 999px;
padding: 5px 20px;
margin-left: 16px;
margin-right: 2.5%;
margin-top: 16px;
margin: 8px 2.5% 8px 16px;
&:hover {
background-color: #0376ff;
Expand Down
88 changes: 0 additions & 88 deletions packages/site/src/components/EditAccount.tsx

This file was deleted.

62 changes: 30 additions & 32 deletions packages/site/src/components/Method.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { InputType } from '../types';

const StyledDescription = styled.p`
font-size: 14px;
padding-top: 16px;
padding-left: 16px;
margin: 8px;
padding-top: 24px;
`;

const InputTitle = styled.p`
Expand All @@ -21,9 +21,9 @@ const InputTitle = styled.p`

const StyledSelect = styled.select`
width: 95%;
padding: 10px;
margin-top: 8px;
margin-left: 16px;
padding-top: 8px;
padding-bottom: 10px;
margin: 8px 2.5% 8px 16px;
border-radius: 5px;
`;

Expand All @@ -47,9 +47,7 @@ const TextField = styled.input`

const CopyableContainer = styled.div`
width: 95%;
margin-left: 2.5%;
margin-right: 2.5%;
margin-top: 20px;
margin: 0px 2.5% 8px 16px;
`;

export type MethodProps = {
Expand Down Expand Up @@ -137,11 +135,12 @@ export const Method = ({
{action && (
<MethodButton
onClick={async () => {
setResponse(null);
setError(null);
setResponse(undefined);
setError(undefined);
try {
const res = await action.callback();
setResponse(res);
// eslint-disable-next-line id-length
const r = await action.callback();
setResponse(r === undefined ? null : r);
// eslint-disable-next-line id-length
} catch (e: any) {
setError(e);
Expand All @@ -152,26 +151,25 @@ export const Method = ({
/>
)}

<CopyableContainer>
{response && (
<>
<AlertBanner
title={successMessage ?? 'Successful Request'}
alertType={AlertType.Success}
/>
<CopyableItem value={JSON.stringify(response, null, 3)} />
</>
)}
{error && (
<>
<AlertBanner
title={failureMessage ?? 'Error Request'}
alertType={AlertType.Failure}
/>
<CopyableItem value={JSON.stringify(error)} />
</>
)}
</CopyableContainer>
{response !== undefined && (
<CopyableContainer>
<AlertBanner
title={successMessage ?? 'Successful request'}
alertType={AlertType.Success}
/>
<CopyableItem value={JSON.stringify(response, null, 2)} />
</CopyableContainer>
)}

{error !== undefined && (
<CopyableContainer>
<AlertBanner
title={failureMessage ?? 'Error request'}
alertType={AlertType.Failure}
/>
<CopyableItem value={JSON.stringify(error, null, 2)} />
</CopyableContainer>
)}
</Grid>
);
};
6 changes: 3 additions & 3 deletions packages/site/src/components/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const Toggle = ({
checkedIcon = '🌞',
uncheckedIcon = '🌜',
}: {
onToggle(): void;
onToggle(): Promise<void>;
defaultChecked?: boolean;
title?: string;
checkedIcon?: string;
Expand All @@ -116,8 +116,8 @@ export const Toggle = ({
setChecked(defaultChecked);
}, [defaultChecked]);

const handleChange = () => {
onToggle();
const handleChange = async () => {
await onToggle();
setChecked(!checked);
};

Expand Down
8 changes: 5 additions & 3 deletions packages/site/src/components/styledComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,15 @@ export const CopyableContainer = styled.div<{ active: boolean }>`

export const CopyableItemValue = styled.div`
color: #0376c9;
text-align: center;
text-align: left;
max-width: 80%;
word-wrap: break-word;
word-break: break-all;
white-space: pre-wrap;
margin: 0px;
/* Body-SM-Medium */
font-family: Euclid Circular B;
font-family: SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono,
Inconsolata, monospace;
font-size: 12px;
font-style: normal;
font-weight: 500;
Expand Down
Loading

0 comments on commit 09087a8

Please sign in to comment.