@nuxtseo/pro-indexing 0.0.0-stage → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,211 @@
1
+ <script setup lang="ts">
2
+ import type { RouteLocationRaw } from 'vue-router'
3
+ import { NuxtLink, UiIcon, UiMetricLabel, UiSeverityDot, UiSparkline, UiTooltip } from '#components'
4
+ import { useProIndexingCopy } from '../composables/useProIndexingCopy'
5
+
6
+ type StepStatus = 'success' | 'error' | 'warning' | 'neutral'
7
+
8
+ interface PipelineStep {
9
+ label: string
10
+ status: StepStatus
11
+ value: string
12
+ /** Large display value (e.g. "275" or "74.7%") — hero variant only */
13
+ displayValue?: string
14
+ /** Icon name for the step (Lucide/Carbon) */
15
+ icon?: string
16
+ tooltip?: string
17
+ sparkline?: number[]
18
+ to?: RouteLocationRaw
19
+ }
20
+
21
+ const { steps, variant = 'hero' } = defineProps<{
22
+ steps: PipelineStep[]
23
+ /** hero: full grid with sparklines. inline: compact horizontal row */
24
+ variant?: 'hero' | 'inline'
25
+ }>()
26
+
27
+ const pipelineLabel = useProIndexingCopy().urls.pipelineLabel
28
+
29
+ /** Status-tinted icon container classes (matches UiNavIcon pattern) */
30
+ const statusContainerColors: Record<StepStatus, string> = {
31
+ success: 'bg-success/10 border-success/15',
32
+ error: 'bg-error/10 border-error/15',
33
+ warning: 'bg-warning/10 border-warning/15',
34
+ neutral: 'bg-primary-300/10 border-primary-300/15 dark:bg-primary-900/10 dark:border-primary-950/15',
35
+ }
36
+
37
+ const statusIconColors: Record<StepStatus, string> = {
38
+ success: 'text-success',
39
+ error: 'text-error',
40
+ warning: 'text-warning',
41
+ neutral: 'text-dimmed',
42
+ }
43
+
44
+ const statusSparklineColors: Record<StepStatus, string> = {
45
+ success: '#22c55e',
46
+ error: '#ef4444',
47
+ warning: '#eab308',
48
+ neutral: '#94a3b8',
49
+ }
50
+ </script>
51
+
52
+ <template>
53
+ <!-- ═══ HERO variant: 4-col grid with sparklines ═══ -->
54
+ <div v-if="variant === 'hero'" class="grid grid-cols-2 gap-4 sm:gap-0 sm:grid-cols-4 divide-default sm:divide-x" role="list" :aria-label="pipelineLabel">
55
+ <component
56
+ :is="step.to ? NuxtLink : 'div'"
57
+ v-for="(step, i) in steps"
58
+ :key="step.label"
59
+ :to="step.to || undefined"
60
+ role="listitem"
61
+ class="hero-step group"
62
+ :class="{ 'hero-step--link': !!step.to }"
63
+ >
64
+ <!-- Label row -->
65
+ <div class="flex items-center gap-1.5 mb-1">
66
+ <div
67
+ v-if="step.icon"
68
+ class="border size-4.5 flex items-center justify-center rounded shrink-0"
69
+ :class="statusContainerColors[step.status]"
70
+ >
71
+ <UiIcon :name="step.icon" class="size-2.5 shrink-0" :class="statusIconColors[step.status]" />
72
+ </div>
73
+ <div
74
+ v-else
75
+ class="size-1.5 rounded-full shrink-0"
76
+ :class="step.status === 'success' ? 'bg-success' : step.status === 'error' ? 'bg-error' : step.status === 'warning' ? 'bg-warning' : 'bg-muted'"
77
+ />
78
+ <UiMetricLabel>{{ step.label }}</UiMetricLabel>
79
+ <UiIcon
80
+ v-if="i < steps.length - 1"
81
+ name="chevron-right"
82
+ class="size-2.5 text-dimmed ml-auto shrink-0 opacity-30"
83
+ />
84
+ </div>
85
+
86
+ <!-- Value -->
87
+ <UiTooltip v-if="step.tooltip" :text="step.tooltip">
88
+ <div class="flex items-baseline gap-1.5">
89
+ <span v-if="step.displayValue" class="text-2xl font-bold text-default">{{ step.displayValue }}</span>
90
+ <span class="text-xs" :class="step.displayValue ? 'text-dimmed' : 'text-lg font-semibold tabular-nums text-default'">{{ step.value }}</span>
91
+ </div>
92
+ </UiTooltip>
93
+ <div v-else class="flex items-baseline gap-1.5">
94
+ <span v-if="step.displayValue" class="text-2xl font-bold text-default">{{ step.displayValue }}</span>
95
+ <span class="text-xs" :class="step.displayValue ? 'text-dimmed' : 'text-lg font-semibold tabular-nums text-default'">{{ step.value }}</span>
96
+ </div>
97
+
98
+ <!-- Sparkline -->
99
+ <UiSparkline
100
+ v-if="step.sparkline?.length && step.sparkline.length > 2"
101
+ :data="step.sparkline"
102
+ :color="statusSparklineColors[step.status]"
103
+ :width="120"
104
+ :height="28"
105
+ :stroke-width="1.5"
106
+ class="mt-2"
107
+ />
108
+ <div v-else class="mt-2 h-[28px]" />
109
+ </component>
110
+ </div>
111
+
112
+ <!-- ═══ INLINE variant: compact horizontal flow ═══ -->
113
+ <div v-else class="inline-pipeline" role="list" :aria-label="pipelineLabel">
114
+ <template v-for="(step, i) in steps" :key="step.label">
115
+ <component
116
+ :is="step.to ? NuxtLink : 'div'"
117
+ :to="step.to || undefined"
118
+ role="listitem"
119
+ class="inline-step"
120
+ :class="{ 'inline-step--link': !!step.to }"
121
+ >
122
+ <span class="inline-label">{{ step.label }}</span>
123
+ <UiTooltip v-if="step.tooltip" :text="step.tooltip">
124
+ <UiSeverityDot :severity="step.status" :label="step.value" />
125
+ </UiTooltip>
126
+ <UiSeverityDot v-else :severity="step.status" :label="step.value" />
127
+ </component>
128
+ <UiIcon v-if="i < steps.length - 1" name="chevron-right" class="inline-arrow" />
129
+ </template>
130
+ </div>
131
+ </template>
132
+
133
+ <style scoped>
134
+ /* ─── Hero variant ─── */
135
+ .hero-step {
136
+ display: flex;
137
+ flex-direction: column;
138
+ padding: 0.75rem 1rem;
139
+ min-width: 0;
140
+ }
141
+
142
+ .hero-step:first-child {
143
+ padding-left: 0;
144
+ }
145
+
146
+ .hero-step:last-child {
147
+ padding-right: 0;
148
+ }
149
+
150
+ .hero-step--link {
151
+ cursor: pointer;
152
+ }
153
+
154
+ @media (prefers-reduced-motion: no-preference) {
155
+ .hero-step--link {
156
+ transition: opacity 0.15s;
157
+ }
158
+ }
159
+
160
+ .hero-step--link:hover {
161
+ opacity: 0.7;
162
+ }
163
+
164
+ /* ─── Inline variant ─── */
165
+ .inline-pipeline {
166
+ display: flex;
167
+ align-items: flex-start;
168
+ gap: 0.375rem;
169
+ overflow-x: auto;
170
+ }
171
+
172
+ .inline-step {
173
+ display: flex;
174
+ flex-direction: column;
175
+ gap: 0.25rem;
176
+ min-width: 0;
177
+ padding: 0.375rem 0.5rem;
178
+ border-radius: 0.375rem;
179
+ }
180
+
181
+ .inline-step--link {
182
+ cursor: pointer;
183
+ }
184
+
185
+ @media (prefers-reduced-motion: no-preference) {
186
+ .inline-step--link {
187
+ transition: opacity 0.15s;
188
+ }
189
+ }
190
+
191
+ .inline-step--link:hover {
192
+ opacity: 0.75;
193
+ }
194
+
195
+ .inline-label {
196
+ font-size: 10px;
197
+ font-weight: 600;
198
+ text-transform: uppercase;
199
+ letter-spacing: 0.06em;
200
+ color: var(--ui-text-dimmed);
201
+ }
202
+
203
+ .inline-arrow {
204
+ width: 0.75rem;
205
+ height: 0.75rem;
206
+ color: var(--ui-text-dimmed);
207
+ flex-shrink: 0;
208
+ margin-top: 1rem;
209
+ opacity: 0.35;
210
+ }
211
+ </style>
@@ -0,0 +1,266 @@
1
+ <script setup lang="ts">
2
+ import type { IndexingOverviewModel, IndexingOverviewWaiting } from '@gscdump/sdk/indexing'
3
+ import type { IndexingSiteDiagnosis } from '../../shared/source'
4
+ import { formatGroupedNumber } from '@nuxtseo/design-system/app/composables/formatting'
5
+ import { fillCopy } from '@nuxtseo/pro-shell/shared/copy'
6
+ import { computed } from 'vue'
7
+ import { UiButton, UiCard, UiSkeleton, UiStatusBadge } from '#components'
8
+ import { useProIndexingCopy } from '../composables/useProIndexingCopy'
9
+
10
+ export type IndexingDiagnosisPanelState
11
+ = | { _tag: 'loading' }
12
+ | { _tag: 'ready', model: IndexingOverviewModel<IndexingSiteDiagnosis> }
13
+
14
+ /**
15
+ * A located claim that replaces the reason-led headline. The SDK's cohort lead
16
+ * (`selectIndexCohortLead`) and regression lead (`selectIndexingRegressionLead`)
17
+ * both fit. Without `actionLabel`, the button reads `copy.diagnosis.leadAction`.
18
+ */
19
+ export type IndexingDiagnosisLead
20
+ = | { _tag: 'lead', title: string, detail: string, actionLabel?: string }
21
+ | { _tag: 'none' }
22
+
23
+ const { state, lead, leadDetail = false } = defineProps<{
24
+ state: IndexingDiagnosisPanelState
25
+ actionTo: string
26
+ sitemapTo: string
27
+ freshness: string | null
28
+ /**
29
+ * A cohort that cleared the significance test. When present it replaces the
30
+ * reason-derived headline and next step: "21 of 76 pages under /docs/og-image
31
+ * are missing" locates the failure, where "Google crawled 38 URLs but chose
32
+ * not to keep them" only names it. Absent when no cohort separates, and the
33
+ * reason-led headline is then still the most specific true statement.
34
+ */
35
+ lead?: IndexingDiagnosisLead
36
+ /** Where the lead's action goes. Required whenever `lead` is a `lead`. */
37
+ leadTo?: string
38
+ /** Draw the lead's detail line, such as "That is 42% not indexed, against 10%", under the headline. */
39
+ leadDetail?: boolean
40
+ }>()
41
+
42
+ defineSlots<{
43
+ /** The waiting state's actions, such as a connect button or a Sitemap link. */
44
+ 'waiting-actions'?: (props: { model: IndexingOverviewWaiting }) => unknown
45
+ }>()
46
+
47
+ const copy = useProIndexingCopy()
48
+
49
+ const cohortLead = computed(() => lead?._tag === 'lead' ? lead : null)
50
+
51
+ const model = computed(() => state._tag === 'ready' ? state.model : null)
52
+
53
+ const status = computed(() => {
54
+ if (model.value?._tag !== 'diagnosis')
55
+ return null
56
+ return model.value.diagnosis.severity === 'severe'
57
+ ? { tone: 'error' as const, label: copy.diagnosis.statusSevere }
58
+ : model.value.diagnosis.severity === 'watch' || model.value.diagnosis.reason !== 'none'
59
+ ? { tone: 'warning' as const, label: copy.diagnosis.statusReview }
60
+ : { tone: 'success' as const, label: copy.diagnosis.statusHealthy }
61
+ })
62
+
63
+ // One supporting line under the headline: the lead's comparison, then the
64
+ // optional scope line a site writes under `copy.diagnosis.scope`.
65
+ const supportLine = computed(() => {
66
+ if (model.value?._tag !== 'diagnosis')
67
+ return ''
68
+ const scope = copy.diagnosis.scope
69
+ ? fillCopy(copy.diagnosis.scope, { indexed: model.value.scope.indexedLabel })
70
+ : ''
71
+ return [leadDetail ? cohortLead.value?.detail : null, scope].filter(Boolean).join(' · ')
72
+ })
73
+ </script>
74
+
75
+ <template>
76
+ <UiCard emphasis size="lg" data-pro-indexing-section="diagnosis">
77
+ <div v-if="state._tag === 'loading'" class="flex min-h-56 flex-col justify-center gap-6" aria-live="polite">
78
+ <div class="space-y-3">
79
+ <UiSkeleton type="text" :base="100" :range="16" />
80
+ <UiSkeleton type="text" :base="520" :range="80" class="!h-8" />
81
+ <UiSkeleton type="text" :base="280" :range="60" />
82
+ </div>
83
+ <div class="flex flex-col gap-4 border-t border-default pt-5 sm:flex-row sm:items-start sm:justify-between">
84
+ <div class="min-w-0 flex-1 space-y-2">
85
+ <UiSkeleton type="text" :base="70" :range="12" />
86
+ <UiSkeleton type="text" :base="240" :range="50" />
87
+ <UiSkeleton type="text" :base="440" :range="80" />
88
+ </div>
89
+ <UiSkeleton type="text" :base="150" :range="20" class="!h-11 shrink-0" />
90
+ </div>
91
+ </div>
92
+
93
+ <template v-else-if="model">
94
+ <div v-if="model._tag === 'waiting'" class="flex min-h-56 flex-col justify-center gap-4">
95
+ <UiStatusBadge
96
+ status="neutral"
97
+ :label="model.state === 'not_connected'
98
+ ? copy.diagnosis.setupNeeded
99
+ : model.progress && model.progress.inspected > 0 ? copy.diagnosis.inspecting : copy.diagnosis.waitingForGoogle"
100
+ />
101
+ <div>
102
+ <h2 class="max-w-2xl text-2xl font-strong text-default">
103
+ <template v-if="model.state === 'not_connected'">
104
+ {{ copy.diagnosis.connectTitle }}
105
+ </template>
106
+ <template v-else-if="model.progress">
107
+ {{ fillCopy(copy.diagnosis.progressTitle, { inspected: formatGroupedNumber(model.progress.inspected), total: formatGroupedNumber(model.progress.total) }) }}
108
+ </template>
109
+ <template v-else>
110
+ {{ copy.diagnosis.waitingTitle }}
111
+ </template>
112
+ </h2>
113
+ <p class="mt-2 max-w-2xl text-sm text-muted">
114
+ {{ model.reason }}
115
+ </p>
116
+ </div>
117
+ <div v-if="model.progress" class="max-w-sm">
118
+ <div
119
+ class="h-2 overflow-hidden rounded-full bg-accented"
120
+ role="progressbar"
121
+ :aria-label="copy.diagnosis.progressLabel"
122
+ :aria-valuenow="model.progress.inspected"
123
+ aria-valuemin="0"
124
+ :aria-valuemax="model.progress.total"
125
+ >
126
+ <div
127
+ class="h-full bg-primary"
128
+ :style="{ width: `${Math.min(100, model.progress.inspected / model.progress.total * 100)}%` }"
129
+ />
130
+ </div>
131
+ </div>
132
+ <div v-if="$slots['waiting-actions']" class="flex flex-wrap gap-2">
133
+ <slot name="waiting-actions" :model="model" />
134
+ </div>
135
+ </div>
136
+
137
+ <div v-else-if="model._tag === 'trust_failure'" class="flex min-h-56 flex-col justify-center gap-4">
138
+ <UiStatusBadge status="error" :label="copy.diagnosis.trustFailureBadge" />
139
+ <div>
140
+ <h2 class="max-w-2xl text-2xl font-strong text-default">
141
+ {{ copy.diagnosis.trustFailureTitle }}
142
+ </h2>
143
+ <p class="mt-2 max-w-2xl text-sm text-muted">
144
+ {{ model.reason }}
145
+ </p>
146
+ </div>
147
+ <UiButton :to="sitemapTo" purpose="cta" trailing-icon="next" class="min-h-11 self-start">
148
+ {{ copy.diagnosis.reviewSitemap }}
149
+ </UiButton>
150
+ </div>
151
+
152
+ <div v-else-if="model._tag === 'verify_scope'" class="flex min-h-56 flex-col justify-center gap-4">
153
+ <UiStatusBadge status="warning" :label="copy.diagnosis.verifyScopeBadge" />
154
+ <div>
155
+ <h2 class="max-w-2xl text-2xl font-strong text-default">
156
+ {{ copy.diagnosis.verifyScopeTitle }}
157
+ </h2>
158
+ <!-- The button already says to verify the inventory; the sentence that
159
+ used to repeat it here was the action twice. -->
160
+ <p class="mt-2 max-w-2xl text-sm text-muted">
161
+ {{ model.reason }}
162
+ </p>
163
+ </div>
164
+ <UiButton :to="sitemapTo" purpose="cta" trailing-icon="next" class="min-h-11 self-start">
165
+ {{ copy.diagnosis.verifySitemap }}
166
+ </UiButton>
167
+ </div>
168
+
169
+ <div v-else-if="model._tag === 'partial_scope'" class="flex min-h-56 flex-col justify-center gap-4">
170
+ <UiStatusBadge status="neutral" :label="copy.diagnosis.inspecting" />
171
+ <div>
172
+ <h2 class="max-w-2xl text-2xl font-strong text-default">
173
+ {{ copy.diagnosis.partialScopeTitle }}
174
+ </h2>
175
+ <p class="mt-2 max-w-2xl text-sm text-muted">
176
+ {{ model.reason }}
177
+ </p>
178
+ </div>
179
+ <UiButton :to="actionTo" purpose="secondary" trailing-icon="next" class="min-h-11 self-start">
180
+ {{ copy.diagnosis.viewInspectedUrls }}
181
+ </UiButton>
182
+ </div>
183
+
184
+ <div v-else class="flex flex-col gap-6">
185
+ <div class="min-w-0">
186
+ <UiStatusBadge
187
+ v-if="status"
188
+ :status="status.tone"
189
+ :label="status.label"
190
+ />
191
+ <h2 class="mt-3 max-w-2xl text-2xl font-strong text-default">
192
+ {{ cohortLead ? cohortLead.title : model.diagnosis.summary }}
193
+ </h2>
194
+ <p v-if="supportLine" class="mt-2 max-w-2xl text-sm text-muted">
195
+ {{ supportLine }}
196
+ </p>
197
+ <p v-if="model.trustNote" class="mt-2 max-w-2xl text-sm text-warning">
198
+ {{ model.trustNote }}
199
+ </p>
200
+ </div>
201
+
202
+ <div
203
+ v-if="cohortLead"
204
+ class="flex flex-col gap-4 border-t border-default pt-5 sm:flex-row sm:items-start sm:justify-between"
205
+ >
206
+ <div class="min-w-0">
207
+ <p class="text-label">
208
+ {{ copy.diagnosis.nextStep }}
209
+ </p>
210
+ <h3 class="mt-1 text-base font-semibold text-default">
211
+ {{ model.primaryAction ? model.primaryAction.label : copy.diagnosis.reviewSection }}
212
+ </h3>
213
+ </div>
214
+ <UiButton
215
+ :to="leadTo ?? actionTo"
216
+ purpose="cta"
217
+ trailing-icon="next"
218
+ class="min-h-11 shrink-0 self-start"
219
+ >
220
+ {{ cohortLead.actionLabel ?? copy.diagnosis.leadAction }}
221
+ </UiButton>
222
+ </div>
223
+
224
+ <div
225
+ v-else-if="model.primaryAction"
226
+ class="flex flex-col gap-4 border-t border-default pt-5 sm:flex-row sm:items-start sm:justify-between"
227
+ >
228
+ <div class="min-w-0">
229
+ <p class="text-label">
230
+ {{ copy.diagnosis.nextStep }}
231
+ </p>
232
+ <h3 class="mt-1 text-base font-semibold text-default">
233
+ {{ model.primaryAction.label }}
234
+ </h3>
235
+ <p class="mt-1 max-w-2xl text-sm text-muted">
236
+ {{ model.primaryAction.detail }}
237
+ </p>
238
+ </div>
239
+ <UiButton
240
+ :to="actionTo"
241
+ purpose="cta"
242
+ trailing-icon="next"
243
+ class="min-h-11 shrink-0 self-start"
244
+ >
245
+ {{ model.primaryAction.buttonLabel }}
246
+ </UiButton>
247
+ </div>
248
+
249
+ <UiButton
250
+ v-else
251
+ :to="actionTo"
252
+ purpose="secondary"
253
+ trailing-icon="next"
254
+ class="min-h-11 self-start"
255
+ >
256
+ {{ copy.diagnosis.viewInspectedUrls }}
257
+ </UiButton>
258
+
259
+ <!-- Freshness is metadata about the verdict, not part of it. -->
260
+ <p v-if="freshness" class="text-mini text-dimmed">
261
+ {{ fillCopy(copy.diagnosis.freshness, { freshness }) }}
262
+ </p>
263
+ </div>
264
+ </template>
265
+ </UiCard>
266
+ </template>