Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
634 changes: 627 additions & 7 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
"@mui/icons-material": "^9.0.1",
"@mui/lab": "^9.0.0-beta.3",
"@mui/material": "^9.0.1",
"@react-three/drei": "^10.7.9",
"@react-three/fiber": "^9.8.2",
"date-fns": "^4.2.1",
"hamburger-react": "^2.4.0",
"leaflet": "^1.9.4",
Expand All @@ -72,13 +74,15 @@
"react-player": "^2.9.0",
"react-responsive-carousel": "^3.2.22",
"react-rotating-text": "^1.4.1",
"react-visibility-sensor": "^5.1.1"
"react-visibility-sensor": "^5.1.1",
"three": "^0.187.0"
},
"devDependencies": {
"@types/leaflet": "^1.9.21",
"@types/node": "^25.9.1",
"@types/react": "^19.2.15",
"@types/react-dom": "^19.2.3",
"@types/three": "^0.187.0",
"eslint": "^8.7.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.3.0",
Expand Down
59 changes: 45 additions & 14 deletions pages/launches/[launchName].tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { useEffect, useMemo, useState } from 'react';
import { useRouter } from 'next/router';
import ArrowBackIcon from '@mui/icons-material/ArrowBack';
import { Alert, Box, Button, Card, CardContent, CircularProgress, Container, Stack, Typography } from '@mui/material';
import { Alert, Box, Button, Card, CardContent, CircularProgress } from '@mui/material';
import { Container, Stack, ToggleButton, ToggleButtonGroup, Typography } from '@mui/material';
import HeightIcon from '@mui/icons-material/Height';
import ScheduleIcon from '@mui/icons-material/Schedule';
import RouteIcon from '@mui/icons-material/Route';
Expand Down Expand Up @@ -38,6 +39,7 @@ export default function LaunchDetailsPage() {
const [launch, setLaunch] = useState<LaunchSummary | null>(null);
const [launchResolved, setLaunchResolved] = useState(false);
const [launchNotFound, setLaunchNotFound] = useState(false);
const [mapViewMode, setMapViewMode] = useState<'2d' | '3d'>('3d');

const { records, isLoadingRecords, recordsError } = useGetLaunchContent(launch?.download_url ?? '', Boolean(launch));

Expand All @@ -50,6 +52,15 @@ export default function LaunchDetailsPage() {
[]
);

const MapTrajectory3D = useMemo(
() =>
dynamic(() => import('@/src/components/Map/MapTrajectory3D'), {
loading: () => <p>A map is loading</p>,
ssr: false
}),
[]
);

useEffect(() => {
router.prefetch('/launches');
}, [router]);
Expand Down Expand Up @@ -189,26 +200,46 @@ export default function LaunchDetailsPage() {
</CardContent>
</Card>

<Typography variant="h5" component="h2" sx={{ fontWeight: 700, my: 2 }}>
Trajetória do lançamento
</Typography>
<Stack
direction="row"
spacing={2}
sx={{ alignItems: 'center', justifyContent: 'space-between', flexWrap: 'wrap', my: 2 }}
>
<Typography variant="h5" component="h2" sx={{ fontWeight: 700 }}>
Trajetória do lançamento
</Typography>
<ToggleButtonGroup
value={mapViewMode}
exclusive
size="small"
onChange={(_event, value: '2d' | '3d' | null) => value && setMapViewMode(value)}
aria-label="Modo de visualização do mapa"
>
<ToggleButton value="2d">2D</ToggleButton>
<ToggleButton value="3d">3D</ToggleButton>
</ToggleButtonGroup>
</Stack>
</React.Fragment>
)}
</Stack>
</Container>

{launch && records.length > 0 && (
<Box sx={{ width: '100%', overflow: 'hidden' }}>
<MapTrajectory
position={[records[0]?.lat, records[0]?.lon]}
zoom={20}
trajectory={records.map((r) => [r.lat, r.lon])}
trajectoryRecords={records}
landingCity={launch.landing_city}
lineColor="#f44336"
lineWeight={4}
mapHeight="600px"
/>
{mapViewMode === '2d' ? (
<MapTrajectory
position={[records[0]?.lat, records[0]?.lon]}
zoom={20}
trajectory={records.map((r) => [r.lat, r.lon])}
trajectoryRecords={records}
landingCity={launch.landing_city}
lineColor="#f44336"
lineWeight={4}
mapHeight="600px"
/>
) : (
<MapTrajectory3D records={records} lineColor="#f44336" lineWeight={4} mapHeight="600px" />
)}
</Box>
)}
</Box>
Expand Down
23 changes: 18 additions & 5 deletions src/components/LaunchCard/LaunchSummaryCard.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Fragment } from 'react';
import { Card, CardActions, CardContent, CardHeader, Button, Chip, Stack, Typography, Box } from '@mui/material';
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
import HeightIcon from '@mui/icons-material/Height';
Expand All @@ -7,6 +8,18 @@ import { LaunchSummaryCardProps } from '@/src/shared/props/components/launch-sum
import MapIcon from '@mui/icons-material/Map';
import { colors } from '@/src/shared/styles/colors';

/** Permite quebra de linha depois de "_" e "-", para nomes como "014_J4840095_day_2" não estourarem o card. */
const withSeparatorBreaks = (text: string) =>
text
.replace(/[_-]/g, '$&\n')
.split('\n')
.map((part, index) => (
<Fragment key={index}>
{index > 0 && <wbr />}
{part}
</Fragment>
));

export default function LaunchSummaryCard({ launch, index, onDetailsClick }: LaunchSummaryCardProps) {
return (
<Card key={`${launch.name}-${launch.launch_datetime}`} elevation={1} sx={cardSx}>
Expand All @@ -19,7 +32,7 @@ export default function LaunchSummaryCard({ launch, index, onDetailsClick }: Lau
{`#${index + 1}`}
</Typography>
<Typography variant="h6" component="h2" sx={titleTypographySx}>
{formatLaunchName(launch.name)}
{withSeparatorBreaks(formatLaunchName(launch.name))}
</Typography>
</Box>
<Chip
Expand Down Expand Up @@ -56,11 +69,11 @@ export default function LaunchSummaryCard({ launch, index, onDetailsClick }: Lau
}

const cardSx = { height: '100%', borderRadius: 3 };
const chipSx = { backgroundColor: colors.primary[600] };
const cardHeaderSx = { pb: 0 };
const chipSx = { backgroundColor: colors.primary[600], flexShrink: 0 };
const cardHeaderSx = { pb: 0, '& .MuiCardHeader-content': { minWidth: 0 } };
const titleBoxSx = { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 2 };
const titleTextBoxSx = { display: 'flex', alignItems: 'center', gap: 1 };
const titleTypographySx = { fontWeight: 700 };
const titleTextBoxSx = { display: 'flex', alignItems: 'center', gap: 1, minWidth: 0 };
const titleTypographySx = { fontWeight: 700, minWidth: 0, overflowWrap: 'anywhere' };
const indexTypographySx = { fontWeight: 500, color: colors.primary[600] };
const cardContentSx = { py: 0, mb: 0 };
const citiesBoxSx = { display: 'flex', alignItems: 'flex-start' };
Expand Down
Loading
Loading