Skip to content
Draft
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
4 changes: 2 additions & 2 deletions src/components/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ defineProps<{
<template>
<header :style="{ '--line-color': toCSSColor(line.backgroundColor) }">
<div role="group">
<img :src="line.pictoPng" alt="" />
<div v-html="line.pictoSvg" class="picto"></div>
<LineIndicator :line="line" height="8vw"></LineIndicator>
</div>
<h1>{{ direction }}</h1>
Expand Down Expand Up @@ -40,7 +40,7 @@ h1 {
margin: 0;
}

img {
.picto {
height: 8vw;
width: auto;
}
Expand Down
97 changes: 1 addition & 96 deletions src/components/LineIndicator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,100 +10,5 @@ defineProps<{
</script>

<template>
<div
:style="{
'--background-color': toCSSColor(line.backgroundColor),
'--text-color': toCSSColor(line.textColor),
'--height': height,
}"
>
<div
v-if="
['circle-filled', 'square-filled', 'rectangle-filled'].includes(
line.backgroundShape
)
"
:class="toCamelCase(line.backgroundShape, '-')"
>
<span>{{ line.number }}</span>
</div>
<div
v-if="line.backgroundShape === 'horizontal-lines'"
class="horizontalLines"
>
<span>{{ line.number }}</span>
</div>
</div>
<div :style="{ height }" v-html="line.numberShapeSvg"></div>
</template>

<style scoped>
.circleFilled,
.squareFilled,
.rectangleFilled,
.horizontalLines {
display: flex;
justify-content: center;
align-items: center;
height: var(--height);
}

.circleFilled,
.squareFilled,
.rectangleFilled {
background-color: var(--background-color);
color: var(--text-color);
}

.circleFilled,
.squareFilled {
width: var(--height);
}

.rectangleFilled {
box-sizing: border-box;
min-width: var(--height);
padding: calc(var(--height) * 0.14) calc(var(--height) * 0.2);
}

.circleFilled {
border-radius: 50%;
}

.squareFilled {
border-radius: calc(var(--height) * 0.2);
}

.rectangleFilled span {
font-size: calc(var(--height) * 0.85);
}
span {
font-size: calc(var(--height) * 0.7);
font-weight: bold;
}

.horizontalLines {
position: relative;
min-width: var(--height);
}

.horizontalLines::before,
.horizontalLines::after {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
height: calc(var(--height) * 0.1);
border-radius: 9999px;
background-color: var(--background-color);
}

.horizontalLines::before {
top: unset;
bottom: 0;
}

.horizontalLines span {
font-size: calc(var(--height) * 0.6);
}
</style>
13 changes: 12 additions & 1 deletion src/components/Screen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ onMounted(async () => {
></Header>
<SuspendedService v-if="serviceIsSuspended"></SuspendedService>
<EmptyState v-else-if="departures.length === 0"></EmptyState>
<div class="withDisruptions" v-else>
<div class="withDisruptions" :empty-panel="disruptions.length === 0" v-else>
<TransitionGroup
tag="section"
name="horizontal"
Expand Down Expand Up @@ -229,6 +229,13 @@ article time {
display: grid;
grid-template-columns: 1fr;
grid-template-rows: 1fr;
transition-property: grid-template-columns, grid-template-rows;
transition-duration: 2s;
transition-timing-function: cubic-bezier(0.28, 0.16, 0.03, 0.94);
}

.withDisruptions[empty-panel="true"] {
grid-template-rows: 1fr 0fr;
}

@media (max-height: 40vw) {
Expand All @@ -245,5 +252,9 @@ article time {
.withDisruptions {
grid-template-columns: 1fr 1fr;
}

.withDisruptions[empty-panel="true"] {
grid-template-columns: 1fr 0fr;
}
}
</style>
8 changes: 4 additions & 4 deletions src/components/Stop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ const lines = computed<SimpleLine[]>(() => stop.lines)
const groupedLines = computed(() => {
const groups: { [key: string]: SimpleLine[] } = {}
lines.value.forEach((line) => {
if (!groups[line.pictoPng]) {
groups[line.pictoPng] = []
if (!groups[line.pictoSvg]) {
groups[line.pictoSvg] = []
}
groups[line.pictoPng].push(line)
groups[line.pictoSvg].push(line)
})

Object.keys(groups).forEach((mode) => {
Expand Down Expand Up @@ -55,7 +55,7 @@ watch(
<div class="stop-lines">
<div v-for="(lines, mode) in groupedLines" :key="mode" class="mode-group">
<div class="lines">
<img :src="String(mode)" alt="Mode icon" class="mode-icon" />
<div v-html="lines.at(0)?.pictoSvg" class="mode-icon"></div>
<button
class="line"
v-for="line in expandedGroups[mode]
Expand Down
4 changes: 2 additions & 2 deletions src/components/disruptions/LineIndicator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const sizeVw = computed(() => (props.size === "default" ? "5vw" : "2vw"))

<template>
<div role="group" :style="{ '--size-vw': sizeVw }">
<img :size="size" :src="disruption.line.pictoPng" />
<div class="picto" :size="size" v-html="disruption.line.pictoSvg"></div>
<LineIndicator :height="sizeVw" :line="disruption.line" />
<div class="icon" :blink="size === 'default'">
<template v-if="size === 'small'">
Expand Down Expand Up @@ -162,7 +162,7 @@ const sizeVw = computed(() => (props.size === "default" ? "5vw" : "2vw"))
</template>

<style scoped>
img {
.picto {
height: 100%;
}

Expand Down
16 changes: 12 additions & 4 deletions src/services/Wagon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ export interface SimpleLine {
number: string
backgroundColor: string
textColor: string
backgroundShape: string
pictoPng: string
pictoSvg?: string
numberShapeSvg?: string
importance: number
}

export interface SimpleStop {
Expand Down Expand Up @@ -36,6 +37,12 @@ export interface SimpleDisruption {

const hostname = window.location.hostname

function processSVG(svg: string): string {
return svg
.replace(/width="[^"]+"/, "")
.replace(/height="[^"]+"/, `height="100%"`)
}

export class Wagon {
private static BASE_URL = "https://api-wagon.arno.cl/gantry/"

Expand Down Expand Up @@ -80,8 +87,9 @@ export class Wagon {
number: lineDto.number,
backgroundColor: lineDto.backgroundColor,
textColor: lineDto.textColor,
backgroundShape: lineDto.shape,
pictoPng: lineDto.picto,
pictoSvg: processSVG(lineDto.modeSvg ?? ""),
numberShapeSvg: processSVG(lineDto.numberShapeSvg ?? ""),
importance: lineDto.importance,
}
}

Expand Down