-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Vehicles page #137
Merged
joao-vasconcelos
merged 26 commits into
production
from
digital-79-finalizar-pagina-veiculos
Feb 10, 2025
Merged
Create Vehicles page #137
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
97b90ae
Created the base structure for vehicles page
Skasix00 335775f
Added translations
Skasix00 380d44d
Context mods
Skasix00 9c7ce28
Added lines shapes and popup handling is fixed
Skasix00 3d43b48
Startedd adding the data filters, only need to return the filtered array
Skasix00 75fd96d
Filter 100% working: Conditional Rendering fase
Skasix00 2876da0
Stylyzed the multiselect separated the popup to it's own component
Skasix00 b430640
Refactored some code on vehicle map and vehiclelistcontext
Skasix00 58ac1d5
Added coloes to the lines and added stops waypoints
Skasix00 12416be
Finished the popup
Skasix00 2cbafd0
Ruff layout added, all the functionallity converted to this layout
Skasix00 3b2c79e
Layout fully converted and functionality 100% working
Skasix00 d6d0ae6
Tweaked some names and fixed some bugs
Skasix00 1e45afb
Removed unused JSON formatter settings from VSCode configuration
joao-vasconcelos 644af1f
Use named exports
joao-vasconcelos ff284c2
Remove unused VehiclesListGroup
joao-vasconcelos 7a76f24
Update translation keys for VehiclesList component
joao-vasconcelos 7cd07f8
Merge branch 'production' into digital-79-finalizar-pagina-veiculos
joao-vasconcelos e72ae1f
Whitespace
joao-vasconcelos 96ff24a
Include previous commit changes (before merge with production)
joao-vasconcelos 1c12a39
Added vehicle list box and starting code refactoring
Skasix00 c20a5d7
Add styles for no data container in VehiclesListToolbar
Skasix00 908bd45
Modified VehhicleList Table Data
Skasix00 a8d4b39
Bump packages
joao-vasconcelos b80429c
Fix rounding of single digit values
joao-vasconcelos b786f1f
Merge branch 'production' into digital-79-finalizar-pagina-veiculos
joao-vasconcelos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* * */ | ||
|
||
import { VehiclesListContextProvider } from '@/contexts/VehiclesList.context'; | ||
|
||
/* * */ | ||
|
||
export default function Layout({ children }) { | ||
return ( | ||
<VehiclesListContextProvider> | ||
{children} | ||
</VehiclesListContextProvider> | ||
); | ||
} |
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 { VehiclesList } from '@/components/vehicles/VehiclesList'; | ||
|
||
/* * */ | ||
|
||
export default function Page() { | ||
return <VehiclesList />; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
'use client'; | ||
|
||
/* * */ | ||
|
||
import { FoundItemsCounter } from '@/components/common/FoundItemsCounter'; | ||
import { Section } from '@/components/layout/Section'; | ||
import { useNewsListContext } from '@/contexts/NewsList.context'; | ||
import { TextInput } from '@mantine/core'; | ||
import { DatePickerInput } from '@mantine/dates'; | ||
import { IconArrowLoopRight, IconCalendarEvent } from '@tabler/icons-react'; | ||
import { useTranslations } from 'next-intl'; | ||
import { useEffect, useRef, useState } from 'react'; | ||
|
||
import styles from './styles.module.css'; | ||
|
||
/* * */ | ||
|
||
export function NewsListToolbar() { | ||
// A. Setup variables | ||
const newsListContext = useNewsListContext(); | ||
const t = useTranslations('news.NewsListToolbar'); | ||
const typingTimeoutRef = useRef<null | ReturnType<typeof setTimeout>>(null); | ||
const [textInput, setTextInput] = useState<null | string>(null); | ||
const [dateInput, setDateInput] = useState<Date | null>(null); | ||
// | ||
// B . Handle Actions | ||
|
||
const handleTextInputChange = ({ currentTarget }) => { | ||
setTextInput(currentTarget.value); | ||
if (!newsListContext.flags.is_loading && newsListContext.data.raw) { | ||
try { | ||
if (typingTimeoutRef.current) { | ||
clearTimeout(typingTimeoutRef.current); | ||
} | ||
typingTimeoutRef.current = setTimeout(() => { | ||
newsListContext.actions.updateFilterByTitle(currentTarget.value); | ||
console.log('News filtered with success ✅'); | ||
}, 500); | ||
} | ||
catch (error) { | ||
console.error('Filtering failed ❌: ', error); | ||
} | ||
} | ||
}; | ||
|
||
const handleDateInputChange = (value: Date | null) => { | ||
setDateInput(value); | ||
newsListContext.actions.updateFilterByDate(value || new Date()); | ||
}; | ||
|
||
// C. Cleanup; | ||
useEffect(() => { | ||
return () => { | ||
if (typingTimeoutRef.current) { | ||
clearTimeout(typingTimeoutRef.current); | ||
} | ||
}; | ||
}, []); | ||
|
||
// D. Render Components | ||
|
||
return ( | ||
<> | ||
<Section heading={t('heading')} withBottomDivider withPadding> | ||
<div className="row-container" style={{ alignItems: 'center', display: 'flex', gap: '1rem', justifyContent: 'space-between' }}> | ||
<TextInput leftSection={<IconArrowLoopRight size={20} />} onChange={handleTextInputChange} placeholder={t('SearchInput.placeholder')} type="search" value={textInput || ''} w="70%" /> | ||
<DatePickerInput | ||
classNames={{ input: styles.datePickerInput, placeholder: styles.datePickerPlaceholder, section: styles.datePickerPlaceholder }} | ||
dropdownType="modal" | ||
leftSection={<IconCalendarEvent />} | ||
onChange={handleDateInputChange} | ||
placeholder={t('DateInput.placeholder')} | ||
size="lg" | ||
value={dateInput} | ||
valueFormat="DD MMM YYYY" | ||
variant="unstyled" | ||
/> | ||
</div> | ||
<FoundItemsCounter text={t('found_items_counter', { count: newsListContext.data.filtered.length })} /> | ||
</Section> | ||
|
||
</> | ||
); | ||
// | ||
} |
39 changes: 39 additions & 0 deletions
39
frontend/components/vehicles/VehicleListMapBadge/index.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,39 @@ | ||
'use client'; | ||
|
||
/* * */ | ||
|
||
import type { Line } from '@carrismetropolitana/api-types/network'; | ||
|
||
import classNames from 'classnames/bind'; | ||
|
||
import styles from './styles.module.css'; | ||
|
||
/* * */ | ||
|
||
interface Props { | ||
color?: string | ||
lineData?: Line | ||
shortName?: string | ||
textColor?: string | ||
} | ||
|
||
/* * */ | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
/* * */ | ||
|
||
export function VehicleListMapBadge({ lineData }: Props) { | ||
// A. Render components | ||
return ( | ||
<> | ||
<div className={cx({ badge: true, md: 'md' })} style={{ backgroundColor: lineData?.color, color: lineData?.text_color }}> | ||
{lineData?.short_name || '• • •'} | ||
</div> | ||
<div> | ||
<p className={styles.line_name}>{lineData?.long_name}</p> | ||
</div> | ||
</> | ||
); | ||
// | ||
} |
38 changes: 38 additions & 0 deletions
38
frontend/components/vehicles/VehicleListMapBadge/styles.module.css
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,38 @@ | ||
/* * */ | ||
/* BADGE */ | ||
|
||
.badge { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border-radius: 999px; | ||
color: var(--color-system-background-100); | ||
background-color: var(--color-system-text-200); | ||
font-weight: var(--font-weight-extrabold); | ||
letter-spacing: 1px; | ||
line-height: 1; | ||
position: relative; | ||
|
||
} | ||
|
||
.badge.md { | ||
font-size: 16px; | ||
min-width: 65px; | ||
max-width: 65px; | ||
min-height: 26px; | ||
max-height: 26px; | ||
text-align: center; | ||
vertical-align: middle; | ||
display: flex; | ||
|
||
} | ||
|
||
/* * */ | ||
|
||
/* LINE HEADER */ | ||
.line_name{ | ||
color: var(--color-system-text-100); | ||
font-size: var(--font-size-subtitle); | ||
font-weight: var(--font-weight-extrabold); | ||
} | ||
/* * */ |
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,48 @@ | ||
'use client'; | ||
|
||
/* * */ | ||
|
||
import { Section } from '@/components/layout/Section'; | ||
import { Surface } from '@/components/layout/Surface'; | ||
import VehiclesListMap from '@/components/vehicles/VehiclesListMap'; | ||
import VehiclesListToolbar from '@/components/vehicles/VehiclesListToolbar'; | ||
import { useTranslations } from 'next-intl'; | ||
|
||
import styles from './styles.module.css'; | ||
|
||
/* * */ | ||
|
||
export function VehiclesList() { | ||
// | ||
|
||
// | ||
// A. Setup variables | ||
|
||
const t = useTranslations('vehicles.VehiclesList'); | ||
|
||
// | ||
// B. Render components | ||
|
||
return ( | ||
<> | ||
<Surface> | ||
<Section heading={t('heading')} subheading={t('subheading')} /> | ||
</Surface> | ||
<Surface> | ||
<Section withGap withPadding> | ||
<p>Informação</p> | ||
</Section> | ||
</Surface> | ||
<Surface> | ||
<div className={styles.container}> | ||
<VehiclesListMap /> | ||
<div className={styles.sidebarWrapper}> | ||
<VehiclesListToolbar /> | ||
</div> | ||
</div> | ||
</Surface> | ||
</> | ||
); | ||
|
||
// | ||
} |
35 changes: 35 additions & 0 deletions
35
frontend/components/vehicles/VehiclesList/styles.module.css
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,35 @@ | ||
/* CONTAINER */ | ||
|
||
.container { | ||
display: grid; | ||
grid-template: | ||
"a b" minmax(65vh, auto) / 1fr 1fr; | ||
align-items: flex-start; | ||
justify-content: flex-start; | ||
width: 100%; | ||
} | ||
|
||
@media (width < 1000px) { | ||
.container { | ||
grid-template: | ||
"a" 50vh [a_] | ||
"b" auto [b_] / 1fr; | ||
} | ||
} | ||
|
||
/* * */ | ||
/* MAP WRAPPER */ | ||
|
||
.sidebarWrapper { | ||
grid-area: b; | ||
height: 100%; | ||
border-left: 1px solid var(--color-system-border-100); | ||
} | ||
|
||
@media (width < 1000px) { | ||
.sidebarWrapper { | ||
position: static; | ||
border: none; | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
É intencional não ser possível alterar os estilos nos componentes que utilizam estes layouts principais, para incentivar a consistência de layout em todo o site. Do que vi também acabaste por não usar, então acho que faz sentido retirar.