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

Replace Gap and FlexBox with new spacing components #2369

Merged
merged 3 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { bind } from "@react-rxjs/core"
import { map } from "rxjs/operators"
import { useTheme } from "styled-components"

import { FlexBox } from "@/client/components/FlexBox"
import { Stack } from "@/client/components/Stack"
import { Typography } from "@/client/components/Typography"
import { formatAsWholeNumber } from "@/client/utils/formatNumber"
import { history$ } from "@/services/analytics"
Expand All @@ -19,7 +19,7 @@ export const LastPosition = () => {

return (
<Typography variant="Text md/Regular">
<FlexBox>
<Stack alignItems="center">
USD
<Typography
style={{
Expand All @@ -35,7 +35,7 @@ export const LastPosition = () => {
>
{lastPosStr}
</Typography>
</FlexBox>
</Stack>
</Typography>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import { merge } from "rxjs"
import styled from "styled-components"

import { FlexBox } from "@/client/components/FlexBox"
import { AnalyticsSectionLayout } from "@/client/components/layout/AnalyticsSectionLayout"
import { Stack } from "@/client/components/Stack"
import { Typography } from "@/client/components/Typography"

import { LastPosition, lastPosition$ } from "./LastPosition"
import { LineChart, lineChart$ } from "./LineChart"

const ProfitAndLossFlexBox = styled(FlexBox)`
const ProfitAndLossFlexBox = styled(Stack)`
flex: 1;
justifycontent: space-between;
`

export const ProfitAndLoss = () => (
<AnalyticsSectionLayout
Header={
<ProfitAndLossFlexBox
style={{ flex: 1, justifyContent: "space-between" }}
>
<ProfitAndLossFlexBox justifyContent="space-between" alignItems="center">
<Typography variant="Text lg/Regular">Profit &amp; Loss</Typography>
<LastPosition />
</ProfitAndLossFlexBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const CardFooter = ({
(quote) => quote.state.type === ACCEPTED_QUOTE_STATE,
)?.dealerId
return (
<CardFooterWrapper>
<CardFooterWrapper alignItems="center" justifyContent="center" padding="md">
{state === RfqState.Open ? (
<LiveFooterContent
rfqId={id}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { memo } from "react"

import { FlexBox } from "@/client/components/FlexBox"
import { Stack } from "@/client/components/Stack"
import { Typography } from "@/client/components/Typography"
import { Direction } from "@/generated/TradingGateway"
import { useCreditInstrumentById } from "@/services/credit"
Expand Down Expand Up @@ -28,7 +28,7 @@ export const CardHeader = memo(function CardHeader({
const instrument = useCreditInstrumentById(instrumentId)

return (
<FlexBox>
<Stack alignItems="center">
{isBuy(direction) && (
<DirectionLabel direction={direction} terminated={terminated}>
<Typography
Expand Down Expand Up @@ -60,6 +60,6 @@ export const CardHeader = memo(function CardHeader({
</Typography>
</DirectionLabel>
)}
</FlexBox>
</Stack>
)
})
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { FC } from "react"
import styled from "styled-components"

import { FlexBox } from "@/client/components/FlexBox"
import { Gap } from "@/client/components/Gap"
import { Stack } from "@/client/components/Stack"
import { Typography } from "@/client/components/Typography"

import { RfqsTab, useSelectedRfqsTab } from "../../selectedRfqsTab"
Expand All @@ -13,11 +12,9 @@ import { NoLiveRfqsIcon } from "./svgs/NoLiveRfqsIcon"
import { NoRfqsIcon } from "./svgs/NoRfqsIcon"
import { IconProps } from "./svgs/types"

const Wrapper = styled(FlexBox)`
const Wrapper = styled(Stack)`
width: 100%;
height: 100%;
flex-direction: column;
justify-content: center;
`

function getTitleForTab(tab: RfqsTab) {
Expand Down Expand Up @@ -75,12 +72,11 @@ export const NoRfqsScreen = () => {
const IconComponent = getIconComponent(selectedRfqsTab)

return (
<Wrapper>
<Wrapper direction="column" justifyContent="center">
<IconComponent />
<Typography variant="Text lg/Semibold">
<Typography variant="Text lg/Semibold" marginBottom="xs">
{getTitleForTab(selectedRfqsTab)}
</Typography>
<Gap height="xs" />
<Typography
variant="Text md/Regular"
color="Colors/Text/text-tertiary (600)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled, { css, DefaultTheme, keyframes } from "styled-components"

import { FlexBox } from "@/client/components/FlexBox"
import { Stack } from "@/client/components/Stack"
import { Typography } from "@/client/components/Typography"
import { Direction } from "@/generated/TradingGateway"

Expand Down Expand Up @@ -76,11 +76,7 @@ export const NoRfqsWrapper = styled.div`

// Card Footer
Copy link
Contributor

Choose a reason for hiding this comment

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

started off taking against this pointless-looking comment .. 😂
.. then found AcceptedCardState is not used, and the final item QuantityTypography is not part of the footer ..
I used to have a mode set in VS Code where it annotated the usage count of each identifier .. got annoying, but might be useful when refactoring, like this ..?


export const CardFooterWrapper = styled(FlexBox)`
display: flex;
align-items: center;
justify-content: center;
padding: ${({ theme }) => theme.spacing.md};
export const CardFooterWrapper = styled(Stack)`
background: ${({ theme }) =>
theme.color["Colors/Background/bg-secondary_subtle"]};
color: ${({ theme }) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import styled from "styled-components"

import { FlexBox } from "@/client/components/FlexBox"
import { Region } from "@/client/components/layout/Region"
import { Loader } from "@/client/components/Loader"
import Logo from "@/client/components/logos/AdaptiveLogo"
import { Stack } from "@/client/components/Stack"
import { TabBar } from "@/client/components/TabBar"
import { Typography } from "@/client/components/Typography"
import { Direction } from "@/generated/TradingGateway"
Expand All @@ -29,11 +29,9 @@ export interface RfqRow {

export type RfqRowKey = keyof RfqRow

const Banner = styled(FlexBox)`
const Banner = styled(Stack)`
background-color: ${({ theme }) =>
theme.color["Colors/Background/bg-secondary"]};
padding: ${({ theme }) => theme.spacing.md};
gap: ${({ theme }) => theme.spacing.md};
height: 24px;
`

Expand All @@ -45,7 +43,7 @@ export const SellSideRfqGrid = () => {
fallback={<Loader ariaLabel="Loading RFQ queue.." />}
Header={
<>
<Banner>
<Banner padding="md" gap="md">
<Logo withText={false} size={1} />
<Typography
variant="Text sm/Regular"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from "styled-components"

import { FlexBox } from "@/client/components/FlexBox"
import { Stack } from "@/client/components/Stack"

export const SellSideWrapper = styled.div`
z-index: 1;
Expand All @@ -23,11 +23,9 @@ export const NoSelectHeader = styled.div`
theme.color["Colors/Background/bg-secondary"]};
`

export const NoSelectedMessage = styled(FlexBox)`
export const NoSelectedMessage = styled(Stack)`
flex: 1 1 auto;
text-align: center;
flex-direction: column;
justify-content: center;
background-color: ${({ theme }) =>
theme.color["Colors/Background/bg-tertiary"]};
`
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const SellSideTradeTicketInner = () => {
No RFQ Selected
</Typography>
</NoSelectHeader>
<NoSelectedMessage>
<NoSelectedMessage direction="column" justifyContent="center">
<Typography
variant="Text sm/Regular"
color="Colors/Text/text-primary (900)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { PropsWithChildren, useEffect, useRef } from "react"

import { TextInput } from "@/client/components/Form/TextInput"
import { Gap } from "@/client/components/Gap"
import { Typography } from "@/client/components/Typography"
import { truncatedDecimalNumberFormatter } from "@/client/utils"
import {
Expand Down Expand Up @@ -43,10 +42,10 @@ const Parameter = ({
<Typography
variant="Text sm/Medium"
color="Colors/Text/text-secondary (700)"
marginBottom="sm"
>
{label}
</Typography>
<Gap height="sm" />
{value && <Typography variant="Text sm/Regular">{value}</Typography>}
{children}
</div>
Expand Down
12 changes: 7 additions & 5 deletions packages/client/src/client/App/Footer/Aeron.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import styled from "styled-components"

import { FlexBox } from "@/client/components/FlexBox"
import { AeronLogo } from "@/client/components/logos/AeronLogo"
import { Stack } from "@/client/components/Stack"
import { Typography } from "@/client/components/Typography"
import { AERON } from "@/client/constants"

const AeronLogoWrapper = styled(FlexBox)`
const AeronLogoWrapper = styled(Stack)`
margin-right: auto;
align-items: flex-start;
gap: ${({ theme }) => theme.spacing.xs};
cursor: pointer;
svg {
fill: ${({ theme }) => theme.color["Colors/Text/text-primary (900)"]};
}
`

export const Aeron = () => (
<AeronLogoWrapper onClick={() => window.open(AERON)}>
<AeronLogoWrapper
alignItems="flex-start"
gap="xs"
onClick={() => window.open(AERON)}
>
<Typography
variant="Text xs/Regular"
color="Colors/Text/text-quaternary (500)"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import { PropsWithChildren } from "react"

import { Gap } from "@/client/components/Gap"
import { Typography } from "@/client/components/Typography"
import { EMAIL, WEBSITE } from "@/client/constants"

import { ContactUsContentResolver, Link } from "./styled"

const Row = ({ children }: PropsWithChildren) => (
<>
<Typography variant="Text sm/Regular">{children}</Typography>
<Gap height="sm" />
<Typography variant="Text sm/Regular" paddingBottom="sm">
{children}
</Typography>
</>
)

export const ContactUs = () => (
<ContactUsContentResolver>
<Typography variant="Text lg/Regular">Contact us</Typography>
<Gap height="md" />
<Typography variant="Text lg/Regular" paddingBottom="md">
Contact us
</Typography>
<Row>2nd floor, 1 Lackington St, London, EC2A 1AL</Row>
<Row>+44 203 725 6000</Row>
<Row>530 7th Avenue, New York</Row>
Expand All @@ -28,10 +29,10 @@ export const ContactUs = () => (
onClick={() => {
window.open(`mailto:${EMAIL}`)
}}
paddingBottom="xs"
>
<Typography>{EMAIL}</Typography>
{EMAIL}
Copy link
Contributor

Choose a reason for hiding this comment

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

minor point - what is the point of Link here .. I'd rather just have the plain Typography element inline - like this, it makes me think that Link has some "special powers" 🙂

</Link>
<Gap height="xs" />

<Link
variant="Text sm/Regular underlined"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { PropsWithChildren } from "react"

import { Gap } from "@/client/components/Gap"
import { Typography } from "@/client/components/Typography"
import { SOCIAL_ADDRESSES, SocialPlatform } from "@/client/constants"

Expand All @@ -17,10 +16,10 @@ const Row = ({
variant="Text sm/Regular underlined"
color="Component colors/Utility/Blue dark/utility-blue-dark-500"
onClick={onClick}
paddingBottom="md"
Copy link
Contributor

Choose a reason for hiding this comment

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

^ ^ can we get some typing on the color, do you think?
I know it has to allow "red", "white" and "inherit" and wotnot .. so not that easy .. but perhaps "csstype"'s Color | UISK theme Color ?
.. seems the base div component's def of color takes precedence - may not be worth the effort, but it would be nice to have completion, I would think ..

>
{children}
</Link>
<Gap height="md" />
</>
)
export const FollowUs = () => {
Expand All @@ -33,8 +32,9 @@ export const FollowUs = () => {

return (
<ContactUsContentResolver>
<Typography variant="Text lg/Regular">Follow us on</Typography>
<Gap height="sm" />
<Typography variant="Text lg/Regular" paddingBottom="sm">
Follow us on
</Typography>
<Row label="LinkedIn" onClick={onClick("LinkedIn")}>
linkedin.com/company/{<br />}adaptive-consulting-ltd/
</Row>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Gap } from "@/client/components/Gap"
import { Typography } from "@/client/components/Typography"
import { ConnectionStatus, useConnectionStatus } from "@/services/connection"

Expand All @@ -15,8 +14,7 @@ export const StatusButtonInner = ({ status }: { status: ConnectionStatus }) => {
return (
<Root>
<StatusCircle status={appStatus} />
<Gap width="xs" />
<Typography variant="Text sm/Regular">
<Typography variant="Text sm/Regular" paddingTop="xs">
{appStatus[0].toUpperCase() + appStatus.slice(1).toLowerCase()}
</Typography>
</Root>
Expand Down
6 changes: 2 additions & 4 deletions packages/client/src/client/App/Header/PWA/PWAInstallModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Button } from "@/client/components/Button"
import { Gap } from "@/client/components/Gap"
import { AppleShareIcon } from "@/client/components/icons"
import { Modal } from "@/client/components/Modal"
import { Typography } from "@/client/components/Typography"
Expand All @@ -13,10 +12,9 @@ interface InstallModalProps {
export const PWAInstallModal = ({ closeModal }: InstallModalProps) => (
<Modal shouldShow>
<ModalWrapper>
<Typography variant="Display sm/Regular">
<Typography variant="Display sm/Regular" paddingBottom="lg">
Install Reactive Trader
</Typography>
<Gap height="lg" />
<Typography
variant="Text sm/Regular"
color="Colors/Text/text-secondary (700)"
Expand All @@ -26,14 +24,14 @@ export const PWAInstallModal = ({ closeModal }: InstallModalProps) => (
<Typography
variant="Text sm/Regular"
color="Colors/Text/text-secondary (700)"
paddingBottom="md"
>
Tap{" "}
<IconWrapper>
<AppleShareIcon />
</IconWrapper>{" "}
from the browsers menu and select &quot;Add to Home Screen&quot;
</Typography>
<Gap height="md" />
<Button variant="outline" size="lg" onClick={closeModal}>
Close
</Button>
Expand Down
Loading