Skip to content

Commit 62c986a

Browse files
authored
Merge pull request #2158 from oasisprotocol/kaja/uil-layerpicker
Layerpicker ui-library layout
2 parents 035adc1 + 33c17fa commit 62c986a

File tree

2 files changed

+39
-83
lines changed

2 files changed

+39
-83
lines changed

.changelog/2158.trivial.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Change Grid and Box components from MUI to Tailwind in Layerpicker
Lines changed: 38 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
import { FC, useState } from 'react'
22
import { useTranslation } from 'react-i18next'
3-
import Box from '@mui/material/Box'
4-
import Button from '@mui/material/Button'
5-
import { Drawer, DrawerContent, DrawerTitle } from '@oasisprotocol/ui-library/src'
3+
import { Drawer, DrawerContent } from '@oasisprotocol/ui-library/src/components/ui/drawer'
64
import { Separator } from '@oasisprotocol/ui-library/src/components/ui/separator'
7-
import Grid from '@mui/material/Unstable_Grid2'
85
import { HomePageLink } from '../PageLayout/Logotype'
9-
import { COLORS } from '../../../styles/theme/colors'
106
import { Network } from '../../../types/network'
117
import { SearchScope } from '../../../types/searchScope'
128
import { useRequiredScopeParam } from '../../hooks/useScopeParam'
139
import { NetworkMenu } from './NetworkMenu'
1410
import { LayerMenu } from './LayerMenu'
1511
import { LayerDetails } from './LayerDetails'
1612
import { scopeFreedom, RouteUtils, mergeNetworksInLayerSelector } from '../../utils/route-utils'
17-
import { styled } from '@mui/material/styles'
18-
import KeyboardArrowLeft from '@mui/icons-material/KeyboardArrowLeft'
1913
import { useScreenSize } from '../../hooks/useScreensize'
2014
import { MobileNetworkButton } from '../PageLayout/NetworkButton'
15+
import { Button } from '@oasisprotocol/ui-library/src/components/ui/button'
16+
import { ChevronLeft } from 'lucide-react'
2117

2218
type LayerPickerProps = {
2319
onClose: () => void
@@ -30,54 +26,13 @@ export const LayerPicker: FC<LayerPickerProps> = ({ onClose, onConfirm, open, is
3026
<>
3127
<Drawer direction="top" open={open} onClose={onClose}>
3228
{/* Match MUI md breakpoint during migration */}
33-
<DrawerContent className="py-4 px-[5%] z-[1200] max-[900px]:h-dvh max-[900px]:!max-h-dvh max-[900px]:mb-0">
29+
<DrawerContent className="py-4 px-[5%] z-[1200] max-lg:h-dvh max-lg:!max-h-dvh max-lg:mb-0">
3430
<LayerPickerContent onClose={onClose} onConfirm={onConfirm} isOutOfDate={isOutOfDate} />
3531
</DrawerContent>
3632
</Drawer>
3733
</>
3834
)
3935

40-
const StyledLayerPickerContent = styled(Box)(({ theme }) => ({
41-
[theme.breakpoints.down('md')]: {
42-
display: 'flex',
43-
flexDirection: 'column',
44-
width: '100%',
45-
flex: 1,
46-
},
47-
}))
48-
49-
const StyledContent = styled(Box)(({ theme }) => ({
50-
flex: 1,
51-
[theme.breakpoints.down('md')]: {
52-
display: 'flex',
53-
flexDirection: 'column',
54-
justifyContent: 'space-between',
55-
},
56-
}))
57-
58-
const TabletBackButton = styled(Button)({
59-
color: COLORS.brandDark,
60-
width: 'fit-content',
61-
textDecoration: 'none',
62-
})
63-
64-
const TabletActionBar = styled(Box)(({ theme }) => ({
65-
display: 'flex',
66-
justifyContent: 'space-between',
67-
alignItems: 'center',
68-
minHeight: '55px',
69-
paddingBottom: theme.spacing(3),
70-
}))
71-
72-
const ActionBar = styled(Box)(({ theme }) => ({
73-
display: 'flex',
74-
justifyContent: 'space-around',
75-
[theme.breakpoints.up('md')]: {
76-
justifyContent: 'flex-end',
77-
gap: theme.spacing(4),
78-
},
79-
}))
80-
8136
type LayerPickerContentProps = Omit<LayerPickerProps, 'open'>
8237

8338
enum LayerPickerTabletStep {
@@ -105,43 +60,43 @@ const LayerPickerContent: FC<LayerPickerContentProps> = ({ isOutOfDate, onClose,
10560
const handleConfirm = () => onConfirm(selectedScope)
10661

10762
return (
108-
<StyledLayerPickerContent>
109-
<DrawerTitle>
110-
<Box sx={{ mb: isTablet ? 0 : 5, position: 'relative' }}>
111-
<HomePageLink color="#0500e2" showText={!isMobile} />
112-
</Box>
113-
</DrawerTitle>
63+
<div className="flex flex-col w-full flex-1 lg:block lg:w-auto lg:flex-none">
64+
<div className="relative mb-0 lg:mb-2 lg:mb-10">
65+
<HomePageLink color="#0500e2" showText={!isMobile} />
66+
</div>
11467
{isTablet && (
115-
<TabletActionBar>
68+
<div className="flex justify-between items-center min-h-12">
11669
<div>
11770
{
11871
// Do we need a "back to networks" button ?
11972
((scopeFreedom === 'network-layer' &&
12073
!mergeNetworksInLayerSelector &&
12174
tabletStep === LayerPickerTabletStep.Layer) || // Stepping back from layers
12275
(scopeFreedom === 'network' && tabletStep === LayerPickerTabletStep.LayerDetails)) && ( // Stepping back from details, skipping layers
123-
<TabletBackButton
124-
variant="text"
125-
startIcon={<KeyboardArrowLeft />}
76+
<Button
77+
variant="ghost"
78+
size="default"
79+
className="text-primary !pl-0"
12680
onClick={() => {
12781
setTabletStep(LayerPickerTabletStep.Network)
12882
}}
12983
>
84+
<ChevronLeft />
13085
{t('layerPicker.viewNetworks')}
131-
</TabletBackButton>
86+
</Button>
13287
)
13388
}
13489
{scopeFreedom !== 'network' &&
13590
tabletStep === LayerPickerTabletStep.LayerDetails && ( // Stepping back from details, going to layers
136-
<TabletBackButton
137-
variant="text"
138-
startIcon={<KeyboardArrowLeft />}
139-
onClick={() => {
140-
setTabletStep(LayerPickerTabletStep.Layer)
141-
}}
91+
<Button
92+
variant="ghost"
93+
size="default"
94+
className="text-primary !pl-0"
95+
onClick={() => setTabletStep(LayerPickerTabletStep.Layer)}
14296
>
97+
<ChevronLeft />
14398
{t('layerPicker.viewLayers')}
144-
</TabletBackButton>
99+
</Button>
145100
)}
146101
</div>
147102
<MobileNetworkButton
@@ -150,14 +105,14 @@ const LayerPickerContent: FC<LayerPickerContentProps> = ({ isOutOfDate, onClose,
150105
layer={activeScope.layer}
151106
onClick={onClose}
152107
/>
153-
</TabletActionBar>
108+
</div>
154109
)}
155110
<Separator />
156-
<StyledContent>
157-
<Grid container>
111+
<div className="flex-1 flex flex-col justify-between lg:block">
112+
<div className="grid grid-cols-12">
158113
{!(scopeFreedom === 'layer' || mergeNetworksInLayerSelector) &&
159114
(!isTablet || (isTablet && tabletStep === LayerPickerTabletStep.Network)) && (
160-
<Grid xs={12} lg={3}>
115+
<div className="col-span-12 lg:col-span-3">
161116
<NetworkMenu
162117
activeNetwork={activeScope.network}
163118
selectedNetwork={selectedNetwork}
@@ -170,11 +125,11 @@ const LayerPickerContent: FC<LayerPickerContentProps> = ({ isOutOfDate, onClose,
170125
)
171126
}}
172127
/>
173-
</Grid>
128+
</div>
174129
)}
175130
{scopeFreedom !== 'network' &&
176131
(!isTablet || (isTablet && tabletStep === LayerPickerTabletStep.Layer)) && (
177-
<Grid xs={12} lg={3}>
132+
<div className="col-span-12 lg:col-span-3">
178133
<LayerMenu
179134
selectedNetwork={selectedNetwork}
180135
selectedScope={selectedScope}
@@ -183,31 +138,31 @@ const LayerPickerContent: FC<LayerPickerContentProps> = ({ isOutOfDate, onClose,
183138
setTabletStep(LayerPickerTabletStep.LayerDetails)
184139
}}
185140
/>
186-
</Grid>
141+
</div>
187142
)}
188143
{(!isTablet || (isTablet && tabletStep === LayerPickerTabletStep.LayerDetails)) && (
189-
<Grid xs={12} lg={6}>
144+
<div className="col-span-12 lg:col-span-6">
190145
<LayerDetails
191146
handleConfirm={handleConfirm}
192147
selectedScope={selectedScope}
193148
isOutOfDate={isOutOfDate}
194149
/>
195-
</Grid>
150+
</div>
196151
)}
197-
</Grid>
152+
</div>
198153

199-
<ActionBar>
200-
<Button onClick={onClose} color="secondary" variant="outlined" size="large">
154+
<div className="flex justify-around lg:justify-end lg:gap-8">
155+
<Button onClick={onClose} color="secondary" variant="outline" size="lg">
201156
{t('common.cancel')}
202157
</Button>
203158

204-
<Button onClick={handleConfirm} color="primary" variant="contained" size="large">
159+
<Button onClick={handleConfirm} color="primary" variant="default" size="lg">
205160
{selectedScope.network === activeScope.network && selectedScope.layer === activeScope.layer
206161
? t('layerPicker.goToDashboard')
207162
: t('common.select')}
208163
</Button>
209-
</ActionBar>
210-
</StyledContent>
211-
</StyledLayerPickerContent>
164+
</div>
165+
</div>
166+
</div>
212167
)
213168
}

0 commit comments

Comments
 (0)