Skip to content
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
merged 26 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
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 Jan 29, 2025
335775f
Added translations
Skasix00 Jan 29, 2025
380d44d
Context mods
Skasix00 Jan 29, 2025
9c7ce28
Added lines shapes and popup handling is fixed
Skasix00 Jan 31, 2025
3d43b48
Startedd adding the data filters, only need to return the filtered array
Skasix00 Feb 1, 2025
75fd96d
Filter 100% working: Conditional Rendering fase
Skasix00 Feb 1, 2025
2876da0
Stylyzed the multiselect separated the popup to it's own component
Skasix00 Feb 1, 2025
b430640
Refactored some code on vehicle map and vehiclelistcontext
Skasix00 Feb 3, 2025
58ac1d5
Added coloes to the lines and added stops waypoints
Skasix00 Feb 3, 2025
12416be
Finished the popup
Skasix00 Feb 3, 2025
2cbafd0
Ruff layout added, all the functionallity converted to this layout
Skasix00 Feb 4, 2025
3b2c79e
Layout fully converted and functionality 100% working
Skasix00 Feb 5, 2025
d6d0ae6
Tweaked some names and fixed some bugs
Skasix00 Feb 5, 2025
1e45afb
Removed unused JSON formatter settings from VSCode configuration
joao-vasconcelos Feb 6, 2025
644af1f
Use named exports
joao-vasconcelos Feb 6, 2025
ff284c2
Remove unused VehiclesListGroup
joao-vasconcelos Feb 6, 2025
7a76f24
Update translation keys for VehiclesList component
joao-vasconcelos Feb 6, 2025
7cd07f8
Merge branch 'production' into digital-79-finalizar-pagina-veiculos
joao-vasconcelos Feb 6, 2025
e72ae1f
Whitespace
joao-vasconcelos Feb 6, 2025
96ff24a
Include previous commit changes (before merge with production)
joao-vasconcelos Feb 7, 2025
1c12a39
Added vehicle list box and starting code refactoring
Skasix00 Feb 7, 2025
c20a5d7
Add styles for no data container in VehiclesListToolbar
Skasix00 Feb 7, 2025
908bd45
Modified VehhicleList Table Data
Skasix00 Feb 7, 2025
a8d4b39
Bump packages
joao-vasconcelos Feb 10, 2025
b80429c
Fix rounding of single digit values
joao-vasconcelos Feb 10, 2025
b786f1f
Merge branch 'production' into digital-79-finalizar-pagina-veiculos
joao-vasconcelos Feb 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions frontend/app/(views)/(website)/vehicles/layout.tsx
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>
);
}
9 changes: 9 additions & 0 deletions frontend/app/(views)/(website)/vehicles/page.tsx
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 />;
}
7 changes: 3 additions & 4 deletions frontend/components/layout/Grid/index.tsx
Copy link
Member

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.

Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* * */

import styles from './styles.module.css';

/* * */

interface Props {
children?: React.ReactNode
classname?: string
columns?: 'a' | 'aab' | 'ab' | 'abb' | 'abc' | 'abcd'
hAlign?: 'center' | 'end' | 'start'
vAlign?: 'center' | 'end' | 'start'
Expand All @@ -14,9 +13,9 @@ interface Props {

/* * */

export function Grid({ children, columns = 'a', hAlign = 'start', vAlign = 'start', withGap }: Props) {
export function Grid({ children, classname, columns = 'a', hAlign = 'start', vAlign = 'start', withGap }: Props) {
return (
<div className={`${styles.container} ${styles[columns]} ${styles[`hAlign${hAlign}`]} ${styles[`vAlign${vAlign}`]} ${withGap && styles.withGap}`}>
<div className={`${styles.container} ${styles[columns]} ${styles[`hAlign${hAlign}`]} ${styles[`vAlign${vAlign}`]} ${withGap && styles.withGap} ${classname}`}>
{children}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/map/MapViewStyleVehicles/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import styles from './styles.module.css';
/* * */

export const MapViewStyleVehiclesPrimaryLayerId = 'default-layer-vehicles-regular';
export const MapViewStyleVehiclesInteractiveLayerId = '';
export const MapViewStyleVehiclesInteractiveLayerId = 'default-layer-vehicles-regular';

/* * */

Expand Down
85 changes: 85 additions & 0 deletions frontend/components/news/NewsListToolbar/index.tsx
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 frontend/components/vehicles/VehicleListMapBadge/index.tsx
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 frontend/components/vehicles/VehicleListMapBadge/styles.module.css
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);
}
/* * */
48 changes: 48 additions & 0 deletions frontend/components/vehicles/VehiclesList/index.tsx
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 frontend/components/vehicles/VehiclesList/styles.module.css
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;
}

}
Loading