feat(ui): add transparent option for Alert component
This commit is contained in:
@@ -36,4 +36,8 @@ div.alert {
|
|||||||
&.success {
|
&.success {
|
||||||
@apply bg-semantic-success-1 border border-semantic-success-3 fg-semantic-success-3;
|
@apply bg-semantic-success-1 border border-semantic-success-3 fg-semantic-success-3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.transparent {
|
||||||
|
@apply bg-transparent border-none p-0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,19 @@ import { expect, fn } from "storybook/test";
|
|||||||
import { StoryContext } from "@kachurun/storybook-solid-vite";
|
import { StoryContext } from "@kachurun/storybook-solid-vite";
|
||||||
|
|
||||||
const AlertExamples = (props: AlertProps) => (
|
const AlertExamples = (props: AlertProps) => (
|
||||||
<div class="flex flex-row gap-4">
|
<div class="grid w-fit grid-cols-2 gap-8">
|
||||||
<div class="w-72">
|
<div class="w-72">
|
||||||
<Alert {...props} />
|
<Alert {...props} />
|
||||||
</div>
|
</div>
|
||||||
<div class="w-72">
|
<div class="w-72">
|
||||||
<Alert {...props} size="s" />
|
<Alert {...props} size="s" />
|
||||||
</div>
|
</div>
|
||||||
|
<div class="w-72">
|
||||||
|
<Alert {...props} transparent />
|
||||||
|
</div>
|
||||||
|
<div class="w-72">
|
||||||
|
<Alert {...props} size="s" transparent />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -7,17 +7,16 @@ import { Alert as KAlert } from "@kobalte/core/alert";
|
|||||||
import { Show } from "solid-js";
|
import { Show } from "solid-js";
|
||||||
|
|
||||||
export interface AlertProps {
|
export interface AlertProps {
|
||||||
|
icon?: IconVariant;
|
||||||
type: "success" | "error" | "warning" | "info";
|
type: "success" | "error" | "warning" | "info";
|
||||||
size?: "default" | "s";
|
size?: "default" | "s";
|
||||||
title: string;
|
title: string;
|
||||||
description?: string;
|
|
||||||
icon?: IconVariant;
|
|
||||||
onDismiss?: () => void;
|
onDismiss?: () => void;
|
||||||
|
transparent?: boolean;
|
||||||
|
description?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Alert = (props: AlertProps) => {
|
export const Alert = (props: AlertProps) => {
|
||||||
console.log("on dismiss", !!props.onDismiss);
|
|
||||||
|
|
||||||
const size = () => props.size || "default";
|
const size = () => props.size || "default";
|
||||||
const titleSize = () => (size() == "default" ? "default" : "xs");
|
const titleSize = () => (size() == "default" ? "default" : "xs");
|
||||||
const bodySize = () => (size() == "default" ? "xs" : "xxs");
|
const bodySize = () => (size() == "default" ? "xs" : "xxs");
|
||||||
@@ -28,6 +27,7 @@ export const Alert = (props: AlertProps) => {
|
|||||||
class={cx("alert", props.type, {
|
class={cx("alert", props.type, {
|
||||||
"has-icon": props.icon,
|
"has-icon": props.icon,
|
||||||
"has-dismiss": props.onDismiss,
|
"has-dismiss": props.onDismiss,
|
||||||
|
transparent: props.transparent,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{props.icon && (
|
{props.icon && (
|
||||||
|
|||||||
Reference in New Issue
Block a user