🎉 First commit !!!

This commit is contained in:
2023-01-22 16:53:45 +01:00
commit dde835760a
68 changed files with 3250 additions and 0 deletions

106
frontend/src/utils.tsx Normal file
View File

@@ -0,0 +1,106 @@
import { getTransportModeSrc } from './types';
export const TransportModeWeights = {
bus: 1,
tram: 2,
val: 3,
funicular: 4,
metro: 5,
rer: 6,
transilien: 7,
ter: 8,
};
export function renderLineTransportMode(line): JSX.Element {
return <img src={getTransportModeSrc(line.transportMode)} />
}
function renderBusLinePicto(line, styles): JSX.Element {
return (
<div class={styles.busLinePicto}>
<svg viewBox="0 0 31.5 14">
<rect x="0" y="0" width="31.5" height="14" rx="1.5" ry="1.5" style={{ fill: `#${line.backColorHexa}` }} />
<text x="50%"
y="55%"
dominant-baseline="middle"
text-anchor="middle"
font-size="7.4"
style={{ fill: `#${line.foreColorHexa}` }}>
{line.shortName}
</text>
</svg>
</div>
);
}
function renderTramLinePicto(line, styles): JSX.Element {
const lineStyle = { fill: `#${line.backColorHexa}` };
return (
<div class={styles.tramLinePicto}>
<svg viewBox="0 0 20 20">
<rect x="0" y="0" width="20" height="3" rx="1" ry="1" style={lineStyle} />
<rect x="0" y="17" width="20" height="3" rx="1" ry="1" style={lineStyle} />
<text x="50%"
y="55%"
dominant-baseline="middle"
text-anchor="middle"
font-size="11"
style={{ fill: "#00000" }}>
{line.shortName}
</text>
</svg>
</div>
);
}
function renderMetroLinePicto(line, styles): JSX.Element {
return (
<div class={styles.metroLinePicto}>
<svg viewbox="0 0 20 20">
<circle cx="10" cy="10" r="10" style={{ fill: `#${line.backColorHexa}` }} />
<text x="50%"
y="55%"
dominant-baseline="middle"
text-anchor="middle"
font-size="11" style={{ fill: `#${line.foreColorHexa}` }}>
{line.shortName}
</text>
</svg>
</div>
);
}
function renderTrainLinePicto(line, styles): JSX.Element {
return (
<div class={styles.trainLinePicto}>
<svg viewbox="0 0 20 20">
<rect x="0" y="0" width="20" height="20" rx="4.5" ry="4.5" style={{ fill: `#${line.backColorHexa}` }} />
<text x="50%"
y="55%"
dominant-baseline="middle"
text-anchor="middle"
font-size="11"
style={{ fill: `#${line.foreColorHexa}` }}>
{line.shortName}
</text>
</svg>
</div>
);
}
export function renderLinePicto(line, styles): JSX.Element {
switch (line.transportMode) {
case "bus":
case "funicular":
return renderBusLinePicto(line, styles);
case "tram":
return renderTramLinePicto(line, styles);
/* case "val": */
case "metro":
return renderMetroLinePicto(line, styles);
case "transilien":
case "rer":
case "ter":
return renderTrainLinePicto(line, styles);
}
}