Skip to content

Commit

Permalink
refactor: utilize alternative text color
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-1979 committed Jan 27, 2025
1 parent 0a7409c commit 19f1dbf
Show file tree
Hide file tree
Showing 35 changed files with 57 additions and 76 deletions.
8 changes: 4 additions & 4 deletions packages/snap/src/listeners/onInstall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ const WelcomeScreen: SnapComponent = () => {
<Box direction='horizontal' alignment='space-between'>
<Box direction='vertical' >
<Heading size='md'>Welcome to Polkadot eco.!</Heading>
<Text color='muted'>
<Text color='alternative'>
<Bold>To View the </Bold><Link href="metamask://snap/npm:@polkagate/snap/home">Home</Link> <Bold> Screen:</Bold>
</Text>
</Box>
<Image src={polkadotMedium} />
</Box>

<Section>
<Text>
<Text color='alternative'>
1. Open MetaMask.
</Text>
<Text>
<Text color='alternative'>
2. Navigate to the <Bold>Menu</Bold> and select <Bold>Snaps</Bold>.
</Text>
<Text>
<Text color='alternative'>
3. Click on the <Bold>PolkaGate logo</Bold>.
</Text>
</Section>
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/components/ActionRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ActionRow: SnapComponent<Props> = ({ label, name, icon, disabled, t
</Box>
<Box direction="horizontal" alignment="end" center>
{!!tag &&
<Text color="muted">
<Text color="alternative">
{String(tag)}
</Text>
}
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/components/Options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const OptionButton: SnapComponent<OptionProps> = ({ description, form, na
{text}
</Text>
{!!description &&
<Text alignment='start' color='muted' size='sm'>
<Text alignment='start' color={isSelected ? 'alternative' : 'muted'} size='sm'>
{description}
</Text>}
</Box>
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/components/Row2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Props = {
*
* @returns The Row 2 component.
*/
export const Row2: SnapComponent<Props> = ({ alignment, label, labelColor = 'muted', extra, extraColor = 'muted', labelSize,valueSize,extraSize, value, valueColor = 'default' }) => (
export const Row2: SnapComponent<Props> = ({ alignment, label, labelColor = 'muted', extra, extraColor = 'alternative', labelSize,valueSize,extraSize, value, valueColor = 'default' }) => (
<Box alignment={alignment || "space-between"} direction="horizontal" center>
<Text color={labelColor} size={labelSize}>
{label}{alignment === 'start' ? ':' : ''}
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/home/partials/TotalBalance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const TotalBalance: SnapComponent<Props> = ({ hideBalance, balancesAll, p
<Tooltip content='Locked balance'>
<Icon name='lock' color='muted' />
</Tooltip>
<Text alignment='end' color='muted'>
<Text alignment='end' color='alternative'>
{hideBalance
? '••••••••'
: `$${lockedCommified} USD`
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/receive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const ui = (formatted: string, genesisHash: HexString, logo: string, qrCode: str
label='Receive'
showHome
/>
<Text alignment="start" color='muted'>
<Text alignment="start" color='alternative'>
Select a network to view your address & QR code
</Text>
<ChainSwitch genesisHash={genesisHash} logo={logo} />
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/send/reviewSend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ui = (
<Heading size="lg">
{`- ${amount} ${token}`}
</Heading>
<Text color="muted">
<Text color="alternative">
${(Number(amount || 0) * price).toFixed(2)}
</Text>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/showSpinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const ui = (label?: string, disabled?: boolean) => {
return (
<Box direction="vertical" alignment="center" center>
<Image src={isWorking ? working : clock} />
<Text alignment="center" color="muted">
<Text alignment="center" color="alternative">
{label ?? 'Processing, Please Wait!'}
</Text>
<Spinner />
Expand Down
6 changes: 4 additions & 2 deletions packages/snap/src/ui/stake/components/PoolOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@ export const PoolOption: SnapComponent<Props> = ({
<Row2
alignment="start"
label="Minimum stake"
labelColor={isSelected ? 'alternative' : 'muted'}
labelSize="sm"
valueSize="sm"
value={`${minJoinBondInHuman || 1} ${token}`}
valueColor="muted"
valueColor={isSelected ? 'alternative' : 'muted'}
/>
<Row2
alignment="start"
label="Rewards"
labelColor={isSelected ? 'alternative' : 'muted'}
labelSize="sm"
valueSize="sm"
value='Claim manually'
valueColor="muted"
valueColor={isSelected ? 'alternative' : 'muted'}
/>
</Box>
<Box direction="vertical" alignment="start">
Expand Down
11 changes: 7 additions & 4 deletions packages/snap/src/ui/stake/components/SoloOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,26 @@ export const SoloOption: SnapComponent<Props> = ({
<Row2
alignment="start"
label="Minimum stake"
labelColor={isSelected ? 'alternative' : 'muted'}
labelSize="sm"
valueSize="sm"
value={`${minimumActiveStakeInHuman} ${token}`}
valueColor="muted"
valueColor={isSelected ? 'alternative' : 'muted'}

/>
<Row2
alignment="start"
label="Rewards"
labelColor={isSelected ? 'alternative' : 'muted'}
labelSize="sm"
valueSize="sm"
value='Paid automatically'
valueColor="muted"
valueColor={isSelected ? 'alternative' : 'muted'}
/>
{/* <Text color="muted" size='sm'>
Reuse tokens in Governance
</Text> */}
<Text color="muted" size="sm">
<Text color= {isSelected ? 'alternative' : 'muted'} size="sm">
Advanced staking management
</Text>
</Box>
Expand All @@ -72,7 +75,7 @@ export const SoloOption: SnapComponent<Props> = ({
</Text>
</Box>
<Box direction="horizontal" alignment="end" center>
<Text color="muted">
<Text color="alternative">
{String(stakingData?.solo?.validators?.length || 0)}
</Text>
<Button name='selectValidators' variant='primary'>
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/src/ui/stake/components/StakeAndEarn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const StakeAndEarn: SnapComponent<Props> = ({ balancesAll, nonStakedChain
<Box direction='horizontal' alignment='start' center>
<Image src={logo} />
<Box direction='vertical' alignment='start'>
<Text>
<Text color='alternative'>
<Bold> {toTitleCase(sanitizedChainName) || 'Unknown'}</Bold>
</Text>
{!!balance?.transferable && !balance.transferable.isZero() &&
Expand All @@ -46,7 +46,7 @@ export const StakeAndEarn: SnapComponent<Props> = ({ balancesAll, nonStakedChain
<Text color='success' alignment='end'>
<Bold>{`+${rate}%`}</Bold>
</Text>
<Text color='muted' alignment='end' size='sm'>
<Text color='alternative' alignment='end' size='sm'>
per year
</Text>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/stake/components/StakeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const StakeForm: SnapComponent<Props> = ({ amount, decimal, formErrors, l
</Heading>
</Box>
<Input name={name || 'stakeAmount'} type="number" placeholder={placeHolder} value={amount} />
<Text color="muted">
<Text color="alternative">
${(Number(amount || 0) * price).toFixed(2)}
</Text>
</Field>
Expand Down
6 changes: 3 additions & 3 deletions packages/snap/src/ui/stake/components/StakedTokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const ChainRow: SnapComponent<ChainRowProps> = ({ logo, netStaked, sanitizedChai
<Box direction='horizontal' alignment='space-between'>
<Box direction='horizontal' center>
<Image src={logo || ''} />
<Text color='muted'>
<Text size='sm' color='alternative'>
{sanitizedChainName.toUpperCase()}
</Text>
</Box>
Expand All @@ -48,7 +48,7 @@ const ChainRow: SnapComponent<ChainRowProps> = ({ logo, netStaked, sanitizedChai
{hasDualStaking &&
<Box direction='horizontal' alignment='end'>
<Image src={type === 'Pool' ? poolSmall : soloSmall} />
<Text color='muted'>
<Text color='alternative'>
{type.toUpperCase()}
</Text>
</Box>
Expand Down Expand Up @@ -123,7 +123,7 @@ const RateRow: SnapComponent<RateRowProps> = ({ amount }) => {
<Text color='success' alignment='end'>
{`+${amount}%`}
</Text>
<Text color='muted' size='sm'>
<Text color='alternative' size='sm'>
/ year
</Text>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/stake/components/UnstakeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const UnstakeForm: SnapComponent<Props> = ({
</Heading>
</Box>
<Input name={name || 'unstakeAmount'} type="number" placeholder={placeHolder || "Enter amount to unstake"} value={amount} />
<Text color="muted">
<Text color="alternative">
${(Number(amount || 0) * price).toFixed(2)}
</Text>
</Field>
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/stake/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const ui = (
<Form name='testNetStaking'>
<Box direction='horizontal' center>
<Checkbox name="enableTestnetStaking" checked={isTestNetStakingEnabled} />
<Text color='muted'>
<Text color={isTestNetStakingEnabled ? 'alternative' : 'muted'}>
Show Test Networks
</Text>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/stake/pool/claim/claim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ui = (
<Heading size="lg">
{`${amountToHuman(amount, decimal, POOL_CLAIMABLE_DECIMAL, true)} ${token}`}
</Heading>
<Text color="muted">
<Text color="alternative">
${(Number(amountToHuman(amount, decimal) || 0) * price).toFixed(2)}
</Text>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/stake/pool/components/Rewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const Rewards: SnapComponent<Props> = ({ amount, decimal, price, token, c
<Heading size="md">
{`${amountToHuman(amount || 0, decimal, 3, true)} ${token}`}
</Heading>
<Text color="muted">
<Text color="alternative">
${`${(Number(amountToHuman(amount || 0, decimal)) * price).toFixed(2)}`}
</Text>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/stake/pool/components/YourStake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const YourStake: SnapComponent<Props> = ({ amount, decimal, token, price
<Heading size="lg">
{`${amountToHuman(amount, decimal, STAKED_AMOUNT_DECIMAL_POINT, true)} ${token}`}
</Heading>
<Text color="muted">
<Text color="alternative">
${`${(Number(amountToHuman(amount, decimal)) * price).toFixed(2)}`}
</Text>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/stake/pool/redeem/poolRedeem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ui = (
<Heading size="lg">
{`${amountToHuman(amount, decimal, 4, true)} ${token}`}
</Heading>
<Text color="muted">
<Text color="alternative">
${(Number(amountToHuman(amount, decimal) || 0) * price).toFixed(2)}
</Text>
</Box>
Expand Down
18 changes: 3 additions & 15 deletions packages/snap/src/ui/stake/pool/stakeMore/poolStakeMore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import { Box, Container, Footer, Button, Image, Section } from "@metamask/snaps-sdk/jsx";
import { amountToHuman } from "../../../../util/amountToHuman";
import { getBalances, getKeyPair } from "../../../../util";
import { getSnapState } from "../../../../rpc/stateManagement";
import { StakeForm } from "../../components/StakeForm";
import { Row2 } from "../../../components/Row2";
import { StakeFormErrors, StakingPoolContextType } from "../../types";
Expand Down Expand Up @@ -82,7 +81,7 @@ export async function poolStakeMore(
context: StakingPoolContextType,
) {

const { address, amount, claimable, decimal, genesisHash, logos, price, rate, sanitizedChainName, stakingRates, token, transferable } = context;
const { address, amount, claimable, decimal, genesisHash, logos, price, token, transferable } = context;
const _amount = formAmount !== undefined ? String(formAmount) : amount;

const _address = address || (await getKeyPair(undefined, genesisHash)).address;
Expand All @@ -99,16 +98,6 @@ export async function poolStakeMore(
_decimal = balances.decimal;
}

let _price = price;
let _rate = rate;

if (_price === undefined || !_rate) {
const priceInfo = await getSnapState('priceInfo');

_price = priceInfo?.prices?.[sanitizedChainName]?.value || 0;
_rate = stakingRates?.[sanitizedChainName || ''] || 0;
}

const fee = context.fee || await getPoolStakeMore(address, amountToMachine(amount, decimal) || BN_ZERO, genesisHash);

await snap.request({
Expand All @@ -122,12 +111,11 @@ export async function poolStakeMore(
genesisHash,
fee: String(fee),
logo: _logo,
price: _price!,
transferable: _transferable!,
token: _token!,
token: _token,
},
id,
ui: ui(_amount, claimable, _decimal, formErrors, _logo, _token, _transferable, _price, fee),
ui: ui(_amount, claimable, _decimal, formErrors, _logo, _token, _transferable, price, fee),
},
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const ui = (
<Heading size="lg">
{`${amount} ${token}`}
</Heading>
<Text color="muted">
<Text color="alternative">
${(Number(amount || 0) * price).toFixed(2)}
</Text>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const ui = (
<Heading size="lg">
{`${amount} ${token}`}
</Heading>
<Text color="muted">
<Text color="alternative">
${(Number(amount || 0) * price).toFixed(2)}
</Text>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/stake/selectValidators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { getValidators } from './utils/getValidators';
import { getValidatorsIdentities, Identities } from './utils/getValidatorIdentities';
import { StakingInitContextType, ValidatorInfo } from './types';
import { FlowHeader } from '../components/FlowHeader';
import { ShowValidator } from './ShowValidator';
import { ShowValidator } from './solo/components/ShowValidator';
import { WentWrong } from '../components/WentWrong';

const ui = (
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/stake/solo/components/Rewards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const Rewards: SnapComponent<Props> = (({ amount, decimal, price, token }
<Heading size="md">
{`${amountToHuman(amount || '0', decimal, 3, true)} ${token}`}
</Heading>
<Text color="muted">
<Text color="alternative">
${`${(Number(amountToHuman(amount || '0', decimal)) * price).toFixed(2)}`}
</Text>
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Box, Text, Tooltip, Icon, Checkbox, Avatar, SnapComponent } from '@metamask/snaps-sdk/jsx';
import { Identity } from './utils/getValidatorIdentities';
import { Identity } from '../../utils/getValidatorIdentities';
import { BN } from '@polkadot/util';
import type { AccountId } from '@polkadot/types/interfaces';
import { ellipsis } from './utils/ellipsis';
import { ellipsis } from '../../utils/ellipsis';

interface Props {
accountId: AccountId | string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ui = (
<Heading size="lg">
{`${amountToHuman(selectedAmountToPayout, decimal, SOLO_REDEEMABLE_DECIMAL, true)} ${token}`}
</Heading>
<Text color="muted">
<Text color="alternative">
${(Number(amountToHuman(selectedAmountToPayout, decimal) || 0) * price).toFixed(2)}
</Text>
</Box>
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/ui/stake/solo/redeem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ui = (
<Heading size="lg">
{`${amountToHuman(amount, decimal, SOLO_REDEEMABLE_DECIMAL, true)} ${token}`}
</Heading>
<Text color="muted">
<Text color="alternative">
${(Number(amountToHuman(amount, decimal) || 0) * price).toFixed(2)}
</Text>
</Box>
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/src/ui/stake/solo/rewards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const makePayee = (value: string | undefined): Payee | undefined => {
return undefined;
}

const ui = (context: StakingSoloContextType, payee: Payee, fee: Balance, maybeNew: Payee | undefined, selectedRewardsDestinationOption: RewardsDestinationOptions) => {
const ui = (context: StakingSoloContextType, payee: Payee, fee: Balance, maybeNew: Payee | undefined) => {

const { address, genesisHash, decimal, price, token } = context;

Expand Down Expand Up @@ -106,7 +106,7 @@ export async function rewardsDestination(
fee: fee,
},
id,
ui: ui(context, payee, fee, maybeNew, selectedRewardsDestinationOption),
ui: ui(context, payee, fee, maybeNew),
},
});
}
Loading

0 comments on commit 19f1dbf

Please sign in to comment.