外观
Attachment 附件
展示附件的文件名、类型和处理状态。可点击整条附件打开预览。
import { SAttachment } from '@icecreamqaq/shadcn/attachment'使用示例
基础用法
attachment.vue组合式 API vue
<template>
<div>
<s-attachment>
<s-attachment-media><file-text aria-hidden="true" /></s-attachment-media>
<s-attachment-content>
<s-attachment-title>评审摘要.txt</s-attachment-title>
<s-attachment-description>文本文档 · 点击预览</s-attachment-description>
</s-attachment-content>
<s-attachment-trigger aria-label="预览评审摘要" :aria-expanded="expanded" :aria-controls="previewId"
@click="expanded = !expanded" />
</s-attachment>
<p v-show="expanded" :id="previewId">下周完成可用性测试,再确认发布日程。</p>
</div>
</template>
<script setup lang="ts">
import { ref, useId } from 'vue'
import { FileText } from '@lucide/vue'
import {
SAttachment, SAttachmentContent, SAttachmentDescription, SAttachmentMedia, SAttachmentTitle, SAttachmentTrigger,
} from '@icecreamqaq/shadcn/attachment'
const expanded = ref(false)
const previewId = useId()
</script>vue
<template>
<div>
<s-attachment>
<s-attachment-media><file-text aria-hidden="true" /></s-attachment-media>
<s-attachment-content>
<s-attachment-title>评审摘要.txt</s-attachment-title>
<s-attachment-description>文本文档 · 点击预览</s-attachment-description>
</s-attachment-content>
<s-attachment-trigger aria-label="预览评审摘要" :aria-expanded="expanded" :aria-controls="previewId"
@click="expanded = !expanded" />
</s-attachment>
<p v-show="expanded" :id="previewId">下周完成可用性测试,再确认发布日程。</p>
</div>
</template>
<script lang="ts">
import { defineComponent, useId } from 'vue'
import { FileText } from '@lucide/vue'
import {
SAttachment, SAttachmentContent, SAttachmentDescription, SAttachmentMedia, SAttachmentTitle, SAttachmentTrigger,
} from '@icecreamqaq/shadcn/attachment'
export default defineComponent({
components: {
FileText, SAttachment, SAttachmentContent, SAttachmentDescription, SAttachmentMedia,
SAttachmentTitle, SAttachmentTrigger,
},
setup() {
return { previewId: useId() }
},
data() {
return { expanded: false }
},
})
</script>常用 API
| 成员 | 类型 | 用法 |
|---|---|---|
SAttachment.state | "idle" | "uploading" | "processing" | "error" | "done" | 根据业务状态改变边框和标题样式,默认为 done。 |
SAttachment.size | "default" | "sm" | "xs" | 控制附件行和预览媒体的尺寸。 |
SAttachment.orientation | "horizontal" | "vertical" | 默认为横向,纵向适用于缩略图。 |
SAttachmentTrigger.as | PrimitiveProps["as"] | 默认渲染覆盖附件区域的 button。用可访问名称说明打开的内容。 |
完整 API
Attachment5 个成员
属性
| 名称 | 类型 |
|---|---|
size | "default" | "xs" | "sm" | null |
orientation | "vertical" | "horizontal" | null |
state | "done" | "idle" | "uploading" | "processing" | "error" |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
AttachmentAction6 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
variant | "default" | "link" | "destructive" | "outline" | "secondary" | "ghost" | null |
size | "default" | "icon" | "xs" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-lg" | null |
asChild | boolean |
as | AsTag | Component |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
AttachmentActions2 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
AttachmentContent2 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
AttachmentDescription2 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
AttachmentGroup2 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
AttachmentMedia3 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
variant | "icon" | "image" | null |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
AttachmentTitle2 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
AttachmentTrigger4 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
asChild | boolean |
as | AsTag | Component |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
分组导出
模板标签为 <s-attachment>。
组件 SAttachment、SAttachmentAction、SAttachmentActions、SAttachmentContent、SAttachmentDescription、SAttachmentGroup、SAttachmentMedia、SAttachmentTitle、SAttachmentTrigger
函数与常量 attachmentMediaVariants、attachmentVariants
类型 AttachmentMediaVariants、AttachmentVariants