-
Notifications
You must be signed in to change notification settings - Fork 89
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
Map tooltip bus #114
Merged
Merged
Map tooltip bus #114
Changes from 25 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
f07cf35
fix in menu.scss for
277c88a
fix in menu.scss for
661ab12
fix in menu.scss for
8135950
Merge branch 'main' into fix-menu-mobile
giladfuchs 88062d5
change rem to px
c6a9667
Merge remote-tracking branch 'origin/fix-menu-mobile' into fix-menu-m…
d856647
begin to design card
b7a347c
tool tip begin to get body
55c8204
add api add hebrew text in file
a402f86
after merge from main and resolve conflict
c095fa2
add bus tool tip for SingleLineMapPage and find bug there
8bc43b0
add bus tool tip for SingleLineMapPage and find bug there
8f5e2c9
Merge remote-tracking branch 'origin/map-tooltip-bus' into map-toolti…
d577f49
Merge branch 'hasadna:main' into main
giladfuchs ddd3633
fix: single line map page
NoamGaash 622ea0b
fix: route times
NoamGaash 6200576
change after comment
88d6902
Merge branch 'fix/single-line-map-page' into map-tooltip-bus
89af229
change from mui element like Card and Typography to div and h4/span.
482c3b8
change from mui element like Card and Typography to div and h4/span.
3e5e473
Merge remote-tracking branch 'origin/main'
681d5a3
change from mui element like Card and Typography to div and h4/span.
ae963df
change from mui element like Card and Typography to div and h4/span.
6532aaf
Merge remote-tracking branch 'origin/map-tooltip-bus' into map-toolti…
cccfe1a
Merge branch 'main' into map-tooltip-bus
NoamGaash ef620c6
add scss file and remove all using of sx
a15392c
Merge remote-tracking branch 'origin/map-tooltip-bus' into map-toolti…
d50eb28
style: clean html & css
NoamGaash 79a9e07
fix for linter
f033397
Merge branch 'main' into map-tooltip-bus
giladfuchs 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
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,106 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import { Point } from 'src/pages/RealtimeMapPage' | ||
import { Button, Grid } from '@mui/material' | ||
import { DivIcon } from 'leaflet' | ||
import moment from 'moment-timezone' | ||
|
||
import { getSiriRideWithRelated } from 'src/api/siriService' | ||
import { SiriRideWithRelatedPydanticModel } from 'open-bus-stride-client/openapi/models/SiriRideWithRelatedPydanticModel' | ||
import { Row } from 'src/pages/components/Row' | ||
import { Label } from 'src/pages/components/Label' | ||
import { TEXTS } from 'src/resources/texts' | ||
import { Spin } from 'antd' | ||
|
||
export function BusToolTip({ position, icon }: { position: Point; icon: DivIcon }) { | ||
const [siriRide, setSiriRide] = useState<SiriRideWithRelatedPydanticModel | undefined>() | ||
const [isLoading, setIsLoading] = useState(false) | ||
const [showJson, setShowJson] = useState(false) | ||
|
||
useEffect(() => { | ||
setIsLoading(true) | ||
getSiriRideWithRelated( | ||
position.point!.siri_route__id.toString(), | ||
position.point!.siri_ride__vehicle_ref.toString(), | ||
position.point!.siri_route__line_ref.toString(), | ||
) | ||
.then((siriRideRes: SiriRideWithRelatedPydanticModel) => setSiriRide(siriRideRes)) | ||
.finally(() => setIsLoading(false)) | ||
}, [position]) | ||
return ( | ||
<div style={showJson ? { minWidth: '30rem', background: 'white' } : {}}> | ||
{isLoading ? ( | ||
<Row> | ||
<Label text={TEXTS.loading_routes} /> | ||
<Spin /> | ||
</Row> | ||
) : showJson ? ( | ||
<pre> | ||
{JSON.stringify(position, null, 2)} | ||
<br /> | ||
{siriRide && JSON.stringify(siriRide, null, 2)} | ||
</pre> | ||
) : ( | ||
<Grid container display="flex" direction="row-reverse" justifyContent="space-between"> | ||
<Grid item xs={4}> | ||
<h4 style={{ alignContent: 'end' }}> | ||
<div dangerouslySetInnerHTML={{ __html: icon.options.html as string }} /> | ||
</h4> | ||
</Grid> | ||
<Grid item xs={8} mt={2}> | ||
<h4 style={{ textAlign: 'start' }}> | ||
{TEXTS.line} :<span>{siriRide && siriRide!.gtfsRouteRouteShortName}</span> | ||
</h4> | ||
</Grid> | ||
<Grid item xs={12}> | ||
<h4 style={{ textAlign: 'start' }}> | ||
{TEXTS.from} : | ||
<span>{siriRide && siriRide!.gtfsRouteRouteLongName?.split('<->')[0]}</span> | ||
</h4> | ||
<h4 style={{ textAlign: 'start' }}> | ||
{TEXTS.destination} : | ||
<span>{siriRide && siriRide!.gtfsRouteRouteLongName?.split('<->')[1]}</span> | ||
</h4> | ||
<h4 style={{ textAlign: 'start' }}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please try to avoid inline CSS 🙃 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||
{TEXTS.velocity} :<span>{`${position.point?.velocity} ${TEXTS.kmh}`}</span> | ||
</h4> | ||
|
||
<h4 style={{ textAlign: 'start' }}> | ||
{TEXTS.sample_time} : | ||
<span> | ||
{moment(position.point!.recorded_at_time as string, moment.ISO_8601) | ||
.tz('Israel') | ||
.format('HH:mm')} | ||
</span> | ||
</h4> | ||
<h4 style={{ textAlign: 'start' }}> | ||
{TEXTS.vehicle_ref} :<span>{position.point?.siri_ride__vehicle_ref}</span> | ||
</h4> | ||
{/*maybe option to add info like this in extend card for now I put this condition */} | ||
{window.screen.height > 1100 && ( | ||
<> | ||
<h4 style={{ textAlign: 'start' }}> | ||
{TEXTS.drive_direction} : | ||
<span> | ||
( {position.point?.bearing} {TEXTS.bearing}) | ||
</span> | ||
</h4> | ||
<h4 style={{ textAlign: 'start' }}> | ||
{TEXTS.coords} :<span>{position.loc.join(' , ')}</span> | ||
</h4> | ||
</> | ||
)} | ||
</Grid>{' '} | ||
</Grid> | ||
)} | ||
<Grid item xs={3} mt={1} mb={1} sx={{ float: 'left' }}> | ||
<Button | ||
variant="contained" | ||
onClick={() => { | ||
setShowJson(!showJson) | ||
}}> | ||
{showJson ? TEXTS.show_card : TEXTS.show_document} | ||
</Button> | ||
</Grid> | ||
</div> | ||
) | ||
} |
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
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.
let's avoid abusing the grid system - it's not necessary here. we can apply CSS. it can be on seperate PR