Skip to content

Commit 6b3ffa9

Browse files
feat: gbfs validator front page styling (#1411)
* gbfs validator front page styling
1 parent 5a109be commit 6b3ffa9

File tree

4 files changed

+195
-78
lines changed

4 files changed

+195
-78
lines changed

web-app/src/app/components/Header.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ export default function DrawerAppBar(): React.ReactElement {
391391
void i18n.changeLanguage(lang.target.value);
392392
}}
393393
variant='standard'
394+
inputProps={{ 'aria-label': 'language select' }}
394395
>
395396
<MenuItem value={'en'}>EN</MenuItem>
396397
<MenuItem value={'fr'}>FR</MenuItem>

web-app/src/app/screens/GbfsValidator/GbfsFeedSearchInput.tsx

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
FormControlLabel,
88
Checkbox,
99
useTheme,
10-
Link,
1110
Container,
1211
FormControl,
1312
MenuItem,
@@ -16,6 +15,7 @@ import {
1615
} from '@mui/material';
1716
import SearchIcon from '@mui/icons-material/Search';
1817
import { useState } from 'react';
18+
import { useNavigate } from 'react-router-dom';
1919

2020
enum AuthTypeEnum {
2121
BASIC = 'Basic Auth',
@@ -26,6 +26,7 @@ enum AuthTypeEnum {
2626

2727
export default function GbfsFeedSearchInput(): React.ReactElement {
2828
const theme = useTheme();
29+
const navigate = useNavigate();
2930
const [autoDiscoveryUrlInput, setAutoDiscoveryUrlInput] =
3031
useState<string>('');
3132
const [requiresAuth, setRequiresAuth] = useState(false);
@@ -81,13 +82,21 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
8182
// navigate to /gbfs-validator?AutoDiscoveryUrl=url&auth details
8283
// store the auth details in context
8384
// let the GbfsValidator component handle the loading state
85+
console.log('Validating GBFS Feed for URL: ', autoDiscoveryUrlInput);
86+
// I'm sure if a query param exists, instead of navigation, we will update the param, and have a useEffect to call the new feed to validate
87+
navigate(
88+
`/gbfs-validator?AutoDiscoveryUrl=${encodeURIComponent(
89+
autoDiscoveryUrlInput,
90+
)}`,
91+
);
8492
};
8593

8694
return (
8795
<Box
8896
id='input-box'
8997
sx={{
9098
padding: 2,
99+
pt: 3,
91100
marginTop: 2,
92101
backgroundColor: theme.palette.background.default,
93102
border: '3px solid ' + theme.palette.text.primary,
@@ -106,6 +115,7 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
106115
>
107116
<TextField
108117
variant='outlined'
118+
label='GBFS Auto-Discovery URL'
109119
placeholder='eg: https://example.com/gbfs.json'
110120
sx={{ width: '100%', mr: 2 }}
111121
onChange={(e) => {
@@ -119,13 +129,10 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
119129
variant='contained'
120130
color='primary'
121131
sx={{ p: '12px' }}
122-
component={Link}
123-
href={`/gbfs-validator?AutoDiscoveryUrl=${encodeURIComponent(
124-
autoDiscoveryUrlInput,
125-
)}`}
126132
disabled={isSubmitBoxDisabled()}
127133
type='submit'
128-
onClick={() => {
134+
onClick={(e) => {
135+
e.preventDefault();
129136
validateGBFSFeed();
130137
}}
131138
>
@@ -134,6 +141,7 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
134141
</Container>
135142
<FormGroup>
136143
<FormControlLabel
144+
sx={{ width: 'fit-content' }}
137145
control={<Checkbox checked={requiresAuth} onChange={handleChange} />}
138146
label='Requires Authentication'
139147
/>
@@ -143,7 +151,7 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
143151
value={authType}
144152
onChange={handleAuthTypeChange}
145153
displayEmpty
146-
inputProps={{ 'aria-label': 'Without label' }}
154+
inputProps={{ 'aria-label': 'authentication type select' }}
147155
>
148156
<MenuItem value={''}>
149157
<em>Select Authentication Type</em>
@@ -158,7 +166,14 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
158166
)}
159167

160168
{requiresAuth && authType === AuthTypeEnum.BASIC && (
161-
<Box sx={{ display: 'flex', gap: 2, mt: 2 }}>
169+
<Box
170+
sx={{
171+
display: 'flex',
172+
gap: 2,
173+
mt: 2,
174+
flexWrap: { xs: 'wrap', md: 'nowrap' },
175+
}}
176+
>
162177
<TextField
163178
size='small'
164179
variant='outlined'
@@ -198,7 +213,14 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
198213
)}
199214

200215
{requiresAuth && authType === AuthTypeEnum.OAUTH && (
201-
<Box sx={{ display: 'flex', gap: 2, mt: 2 }}>
216+
<Box
217+
sx={{
218+
display: 'flex',
219+
gap: 2,
220+
mt: 2,
221+
flexWrap: { xs: 'wrap', md: 'nowrap' },
222+
}}
223+
>
202224
<TextField
203225
size='small'
204226
variant='outlined'
@@ -232,11 +254,19 @@ export default function GbfsFeedSearchInput(): React.ReactElement {
232254
</Box>
233255
)}
234256
</FormGroup>
235-
<Box id='cta-buttons' sx={{ display: 'flex', gap: 2, mt: 2 }}>
236-
<Button variant='text' color='primary'>
237-
Broswe GBFS Feeds
257+
<Box
258+
id='cta-buttons'
259+
sx={{
260+
display: 'flex',
261+
gap: { xs: 0, md: 2 },
262+
mt: 2,
263+
flexWrap: { xs: 'wrap', md: 'nowrap' },
264+
}}
265+
>
266+
<Button variant='text' color='primary' href='/feeds?gbfs=true'>
267+
Browse GBFS Feeds
238268
</Button>
239-
<Button variant='text' color='primary' endIcon={<OpenInNew />}>
269+
<Button variant='text' color='primary' href='/' endIcon={<OpenInNew />}>
240270
View GBFS Validator API Docs
241271
</Button>
242272
</Box>

0 commit comments

Comments
 (0)