-
Notifications
You must be signed in to change notification settings - Fork 177
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
14 changed files
with
152 additions
and
117 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
File renamed without changes.
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
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,111 @@ | ||
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
import { faHive } from '@fortawesome/free-brands-svg-icons' | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | ||
import { useEffectIgnoreInitial } from '@w3ux/hooks' | ||
import { Odometer } from '@w3ux/react-odometer' | ||
import { capitalizeFirstLetter } from '@w3ux/utils' | ||
import CloudIconSVG from 'assets/svg/cloudIcon.svg?react' | ||
import BigNumber from 'bignumber.js' | ||
import { MaxPageWidth } from 'consts' | ||
import { useNetwork } from 'contexts/Network' | ||
import { usePlugins } from 'contexts/Plugins' | ||
import { isCustomEvent } from 'controllers/utils' | ||
import { useRef, useState } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { Footer } from 'ui-structure' | ||
import { useEventListener } from 'usehooks-ts' | ||
import { Status } from './Status' | ||
import { TokenPrice } from './TokenPrice' | ||
import { Summary, Wrapper } from './Wrappers' | ||
|
||
export const MainFooter = () => { | ||
const { t } = useTranslation('library') | ||
const { plugins } = usePlugins() | ||
const { network } = useNetwork() | ||
const PRIVACY_URL = import.meta.env.VITE_PRIVACY_URL | ||
const DISCLAIMER_URL = import.meta.env.VITE_DISCLAIMER_URL | ||
const ORGANISATION = import.meta.env.VITE_ORGANISATION | ||
const LEGAL_DISCLOSURES_URL = import.meta.env.VITE_LEGAL_DISCLOSURES_URL | ||
|
||
// Store incoming block number. | ||
const [blockNumber, setBlockNumber] = useState<string>() | ||
|
||
const newBlockCallback = (e: Event) => { | ||
if (isCustomEvent(e)) { | ||
setBlockNumber(e.detail.blockNumber) | ||
} | ||
} | ||
|
||
const ref = useRef<Document>(document) | ||
useEventListener('new-block-number', newBlockCallback, ref) | ||
|
||
// Reset block number on network change. | ||
useEffectIgnoreInitial(() => { | ||
setBlockNumber('0') | ||
}, [network]) | ||
|
||
return ( | ||
<Footer> | ||
<Wrapper | ||
className="page-padding" | ||
style={{ maxWidth: `${MaxPageWidth}px` }} | ||
> | ||
<CloudIconSVG className="icon" /> | ||
<Summary> | ||
<section> | ||
<p> | ||
{ORGANISATION === undefined | ||
? capitalizeFirstLetter(network) | ||
: ORGANISATION} | ||
</p> | ||
<Status /> | ||
{PRIVACY_URL !== undefined && ( | ||
<p> | ||
<a href={PRIVACY_URL} target="_blank" rel="noreferrer"> | ||
{t('privacy')} | ||
</a> | ||
</p> | ||
)} | ||
{DISCLAIMER_URL !== undefined && ( | ||
<p> | ||
<a href={DISCLAIMER_URL} target="_blank" rel="noreferrer"> | ||
{t('disclaimer')} | ||
</a> | ||
</p> | ||
)} | ||
{LEGAL_DISCLOSURES_URL !== undefined && ( | ||
<p> | ||
<a | ||
href={LEGAL_DISCLOSURES_URL} | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
{t('legalDisclosures')} | ||
</a> | ||
</p> | ||
)} | ||
</section> | ||
<section> | ||
<div className="hide-small"> | ||
{plugins.includes('staking_api') && network !== 'westend' && ( | ||
<TokenPrice /> | ||
)} | ||
{import.meta.env.MODE === 'development' && ( | ||
<div className="stat last"> | ||
<FontAwesomeIcon icon={faHive} /> | ||
<Odometer | ||
wholeColor="var(--text-color-secondary)" | ||
value={new BigNumber(blockNumber || '0').toFormat()} | ||
spaceBefore={'0.35rem'} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
</section> | ||
</Summary> | ||
</Wrapper> | ||
</Footer> | ||
) | ||
} |
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
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
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,11 @@ | ||
/* Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors | ||
SPDX-License-Identifier: GPL-3.0-only */ | ||
|
||
.footer { | ||
display: flex; | ||
flex-direction: column; | ||
position: absolute; | ||
bottom: 0; | ||
left: 0; | ||
width: 100%; | ||
} |
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,15 @@ | ||
// Copyright 2024 @polkadot-cloud/polkadot-staking-dashboard authors & contributors | ||
// SPDX-License-Identifier: GPL-3.0-only | ||
|
||
import type { ComponentBase } from '@w3ux/types' | ||
import classes from './index.module.scss' | ||
|
||
/** | ||
* @name Footer | ||
* @summary Footer container. | ||
*/ | ||
export const Footer = ({ children, style }: ComponentBase) => ( | ||
<div className={classes.footer} style={style}> | ||
{children} | ||
</div> | ||
) |
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 |
---|---|---|
|
@@ -7,4 +7,5 @@ | |
flex-direction: column; | ||
max-width: 100%; | ||
flex: 1; | ||
padding-bottom: 4.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
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