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 | 27x 47x 7x 3x 3x 3x 3x 3x 10x 20x 20x 27x 47x 82x 92x 47x 47x 87x | <template>
<div class="grid gap-3 sm:grid-cols-2">
<button
v-for="card in cards"
:key="card.id"
type="button"
role="switch"
:aria-checked="card.enabled"
:aria-label="`${card.title} in this project`"
:disabled="!editable || card.needs !== null"
class="group flex flex-col gap-3 rounded-xl border p-4 text-left transition-colors enabled:cursor-pointer enabled:hover:bg-elevated/50 disabled:cursor-default"
:class="[
card.enabled ? 'border-primary bg-primary/5' : 'border-default bg-default',
card.within ? 'sm:col-span-2 sm:ml-8' : card.parent ? 'sm:col-span-2' : '',
card.needs ? 'opacity-50' : '',
]"
@click="emit('toggle', card.id, !card.enabled)"
>
<span class="flex items-start gap-3">
<span
class="flex size-9 shrink-0 items-center justify-center rounded-lg"
:class="card.enabled ? 'bg-primary text-inverted' : 'bg-elevated text-muted'"
>
<UIcon :name="card.icon" class="size-5" />
</span>
<span class="min-w-0 flex-1">
<span class="flex items-center gap-2">
<span class="font-semibold">{{ card.title }}</span>
<UBadge
:label="$t('workflowFeaturePicker.points', { points: card.points })"
color="neutral"
variant="subtle"
size="sm"
class="tabular-nums"
/>
</span>
<span class="block text-sm text-muted">{{ card.summary }}</span>
</span>
<UIcon
:name="card.enabled ? 'i-lucide-circle-check' : 'i-lucide-circle'"
class="size-5 shrink-0"
:class="card.enabled ? 'text-primary' : 'text-dimmed'"
/>
</span>
<span
v-if="card.blocks.length > 1 || card.needs"
class="flex flex-wrap items-center gap-1.5 text-xs text-muted"
>
<template v-if="card.blocks.length > 1">
<UBadge
v-for="block in card.blocks"
:key="block.title"
:label="
$t('workflowFeaturePicker.block', {
title: block.title,
points: block.complexity ?? 0,
})
"
color="neutral"
variant="subtle"
size="sm"
/>
</template>
<span v-if="card.needs">
{{ $t("workflowFeaturePicker.needs", { feature: card.needs }) }}
</span>
</span>
</button>
</div>
</template>
<script setup lang="ts">
import type { Feature } from "#layers/workflows/shared/workflows.ts";
interface Props {
features: Feature[];
editable?: boolean;
}
const { features, editable = false } = defineProps<Props>();
const emit = defineEmits<{ toggle: [feature: string, on: boolean] }>();
/** A feature inside another, such as comments in the blog, follows its parent's full-width card. */
const cards = computed(() =>
features
.filter((feature) => feature.within === null)
.flatMap((parent) => [parent, ...features.filter(({ within }) => within === parent.id)])
.map((feature) => {
const parent = features.find(({ id }) => id === feature.within);
const needs = parent && !parent.enabled ? parent.title : null;
return {
...feature,
needs,
parent: features.some(({ within }) => within === feature.id),
icon: feature.blocks.length > 1 ? "i-lucide-layers" : "i-lucide-puzzle",
};
}),
);
</script>
|