Skip to content

Commit

Permalink
fix: styles and naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeday committed Mar 11, 2024
1 parent 8bbb511 commit 406e11c
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 47 deletions.
2 changes: 1 addition & 1 deletion features/ipfs/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { HomePageIpfs } from './home-page-ipfs';

export { FaqPlaceholder } from './faq-placeholder';
export { UpgradePromtBanner } from './update-promt-banner';
export { SecurityStatusBanner } from './security-status-banner';
export { InsertIpfsBaseScript } from './ipfs-base-script';
1 change: 1 addition & 0 deletions features/ipfs/security-status-banner/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SecurityStatusBanner } from './security-status-banner';
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ import { Button, Modal } from '@lidofinance/lido-ui';

import { dynamics } from 'config';

import { WarningIcon, Wrapper, WarningText, WarningSubText } from './styles';
import {
WarningIcon,
Wrapper,
WarningText,
WarningSubText,
WarningBlock,
WarningTitle,
} from './styles';
import { useVersionCheck } from './use-version-check';
import NoSsrWrapper from 'shared/components/no-ssr-wrapper';

Expand All @@ -26,11 +33,10 @@ const warningContent = ({
case isIpfs && isNotVerifiable:
return {
content: (
<WarningText>
This IPFS version can’t be verified
<br />
<WarningBlock>
<WarningTitle>This IPFS version can’t be verified</WarningTitle>
<WarningSubText>Please try again later</WarningSubText>
</WarningText>
</WarningBlock>
),
canClose: false,
};
Expand Down Expand Up @@ -59,13 +65,14 @@ const warningContent = ({
case isIpfs && isUpdateAvailable:
return {
content: (
<WarningText>
This is not the most up to date version of the IPFS widget
<br />
<WarningBlock>
<WarningTitle>
This is not the most up to date version of the IPFS widget
</WarningTitle>
<WarningSubText>
Please note that the functionality of this version may be lacking
</WarningSubText>
</WarningText>
</WarningBlock>
),
canClose: true,
};
Expand All @@ -74,7 +81,7 @@ const warningContent = ({
}
};

export const UpgradePromtBanner = () => {
export const SecurityStatusBanner = () => {
const {
areConditionsAccepted,
setConditionsAccepted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,22 @@ export const WarningText = styled(Text).attrs({
text-wrap: balance;
`;

export const WarningBlock = styled.p`
text-align: center;
margin: 12px 0 28px;
`;

export const WarningTitle = styled(Text).attrs({
weight: 700,
})`
font-size: 26px;
text-align: center;
text-wrap: balance;
`;

export const WarningSubText = styled(Text).attrs({
weight: 400,
size: 'xs',
as: 'span',
color: 'secondary',
})`
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { useEffect, useState } from 'react';
import { useLidoSWR } from '@lido-sdk/react';
import { useWeb3 } from 'reef-knot/web3-react';
import { useForceDisconnect } from 'reef-knot/core-react';

import { BASE_PATH_ASSET, dynamics } from 'config';
import { useMainnetStaticRpcProvider } from 'shared/hooks/use-mainnet-static-rpc-provider';
import { standardFetcher } from 'utils/standardFetcher';
import { STRATEGY_IMMUTABLE, STRATEGY_LAZY } from 'utils/swrStrategies';
import { useClientConfig } from 'providers/client-config';

import { isVersionLess } from './utils';

import buildInfo from 'build-info.json';
import { useClientConfig } from 'providers/client-config';
import { useWeb3 } from 'reef-knot/web3-react';

export const NO_SAFE_VERSION = 'NONE_AVAILABLE';

Expand All @@ -36,29 +38,6 @@ const URL_CID_REGEX =
const IPFS_RELEASE_URL =
'https://raw.githubusercontent.com/lidofinance/ethereum-staking-widget/main/IPFS.json';

const isVersionLess = (versionA: string, versionB: string): boolean => {
const verA = versionA
.trim()
.split('.')
.map((v) => parseInt(v));
const verB = versionB
.trim()
.split('.')
.map((v) => parseInt(v));

// eslint-disable-next-line unicorn/no-for-loop
for (let index = 0; index < verA.length; index++) {
const a = verA[index];
const b = verB[index];
// validation
if (b === undefined || isNaN(a) || isNaN(b)) return false;
if (a > b) return false;
if (a < b) return true;
}
// versions are equal
return false;
};

export const useVersionCheck = () => {
const { active } = useWeb3();
const { setIsWalletConnectionAllowed } = useClientConfig();
Expand Down
22 changes: 22 additions & 0 deletions features/ipfs/security-status-banner/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export const isVersionLess = (versionA: string, versionB: string): boolean => {
const verA = versionA
.trim()
.split('.')
.map((v) => parseInt(v));
const verB = versionB
.trim()
.split('.')
.map((v) => parseInt(v));

// eslint-disable-next-line unicorn/no-for-loop
for (let index = 0; index < verA.length; index++) {
const a = verA[index];
const b = verB[index];
// validation
if (b === undefined || isNaN(a) || isNaN(b)) return false;
if (a > b) return false;
if (a < b) return true;
}
// versions are equal
return false;
};
1 change: 0 additions & 1 deletion features/ipfs/update-promt-banner/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion features/stake/stake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const Stake = () => {
<StakeForm key={key} />
</NoSSRWrapper>
<LidoStats />
<OnlyInfraRender placeholder={<FaqPlaceholder />}>
<OnlyInfraRender renderIPFS={<FaqPlaceholder />}>
<StakeFaq />
</OnlyInfraRender>
</>
Expand Down
2 changes: 1 addition & 1 deletion features/withdrawals/claim/claim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const Claim = () => {
<ClaimFormProvider>
<ClaimWallet />
<ClaimForm />
<OnlyInfraRender placeholder={<FaqPlaceholder />}>
<OnlyInfraRender renderIPFS={<FaqPlaceholder />}>
<ClaimFaq />
</OnlyInfraRender>
</ClaimFormProvider>
Expand Down
2 changes: 1 addition & 1 deletion features/withdrawals/request/request.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const Request = () => {
<RequestFormProvider>
<RequestWallet />
<RequestForm />
<OnlyInfraRender placeholder={<FaqPlaceholder />}>
<OnlyInfraRender renderIPFS={<FaqPlaceholder />}>
<RequestFaq />
</OnlyInfraRender>
</RequestFormProvider>
Expand Down
2 changes: 1 addition & 1 deletion features/wsteth/wrap-unwrap-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const WrapUnwrapTabs = ({ mode }: WrapUnwrapLayoutProps) => {
<Wallet />
{isUnwrapMode ? <UnwrapForm /> : <WrapForm />}
</NoSsrWrapper>
<OnlyInfraRender placeholder={<FaqPlaceholder />}>
<OnlyInfraRender renderIPFS={<FaqPlaceholder />}>
<WrapFaq />
</OnlyInfraRender>
</>
Expand Down
4 changes: 2 additions & 2 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Providers } from 'providers';
import { BackgroundGradient } from 'shared/components/background-gradient/background-gradient';
import { nprogress, COOKIES_ALLOWED_FULL_KEY } from 'utils';
import { withCsp } from 'utilsApi/withCSP';
import { UpgradePromtBanner } from 'features/ipfs';
import { SecurityStatusBanner } from 'features/ipfs';

// Migrations old theme cookies to new cross domain cookies
migrationThemeCookiesToCrossDomainCookiesClientSide();
Expand Down Expand Up @@ -56,7 +56,7 @@ const AppWrapper = (props: AppProps): JSX.Element => {
<ToastContainer />
<MemoApp {...rest} />
<CookiesTooltip />
<UpgradePromtBanner />
<SecurityStatusBanner />
</Providers>
);
};
Expand Down
6 changes: 3 additions & 3 deletions shared/components/only-infra-render/only-infra-render.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { dynamics } from 'config';

type OnlyInfraRenderProps = {
placeholder?: React.ReactNode;
renderIPFS?: React.ReactNode;
};

export const OnlyInfraRender = ({
children,
placeholder = null,
renderIPFS = null,
}: React.PropsWithChildren<OnlyInfraRenderProps>) => {
return <>{dynamics.ipfsMode ? placeholder : children}</>;
return <>{dynamics.ipfsMode ? renderIPFS : children}</>;
};

0 comments on commit 406e11c

Please sign in to comment.