feat: migrate Toast and Table with reviewed state focus and SSR contracts
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent, h, inject, useAttrs, type PropType } from "vue";
|
||||
import type { ToastVariants } from "@heroui-vue/styles";
|
||||
import { toastContextKey } from "./context";
|
||||
import {
|
||||
ToastDangerIcon,
|
||||
ToastInfoIcon,
|
||||
ToastSuccessIcon,
|
||||
ToastWarningIcon,
|
||||
} from "./icons";
|
||||
|
||||
export default defineComponent({
|
||||
name: "ToastIndicator",
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
variant: {
|
||||
type: String as PropType<ToastVariants["variant"]>,
|
||||
default: "default",
|
||||
},
|
||||
as: { type: String, default: "div" },
|
||||
},
|
||||
setup(props, { slots }) {
|
||||
const attrs = useAttrs();
|
||||
const ctx = inject(toastContextKey, null);
|
||||
function defaultIcon() {
|
||||
switch (props.variant) {
|
||||
case "success":
|
||||
return h(ToastSuccessIcon, { "data-slot": "toast-default-icon" });
|
||||
case "warning":
|
||||
return h(ToastWarningIcon, { "data-slot": "toast-default-icon" });
|
||||
case "danger":
|
||||
return h(ToastDangerIcon, { "data-slot": "toast-default-icon" });
|
||||
default:
|
||||
return h(ToastInfoIcon, { "data-slot": "toast-default-icon" });
|
||||
}
|
||||
}
|
||||
return () =>
|
||||
h(
|
||||
props.as,
|
||||
{
|
||||
...attrs,
|
||||
class: [ctx?.slots.value.indicator(), attrs.class],
|
||||
"data-slot": "toast-indicator",
|
||||
},
|
||||
slots.default?.() ?? [defaultIcon()],
|
||||
);
|
||||
},
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user