Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop into testnet #1759

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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