All files / apps/portfolio/app/components WorkflowProjectMap.vue

100% Statements 14/14
100% Branches 5/5
100% Functions 6/6
100% Lines 14/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76  7x 1x 4x 1x 1x 4x               1x         1x                                 4x     2x 4x                         1x 21x                                     7x    
<template>
    <figure data-workflow-map class="flex flex-col gap-4">
        <ol class="flex flex-col gap-6 md:hidden">
            <li v-for="stage in map.stages" :key="stage.id" class="flex flex-col gap-2">
                <span class="font-mono text-xs text-muted uppercase">{{ stage.title }}</span>
                <ul class="flex flex-col gap-1">
                    <li
                        v-for="block in stage.blocks"
                        :key="block.id"
                        :data-tone="block.tone"
                        class="flex items-baseline gap-2 text-sm"
                    >
                        <span aria-hidden="true" class="font-mono">{{ GLYPHS[block.tone] }}</span>
                        <span>{{ block.title }}</span>
                        <span class="sr-only"
                            >, {{ $t(`workflowProjectMap.legend.${block.tone}`) }}</span
                        >
                        <span v-if="block.owner" class="text-muted">
                            ◆
                            <span class="sr-only">{{ $t("workflowProjectMap.owner") }}</span>
                        </span>
                    </li>
                </ul>
            </li>
        </ol>
 
        <!-- A map wider than the page scrolls, so a keyboard has to be able to reach it -->
        <div tabindex="0" role="region" :aria-label="label" class="hidden overflow-x-auto md:block">
            <svg
                :width="map.width"
                :height="map.height"
                :viewBox="`0 0 ${map.width} ${map.height}`"
                role="img"
                :aria-label="label"
                class="font-mono text-xs"
            >
                <text v-for="stage in map.stages" :key="stage.id" :x="stage.x" y="14" data-column>
                    {{ stage.title }}
                </text>
                <path v-for="edge in map.edges" :key="edge.id" :d="edge.d" data-edge />
                <g
                    v-for="node in map.nodes"
                    :key="node.id"
                    :transform="`translate(${node.x} ${node.y})`"
                    :data-tone="node.tone"
                >
                    <title>{{ node.title }}</title>
                    <rect :width="map.nodeWidth" :height="map.nodeHeight" />
                    <text x="10" y="19">{{ node.owner ? "◆ " : "" }}{{ node.label }}</text>
                </g>
            </svg>
        </div>
 
        <figcaption class="flex flex-wrap gap-x-6 gap-y-1 font-mono text-xs text-muted">
            <span v-for="(glyph, tone) in GLYPHS" :key="tone">
                {{ glyph }} {{ $t(`workflowProjectMap.legend.${tone}`) }}
            </span>
            <span>◆ {{ $t("workflowProjectMap.owner") }}</span>
        </figcaption>
    </figure>
</template>
 
<script setup lang="ts">
import type { ProjectMap } from "~/types/ProjectMap";
import type { MapTone } from "~/types/MapTone";
 
interface Props {
    map: ProjectMap;
    label: string;
}
 
defineProps<Props>();
 
const GLYPHS = { done: "■", moving: "□", waiting: "⬚" } as const satisfies Record<MapTone, string>;
</script>