kunkun/packages/ui/src/components/common/ElementAlert.svelte
Huakun Shen e4d1441d73
Some checks are pending
CI / build-test (macos-14) (push) Waiting to run
CI / build-test (ubuntu-24.04) (push) Waiting to run
CI / build-test (windows-latest) (push) Waiting to run
Feature: support npm extension publish (#62)
* feat: npm package registry API

* refactor: move package registry files

* refactor: move jsr and npm api to a new package

* ci: add verify-package-export

* test: implement tests for npm package validation as kunkun extension

* chore: add missing dep for package-registry pkg

* feat: make provenance an optional input for npm validation function

* ci: add verify-package-export as dev dep to 2 packages that uses it

* feat: add rekor log API, and return commit from jsr & npm package in validation function

* feat: return github repo info from validation function of jsr and npm

* feat: extend ExtPublishMetadata to include optional GitHub repository details

* fix: eslint for ui package

* refactor: format desktop

* fix: eslint errors in desktop

* format: all code

* ci: add lint to CI

* feat: add more info to validation function returned from package-registry npm jsr

* pnpm lock

* feat: add 2 more variables to supabase extension metadata model

* format

* feat: add provenance card

* feat: add workflow path to ExtPublishMetadata and jsr/npm validation

* update provenance

* feat: make store extension and provenance more responsive

* chore: add globals to ui package

* fix: remove unnecessary any to fix eslint

* fix: svg sanitize

* chore: add @typescript-eslint/eslint-plugin to ui package to fix eslint

* fix: update eslint dep to fix error

* fix: try fixing eslint

* fix: update eslint configuration for improved compatibility

* chore: add globals package and update README for Discord invite

* fix: update eslint rules and upgrade typescript-eslint dependency

- Disabled additional eslint rules to resolve errors:
  - @typescript-eslint/no-unused-expressions
  - svelte/no-inner-declarations
- Upgraded typescript-eslint from version 8.19.1 to 8.20.0 for improved compatibility.

* update pnpm lock

---------

Co-authored-by: Huakun Shen <huaukun.shen@huakunshen.com>
2025-01-16 06:00:07 -05:00

122 lines
2.5 KiB
Svelte

<!-- Element Plus Style Alert (created because the original Shadcn Alert is not very good looking) -->
<script lang="ts" module>
export type AlertProps = {
title?: string
closable?: boolean
description?: string
variant?: "success" | "info" | "warning" | "error"
onClose?: () => void
class?: string
withIcon?: boolean
children?: Snippet
}
</script>
<script lang="ts">
import {
CircleAlertIcon,
CircleCheckBigIcon,
CircleHelpIcon,
CircleXIcon,
XIcon
} from "lucide-svelte"
import type { Snippet } from "svelte"
import { fade } from "svelte/transition"
import { cn } from "../../utils"
const config: Record<
"success" | "info" | "warning" | "error",
{
color: string
}
> = {
success: {
color: "green"
},
info: {
color: "blue"
},
warning: {
color: "yellow"
},
error: {
color: "red"
}
}
let {
title,
description,
class: className,
variant: type = "info",
closable,
withIcon,
onClose,
children
}: AlertProps = $props()
let show = $state(true)
</script>
{#if show}
<div
class={cn("flex items-center gap-3 rounded-xl px-3 py-3", className, {
"bg-red-500/10": type === "error",
"bg-blue-500/10": type === "info",
"bg-yellow-500/10": type === "warning",
"bg-green-500/10": type === "success"
})}
transition:fade
>
{#if withIcon}
{#if type === "success"}
<CircleCheckBigIcon class="h-6 w-6 shrink-0 text-green-400" />
{:else if type === "info"}
<CircleHelpIcon class="h-6 w-6 shrink-0 text-blue-400" />
{:else if type === "warning"}
<CircleAlertIcon class="h-6 w-6 shrink-0 text-yellow-400" />
{:else if type === "error"}
<CircleXIcon class="h-6 w-6 shrink-0 text-red-400" />
{/if}
{/if}
<div class="flex grow flex-col">
{#if title}
<span
class={cn("font-semibold", {
"text-green-400": type === "success",
"text-blue-400": type === "info",
"text-yellow-400": type === "warning",
"text-red-400": type === "error"
})}
>
{title}
</span>
{/if}
{#if description}
<small
class={cn("text-sm", {
"text-green-400/90": type === "success",
"text-blue-400/90": type === "info",
"text-yellow-400/90": type === "warning",
"text-red-400/90": type === "error"
})}
>
{description}
</small>
{/if}
{#if children}
{@render children()}
{/if}
</div>
{#if closable}
<XIcon
onclick={() => {
if (onClose) {
onClose()
}
show = false
}}
class="h-4 w-4 shrink-0 cursor-pointer self-start"
/>
{/if}
</div>
{/if}