Skip to content

Commit

Permalink
Merge pull request #1758 from nervosnetwork/testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY authored Aug 21, 2024
2 parents beb2942 + 866fdc0 commit cb18e12
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 40 deletions.
12 changes: 12 additions & 0 deletions src/assets/small-spinner.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/components/AwesomeLoadings/SmallSpinner/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import styles from './styles.module.scss'
import { ReactComponent as SmallSpinner } from '../../../assets/small-spinner.svg'

const Loading = () => {
return <SmallSpinner className={styles.container} />
}
export default Loading
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@import '../../../styles/variables.module';

.container {
margin: 40px auto;
color: var(--primary-color);
}
2 changes: 0 additions & 2 deletions src/components/Search/HighlightText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export const HighlightText: FC<HighlightTextProps> = ({ text, keyword, ...props
const [originTextWidth, setOriginTextWidth] = useState(0)

useEffect(() => {
// eslint-disable-next-line no-console
// console.log('HighlightText useEffect', text, keyword, resizedWidth)
if (!ref.current || !text || !keyword) return
const minSideLen = 3
const wrapperWidth = resizedWidth ?? ref.current.clientWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
}
}

.content {
height: 100%;
display: flex;
flex-direction: column;
overflow-y: auto;
flex: 1;
}

.noRecords {
display: flex;
background: #fff;
Expand All @@ -25,7 +33,6 @@
gap: 16px;
font-size: 16px;
white-space: nowrap;
overflow: hidden;
margin-bottom: 1rem;

@media screen and (max-width: $mobileBreakPoint) {
Expand Down Expand Up @@ -144,11 +151,9 @@
}

.list {
max-height: 540px;
height: 100%;
overflow-y: auto;
scroll-snap-type: y mandatory;

& > div {
scroll-snap-align: center;
}
display: flex;
flex-direction: column;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import CloseIcon from '../../../assets/modal_close.png'
import { TransactionRGBPPDigestContent } from './TransactionRGBPPDigestContent'
import { explorerService } from '../../../services/ExplorerService'
import { TransactionLeapDirection } from '../../RGBPP/types'
import SmallSpinner from '../../AwesomeLoadings/SmallSpinner'

const TransactionRGBPPDigestModal = ({ hash, onClickClose }: { onClickClose: Function; hash: string }) => {
const { t } = useTranslation()

const { data, isFetched } = useQuery(['rgb-digest', hash], () => explorerService.api.fetchRGBDigest(hash))
const { data, isFetched, isLoading } = useQuery(['rgb-digest', hash], () => explorerService.api.fetchRGBDigest(hash))

const direction = useMemo(() => {
switch (data?.data.leapDirection) {
Expand All @@ -25,25 +26,30 @@ const TransactionRGBPPDigestModal = ({ hash, onClickClose }: { onClickClose: Fun
}
}, [data])

if (isFetched && data?.data) {
return (
<div className={styles.container}>
<div className={styles.header}>
<div className={styles.left}>
<span>{t('address.transaction_rgbpp_digest')}</span>
{direction !== TransactionLeapDirection.NONE && (
<span className={styles.leap}>{t(`address.leap_${direction}`)}</span>
)}
</div>
<button onClick={() => onClickClose()} type="button" className={styles.buttonClose}>
<img src={CloseIcon} alt="close icon" className={styles.closeIcon} />
</button>
return (
<div className={styles.container}>
{isLoading ? (
<div style={{ margin: 'auto', width: '100%', display: 'flex' }}>
<SmallSpinner />
</div>
<TransactionRGBPPDigestContent hash={hash} digest={data?.data} isFetched={isFetched} />
</div>
)
}
return null
) : (
<>
<div className={styles.header}>
<div className={styles.left}>
<span>{t('address.transaction_rgbpp_digest')}</span>
{direction !== TransactionLeapDirection.NONE && (
<span className={styles.leap}>{t(`address.leap_${direction}`)}</span>
)}
</div>
<button onClick={() => onClickClose()} type="button" className={styles.buttonClose}>
<img src={CloseIcon} alt="close icon" className={styles.closeIcon} />
</button>
</div>
<TransactionRGBPPDigestContent hash={hash} digest={data?.data} isFetched={isFetched} />
</>
)}
</div>
)
}

export default TransactionRGBPPDigestModal
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@
background-color: #fff;
padding: 20px 40px;
width: 75%;
margin: 15% auto;
max-height: 80%;
top: 50%;
left: 50%;
gap: 10px;
transform: translate(-50%, -50%);
border-radius: 4px;
position: fixed;
display: flex;
flex-direction: column;

@media screen and (max-width: $mobileBreakPoint) {
width: 90%;
padding: 16px;
margin: 178px auto;
}
}

.header {
display: flex;
justify-content: space-between;
margin-bottom: 10px;

.left {
display: flex;
Expand Down
25 changes: 22 additions & 3 deletions src/components/XUDTTag/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import classNames from 'classnames'
import { useTranslation } from 'react-i18next'
import { useHistory } from 'react-router-dom'
import { Popover } from 'antd'
import styles from './styles.module.scss'

const HIDDEN_TAGS = ['duplicate', 'suspicious', 'utility', 'supply-unlimited', 'out-of-length-range']

const XUDTTag = ({ tagName, to }: { tagName: string; to?: string }) => {
const { t } = useTranslation()
const XUDTTag = ({ tagName, to, tooltip = false }: { tagName: string; to?: string; tooltip?: boolean }) => {
const { t, i18n } = useTranslation()
const { push } = useHistory()

// FIXME: the tag should be updated in the backend
Expand Down Expand Up @@ -39,7 +40,25 @@ const XUDTTag = ({ tagName, to }: { tagName: string; to?: string }) => {
} else {
search.set('tags', [...tags, tag].join(','))
}
push(`${to ?? window.location.pathname}?${search}`)
push(`${`/${i18n.language}${to ?? window.location.pathname}`}?${search}`)
}

if (tooltip) {
return (
<Popover
overlayClassName={styles.tagPopover}
content={
<>
<div>{t(`xudt.tags_description.${tag}`)}</div>
<a href={`/${i18n.language}${to}?tags=${tag}`}>{t('xudt.tags_description.view_more')}</a>
</>
}
>
<button type="button" className={classNames(styles.container, styles.normal)} data-type={tagName}>
{content}
</button>
</Popover>
)
}

return (
Expand Down
29 changes: 29 additions & 0 deletions src/components/XUDTTag/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,32 @@
.normal {
border: 1px solid;
}

/* stylelint-disable selector-class-pattern */
.tagPopover {
max-width: 320px;

:global {
.ant-popover-content {
.ant-popover-arrow {
.ant-popover-arrow-content {
--antd-arrow-background-color: rgb(0 0 0 / 80%);
}
}
}

.ant-popover-inner {
background-color: rgb(0 0 0 / 80%);
border-radius: 6px;

.ant-popover-inner-content {
color: #fff;

a {
color: var(--primary-color);
text-decoration: underline;
}
}
}
}
}
6 changes: 0 additions & 6 deletions src/hooks/useCKBNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,6 @@ export const CKBNodeProvider = ({ children, defaultEndpoint }: PropsWithChildren
const [nodes, setNodes] = useState<Map<string, string>>(new Map(Object.entries(loadEndpoints())))
const [isActivated, _setIsActivated] = useState(localStorage.getItem(NODE_CONNECT_MODE_KEY) === 'true')

// eslint-disable-next-line no-console
console.log('loadEndpoints', loadEndpoints())

// eslint-disable-next-line no-console
console.log('nodes', nodes)

const setIsActivated = (value: boolean) => {
localStorage.setItem(NODE_CONNECT_MODE_KEY, value.toString())
_setIsActivated(value)
Expand Down
14 changes: 14 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,20 @@
"rgb++": "RGB++",
"unnamed": "Unnamed"
},
"tags_description": {
"invalid": "This tag marks an asset whose name contains invalid characters.",
"suspicious": "This tag marks an asset whose name contains multiple hidden character types.",
"out-of-length-range": "This tag marks an asset whose name exceeds 60 characters in length.",
"duplicate": "Under case-sensitive conditions, this tag marks an asset whose name duplicates an already issued asset.",
"rgb++": "This tag marks an asset that is compatible with the RGB++ protocol, allowing for transfers between BTC and CKB.",
"layer-1-asset": "This tag marks an asset that is issued on Layer 1.",
"layer-2-asset": "This tag marks an asset that is issued on Layer 2.",
"verified-on": "This tag marks an asset that has been verified by Cell Studio.",
"supply-limited": "This tag marks an asset that has a limited supply, with a maximum quantity limit.",
"supply-unlimited": "This tag marks an asset that has an unlimited supply, with no maximum quantity limit.",
"view_more": "View more items",
"unnamed": "This tag marks an asset whose name field is empty."
},
"category": "Category"
},
"nft": {
Expand Down
14 changes: 14 additions & 0 deletions src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,20 @@
"rgb++": "RGB++",
"unnamed": "未命名"
},
"tags_description": {
"invalid": "此 Tag 标记的资产名称中含有无效字符。",
"suspicious": "此 Tag 标记的资产名称中含有大量隐藏字符类型。",
"out-of-length-range": "此 Tag 标记的资产名称长度超过 60 字符。",
"duplicate": "区分大小写前提下,此 Tag 标记的资产名称与已发行过的资产重复。",
"rgb++": "此 Tag 标记的资产是 RGB++ 协议兼容资产,可以在 BTC 和 CKB 之间相互转移。",
"layer-1-asset": "此 Tag 标记的资产是发行在 Layer1 上的资产。",
"layer-2-asset": "此 Tag 标记的资产是发行在 Layer2 上的资产。",
"verified-on": "此 Tag 标记的资产是经过 Cell Studio 校验的资产。",
"supply-limited": "此Tag标记的资产是有限供应的资产,有最大资产数量限制。",
"supply-unlimited": "此Tag标记的资产是无限供应的资产,无最大资产数量限制。",
"view_more": "查看更多",
"unnamed": "此Tag标记的资产名称字段为空。"
},
"category": "类别"
},
"nft": {
Expand Down
9 changes: 9 additions & 0 deletions src/pages/UDT/UDTComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,15 @@ export const UDTComp = ({
</UDTNoResultPanel>
)
}

if (transactions.length === 0) {
return (
<UDTNoResultPanel>
<span>{t('transaction.no_records')}</span>
</UDTNoResultPanel>
)
}

return (
<>
<UDTTransactionsPanel>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Xudt/UDTComp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export const UDTOverviewCard = ({

<div className={styles.tags}>
{tags.map(tag => (
<XUDTTag tagName={tag} />
<XUDTTag tagName={tag} to="/xudts" tooltip />
))}
{xudtCodeUrl ? (
<Link className={styles.openSource} to={xudtCodeUrl}>
Expand Down

0 comments on commit cb18e12

Please sign in to comment.