-
Notifications
You must be signed in to change notification settings - Fork 145
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 use composition
- Loading branch information
1 parent
cf35f60
commit 8302c84
Showing
82 changed files
with
902 additions
and
769 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
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
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
16 changes: 16 additions & 0 deletions
16
src/app/features/container/containers/container.layout.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Flex } from 'leather-styles/jsx'; | ||
|
||
interface ContainerLayoutProps { | ||
content?: React.JSX.Element | React.JSX.Element[]; | ||
header?: React.JSX.Element | null; | ||
} | ||
export function ContainerLayout({ content, header }: ContainerLayoutProps) { | ||
return ( | ||
<Flex flexDirection="column" flexGrow={1} width="100%" height={{ base: '100vh', sm: '100%' }}> | ||
{header} | ||
<Flex className="main-content" flexGrow={1} position="relative" width="100%"> | ||
{content} | ||
</Flex> | ||
</Flex> | ||
); | ||
} |
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
61 changes: 61 additions & 0 deletions
61
src/app/features/container/containers/home/home-header.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { ReactNode, useState } from 'react'; | ||
|
||
import { SettingsSelectors } from '@tests/selectors/settings.selectors'; | ||
import { Flex, Grid, GridItem, HStack, styled } from 'leather-styles/jsx'; | ||
|
||
import { HamburgerIcon } from '@leather.io/ui'; | ||
|
||
import { SwitchAccountDialog } from '@app/features/dialogs/switch-account-dialog/switch-account-dialog'; | ||
|
||
import { Settings } from '../../../settings/settings'; | ||
|
||
interface HomeHeaderProps { | ||
networkBadge?: ReactNode; | ||
logo?: ReactNode; | ||
} | ||
|
||
export function HomeHeader({ networkBadge, logo }: HomeHeaderProps) { | ||
const [isShowingSwitchAccount, setIsShowingSwitchAccount] = useState(false); | ||
return ( | ||
<> | ||
{isShowingSwitchAccount && ( | ||
<SwitchAccountDialog | ||
isShowing={isShowingSwitchAccount} | ||
onClose={() => setIsShowingSwitchAccount(false)} | ||
/> | ||
)} | ||
<styled.header | ||
justifyContent="center" | ||
margin={{ base: 0, md: 'auto' }} | ||
p="space.04" | ||
bg="transparent" | ||
maxWidth={{ base: '100vw', md: 'fullPageMaxWidth' }} | ||
width="100%" | ||
> | ||
<Grid | ||
alignItems="center" | ||
// same as onboarding-header.tsx - don't need grid really as no title | ||
gridTemplateColumns={'auto 4fr auto'} | ||
gridAutoFlow="column" | ||
width="100%" | ||
> | ||
<GridItem justifySelf="start"> | ||
<Flex py={{ base: 0, md: 'space.01' }}>{logo}</Flex> | ||
</GridItem> | ||
|
||
{/* This grid item could be un-needed */} | ||
<GridItem margin="auto"></GridItem> | ||
<GridItem> | ||
<HStack alignItems="center" justifyContent="flex-end"> | ||
{networkBadge} | ||
<Settings | ||
triggerButton={<HamburgerIcon data-testid={SettingsSelectors.SettingsMenuBtn} />} | ||
toggleSwitchAccount={() => setIsShowingSwitchAccount(!isShowingSwitchAccount)} | ||
/> | ||
</HStack> | ||
</GridItem> | ||
</Grid> | ||
</styled.header> | ||
</> | ||
); | ||
} |
36 changes: 36 additions & 0 deletions
36
src/app/features/container/containers/home/home.layout.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Outlet } from 'react-router-dom'; | ||
|
||
import { ChainID } from '@stacks/transactions'; | ||
import { Box } from 'leather-styles/jsx'; | ||
|
||
import { Logo, NetworkModeBadge } from '@leather.io/ui'; | ||
|
||
import { useCurrentNetworkState } from '@app/store/networks/networks.hooks'; | ||
|
||
import { ContainerLayout } from '../container.layout'; | ||
import { HomeHeader } from './home-header'; | ||
|
||
export function HomeLayout() { | ||
const { chain, name: chainName } = useCurrentNetworkState(); | ||
|
||
return ( | ||
<ContainerLayout | ||
header={ | ||
<HomeHeader | ||
networkBadge={ | ||
<NetworkModeBadge | ||
isTestnetChain={chain.stacks.chainId === ChainID.Testnet} | ||
name={chainName} | ||
/> | ||
} | ||
logo={ | ||
<Box height="headerContainerHeight" margin="auto" px="space.02"> | ||
<Logo /> | ||
</Box> | ||
} | ||
/> | ||
} | ||
content={<Outlet />} | ||
/> | ||
); | ||
} |
Oops, something went wrong.