Skip to content

Commit

Permalink
chore(coinmarket): update card wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
adderpositive authored and tomasklim committed Oct 8, 2024
1 parent 544f334 commit 54102a6
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import {
CoinmarketTradeBuyType,
} from 'src/types/coinmarket/coinmarket';
import { CoinmarketSelectedOfferInfo } from 'src/views/wallet/coinmarket/common/CoinmarketSelectedOffer/CoinmarketSelectedOfferInfo';
import {
CoinmarketLeftWrapper,
CoinmarketRightWrapper,
CoinmarketWrapper,
} from 'src/views/wallet/coinmarket';
import { CoinmarketDetailBuyPaymentPaymentSuccessful } from 'src/views/wallet/coinmarket/common/CoinmarketDetail/CoinmarketDetailBuy/CoinmarketDetailBuyPaymentSuccessful';
import { CoinmarketDetailBuyPaymentFailed } from 'src/views/wallet/coinmarket/common/CoinmarketDetail/CoinmarketDetailBuy/CoinmarketDetailBuyPaymentFailed';
import { CoinmarketDetailBuyPaymentProcessing } from 'src/views/wallet/coinmarket/common/CoinmarketDetail/CoinmarketDetailBuy/CoinmarketDetailBuyPaymentProcessing';
import { CoinmarketDetailBuyPaymentWaitingForUser } from 'src/views/wallet/coinmarket/common/CoinmarketDetail/CoinmarketDetailBuy/CoinmarketDetailBuyPaymentWaitingForUser';
import {
CoinmarketSideWrapper,
CoinmarketWrapper,
} from 'src/views/wallet/coinmarket/common/CoinmarketWrapper';

const Wrapper = styled.div`
${CoinmarketWrapper}
Expand Down Expand Up @@ -62,7 +61,7 @@ export const CoinmarketDetailBuy = () => {

return (
<Wrapper>
<CoinmarketLeftWrapper>
<CoinmarketSideWrapper side="left">
{showError && (
<CoinmarketDetailBuyPaymentFailed account={account} supportUrl={supportUrl} />
)}
Expand All @@ -75,8 +74,8 @@ export const CoinmarketDetailBuy = () => {
/>
)}
{showSuccess && <CoinmarketDetailBuyPaymentPaymentSuccessful account={account} />}
</CoinmarketLeftWrapper>
<CoinmarketRightWrapper>
</CoinmarketSideWrapper>
<CoinmarketSideWrapper side="right">
<CoinmarketSelectedOfferInfo
account={account}
selectedQuote={trade.data}
Expand All @@ -85,7 +84,7 @@ export const CoinmarketDetailBuy = () => {
quoteAmounts={quoteAmounts}
type="buy"
/>
</CoinmarketRightWrapper>
</CoinmarketSideWrapper>
</Wrapper>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ import {
CoinmarketTradeExchangeType,
} from 'src/types/coinmarket/coinmarket';
import { CoinmarketSelectedOfferInfo } from 'src/views/wallet/coinmarket/common/CoinmarketSelectedOffer/CoinmarketSelectedOfferInfo';
import {
CoinmarketLeftWrapper,
CoinmarketRightWrapper,
CoinmarketWrapper,
} from 'src/views/wallet/coinmarket';
import { CoinmarketDetailExchangePaymentSuccessful } from 'src/views/wallet/coinmarket/common/CoinmarketDetail/CoinmarketDetailExchange/CoinmarketDetailExchangePaymentSuccessful';
import { CoinmarketDetailExchangePaymentKYC } from 'src/views/wallet/coinmarket/common/CoinmarketDetail/CoinmarketDetailExchange/CoinmarketDetailExchangePaymentKYC';
import { CoinmarketDetailExchangePaymentFailed } from 'src/views/wallet/coinmarket/common/CoinmarketDetail/CoinmarketDetailExchange/CoinmarketDetailExchangePaymentFailed';
import { CoinmarketDetailExchangePaymentConverting } from 'src/views/wallet/coinmarket/common/CoinmarketDetail/CoinmarketDetailExchange/CoinmarketDetailExchangePaymentConverting';
import { CoinmarketDetailExchangePaymentSending } from 'src/views/wallet/coinmarket/common/CoinmarketDetail/CoinmarketDetailExchange/CoinmarketDetailExchangePaymentSending';
import {
CoinmarketSideWrapper,
CoinmarketWrapper,
} from 'src/views/wallet/coinmarket/common/CoinmarketWrapper';

const Wrapper = styled.div`
${CoinmarketWrapper}
Expand Down Expand Up @@ -63,7 +62,7 @@ export const CoinmarketDetailExchange = () => {

return (
<Wrapper>
<CoinmarketLeftWrapper>
<CoinmarketSideWrapper side="left">
{tradeStatus === 'SUCCESS' && (
<CoinmarketDetailExchangePaymentSuccessful account={account} />
)}
Expand All @@ -85,16 +84,16 @@ export const CoinmarketDetailExchange = () => {
<CoinmarketDetailExchangePaymentConverting supportUrl={supportUrl} />
)}
{showSending && <CoinmarketDetailExchangePaymentSending supportUrl={supportUrl} />}
</CoinmarketLeftWrapper>
<CoinmarketRightWrapper>
</CoinmarketSideWrapper>
<CoinmarketSideWrapper side="right">
<CoinmarketSelectedOfferInfo
selectedQuote={trade.data}
transactionId={trade.key}
providers={info?.providerInfos}
type="exchange"
quoteAmounts={quoteAmounts}
/>
</CoinmarketRightWrapper>
</CoinmarketSideWrapper>
</Wrapper>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ import {
CoinmarketGetCryptoQuoteAmountProps,
CoinmarketTradeSellType,
} from 'src/types/coinmarket/coinmarket';
import {
CoinmarketLeftWrapper,
CoinmarketRightWrapper,
CoinmarketWrapper,
} from 'src/views/wallet/coinmarket';
import { CoinmarketSelectedOfferInfo } from 'src/views/wallet/coinmarket/common/CoinmarketSelectedOffer/CoinmarketSelectedOfferInfo';
import { CoinmarketDetailSellPaymentSuccessful } from 'src/views/wallet/coinmarket/common/CoinmarketDetail/CoinmarketDetailSell/CoinmarketDetailSellPaymentSuccessful';
import { CoinmarketDetailSellPaymentFailed } from 'src/views/wallet/coinmarket/common/CoinmarketDetail/CoinmarketDetailSell/CoinmarketDetailSellPaymentFailed';
import { CoinmarketDetailSellPaymentPending } from 'src/views/wallet/coinmarket/common/CoinmarketDetail/CoinmarketDetailSell/CoinmarketDetailSellPaymentPending';
import {
CoinmarketSideWrapper,
CoinmarketWrapper,
} from 'src/views/wallet/coinmarket/common/CoinmarketWrapper';

const Wrapper = styled.div`
${CoinmarketWrapper}
Expand Down Expand Up @@ -61,7 +60,7 @@ export const CoinmarketDetailSell = () => {

return (
<Wrapper>
<CoinmarketLeftWrapper>
<CoinmarketSideWrapper side="left">
{tradeStatus === 'SUCCESS' && (
<CoinmarketDetailSellPaymentSuccessful account={account} />
)}
Expand All @@ -73,8 +72,8 @@ export const CoinmarketDetailSell = () => {
/>
)}
{showPending && <CoinmarketDetailSellPaymentPending supportUrl={supportUrl} />}
</CoinmarketLeftWrapper>
<CoinmarketRightWrapper>
</CoinmarketSideWrapper>
<CoinmarketSideWrapper side="right">
<CoinmarketSelectedOfferInfo
account={account}
providers={info?.providerInfos}
Expand All @@ -83,7 +82,7 @@ export const CoinmarketDetailSell = () => {
type="sell"
quoteAmounts={quoteAmounts}
/>
</CoinmarketRightWrapper>
</CoinmarketSideWrapper>
</Wrapper>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { CoinmarketFormInputs } from 'src/views/wallet/coinmarket/common/Coinmar
import { CoinmarketFormOffer } from 'src/views/wallet/coinmarket/common/CoinmarketForm/CoinmarketFormOffer';
import { CoinmarketFeaturedOffers } from 'src/views/wallet/coinmarket/common/CoinmarketFeaturedOffers/CoinmarketFeaturedOffers';
import {
CoinmarketSideWrapper,
CoinmarketWrapper,
CoinmarketLeftWrapper,
CoinmarketRightWrapper,
} from 'src/views/wallet/coinmarket';
} from 'src/views/wallet/coinmarket/common/CoinmarketWrapper';

const CoinmarketFormLayoutWrapper = styled.form`
${CoinmarketWrapper}
Expand All @@ -15,12 +14,12 @@ const CoinmarketFormLayoutWrapper = styled.form`
export const CoinmarketFormLayout = () => (
<>
<CoinmarketFormLayoutWrapper>
<CoinmarketLeftWrapper>
<CoinmarketSideWrapper side="left">
<CoinmarketFormInputs />
</CoinmarketLeftWrapper>
<CoinmarketRightWrapper>
</CoinmarketSideWrapper>
<CoinmarketSideWrapper side="right">
<CoinmarketFormOffer />
</CoinmarketRightWrapper>
</CoinmarketSideWrapper>
</CoinmarketFormLayoutWrapper>
<CoinmarketFeaturedOffers />
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
isCoinmarketExchangeOffers,
isCoinmarketSellOffers,
} from 'src/hooks/wallet/coinmarket/offers/useCoinmarketCommonOffers';
import { CoinmarketWrapper } from 'src/views/wallet/coinmarket';
import { CoinmarketOfferSell } from 'src/views/wallet/coinmarket/common/CoinmarketSelectedOffer/CoinmarketOfferSell/CoinmarketOfferSell';
import { CoinmarketOfferBuy } from 'src/views/wallet/coinmarket/common/CoinmarketSelectedOffer/CoinmarketOfferBuy/CoinmarketOfferBuy';
import { CoinmarketOfferExchange } from 'src/views/wallet/coinmarket/common/CoinmarketSelectedOffer/CoinmarketOfferExchange/CoinmarketOfferExchange';
import { CoinmarketWrapper } from 'src/views/wallet/coinmarket/common/CoinmarketWrapper';

const Wrapper = styled.div`
${CoinmarketWrapper}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CoinmarketLeftWrapper, CoinmarketRightWrapper } from 'src/views/wallet/coinmarket';
import { CoinmarketSideWrapper } from 'src/views/wallet/coinmarket/common/CoinmarketWrapper';

interface CoinmarketSelectedOfferWrapperProps {
leftChildren: React.ReactNode;
Expand All @@ -10,7 +10,9 @@ export const CoinmarketSelectedOfferWrapper = ({
rightChildren,
}: CoinmarketSelectedOfferWrapperProps) => (
<>
<CoinmarketLeftWrapper $isWithoutPadding>{leftChildren}</CoinmarketLeftWrapper>
<CoinmarketRightWrapper>{rightChildren}</CoinmarketRightWrapper>
<CoinmarketSideWrapper side="left" isLeftSideWithoutPadding>
{leftChildren}
</CoinmarketSideWrapper>
<CoinmarketSideWrapper side="right">{rightChildren}</CoinmarketSideWrapper>
</>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { Card, variables } from '@trezor/components';
import { spacingsPx } from '@trezor/theme';
import { PropsWithChildren } from 'react';
import styled from 'styled-components';

export const CoinmarketWrapper = `
display: flex;
justify-content: space-between;
padding-bottom: ${spacingsPx.xxxl};
${variables.SCREEN_QUERY.BELOW_LAPTOP} {
flex-wrap: wrap;
}
`;

const CoinmarketLeftWrapper = styled.div`
width: 60%;
${variables.SCREEN_QUERY.BELOW_DESKTOP} {
width: 49%;
}
${variables.SCREEN_QUERY.BELOW_LAPTOP} {
width: 100%;
}
`;

const CoinmarketLeftPaddingWrapper = styled.div<{ $isWithoutPadding?: boolean }>`
padding: ${({ $isWithoutPadding }) =>
$isWithoutPadding ? 0 : `${spacingsPx.xl} ${spacingsPx.xl} ${spacingsPx.lg}`};
${variables.SCREEN_QUERY.BELOW_DESKTOP} {
padding: ${spacingsPx.md};
}
${variables.SCREEN_QUERY.BELOW_LAPTOP} {
padding-bottom: ${spacingsPx.zero};
}
`;

const CoinmarketRightWrapper = styled.div`
width: 37%;
${variables.SCREEN_QUERY.BELOW_DESKTOP} {
width: 49%;
}
${variables.SCREEN_QUERY.BELOW_LAPTOP} {
width: 100%;
margin-top: ${spacingsPx.sm};
}
`;

const CoinmarketRightPaddingWrapper = styled.div`
padding: ${spacingsPx.xl} ${spacingsPx.xl} ${spacingsPx.xxxl};
${variables.SCREEN_QUERY.BELOW_DESKTOP} {
padding: ${spacingsPx.md} ${spacingsPx.md} ${spacingsPx.xxl};
}
`;

interface CoinmarketSideWrapperProps extends PropsWithChildren {
side: 'left' | 'right';
isLeftSideWithoutPadding?: boolean;
}

export const CoinmarketSideWrapper = ({
side,
isLeftSideWithoutPadding,
children,
}: CoinmarketSideWrapperProps) => {
if (side === 'left') {
return (
<CoinmarketLeftWrapper>
<Card paddingType="none" height="100%">
<CoinmarketLeftPaddingWrapper $isWithoutPadding={isLeftSideWithoutPadding}>
{children}
</CoinmarketLeftPaddingWrapper>
</Card>
</CoinmarketLeftWrapper>
);
}

return (
<CoinmarketRightWrapper>
<Card paddingType="none" height="100%">
<CoinmarketRightPaddingWrapper>{children}</CoinmarketRightPaddingWrapper>
</Card>
</CoinmarketRightWrapper>
);
};
47 changes: 1 addition & 46 deletions packages/suite/src/views/wallet/coinmarket/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from 'styled-components';
import { variables, Card, Spinner } from '@trezor/components';
import { variables, Spinner } from '@trezor/components';
import {
Elevation,
mapElevationToBackground,
Expand All @@ -17,51 +17,6 @@ interface ResponsiveSize {
$responsiveSize: keyof typeof variables.SCREEN_SIZE;
}

export const CoinmarketWrapper = `
display: flex;
justify-content: space-between;
padding-bottom: ${spacingsPx.xxxl};
${SCREEN_QUERY.BELOW_LAPTOP} {
flex-wrap: wrap;
}
`;

// reason: responsive sizes
// eslint-disable-next-line local-rules/no-override-ds-component
export const CoinmarketLeftWrapper = styled(Card)<{ $isWithoutPadding?: boolean }>`
padding: ${({ $isWithoutPadding }) =>
$isWithoutPadding ? 0 : `${spacingsPx.xl} ${spacingsPx.xl} ${spacingsPx.lg}`};
width: 60%;
${SCREEN_QUERY.BELOW_DESKTOP} {
padding: ${spacingsPx.md};
width: 49%;
}
${SCREEN_QUERY.BELOW_LAPTOP} {
width: 100%;
padding-bottom: ${spacingsPx.zero};
}
`;

// reason: responsive sizes
// eslint-disable-next-line local-rules/no-override-ds-component
export const CoinmarketRightWrapper = styled(Card)`
padding: ${spacingsPx.xl} ${spacingsPx.xl} ${spacingsPx.xxxl};
width: 37%;
${SCREEN_QUERY.BELOW_DESKTOP} {
padding: ${spacingsPx.md} ${spacingsPx.md} ${spacingsPx.xxl};
width: 49%;
}
${SCREEN_QUERY.BELOW_LAPTOP} {
width: 100%;
margin-top: ${spacingsPx.sm};
}
`;

export const Wrapper = styled.div<ResponsiveSize>`
display: flex;
flex: 1;
Expand Down

0 comments on commit 54102a6

Please sign in to comment.