-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: refactor containers to make them more composable
- Loading branch information
1 parent
967f7b1
commit 826a074
Showing
110 changed files
with
1,560 additions
and
1,586 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { ChainID } from '@stacks/transactions'; | ||
import { Flex, Grid, GridItem, type GridProps, HStack } from 'leather-styles/jsx'; | ||
|
||
import { NetworkModeBadge } from '@leather.io/ui'; | ||
|
||
import type { HasChildren } from '@app/common/has-children'; | ||
import { useCurrentNetworkState } from '@app/store/networks/networks.hooks'; | ||
|
||
interface HeaderGridProps extends GridProps { | ||
leftCol: React.ReactNode; | ||
centerCol?: React.ReactNode; | ||
rightCol: React.ReactNode; | ||
} | ||
export function HeaderGrid({ leftCol, centerCol, rightCol, ...props }: HeaderGridProps) { | ||
return ( | ||
<Grid | ||
alignItems="center" | ||
gridTemplateColumns={centerCol ? '2fr 4fr 2fr' : 'auto 4fr auto'} | ||
gridAutoFlow="column" | ||
width="100%" | ||
{...props} | ||
> | ||
<GridItem justifySelf="start"> | ||
<Flex py={{ base: 0, md: 'space.01' }}>{leftCol}</Flex> | ||
</GridItem> | ||
{centerCol && <GridItem margin="auto">{centerCol}</GridItem>} | ||
<GridItem>{rightCol}</GridItem> | ||
</Grid> | ||
); | ||
} | ||
|
||
export function HeaderGridRightCol({ children }: HasChildren) { | ||
const { chain, name: chainName } = useCurrentNetworkState(); | ||
return ( | ||
<HStack alignItems="center" justifyContent="flex-end"> | ||
<NetworkModeBadge | ||
isTestnetChain={chain.stacks.chainId === ChainID.Testnet} | ||
name={chainName} | ||
/> | ||
{children} | ||
</HStack> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { type BoxProps, styled } from 'leather-styles/jsx'; | ||
|
||
import type { HasChildren } from '@app/common/has-children'; | ||
|
||
export function Header({ children, ...props }: HasChildren & BoxProps) { | ||
return ( | ||
<> | ||
<styled.header | ||
justifyContent="center" | ||
margin={{ base: 0, md: 'auto' }} | ||
p="space.04" | ||
bg="transparent" | ||
maxWidth={{ base: '100vw', md: 'fullPageMaxWidth' }} | ||
width="100%" | ||
{...props} | ||
> | ||
{children} | ||
</styled.header> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { OnboardingSelectors } from '@tests/selectors/onboarding.selectors'; | ||
import { Box } from 'leather-styles/jsx'; | ||
|
||
import { Logo } from '@leather.io/ui'; | ||
|
||
import { RouteUrls } from '@shared/route-urls'; | ||
|
||
export function LogoBox({ isSessionLocked }: { isSessionLocked?: boolean | undefined }) { | ||
const navigate = useNavigate(); | ||
return ( | ||
<Box | ||
height="headerContainerHeight" | ||
margin="auto" | ||
px="space.02" | ||
hideBelow={isSessionLocked ? undefined : 'sm'} | ||
hideFrom={isSessionLocked ? 'sm' : undefined} | ||
> | ||
<Logo | ||
data-testid={OnboardingSelectors.LogoRouteToHome} | ||
onClick={() => navigate(RouteUrls.Home)} | ||
/> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export { Page } from './page/page.layout'; | ||
export { Footer } from './footer/footer'; | ||
export { Card } from './card/card'; | ||
export { CardContent } from './card/card-content'; | ||
export { AvailableBalance } from './footer/available-balance'; | ||
|
||
export { HomeLayout } from './layouts/home.layout'; | ||
export { Content } from './layouts/content.layout'; | ||
export { TwoColumnLayout } from './layouts/two-column.layout'; | ||
export { ContainerLayout } from './layouts/container.layout'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Flex } from 'leather-styles/jsx'; | ||
|
||
import type { HasChildren } from '@app/common/has-children'; | ||
|
||
export function ContainerLayout({ children }: HasChildren) { | ||
return ( | ||
<Flex flexDirection="column" flexGrow={1} width="100%" height={{ base: '100vh', sm: '100%' }}> | ||
{children} | ||
</Flex> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Flex } from 'leather-styles/jsx'; | ||
|
||
import type { HasChildren } from '@app/common/has-children'; | ||
|
||
export function Content({ children }: HasChildren) { | ||
return ( | ||
<Flex className="main-content" flexGrow={1} position="relative" width="100%"> | ||
{children} | ||
</Flex> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { Outlet, useOutletContext } from 'react-router-dom'; | ||
|
||
import { SwitchAccountOutletContext } from '@shared/switch-account'; | ||
|
||
import { Content } from '../layouts/content.layout'; | ||
|
||
export function HomeLayout() { | ||
const { isShowingSwitchAccount, setIsShowingSwitchAccount } = | ||
useOutletContext<SwitchAccountOutletContext>(); | ||
return ( | ||
<Content> | ||
<Outlet context={{ isShowingSwitchAccount, setIsShowingSwitchAccount }} /> | ||
</Content> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Outlet, useOutletContext } from 'react-router-dom'; | ||
|
||
import { SwitchAccountOutletContext } from '@shared/switch-account'; | ||
|
||
export function PageLayout() { | ||
const { isShowingSwitchAccount, setIsShowingSwitchAccount } = | ||
useOutletContext<SwitchAccountOutletContext>(); | ||
return <Outlet context={{ isShowingSwitchAccount, setIsShowingSwitchAccount }} />; | ||
} |
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...pp/ui/layout/page/page.layout.stories.tsx → ...nents/layout/page/page.layout.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.