Skip to content

Commit

Permalink
Tom/site information component (#1552)
Browse files Browse the repository at this point in the history
* refactor: remove legacy testnet banner component

* feature: add site information component

* fix: whitespace

* chore: update default env variable

* refactor: extend main container

* refactor: add information component to main container

* rename const

* refactor: update alert styling

* fix: bold link styling
  • Loading branch information
tomjeatt authored Sep 5, 2023
1 parent 6e11ce3 commit 1f80570
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ REACT_APP_FAUCET_URL="http://localhost:3035"
REACT_APP_RELAY_CHAIN_NAME="kusama"
DOCKER_RELAY_CHAIN_CURRENCY="KSM"
REACT_APP_MARKET_DATA_URL="https://api.coingecko.com/api/v3/simple/price?vs_currencies=usd"
REACT_APP_SITE_INFORMATION_MESSAGE="This is an informational message that will be shown on every page of the application."
REACT_APP_SITE_INFORMATION_LINK="https://gobob.xyz"


// Kintsugi testnet

Expand Down
5 changes: 1 addition & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ import { Redirect, Route, Switch } from 'react-router-dom';

import { isVaultClientLoaded } from '@/common/actions/general.actions';
import { StoreType } from '@/common/types/util.types';
import { Layout, TransactionModal } from '@/components';
import ErrorFallback from '@/legacy-components/ErrorFallback';
import FullLoadingSpinner from '@/legacy-components/FullLoadingSpinner';
import { useSubstrate, useSubstrateSecureState } from '@/lib/substrate';
import graphqlFetcher, { GRAPHQL_FETCHER, GraphqlReturn } from '@/services/fetchers/graphql-fetcher';
import vaultsByAccountIdQuery from '@/services/queries/vaults-by-accountId-query';
import { BitcoinNetwork } from '@/types/bitcoin';
import { PAGES } from '@/utils/constants/links';

import { Layout, TransactionModal } from './components';
import * as constants from './constants';
import { FeatureFlags, useFeatureFlag } from './hooks/use-feature-flag';
import TestnetBanner from './legacy-components/TestnetBanner';

const BTC = React.lazy(() => import(/* webpackChunkName: 'btc' */ '@/pages/BTC'));
const Strategies = React.lazy(() => import(/* webpackChunkName: 'strategies' */ '@/pages/Strategies'));
Expand Down Expand Up @@ -80,7 +78,6 @@ const App = (): JSX.Element => {

return (
<Layout>
{process.env.REACT_APP_BITCOIN_NETWORK === BitcoinNetwork.Testnet && <TestnetBanner />}
<Route
render={({ location }) => (
<React.Suspense fallback={<FullLoadingSpinner />}>
Expand Down
4 changes: 2 additions & 2 deletions src/component-library/Alert/Alert.style.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ interface StyledAlertProps {

const StyledAlert = styled(Flex)<StyledAlertProps>`
padding: ${theme.spacing.spacing2};
color: ${({ $status }) => theme.alert.status[$status]};
border: 1px solid ${({ $status }) => theme.alert.status[$status]};
background-color: ${({ $status }) => theme.alert.bg[$status]};
border-radius: ${theme.rounded.md};
font-size: ${theme.text.xs};
`;

const StyledWarningIcon = styled(WarningIcon)`
const StyledWarningIcon = styled(WarningIcon)<StyledAlertProps>`
color: ${({ $status }) => theme.alert.status[$status]};
width: ${theme.spacing.spacing5};
height: ${theme.spacing.spacing5};
flex-shrink: 0;
Expand Down
2 changes: 1 addition & 1 deletion src/component-library/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type AlertProps = Props & InheritAttrs;

const Alert = ({ status = 'success', children, ...props }: AlertProps): JSX.Element => (
<StyledAlert $status={status} role='alert' gap='spacing4' alignItems='center' {...props}>
<StyledWarningIcon />
<StyledWarningIcon $status={status} />
<div>{children}</div>
</StyledAlert>
);
Expand Down
14 changes: 11 additions & 3 deletions src/components/MainContainer/MainContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { FlexProps } from '@/component-library';
import { SiteInformation } from '@/components';

import { StyledContainer } from './MainContainer.styles';

type MainContainerProps = FlexProps;

const MainContainer = ({ direction = 'column', gap = 'spacing8', ...props }: MainContainerProps): JSX.Element => (
<StyledContainer direction={direction} gap={gap} {...props} />
);
const MainContainer = ({ direction = 'column', gap = 'spacing8', ...props }: MainContainerProps): JSX.Element => {
const showSiteInformationMessage = !!process.env.REACT_APP_SITE_INFORMATION_MESSAGE;

return (
<StyledContainer direction={direction} gap={gap} {...props}>
{showSiteInformationMessage && <SiteInformation />}
{props.children}
</StyledContainer>
);
};

export { MainContainer };
21 changes: 21 additions & 0 deletions src/components/SiteInformation/SiteInformation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Alert, TextLink } from '@/component-library';

const SiteInformation = (): JSX.Element => {
const hasLink = !!process.env.REACT_APP_SITE_INFORMATION_LINK;

return (
<Alert status='warning'>
{process.env.REACT_APP_SITE_INFORMATION_MESSAGE}
{hasLink && (
<>
{' '}
<TextLink weight='bold' external icon to={process.env.REACT_APP_SITE_INFORMATION_LINK || ''}>
More information
</TextLink>
</>
)}
</Alert>
);
};

export { SiteInformation };
1 change: 1 addition & 0 deletions src/components/SiteInformation/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SiteInformation } from './SiteInformation';
1 change: 1 addition & 0 deletions src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export { PlusDivider } from './PlusDivider';
export type { PoolsTableProps } from './PoolsTable';
export { PoolsTable } from './PoolsTable';
export { ReceivableAssets } from './ReceivableAssets';
export { SiteInformation } from './SiteInformation';
export type { SlippageManagerProps } from './SlippageManager';
export { SlippageManager } from './SlippageManager';
export type { ToastContainerProps } from './ToastContainer';
Expand Down
14 changes: 0 additions & 14 deletions src/legacy-components/TestnetBanner/index.tsx

This file was deleted.

2 comments on commit 1f80570

@vercel
Copy link

@vercel vercel bot commented on 1f80570 Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 1f80570 Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.