Skip to content

Commit 95ca989

Browse files
zhouLioncwandev
authored andcommitted
feat: implement Artifact component with subcomponents and update installation instructions
1 parent b99ea91 commit 95ca989

File tree

13 files changed

+466
-64
lines changed

13 files changed

+466
-64
lines changed

apps/www/content/2.components/artifact.md

Lines changed: 402 additions & 0 deletions
Large diffs are not rendered by default.

apps/www/plugins/ai-elements.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
Actions,
33
ActionsHover,
4+
Artifact,
45
Branch,
56
ChainOfThought,
67
Checkpoint,
@@ -40,6 +41,7 @@ export default defineNuxtPlugin((nuxtApp) => {
4041
vueApp.component('ComponentLoader', ComponentLoader)
4142
vueApp.component('ComponentViewer', ComponentViewer)
4243

44+
vueApp.component('Artifact', Artifact)
4345
vueApp.component('Actions', Actions)
4446
vueApp.component('ActionsHover', ActionsHover)
4547
vueApp.component('Branch', Branch)

packages/elements/src/artifact/Artifact.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
<script setup lang="ts">
2-
import type { ArtifactProps } from './props'
2+
import type { HTMLAttributes } from 'vue'
33
import { cn } from '@repo/shadcn-vue/lib/utils'
4-
import { computed } from 'vue'
4+
import { computed, useAttrs } from 'vue'
55
6-
const props = defineProps<ArtifactProps>()
6+
const props = defineProps<{
7+
class?: HTMLAttributes['class']
8+
}>()
79
810
const classes = computed(() => cn(
911
'flex flex-col overflow-hidden rounded-lg border bg-background shadow-sm',
1012
props.class,
1113
))
14+
const attrs = useAttrs()
1215
</script>
1316

1417
<template>
1518
<div
16-
v-bind="{
17-
...props,
18-
class: classes,
19-
}"
19+
:class="classes"
20+
v-bind="attrs"
2021
>
2122
<slot />
2223
</div>

packages/elements/src/artifact/ArtifactAction.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
<script setup lang="ts">
2-
import type { ArtifactActionProps } from './props'
2+
import type { ButtonVariants } from '@repo/shadcn-vue/components/ui/button'
3+
import type { LucideIcon } from 'lucide-vue-next'
34
import { Button } from '@repo/shadcn-vue/components/ui/button'
45
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@repo/shadcn-vue/components/ui/tooltip'
56
import { cn } from '@repo/shadcn-vue/lib/utils'
67
import { computed } from 'vue'
78
9+
interface ArtifactActionProps {
10+
class?: string
11+
tooltip?: string
12+
label?: string
13+
variant?: ButtonVariants['variant']
14+
size?: ButtonVariants['size']
15+
icon?: LucideIcon
16+
}
17+
818
const props = withDefaults(defineProps<ArtifactActionProps>(), {
919
variant: 'ghost',
1020
size: 'sm',

packages/elements/src/artifact/ArtifactActions.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<script setup lang="ts">
2-
import type { ArtifactActionsProps } from './props'
2+
import type { HTMLAttributes } from 'vue'
33
import { cn } from '@repo/shadcn-vue/lib/utils'
4-
import { computed } from 'vue'
5-
6-
const props = defineProps<ArtifactActionsProps>()
4+
import { computed, useAttrs } from 'vue'
75
6+
const props = defineProps<{
7+
class?: HTMLAttributes['class']
8+
}>()
9+
const attrs = useAttrs()
810
const classes = computed(() => cn('flex items-center gap-1', props.class))
911
</script>
1012

1113
<template>
1214
<div
13-
v-bind="{
14-
...props,
15-
class: classes,
16-
}"
15+
:class="classes"
16+
v-bind="attrs"
1717
>
1818
<slot />
1919
</div>

packages/elements/src/artifact/ArtifactClose.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
<script setup lang="ts">
2-
import type { ArtifactCloseProps } from './props'
2+
import type { ButtonVariants } from '@repo/shadcn-vue/components/ui/button'
33
import { Button } from '@repo/shadcn-vue/components/ui/button'
44
import { cn } from '@repo/shadcn-vue/lib/utils'
55
import { X } from 'lucide-vue-next'
66
import { computed } from 'vue'
77
8+
interface ArtifactCloseProps {
9+
class?: string
10+
variant?: ButtonVariants['variant']
11+
size?: ButtonVariants['size']
12+
}
13+
814
const props = withDefaults(defineProps<ArtifactCloseProps>(), {
915
variant: 'ghost',
1016
size: 'sm',

packages/elements/src/artifact/ArtifactContent.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<script setup lang="ts">
2+
import type { HTMLAttributes } from 'vue'
23
import { cn } from '@repo/shadcn-vue/lib/utils'
34
import { computed, useAttrs } from 'vue'
45
5-
interface Props {
6-
class?: string
7-
}
8-
9-
const props = defineProps<Props>()
6+
const props = defineProps<{
7+
class?: HTMLAttributes['class']
8+
}>()
109
const attrs = useAttrs()
1110
1211
const classes = computed(() => cn('flex-1 overflow-auto p-4', props.class))

packages/elements/src/artifact/ArtifactDescription.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
<script setup lang="ts">
2-
import type { ArtifactDescriptionProps } from './props'
2+
import type { HTMLAttributes } from 'vue'
33
import { cn } from '@repo/shadcn-vue/lib/utils'
4-
import { computed } from 'vue'
4+
import { computed, useAttrs } from 'vue'
55
6-
const props = defineProps<ArtifactDescriptionProps>()
6+
const props = defineProps<{
7+
class?: HTMLAttributes['class']
8+
}>()
9+
const attrs = useAttrs()
710
811
const classes = computed(() => cn('text-muted-foreground text-sm', props.class))
912
</script>
1013

1114
<template>
1215
<p
13-
v-bind="{
14-
...props,
15-
class: classes,
16-
}"
16+
:class="classes"
17+
v-bind="attrs"
1718
>
1819
<slot />
1920
</p>

packages/elements/src/artifact/ArtifactHeader.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
<script setup lang="ts">
2-
import type { ArtifactHeaderProps } from './props'
2+
import type { HTMLAttributes } from 'vue'
33
import { cn } from '@repo/shadcn-vue/lib/utils'
4-
import { computed } from 'vue'
4+
import { computed, useAttrs } from 'vue'
55
6-
const props = defineProps<ArtifactHeaderProps>()
6+
const props = defineProps<{
7+
class?: HTMLAttributes['class']
8+
}>()
79
810
const classes = computed(() => cn(
911
'flex items-center justify-between border-b bg-muted/50 px-4 py-3',
1012
props.class,
1113
))
14+
const attrs = useAttrs()
1215
</script>
1316

1417
<template>
1518
<div
1619
:class="classes"
17-
v-bind="{
18-
...props,
19-
class: classes,
20-
}"
20+
v-bind="attrs"
2121
>
2222
<slot />
2323
</div>

packages/elements/src/artifact/ArtifactTitle.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
<script setup lang="ts">
2-
import type { ArtifactTitleProps } from './props'
2+
import type { HTMLAttributes } from 'vue'
33
import { cn } from '@repo/shadcn-vue/lib/utils'
4-
import { computed } from 'vue'
4+
import { computed, useAttrs } from 'vue'
55
6-
const props = defineProps<ArtifactTitleProps>()
6+
const props = defineProps<{
7+
class?: HTMLAttributes['class']
8+
}>()
79
810
const classes = computed(() => cn('font-medium text-foreground text-sm', props.class))
11+
const attrs = useAttrs()
912
</script>
1013

1114
<template>
1215
<p
13-
v-bind="{
14-
...props,
15-
class: classes,
16-
}"
16+
v-bind="attrs"
17+
:class="classes"
1718
>
1819
<slot />
1920
</p>

0 commit comments

Comments
 (0)