Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions apps/test/app/examples/code-block.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { CodeBlock } from '@repo/elements/code-block'
import { CodeBlock, CodeBlockCopyButton } from '@repo/elements/code-block'

const code = `<template>
<div>
Expand All @@ -15,8 +15,22 @@ interface Props {

defineProps<Props>()
<\/script>`

function handleCopy() {
// eslint-disable-next-line no-console
console.log('Copied code to clipboard')
}

function handleError(error: Error) {
console.error('Failed to copy code to clipboard', error)
}
</script>

<template>
<CodeBlock :code="code" lang="vue" />
<CodeBlock :code="code" language="vue">
<CodeBlockCopyButton
@copy="handleCopy"
@error="handleError"
/>
</CodeBlock>
</template>
9 changes: 8 additions & 1 deletion apps/www/assets/css/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,11 @@
}
}


@layer components {
/* Override shadcn-docs-nuxt's .shiki code span.line styles
to prevent conflicts with code-block component preview */
.docs-component-preview .shiki code span.line {
min-height: 0 !important;
line-height: 0 !important;
}
}
4 changes: 3 additions & 1 deletion apps/www/components/ComponentViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ defineProps<Props>()
<ClientOnly>
<Suspense>
<template #default>
<component :is="componentName" />
<div class="docs-component-preview">
<component :is="componentName" />
</div>
</template>
<template #fallback>
<div class="p-4" />
Expand Down
3 changes: 3 additions & 0 deletions apps/www/content/1.overview/1.Introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,7 @@ You can install it with:
:::ComponentLoader{label="InlineCitation" componentName="InlineCitation"}
:::

:::ComponentLoader{label="CodeBlock" componentName="CodeBlock"}
:::

View the [source code](https://github.com/cwandev/ai-elements-vue) for all components on GitHub.
Loading