Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-vasconcelos committed Dec 5, 2023
1 parent 59b002e commit 11212f6
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 60 deletions.
13 changes: 2 additions & 11 deletions frontend/components/LinesExplorerContent/LinesExplorerContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,10 @@ export default function LinesExplorerContent() {
return (
linesExplorerContext?.entities?.line?.id && (
<div className={styles.container}>
<div className={styles.toolbar}>
<LinesExplorerContentHeader />
</div>
<div className={styles.map}>{linesExplorerContext.entities.pattern?.shape_id && <LinesExplorerContentPatternMap />}</div>
<div className={styles.sidebar}>
{linesExplorerContext.entities.pattern?.id ? (
<>
<LinesExplorerContentHeader />
<LinesExplorerContentPatternPath />
</>
) : (
<NoDataLabel text={t('no_selection')} />
)}
<LinesExplorerContentHeader />
{linesExplorerContext.entities.pattern?.id ? <LinesExplorerContentPatternPath /> : <NoDataLabel text={t('no_selection')} />}
</div>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
.container {
display: grid;
grid-template-columns: 5fr 3fr;
grid-template-rows: auto 600px;
grid-template-rows: 600px;
width: 100%;
border-top: 1px solid var(--gray3);
}

@media (max-width: 900px) {
.container {
grid-template-columns: 1fr;
grid-template-rows: auto 300px minmax(100px, auto);
grid-template-rows: 300px minmax(100px, auto);
}
}

Expand All @@ -28,33 +29,20 @@
position: absolute;
width: 100%;
height: 100%;
grid-template-rows: auto 1fr;
grid-template-rows: 1fr;
}
}

@media all and (max-width: 900px) and (display-mode: standalone) {
.container {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto 2fr 3fr;
grid-template-rows: 2fr 3fr;
width: 100%;
overflow: scroll;
}
}

/* * */
/* TOOLBAR */

.toolbar {
grid-column: 1/3;
}

@media (max-width: 900px) {
.toolbar {
grid-column: 1;
}
}

/* * */
/* MAP */

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
padding: var(--size-lg);
align-items: center;
width: 100%;
border-bottom: 1px solid var(--gray3);
background-color: var(--reference-0);
z-index: 200;
}

/* * */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ export default function LinesExplorerContentPatternPath() {

return (
<div className={styles.container}>
<div>{linesExplorerContext.entities.pattern.id}</div>
{linesExplorerContext.entities.pattern.path?.map((pathStop, pathIndex) => (
<div key={pathIndex}>
<LinePatternPathStop pathStopData={pathStop} pathIndex={pathIndex} pathIndexMax={linesExplorerContext.entities.pattern.path.length - 1} />
</div>
))}
<div>{linesExplorerContext.entities.pattern.id}</div>
</div>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,15 @@ export default function LinesExplorerContentSelectPattern() {
(async function () {
// Exit if no line is selected
if (!linesExplorerContext.entities?.line?.id) return;
// Exit if no date is selected
if (!linesExplorerContext.entities?.date_string) return;
// Initiate a temporaty variable to hold formatted patterns
let formattedPatternOptions = [];
// Loop through each line pattern to retrieve its info
for (const patternId of linesExplorerContext.entities.line.patterns) {
// Fetch pattern info
const patternDataResponse = await fetch(`https://api.carrismetropolitana.pt/patterns/${patternId}`);
const patternData = await patternDataResponse.json();
// Check if this pattern is valid on the selected date
const isValidOnSelectedDate = patternData.valid_on.includes(linesExplorerContext.entities.date_string);
// Format response
formattedPatternOptions.push({
...patternData,
disabled: !isValidOnSelectedDate,
});
// Save pattern
formattedPatternOptions.push(patternData);
}
// Update state with formatted patterns
setAllPatternsData(formattedPatternOptions);
Expand Down Expand Up @@ -148,7 +141,7 @@ export default function LinesExplorerContentSelectPattern() {
<Combobox.Empty>{t('no_results')}</Combobox.Empty>
) : (
allPatternsDataFilteredBySearchQuery.map((item) => (
<Combobox.Option key={item.id} value={item.id} className={item.id === linesExplorerContext.entities.line?.id && styles.selected} disabled={item.disabled}>
<Combobox.Option key={item.id} value={item.id} className={item.id === linesExplorerContext.entities.line?.id && styles.selected}>
<div className={styles.comboboxOption}>{item.headsign}</div>
</Combobox.Option>
))
Expand All @@ -158,4 +151,6 @@ export default function LinesExplorerContentSelectPattern() {
</Combobox>
</div>
);

//
}
10 changes: 5 additions & 5 deletions frontend/components/LinesExplorerToolbar/LinesExplorerToolbar.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use client';

/* * */

import styles from './LinesExplorerToolbar.module.css';
import LinesExplorerToolbarSelectMunicipality from '@/components/LinesExplorerToolbarSelectMunicipality/LinesExplorerToolbarSelectMunicipality';
import LinesExplorerToolbarSelectLine from '@/components/LinesExplorerToolbarSelectLine/LinesExplorerToolbarSelectLine';
import LinesExplorerToolbarSelectDate from '../LinesExplorerToolbarSelectDate/LinesExplorerToolbarSelectDate';

/* * */

Expand All @@ -20,10 +21,9 @@ export default function LinesExplorerToolbar() {
<LinesExplorerToolbarSelectMunicipality />
<LinesExplorerToolbarSelectMunicipality />
</div>
<div className={styles.main}>
<LinesExplorerToolbarSelectLine />
<LinesExplorerToolbarSelectDate />
</div>
<LinesExplorerToolbarSelectLine />
</div>
);

//
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,3 @@
grid-template-columns: 1fr;
}
}

/* * */
/* MAIN */

.main {
width: 100%;
display: grid;
grid-template-columns: 3fr 1fr;
gap: var(--size-lg);
}

@media (max-width: 900px) {
.main {
grid-template-columns: 1fr;
}
}

0 comments on commit 11212f6

Please sign in to comment.