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.
- Loading branch information
Showing
26 changed files
with
291 additions
and
270 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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
@import '../../styles/variables.module'; | ||
|
||
.container { | ||
display: inline-flex; | ||
align-items: flex-end; | ||
font-size: 1rem; | ||
|
||
span[data-role='dec'] { | ||
font-size: 0.875em; | ||
} | ||
|
||
.unit { | ||
margin-left: 5px; | ||
} | ||
|
||
&[data-type='value'] { | ||
span[data-role='dec'] { | ||
color: var(--decimal-color); | ||
} | ||
} | ||
|
||
&[data-type='diff'] { | ||
&[data-diff-status='positive'] { | ||
color: var(--primary-color); | ||
|
||
&::before { | ||
content: '+'; | ||
} | ||
} | ||
|
||
&[data-diff-status='negative'] { | ||
color: var(--accent-color); | ||
} | ||
} | ||
|
||
&[data-layout='responsive'] { | ||
@media screen and (width <= $largeBreakPoint) { | ||
font-size: 0.75rem; | ||
|
||
span[data-role='dec'] { | ||
font-size: 0.9em; | ||
} | ||
|
||
.unit { | ||
font-size: 1rem; | ||
} | ||
} | ||
} | ||
} |
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,41 @@ | ||
import BigNumber from 'bignumber.js' | ||
import { useMemo } from 'react' | ||
import styles from './Capacity.module.scss' | ||
|
||
interface CapacityProps { | ||
capacity: string | ||
type?: 'value' | 'diff' | ||
layout?: 'responsive' | 'fixed' | ||
unit?: 'CKB' | null | ||
display?: 'full' | 'short' | ||
} | ||
|
||
const Capacity: React.FC<CapacityProps> = ({ | ||
capacity, | ||
type = 'value', | ||
layout = 'fixed', | ||
unit = 'CKB', | ||
display = 'full', | ||
}) => { | ||
const [int, dec, diffStatus] = useMemo(() => { | ||
const c = new BigNumber(capacity) | ||
const [int, dec] = c.toFormat(display === 'full' ? 8 : undefined).split('.') | ||
if (type !== 'diff' || c.isZero()) return [int, dec] | ||
if (c.isPositive()) return [int, dec, 'positive'] | ||
return [int, dec, 'negative'] | ||
}, [capacity, display, type]) | ||
|
||
return ( | ||
<div className={styles.container} data-type={type} data-diff-status={diffStatus} data-layout={layout}> | ||
<span data-role="int">{int}</span> | ||
{dec ? ( | ||
<span data-role="dec" className="monospace"> | ||
{`.${dec}`} | ||
</span> | ||
) : null} | ||
{unit && <span className={`${styles.unit} monospace`}>{unit}</span>} | ||
</div> | ||
) | ||
} | ||
|
||
export default Capacity |
This file was deleted.
Oops, something went wrong.
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
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
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.
57184a4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
ckb-explorer-frontend-in-magickbase-repo – ./
ckb-explorer-frontend-in-magickbase-repo-git-develop-magickbase.vercel.app
ckb-explorer-six.vercel.app
ckb-explorer.magickbase.vercel.app
ckb-explorer-frontend-in-magickbase-repo-magickbase.vercel.app