forked from nervosnetwork/ckb-explorer-frontend
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement tools page address conversion (#287)
* feat: implement tools page address conversion * chore: change antd to radixui & remove deprecated address parser * fix: ui display error * feat: change the language menu to more * feat: mobile header support language modal * chore: optimize header more menu style * chore: fix typo * chore: remove unnecessary trigger
- Loading branch information
1 parent
1b6f2e6
commit 47b2da3
Showing
37 changed files
with
1,227 additions
and
93 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,36 @@ | ||
import { FC } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { ReactComponent as CopyIcon } from './copy.svg' | ||
import { useSetToast } from '../Toast' | ||
import styles from './styles.module.scss' | ||
|
||
const CopyableText: FC<{ | ||
children: string | ||
}> = ({ children: text }) => { | ||
const { t } = useTranslation() | ||
const setToast = useSetToast() | ||
|
||
const handleCopy = (e: React.MouseEvent<HTMLButtonElement>) => { | ||
e.stopPropagation() | ||
e.preventDefault() | ||
const { detail } = e.currentTarget.dataset | ||
if (!detail) return | ||
navigator.clipboard.writeText(detail).then(() => { | ||
setToast({ message: t('common.copied') }) | ||
}) | ||
} | ||
|
||
const content = ( | ||
<> | ||
{text} | ||
|
||
<button type="button" className={styles.copy} onClick={handleCopy} data-detail={text}> | ||
<CopyIcon /> | ||
</button> | ||
</> | ||
) | ||
|
||
return content | ||
} | ||
|
||
export default CopyableText |
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,17 @@ | ||
.copy { | ||
appearance: none; | ||
border: none; | ||
background: none; | ||
width: 14px; | ||
cursor: pointer; | ||
height: 14px; | ||
margin-left: 4px; | ||
margin-top: -4px; | ||
vertical-align: middle; | ||
display: inline; | ||
color: var(--primary-color); | ||
|
||
svg { | ||
pointer-events: none; | ||
} | ||
} |
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,49 @@ | ||
import { useRef } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { useCurrentLanguage, SupportedLngs, useChangeLanguage } from '../../../utils/i18n' | ||
import CommonModal from '../../CommonModal' | ||
import CommonSelect from '../../CommonSelect' | ||
import CloseIcon from '../../../assets/modal_close.png' | ||
import styles from './style.module.scss' | ||
|
||
export const LanguageModal = ({ onClose }: { onClose: () => void }) => { | ||
const { t } = useTranslation() | ||
const ref = useRef<HTMLDivElement>(null) | ||
const currentLanguage = useCurrentLanguage() | ||
const { changeLanguage } = useChangeLanguage() | ||
|
||
const handleLanguageChange = (lng: string) => { | ||
changeLanguage(lng) | ||
} | ||
|
||
return ( | ||
<CommonModal isOpen onClose={onClose}> | ||
<div ref={ref} className={styles.modalWrapper}> | ||
<div className={styles.contentWrapper}> | ||
<div className={styles.modalTitle}> | ||
<p>{t('navbar.language')}</p> | ||
<button type="button" onClick={onClose} className={styles.closeBtn}> | ||
<img src={CloseIcon} alt="close icon" /> | ||
</button> | ||
</div> | ||
|
||
<div className={styles.modalContent}> | ||
<CommonSelect | ||
className={styles.languageSelect} | ||
options={SupportedLngs.map(lng => ({ | ||
value: lng, | ||
label: t(`navbar.language_${lng}`), | ||
}))} | ||
onChange={handleLanguageChange} | ||
defaultValue={currentLanguage} | ||
/> | ||
</div> | ||
|
||
<button type="button" className={styles.doneBtn} onClick={onClose}> | ||
{t('nervos_dao.done')} | ||
</button> | ||
</div> | ||
</div> | ||
</CommonModal> | ||
) | ||
} |
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,69 @@ | ||
@import '../../../styles/variables.module'; | ||
|
||
.contentWrapper { | ||
background-color: white; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
border-radius: 4px; | ||
width: 80vw; | ||
max-width: 280px; | ||
padding: 24px; | ||
|
||
@media screen and (width <= 750px) { | ||
padding: 16px; | ||
width: calc(100vw - 32px); | ||
} | ||
|
||
p { | ||
margin: 0; | ||
} | ||
} | ||
|
||
.modalTitle { | ||
display: flex; | ||
width: 100%; | ||
align-items: center; | ||
justify-content: space-between; | ||
color: #333; | ||
font-weight: 600; | ||
font-size: 16px; | ||
line-height: 20px; | ||
} | ||
|
||
.modalContent { | ||
width: 100%; | ||
margin-top: 32px; | ||
} | ||
|
||
.languageSelect { | ||
color: #333; | ||
} | ||
|
||
.closeBtn { | ||
border: none; | ||
background: transparent; | ||
cursor: pointer; | ||
|
||
img { | ||
width: 13px; | ||
height: 13px; | ||
} | ||
} | ||
|
||
.doneBtn { | ||
width: 100%; | ||
margin-top: 32px; | ||
height: 47px; | ||
background: var(--primary-color); | ||
border: none; | ||
border-radius: 4px; | ||
color: #fff; | ||
font-size: 16px; | ||
cursor: pointer; | ||
} | ||
|
||
.loading { | ||
text-align: center; | ||
} |
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
Oops, something went wrong.