diff --git a/frontend/src/passagesPanel.tsx b/frontend/src/passagesPanel.tsx index 0d469ed..143111a 100644 --- a/frontend/src/passagesPanel.tsx +++ b/frontend/src/passagesPanel.tsx @@ -1,12 +1,11 @@ import { VoidComponent, createResource, onMount, ParentComponent, ParentProps, Show, useContext, For } from 'solid-js'; import { createDateNow, getTime } from '@solid-primitives/date'; -import { timeline } from '@motionone/dom'; import { AnimationOptions } from '@motionone/types'; import { Motion } from "@motionone/solid"; import { format } from "date-fns"; import { Line, TrafficStatus } from './types'; -import { renderLineTransportMode, renderLinePicto } from './utils'; +import { renderLineTransportMode, renderLinePicto, ScrollingText } from './utils'; import { BusinessDataContext, BusinessDataStore } from "./businessData"; import "./passagesPanel.scss"; @@ -123,24 +122,6 @@ const DestinationPassages: VoidComponent<{ line: Line, destination: string }> = // const trafficStatusStyle = { fill: trafficStatusColor.get(props.line.trafficStatus) }; const trafficStatusStyle = { fill: trafficStatusColor.get(TrafficStatus.UNKNOWN) }; - let destinationViewboxRef: SVGSVGElement | undefined = undefined; - let destinationTextRef: SVGTextElement | undefined = undefined; - - onMount(() => { - if (destinationViewboxRef !== undefined && destinationTextRef !== undefined) { - const overlap = destinationTextRef.getComputedTextLength() - destinationViewboxRef.viewBox.baseVal.width; - if (overlap > 0) { - timeline( - [ - [destinationTextRef, { x: [-overlap] }, { duration: 5 }], - [destinationTextRef, { x: [0] }, { duration: 2 }], - ], - { repeat: Infinity }, - ); - } - } - }); - return (
@@ -148,14 +129,7 @@ const DestinationPassages: VoidComponent<{ line: Line, destination: string }> =
{renderLinePicto(props.line)}
- - - {props.destination} - - +
diff --git a/frontend/src/stopsSearchMenu.scss b/frontend/src/stopsSearchMenu.scss index 599a4f6..24e500b 100644 --- a/frontend/src/stopsSearchMenu.scss +++ b/frontend/src/stopsSearchMenu.scss @@ -53,16 +53,19 @@ border-bottom: solid calc(2px); .name { + margin-left: calc(40/1920*100%); width: 60%; + aspect-ratio: 2.5; + + display: flex; + align-items: center; font-family: IDFVoyageur-bold; } .lineRepr { - // height: 100%; width: 40%; aspect-ratio: 2.5; - // margin-left: auto; display: flex; flex-direction: row; diff --git a/frontend/src/stopsSearchMenu.tsx b/frontend/src/stopsSearchMenu.tsx index b30b802..c0ab089 100644 --- a/frontend/src/stopsSearchMenu.tsx +++ b/frontend/src/stopsSearchMenu.tsx @@ -9,7 +9,7 @@ import { } from 'leaflet'; import { Stop } from './types'; -import { PositionedPanel, renderLineTransportMode, renderLinePicto, TransportModeWeights } from './utils'; +import { PositionedPanel, renderLineTransportMode, renderLinePicto, ScrollingText, TransportModeWeights } from './utils'; import { AppContextContext, AppContextStore } from "./appContext"; import { BusinessDataContext, BusinessDataStore } from "./businessData"; @@ -191,10 +191,10 @@ const StopRepr: VoidComponent<{ stop: Stop }> = (props) => { type ByTransportModeReprs = { mode: JSX.Element | undefined; lines: Record; -}; - +} const StopAreaRepr: VoidComponent<{ stop: Stop }> = (props) => { + const fontSize: number = 10; const businessDataStore: BusinessDataStore | undefined = useContext(BusinessDataContext); const appContextStore: AppContextStore | undefined = useContext(AppContextContext); @@ -248,7 +248,9 @@ const StopAreaRepr: VoidComponent<{ stop: Stop }> = (props) => { return (
setDisplayedStops([props.stop])}> -
{props.stop.name}
+
+ +
{lineReprs()}
); diff --git a/frontend/src/utils.tsx b/frontend/src/utils.tsx index 739e6ff..d5d8cce 100644 --- a/frontend/src/utils.tsx +++ b/frontend/src/utils.tsx @@ -1,4 +1,5 @@ -import { JSX } from 'solid-js'; +import { JSX, onMount, VoidComponent } from 'solid-js'; +import { timeline } from '@motionone/dom'; import { Line } from './types'; @@ -129,3 +130,37 @@ export type PositionedPanel = { // TODO: Should be PassagesPanelComponent ? panel: JSX.Element; }; + + +export const ScrollingText: VoidComponent<{ height: number, width: number, content: string }> = (props) => { + + let viewBoxRef: SVGSVGElement | undefined = undefined; + let textRef: SVGTextElement | undefined = undefined; + + onMount(() => { + if (viewBoxRef !== undefined && textRef !== undefined) { + const overlap = textRef.getComputedTextLength() - viewBoxRef.viewBox.baseVal.width; + if (overlap > 0) { + timeline( + [ + [textRef, { x: [-overlap] }, { duration: 5 }], + [textRef, { x: [0] }, { duration: 2 }], + ], + { repeat: Infinity }, + ); + } + } + }); + + return ( + + + {props.content} + + + ); +}