Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Dark mode overlays #73

Merged
merged 14 commits into from
Oct 19, 2024
4 changes: 2 additions & 2 deletions src/components/OverlayAction/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useRef } from 'react';
import { CSSTransition } from 'react-transition-group';

Check warning on line 2 in src/components/OverlayAction/index.tsx

View workflow job for this annotation

GitHub Actions / lint

'react-transition-group' should be listed in the project's dependencies. Run 'npm i -S react-transition-group' to add it
import Uik from '@reef-chain/ui-kit';
import { faXmark } from '@fortawesome/free-solid-svg-icons';
import './overlay-action.css';
Expand Down Expand Up @@ -58,10 +58,10 @@
>
<div className="overlay-action__content">
<div className="overlay-action__head">
<div className="overlay-action__title">{ title }</div>
<div className={`${!isDarkMode?`overlay-action__title`:`overlay-action__title-dark`} overlay-action__title-base`}>{ title }</div>

<button
className="overlay-action__close-btn"
className={`overlay-action__close-btn${isDarkMode?'-dark':''}`}
aria-label="Close button"
type="button"
onClick={onClose}
Expand Down
62 changes: 49 additions & 13 deletions src/components/OverlayAction/overlay-action.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,6 @@
position: relative;
}

.overlay-action__title {
font-size: 1.625rem;
line-height: 1.2;
font-weight: 500;
color: hsla(
var(--text--h),
var(--text--s),
var(--text--l),
0.9
);
}

.overlay-action__close-btn {
position: absolute;
right: 0;
Expand Down Expand Up @@ -141,4 +129,52 @@
justify-content: center;
align-items: flex-start;
padding-top: 40px;
}
}

/* new */

.overlay-action__title-base{
font-size: 1.625rem;
line-height: 1.2;
font-weight: 500;
}

.overlay-action__title {
color: hsla(
var(--text--h),
var(--text--s),
var(--text--l),
0.9
);
}

.overlay-action__title-dark {
color: white!important;
}


.overlay-action__close-btn-dark {
position: absolute;
right: 0;
display: flex;
justify-content: center;
align-items: center;
width: 54px;
height: 54px;
min-width: 54px;
border-radius: 50%;
background-color: transparent;
border: none;
transition: all 0.125s;
color: white;
box-shadow: none;
}

.overlay-action__close-btn-dark:hover {
color: white;
cursor: pointer;
}

.overlay-action__close-btn-dark:active {
color: white;
}
5 changes: 3 additions & 2 deletions src/components/Overlays/OverlaySend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { OverlayAction } from '../OverlayAction';
import './overlay.css';
import { Notify, ReefSigner, Token } from '../../state';
import { Provider } from '@reef-chain/evm-provider';

Check failure on line 7 in src/components/Overlays/OverlaySend.tsx

View workflow job for this annotation

GitHub Actions / lint

`@reef-chain/evm-provider` import should occur before import of `../Transfer`

interface OverlaySend {
tokenAddress?: string;
Expand Down Expand Up @@ -32,16 +32,16 @@
isDarkMode,
isWalletConnect,
handleWalletConnectModal,
}: OverlaySend): JSX.Element => {

Check failure on line 35 in src/components/Overlays/OverlaySend.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`
return (
<OverlayAction
isOpen={isOpen}
title="Send"
onClose={onClose}
className="overlay-swap"
className={`overlay-swap${isDarkMode?'-dark':''}`}
isDarkMode={isDarkMode}
>
<div className="uik-pool-actions pool-actions">
<div className={`uik-pool-actions pool-actions ${isDarkMode?'uik-pool-actions-dark':''}`}>
{ provider && selectedSigner
&& (
<Send
Expand All @@ -53,6 +53,7 @@
tokenAddress={tokenAddress}
isWalletConnect={isWalletConnect}
handleWalletConnectModal={handleWalletConnectModal}
isDarkMode={isDarkMode}
/>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Overlays/OverlaySendNft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
return list.filter((acc) => acc.address.toLowerCase().startsWith(query.toLowerCase())
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|| (acc.name as any).replaceAll(' ', '').toLowerCase().startsWith(query.toLowerCase()));
}, [accounts, query]);

Check warning on line 96 in src/components/Overlays/OverlaySendNft.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useMemo has a missing dependency: 'selectedAccount.address'. Either include it or remove the dependency array

return (
<div className="send-accounts">
Expand Down Expand Up @@ -201,7 +201,7 @@
const calculateAndSetPercentage = (val: number): void => {
const closestToVal = Math.ceil((val * parsedBalance) / 100);
setAmount(closestToVal);
setPercentage(closestToVal * 100 / parsedBalance);

Check warning on line 204 in src/components/Overlays/OverlaySendNft.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected mix of '*' and '/'. Use parentheses to clarify the intended order of operations

Check warning on line 204 in src/components/Overlays/OverlaySendNft.tsx

View workflow job for this annotation

GitHub Actions / lint

Unexpected mix of '*' and '/'. Use parentheses to clarify the intended order of operations
};

const createSliderConfig = (): { position: number, text?: string }[] => {
Expand All @@ -226,7 +226,7 @@
const position = Math.ceil(step * i);
const positionText = Math.ceil(parsedBalance * (step / 100) * i).toString();
const text = (i % 2 === 0 || position === parsedBalance) ? positionText : '';
//@ts-ignore

Check failure on line 229 in src/components/Overlays/OverlaySendNft.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected exception block, space or tab after '//' in comment
helpers.push({ position, text });
}
return helpers;
Expand Down Expand Up @@ -305,7 +305,7 @@
/>
)}
</div>
<div className="send__address">
<div className={`send__address ${isDarkMode?'send__address-dark':''}`}>
<Identicon className="send__address-identicon" value={destinationAddress} size={46} theme="substrate" />
<input
className="send__address-input"
Expand Down
10 changes: 7 additions & 3 deletions src/components/Overlays/OverlaySwap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
} from 'react';
import { BigNumber } from 'ethers';
import axios, { AxiosInstance } from 'axios';
import { network as libNet } from '@reef-chain/util-lib';

Check failure on line 6 in src/components/Overlays/OverlaySwap.tsx

View workflow job for this annotation

GitHub Actions / lint

'/home/runner/work/react-lib/react-lib/node_modules/@reef-chain/util-lib/dist/dts/main.d.ts' imported multiple times
import './overlay.css';
import { Notify, Pool, PoolWithReserves, ReefSigner, Token, TokenPrices } from '../../state';
import { network as nw } from '@reef-chain/util-lib';

Check failure on line 9 in src/components/Overlays/OverlaySwap.tsx

View workflow job for this annotation

GitHub Actions / lint

`@reef-chain/util-lib` import should occur before import of `../../state`

Check failure on line 9 in src/components/Overlays/OverlaySwap.tsx

View workflow job for this annotation

GitHub Actions / lint

'/home/runner/work/react-lib/react-lib/node_modules/@reef-chain/util-lib/dist/dts/main.d.ts' imported multiple times
import * as store from '../../store';
import { onSwap as hooksOnswap, useSwapState } from '../../hooks';
import { OverlayAction } from '../OverlayAction';
Expand All @@ -27,6 +27,7 @@
pools:PoolWithReserves[];
network:libNet.DexProtocolv2 |undefined;
notify:(message: string, type?: Notify) => void;
isDarkMode?:boolean;
}

const poolWithReservesToPool = (p: PoolWithReserves): Pool => ({
Expand Down Expand Up @@ -65,7 +66,8 @@
tokenPrices,
pools,
network,
notify
notify,
isDarkMode=false
}: OverlaySwap): JSX.Element => {
const [address1, setAddress1] = useState(tokenAddress);
const [address2, setAddress2] = useState('0x');
Expand Down Expand Up @@ -172,16 +174,18 @@
isOpen={isOpen}
title="Swap"
onClose={onClose}
className="overlay-swap"
className={`overlay-swap${isDarkMode?'-dark':''}`}
isDarkMode={isDarkMode}
>
<div className="uik-pool-actions pool-actions">
<div className={`uik-pool-actions pool-actions ${isDarkMode?'uik-pool-actions-dark':''}`}>
{
finalized
? (
<Trade
pools={pools}
tokens={tokens}
state={tradeState}
isDarkMode={isDarkMode}
maxSlippage={MAX_SLIPPAGE}
actions={{
onSwap,
Expand Down
148 changes: 148 additions & 0 deletions src/components/Overlays/overlay.css
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,151 @@
pointer-events: none;
}

/* dark */
.overlay-swap-dark .overlay-action__wrapper {
background: hsla(
var(--bg--h),
var(--bg--s),
var(--bg--l),
0.9
);
}

.overlay-swap-dark .overlay-action__close-btn {
background-color: #26272c;
}

.overlay-swap-dark .overlay-action__content {
max-width: 600px;
}

.overlay-swap-dark .overlay-action__slot {
align-items: center;
padding-top: 60px;
}

.overlay-swap-dark .uik-pool-actions {
box-shadow: none;
max-width: 100%;
min-width: 100%;
width: 100%;
margin-right: 0;
}

.overlay-swap-dark .uik-pool-actions__tokens {
margin-top: 0;
}

.nft-name--modal{
font-size: x-large;
font-weight: bold;
}

.nft-iconurl{
max-width: 250px;
border-radius: 20px;
margin-top: 15px;
}
.nft-iconurl-small{
max-width: 50%;
border-radius: 5px;
margin-bottom: 20px;
}

.send-nft-view{
display: flex;
align-items: center;
justify-content: center;
}

.nfts__item-video-small {
max-width: 50%;
}

.nft-view{
display: flex;
justify-content: center;
align-items: center;
}

.display-table{
padding: 6px;
font-size: 14px;
background-color: #e6e2f1;
margin-top: 8px;
border-radius: 10px;

}

.display-table-label{
font-weight: bold;
color: #a93185;
}

.nft-box-send-btn{
display: flex;
justify-content: center;
align-items: center;
margin-top: 16px;
}

.nft__button{
outline: none;
border: none;
}

.nft-hidden {
display: none;
}

.send__address {
width: 100%;
position: relative;
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 10px;
margin-top: 6px;
}

.send__address-input {
width: 100%;
border-radius: 15px;
border: none;
background-color: #e6e2f1;
transition: all 0.125s;
height: 70px;
padding: 0 17px 1px 71px;
font-family: var(--font);
font-size: 15px;
color: var(--text);
font-weight: 500;
line-height: 1.2;
}
.send__amount-input {
width: 100%;
border-radius: 15px;
border: none;
background-color: #e6e2f1;
transition: all 0.125s;
height: 70px;
padding: 0 17px 1px 17px;
font-family: var(--font);
font-size: 15px;
color: var(--text);
font-weight: 500;
line-height: 1.2;
}

.send__address .send__address-identicon {
position: absolute;
left: 13px;
background-color: #dad5eaad;
border-radius: 10px;
pointer-events: none;
}

/* this one is override for send */
.uik-pool-actions-dark{
background-color: #26272c!important;
}
11 changes: 6 additions & 5 deletions src/components/PoolActions/TokenDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface TokenDropdown {
token: TokenWithAmount;
tokens: Token[];
selectToken?: (token: Token) => void;
isDarkMode?:boolean;
}

interface TokenDropdownItem {
Expand Down Expand Up @@ -47,7 +48,7 @@ const TokenDropdownItem = ({ token, selectToken }: TokenDropdownItem): JSX.Eleme
</Uik.DropdownItem>
);

const TokenDropdown = ({ token, tokens, selectToken } : TokenDropdown): JSX.Element => {
const TokenDropdown = ({ token, tokens, selectToken,isDarkMode } : TokenDropdown): JSX.Element => {
const [isOpen, setOpen] = useState(token.isEmpty && !!selectToken);
const [search, setSearch] = useState('');

Expand Down Expand Up @@ -86,7 +87,7 @@ const TokenDropdown = ({ token, tokens, selectToken } : TokenDropdown): JSX.Elem
<button
className={!token.isEmpty
? 'uik-pool-actions-token__token'
: 'uik-pool-actions-token uik-pool-actions-token--select'}
: `uik-pool-actions-token uik-pool-actions-token--select ${isDarkMode?'uik-pool-actions-token--select-dark':''}`}
type="button"
disabled={!selectToken}
onClick={() => setOpen(true)}
Expand All @@ -106,8 +107,8 @@ const TokenDropdown = ({ token, tokens, selectToken } : TokenDropdown): JSX.Elem
{ !token.isEmpty
&& (
<div className="uik-pool-actions-token__info">
<div className="uik-pool-actions-token__symbol">{ token.symbol }</div>
<div className="uik-pool-actions-token__amount" title={showBalance(token)}>
<div className={`uik-pool-actions-token__symbol${isDarkMode?'-dark':''}`}>{ token.symbol }</div>
<div className={`uik-pool-actions-token__amount ${isDarkMode?'uik-pool-actions-token__amount-dark':''}`} title={showBalance(token)}>
{ formatHumanBalance(token) }
{' '}
{ token.symbol }
Expand All @@ -117,7 +118,7 @@ const TokenDropdown = ({ token, tokens, selectToken } : TokenDropdown): JSX.Elem
</button>

<Uik.Dropdown
className="uik-pool-actions-token__select-dropdown"
className={`uik-pool-actions-token__select-dropdown ${isDarkMode?'dark-dropdown':''}`}
isOpen={isOpen}
onClose={() => setOpen(false)}
>
Expand Down
4 changes: 4 additions & 0 deletions src/components/PoolActions/TokenField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ interface TokenField {
tokens?: Token[];
selectToken?: SelectToken;
onAmountChange: (amount: string) => void;
isDarkMode?:boolean;
}

const TokenField = ({
token,
tokens = [],
onAmountChange,
selectToken,
isDarkMode=false,
}: TokenField): JSX.Element => {
const [isFocused, setFocused] = useState(false);
const onInputFocus = (): void => setFocused(true);
Expand All @@ -44,13 +46,15 @@ const TokenField = ({
<div
className={`
uik-pool-actions-token
${isDarkMode?'uik-pool-actions-token-dark':''}
${isFocused ? 'uik-pool-actions-token--focused' : isFocused}
`}
>
<TokenDropdown
token={token}
tokens={tokens}
selectToken={selectToken}
isDarkMode={isDarkMode}
/>
{ !token.isEmpty
&& (
Expand Down
Loading
Loading