| @click="emit('update:modelValue', pill.status)" |
| 9 | > |
| 10 | {{ pill.label }} {{ pill.count }} |
| 11 | </button> |
| 12 | </div> |
| 13 | </template> |
| 14 |
| 15 | <script setup lang="ts"> |
| 16 | import { computed } from 'vue' |
| 17 |
| 18 | interface Props { |
| 19 | items: Array<{ status: string }> |
| 20 | modelValue: string |
| 21 | } |
| 22 |
| 23 | const props = defineProps<Props>() |
| 24 |
| 25 | const emit = defineEmits<{ |
| 26 | 'update:modelValue': [value: string] |
| 27 | }>() |
| 28 |
| 29 | const pills = computed(() => { |
| 30 | const counts = { running: 0, error: 0, waiting: 0 } |
| 31 | for (const item of props.items) { |
| 32 | const s = item.status as keyof typeof counts |
| 33 | if (s in counts) { |
| 34 | counts[s]++ |
| 35 | } |
| 36 | } |
| 37 | return [ |
| 38 | { status: '', label: 'All', count: props.items.length }, |
| 39 | { status: 'running', label: 'Running', count: counts.running }, |
| 40 | { status: 'error', label: 'Error', count: counts.error }, |
| 41 | { status: 'waiting', label: 'Waiting', count: counts.waiting }, |
| 42 | ] |
| 43 | }) |
| 44 | </script> |
| 45 |
| 46 | <style scoped lang="scss"> |
| 47 | .status-pills { |
| 48 | display: flex; |
| 49 | gap: $spacing-sm; |
| 50 | } |
| 51 |
| 52 | .pill { |
| 53 | border: none; |
| 54 | border-radius: 12px; |
| 55 | padding: $spacing-xs $spacing-md; |
| 56 | font-size: $font-size-xs; |
| 57 | font-weight: $font-weight-medium; |
| 58 | cursor: pointer; |
| 59 | background: $color-bg-muted; |
| 60 | color: $color-text-secondary; |
| 61 | transition: all $transition-fast; |
| 62 | white-space: nowrap; |
| 63 |
| 64 | &:hover { |
| 65 | opacity: 0.85; |
| 66 | } |
| 67 |
| 68 | &.active { |
| 69 | &.all { |
| 70 | background: $color-bg-muted; |
| 71 | color: $color-text-secondary; |
| 72 | } |
| 73 |
| 74 | &.running { |
| 75 | background: rgba(103, 194, 58, 0.1); |
| 76 | color: #67c23a; |
| 77 | } |
| 78 |
| 79 | &.error { |
| 80 | background: rgba(245, 108, 108, 0.1); |
| 81 | color: #f56c6c; |
| 82 | } |
| 83 |
| 84 | &.waiting { |
| 85 | background: rgba(230, 162, 60, 0.1); |
| 86 | color: #e6a23c; |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 |
| 91 | @include mobile { |
| 92 | .status-pills { |
| 93 | overflow-x: auto; |
| 94 | flex-wrap: nowrap; |
| 95 | scrollbar-width: none; |
| 96 | -ms-overflow-style: none; |
| 97 |
| 98 | &::-webkit-scrollbar { |
| 99 | display: none; |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | </style> |