Skip to content

Commit 93c7aaf

Browse files
committed
refactor: use alert component
1 parent 17c0438 commit 93c7aaf

1 file changed

Lines changed: 19 additions & 42 deletions

File tree

app/components/Package/ClaimPackageModal.vue

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -199,28 +199,26 @@ const previewPackageJson = computed(() => {
199199
</div>
200200

201201
<!-- Validation errors -->
202-
<div
202+
<Alert
203203
v-if="checkResult.validationErrors?.length"
204-
class="p-3 text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-md"
205-
role="alert"
204+
variant="error"
205+
:title="$t('claim.modal.invalid_name')"
206206
>
207-
<p class="font-medium mb-1">{{ $t('claim.modal.invalid_name') }}</p>
208207
<ul class="list-disc list-inside space-y-1">
209208
<li v-for="err in checkResult.validationErrors" :key="err">{{ err }}</li>
210209
</ul>
211-
</div>
210+
</Alert>
212211

213212
<!-- Validation warnings -->
214-
<div
213+
<Alert
215214
v-if="checkResult.validationWarnings?.length"
216-
class="p-3 text-sm text-yellow-400 bg-yellow-500/10 border border-yellow-500/20 rounded-md"
217-
role="alert"
215+
variant="warning"
216+
:title="$t('common.warnings')"
218217
>
219-
<p class="font-medium mb-1">{{ $t('common.warnings') }}</p>
220218
<ul class="list-disc list-inside space-y-1">
221219
<li v-for="warn in checkResult.validationWarnings" :key="warn">{{ warn }}</li>
222220
</ul>
223-
</div>
221+
</Alert>
224222

225223
<!-- Availability status -->
226224
<template v-if="checkResult.valid">
@@ -305,39 +303,23 @@ const previewPackageJson = computed(() => {
305303
</template>
306304

307305
<!-- Error message -->
308-
<div
309-
v-if="mergedError"
310-
role="alert"
311-
class="p-3 text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-md"
312-
>
313-
{{ mergedError }}
314-
</div>
306+
<Alert v-if="mergedError" variant="error">{{ mergedError }}</Alert>
315307

316308
<!-- Actions -->
317309
<div v-if="checkResult.available && checkResult.valid" class="space-y-3">
318310
<!-- Warning for unscoped packages -->
319-
<div
320-
v-if="!isScoped"
321-
class="p-3 text-sm text-yellow-400 bg-yellow-500/10 border border-yellow-500/20 rounded-md"
322-
>
323-
<p class="font-medium mb-1">{{ $t('claim.modal.scope_warning_title') }}</p>
324-
<p class="text-xs text-yellow-400/80">
325-
{{
326-
$t('claim.modal.scope_warning_text', {
327-
username: npmUser || 'username',
328-
name: packageName,
329-
})
330-
}}
331-
</p>
332-
</div>
311+
<Alert v-if="!isScoped" variant="warning" :title="$t('claim.modal.scope_warning_title')">
312+
{{
313+
$t('claim.modal.scope_warning_text', {
314+
username: npmUser || 'username',
315+
name: packageName,
316+
})
317+
}}
318+
</Alert>
333319

334320
<!-- Not connected warning -->
335321
<div v-if="!isConnected" class="space-y-3">
336-
<div
337-
class="p-3 text-sm text-yellow-400 bg-yellow-500/10 border border-yellow-500/20 rounded-md"
338-
>
339-
<p>{{ $t('claim.modal.connect_required') }}</p>
340-
</div>
322+
<Alert variant="warning">{{ $t('claim.modal.connect_required') }}</Alert>
341323
<button
342324
type="button"
343325
class="w-full px-4 py-2 font-mono text-sm text-bg bg-fg rounded-md transition-colors duration-200 hover:bg-fg/90 focus-visible:outline-accent/70"
@@ -389,12 +371,7 @@ const previewPackageJson = computed(() => {
389371

390372
<!-- Error state -->
391373
<div v-else-if="mergedError" class="space-y-4">
392-
<div
393-
role="alert"
394-
class="p-3 text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded-md"
395-
>
396-
{{ mergedError }}
397-
</div>
374+
<Alert variant="error">{{ mergedError }}</Alert>
398375
<button
399376
type="button"
400377
class="w-full px-4 py-2 font-mono text-sm text-fg-muted bg-bg-subtle border border-border rounded-md transition-colors duration-200 hover:text-fg hover:border-border-hover focus-visible:outline-accent/70"

0 commit comments

Comments
 (0)