All files / apps/developer-portal/layers/workflows/app/components WorkflowSkyline.vue

88.88% Statements 8/9
80% Branches 8/10
75% Functions 3/4
87.5% Lines 7/8

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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134  14x 24x                   23x                                       1x                                   3x   3x                                     12x                                                                                                                            
<template>
    <ol class="skyline grid grid-cols-7 items-end">
        <li
            v-for="(stage, index) in stages"
            :key="stage.id"
            class="relative flex min-w-0 flex-col gap-2"
            :style="{ '--hue': stageColor(index) }"
        >
            <div
                class="tower pointer-events-none relative z-10 flex flex-wrap-reverse gap-0.75 rounded-lg p-1 transition-colors sm:p-1.5"
                :class="{ 'is-selected': stage.id === selected }"
            >
                <button
                    v-for="capability in stage.capabilities"
                    :key="capability.id"
                    type="button"
                    class="cell pointer-events-auto size-3 rounded-xs border sm:size-3.5"
                    :class="[capability.state, capability.id === highlight && 'is-highlighted']"
                    :aria-pressed="capability.id === highlight"
                    :style="{ '--state': capabilityColor(capability.state) }"
                    :title="
                        $t('workflowSkyline.title', {
                            title: capability.title,
                            state: $t(`workflows.capabilityState.${capability.state}`),
                        })
                    "
                    :aria-label="
                        $t('workflowSkyline.label', {
                            title: capability.title,
                            state: $t(`workflows.capabilityState.${capability.state}`),
                        })
                    "
                    @click.stop="(emit('select-stage', stage.id), emit('select', capability.id))"
                />
            </div>
 
            <span class="h-0.5 bg-(--hue) opacity-70" aria-hidden="true" />
 
            <!-- Stretched over the whole column, so a click between the squares picks the stage too -->
            <button
                type="button"
                class="flex flex-col items-start gap-1 rounded-sm text-left after:absolute after:inset-0"
                :aria-pressed="stage.id === selected"
                @click="emit('select-stage', stage.id)"
            >
                <span
                    class="text-sm/tight font-bold"
                    :class="stage.id === selected ? 'text-highlighted' : 'text-muted'"
                >
                    <span class="sm:hidden" aria-hidden="true">{{ index + 1 }}</span>
                    <span class="sr-only sm:not-sr-only">{{ stage.title }}</span>
                </span>
                <span class="hidden font-mono text-xs text-muted tabular-nums sm:inline"
                    >{{ stage.progress.done }}/{{ stage.progress.total }}</span
                >
            </button>
        </li>
    </ol>
</template>
 
<script setup lang="ts">
import type { StageView } from "#layers/workflows/shared/workflows.ts";
 
interface Props {
    stages: StageView[];
    selected: string | null;
    /** The selected block, ringed so picking it anywhere else on the page points at its square. */
    highlight?: string | null;
}
 
const { stages, selected, highlight = null } = defineProps<Props>();
const emit = defineEmits<{
    "select-stage": [stage: string];
    select: [capability: string];
}>();
</script>
 
<style scoped>
.skyline {
    gap: clamp(0.375rem, 2vw, 1.5rem);
}
 
.tower.is-selected {
    background: color-mix(in oklab, var(--hue) 10%, transparent);
}
 
.cell {
    border-color: var(--state);
}
 
.cell.done,
.cell.in-flight,
.cell.ready,
.cell.waiting-on-you,
.cell.skipped {
    background: var(--state);
}
 
.cell.off {
    border-style: dashed;
    opacity: 0.45;
}
 
.cell.skipped {
    opacity: 0.6;
}
 
.cell:hover,
.cell.is-highlighted {
    transform: scale(1.35);
}
 
.cell.is-highlighted {
    outline: 2px solid var(--ui-text-highlighted);
    outline-offset: 1px;
}
 
@media (prefers-reduced-motion: no-preference) {
    .cell {
        transition: transform 0.15s;
    }
 
    .cell.in-flight {
        animation: breathe 2.4s ease-in-out infinite;
    }
}
 
@keyframes breathe {
    50% {
        opacity: 0.55;
    }
}
</style>