forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a572af
commit 91decc3
Showing
21 changed files
with
489 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,3 @@ | |
font-weight: 700; | ||
color: #404040; | ||
} | ||
|
||
.copy-icon { | ||
margin-left: 6px; | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
wallet/src/ui/app/components/copy-to-clipboard/CopyToClipboard.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.container { | ||
display: inline-flex; | ||
flex-flow: row nowrap; | ||
align-items: center; | ||
} | ||
|
||
.copy-icon { | ||
margin-left: 6px; | ||
cursor: pointer; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import cl from 'classnames'; | ||
import { memo, useCallback, useEffect, useState } from 'react'; | ||
|
||
import BsIcon from '_components/bs-icon'; | ||
|
||
import type { ReactNode, MouseEventHandler } from 'react'; | ||
|
||
import st from './CopyToClipboard.module.scss'; | ||
|
||
const COPY_CHECKMARK_MILLIS = 600; | ||
|
||
export type CopyToClipboardProps = { | ||
txt: string; | ||
children: ReactNode; | ||
copyOnlyOnIconClick?: boolean; | ||
className?: string; | ||
}; | ||
|
||
function CopyToClipboard({ | ||
txt, | ||
children, | ||
copyOnlyOnIconClick = false, | ||
className, | ||
}: CopyToClipboardProps) { | ||
const [copied, setCopied] = useState(false); | ||
const copyToClipboard = useCallback<MouseEventHandler<HTMLElement>>( | ||
async (e) => { | ||
e.stopPropagation(); | ||
e.preventDefault(); | ||
if (!txt) { | ||
return; | ||
} | ||
await navigator.clipboard.writeText(txt); | ||
setCopied(true); | ||
}, | ||
[txt] | ||
); | ||
useEffect(() => { | ||
let timeout: number; | ||
if (copied) { | ||
timeout = window.setTimeout( | ||
() => setCopied(false), | ||
COPY_CHECKMARK_MILLIS | ||
); | ||
} | ||
return () => { | ||
if (timeout) { | ||
clearTimeout(timeout); | ||
} | ||
}; | ||
}, [copied]); | ||
return ( | ||
<span | ||
className={cl(st.container, className)} | ||
onClick={!copyOnlyOnIconClick ? copyToClipboard : undefined} | ||
> | ||
{children} | ||
<BsIcon | ||
className={st['copy-icon']} | ||
icon={`clipboard${copied ? '-check' : ''}`} | ||
onClick={copyToClipboard} | ||
title="Copy to clipboard" | ||
/> | ||
</span> | ||
); | ||
} | ||
|
||
export default memo(CopyToClipboard); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { memo } from 'react'; | ||
|
||
import AccountAddress from '_components/account-address'; | ||
import Alert from '_components/alert'; | ||
import BsIcon from '_components/bs-icon'; | ||
import LoadingIndicator from '_components/loading/LoadingIndicator'; | ||
import { useAppSelector } from '_hooks'; | ||
|
||
import type { ReactNode } from 'react'; | ||
|
||
import st from './ObjectsLayout.module.scss'; | ||
|
||
export type ObjectsLayoutProps = { | ||
children: ReactNode; | ||
emptyMsg: string; | ||
totalItems: number; | ||
}; | ||
|
||
function ObjectsLayout({ children, emptyMsg, totalItems }: ObjectsLayoutProps) { | ||
const objectsLoading = useAppSelector( | ||
({ suiObjects }) => suiObjects.loading | ||
); | ||
const objectsLastSync = useAppSelector( | ||
({ suiObjects }) => suiObjects.lastSync | ||
); | ||
const objectsError = useAppSelector(({ suiObjects }) => suiObjects.error); | ||
const showError = | ||
!!objectsError && | ||
(!objectsLastSync || Date.now() - objectsLastSync > 30 * 1000); | ||
const showEmptyNotice = !!(objectsLastSync && !totalItems); | ||
const showItems = !!(objectsLastSync && totalItems); | ||
const showLoading = objectsLoading && !objectsLastSync; | ||
return ( | ||
<div className={st.container}> | ||
<div> | ||
<span className={st.title}>Active Account:</span> | ||
<AccountAddress /> | ||
</div> | ||
<div className={st.items}> | ||
{showError ? ( | ||
<Alert className={st.alert}> | ||
<strong>Sync error (data might be outdated).</strong>{' '} | ||
<small>{objectsError.message}</small> | ||
</Alert> | ||
) : null} | ||
{showItems ? children : null} | ||
{showEmptyNotice ? ( | ||
<div className={st.empty}> | ||
<BsIcon icon="droplet" className={st['empty-icon']} /> | ||
<div className={st['empty-text']}>{emptyMsg}</div> | ||
</div> | ||
) : null} | ||
{showLoading ? ( | ||
<div className={st.loader}> | ||
<LoadingIndicator /> | ||
</div> | ||
) : null} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default memo(ObjectsLayout); |
72 changes: 72 additions & 0 deletions
72
wallet/src/ui/app/components/sui-object/SuiObject.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
.container { | ||
display: flex; | ||
padding: 24px 16px; | ||
align-self: stretch; | ||
flex: 1; | ||
border-radius: 2px; | ||
background-color: #f0f0f0; | ||
box-shadow: 0 0 3px 0 #00000050; | ||
position: relative; | ||
|
||
& + .container { | ||
margin-top: 12px; | ||
} | ||
} | ||
|
||
.type { | ||
position: absolute; | ||
top: 2px; | ||
right: 3px; | ||
font-size: 8px; | ||
font-weight: 700; | ||
letter-spacing: -0.6px; | ||
color: #8bc3df; | ||
} | ||
|
||
.id { | ||
font-size: 9px; | ||
font-weight: 700; | ||
letter-spacing: -0.5px; | ||
position: absolute; | ||
top: 2px; | ||
left: 2px; | ||
} | ||
|
||
.content { | ||
display: flex; | ||
flex-flow: row nowrap; | ||
align-items: center; | ||
max-width: 100%; | ||
max-height: 20vh; | ||
overflow: hidden; | ||
} | ||
|
||
.splitter { | ||
align-self: stretch; | ||
background-color: #d5d5d5; | ||
width: 1px; | ||
margin: 5px 16px; | ||
} | ||
|
||
.img-container { | ||
display: flex; | ||
flex-flow: column nowrap; | ||
align-items: center; | ||
justify-content: center; | ||
width: 30%; | ||
max-height: 100%; | ||
} | ||
|
||
.img { | ||
max-width: 100%; | ||
max-height: 100%; | ||
min-height: 0; | ||
} | ||
|
||
.fields { | ||
max-width: 70%; | ||
display: flex; | ||
flex-flow: column nowrap; | ||
overflow-y: auto; | ||
max-height: 100%; | ||
} |
16 changes: 16 additions & 0 deletions
16
wallet/src/ui/app/components/sui-object/field/Field.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.field { | ||
margin: 0 6px 6px 0; | ||
} | ||
|
||
.name { | ||
font-size: 10px; | ||
font-weight: 500; | ||
color: #666; | ||
margin-bottom: 2px; | ||
margin-right: 3px; | ||
} | ||
|
||
.value { | ||
overflow-wrap: anywhere; | ||
font-weight: 600; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) 2022, Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { memo } from 'react'; | ||
|
||
import type { ReactNode } from 'react'; | ||
|
||
import st from './Field.module.scss'; | ||
|
||
export type FieldProps = { | ||
name: string; | ||
children: ReactNode; | ||
}; | ||
|
||
function Field({ name, children }: FieldProps) { | ||
return ( | ||
<div className={st.field}> | ||
<span className={st.name}>{name}</span> | ||
<span className={st.value}>{children}</span> | ||
</div> | ||
); | ||
} | ||
|
||
export default memo(Field); |
Oops, something went wrong.