fix: new-york demos are using the incorrect icon library
This commit is contained in:
parent
454ecf0df7
commit
c5df2cb2cc
|
|
@ -4,7 +4,7 @@ import { Icon } from '@iconify/vue'
|
||||||
import { makeCodeSandboxParams } from '../utils/codeeditor'
|
import { makeCodeSandboxParams } from '../utils/codeeditor'
|
||||||
import Tooltip from './Tooltip.vue'
|
import Tooltip from './Tooltip.vue'
|
||||||
import { Button } from '@/lib/registry/new-york/ui/button'
|
import { Button } from '@/lib/registry/new-york/ui/button'
|
||||||
import { type Style } from '@/lib/registry/styles'
|
import type { Style } from '@/lib/registry/styles'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
name: string
|
name: string
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { computed, onMounted } from 'vue'
|
||||||
import StyleSwitcher from './StyleSwitcher.vue'
|
import StyleSwitcher from './StyleSwitcher.vue'
|
||||||
import ComponentLoader from './ComponentLoader.vue'
|
import ComponentLoader from './ComponentLoader.vue'
|
||||||
import Stackblitz from './Stackblitz.vue'
|
import Stackblitz from './Stackblitz.vue'
|
||||||
|
|
@ -11,14 +12,24 @@ defineOptions({
|
||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
name: string
|
name: string
|
||||||
align?: 'center' | 'start' | 'end'
|
align?: 'center' | 'start' | 'end'
|
||||||
sfcTsCode?: string
|
sfcTsCode?: string
|
||||||
sfcTsHtml?: string
|
sfcTsHtml?: string
|
||||||
|
sfcTsCodeNewYork?: string
|
||||||
|
sfcTsHtmlNewYork?: string
|
||||||
}>(), { align: 'center' })
|
}>(), { align: 'center' })
|
||||||
|
|
||||||
const { style } = useConfigStore()
|
const { style } = useConfigStore()
|
||||||
|
|
||||||
|
const sfcTsCodeComputed = computed(() => {
|
||||||
|
return style.value === 'default' ? decodeURIComponent(props.sfcTsCode ?? '') : decodeURIComponent(props.sfcTsCodeNewYork ?? '')
|
||||||
|
})
|
||||||
|
|
||||||
|
const sfcTsHtmlComputed = computed(() => {
|
||||||
|
return style.value === 'default' ? decodeURIComponent(props.sfcTsHtml ?? '') : decodeURIComponent(props.sfcTsHtmlNewYork ?? '')
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -47,8 +58,8 @@ const { style } = useConfigStore()
|
||||||
<StyleSwitcher />
|
<StyleSwitcher />
|
||||||
|
|
||||||
<div class="flex items-center gap-x-1">
|
<div class="flex items-center gap-x-1">
|
||||||
<Stackblitz :key="style" :style="style" :name="name" :code="decodeURIComponent(sfcTsCode ?? '')" />
|
<Stackblitz :key="style" :style="style" :name="name" :code="sfcTsCodeComputed" />
|
||||||
<CodeSandbox :key="style" :style="style" :name="name" :code="decodeURIComponent(sfcTsCode ?? '')" />
|
<CodeSandbox :key="style" :style="style" :name="name" :code="sfcTsCodeComputed" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|
@ -62,7 +73,7 @@ const { style } = useConfigStore()
|
||||||
</div>
|
</div>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
<TabsContent value="code">
|
<TabsContent value="code">
|
||||||
<div v-if="sfcTsHtml" class="language-vue" style="flex: 1;" v-html="decodeURIComponent(sfcTsHtml)" />
|
<div v-if="sfcTsHtml" class="language-vue" style="flex: 1;" v-html="sfcTsHtmlComputed" />
|
||||||
<slot v-else />
|
<slot v-else />
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { Icon } from '@iconify/vue'
|
||||||
import { makeStackblitzParams } from '../utils/codeeditor'
|
import { makeStackblitzParams } from '../utils/codeeditor'
|
||||||
import Tooltip from './Tooltip.vue'
|
import Tooltip from './Tooltip.vue'
|
||||||
import { Button } from '@/lib/registry/new-york/ui/button'
|
import { Button } from '@/lib/registry/new-york/ui/button'
|
||||||
import { type Style } from '@/lib/registry/styles'
|
import type { Style } from '@/lib/registry/styles'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
name: string
|
name: string
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ const props = withDefaults(defineProps<{
|
||||||
align?: 'center' | 'start' | 'end'
|
align?: 'center' | 'start' | 'end'
|
||||||
sfcTsCode?: string
|
sfcTsCode?: string
|
||||||
sfcTsHtml?: string
|
sfcTsHtml?: string
|
||||||
|
sfcTsCodeNewYork?: string
|
||||||
|
sfcTsHtmlNewYork?: string
|
||||||
}>(), {
|
}>(), {
|
||||||
align: 'center',
|
align: 'center',
|
||||||
names: () => ['CLI', 'Manual'],
|
names: () => ['CLI', 'Manual'],
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,16 @@ export default function (md: MarkdownRenderer) {
|
||||||
const { name, attrs } = props
|
const { name, attrs } = props
|
||||||
const pluginPath = dirname(__dirname)
|
const pluginPath = dirname(__dirname)
|
||||||
const srcPath = resolve(pluginPath, '../../src/lib/registry/default/example/', `${name}.vue`).replace(/\\/g, '/')
|
const srcPath = resolve(pluginPath, '../../src/lib/registry/default/example/', `${name}.vue`).replace(/\\/g, '/')
|
||||||
|
const srcPathNewYork = resolve(pluginPath, '../../src/lib/registry/new-york/example/', `${name}.vue`).replace(/\\/g, '/')
|
||||||
|
|
||||||
if (!fs.existsSync(srcPath)) {
|
if (!fs.existsSync(srcPath)) {
|
||||||
console.error(`rendering ${path}: ${srcPath} does not exist`)
|
console.error(`rendering ${path}: ${srcPath} does not exist`)
|
||||||
return defaultRender!(tokens, idx, options, env, self)
|
return defaultRender!(tokens, idx, options, env, self)
|
||||||
}
|
}
|
||||||
|
if (!fs.existsSync(srcPathNewYork)) {
|
||||||
|
console.error(`rendering ${path}: ${srcPathNewYork} does not exist`)
|
||||||
|
return defaultRender!(tokens, idx, options, env, self)
|
||||||
|
}
|
||||||
|
|
||||||
let code = fs.readFileSync(srcPath, 'utf-8')
|
let code = fs.readFileSync(srcPath, 'utf-8')
|
||||||
code = code.replaceAll(
|
code = code.replaceAll(
|
||||||
|
|
@ -30,10 +35,17 @@ export default function (md: MarkdownRenderer) {
|
||||||
'@/components/',
|
'@/components/',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
let codeNewYork = fs.readFileSync(srcPathNewYork, 'utf-8')
|
||||||
|
codeNewYork = codeNewYork.replaceAll(
|
||||||
|
'@/lib/registry/default/',
|
||||||
|
'@/components/',
|
||||||
|
)
|
||||||
|
|
||||||
const demoScripts = generateDemoComponent(md, env, {
|
const demoScripts = generateDemoComponent(md, env, {
|
||||||
attrs,
|
attrs,
|
||||||
props,
|
props,
|
||||||
code,
|
code,
|
||||||
|
codeNewYork,
|
||||||
path: srcPath,
|
path: srcPath,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,19 +9,24 @@ export interface GenerateOptions {
|
||||||
props: Record<string, any>
|
props: Record<string, any>
|
||||||
path: string
|
path: string
|
||||||
code: string
|
code: string
|
||||||
|
codeNewYork: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function parse(
|
export function parse(
|
||||||
md: MarkdownRenderer,
|
md: MarkdownRenderer,
|
||||||
env: MarkdownEnv,
|
env: MarkdownEnv,
|
||||||
{ code, attrs: _attrs, props }: GenerateOptions,
|
{ code, codeNewYork, attrs: _attrs, props }: GenerateOptions,
|
||||||
) {
|
) {
|
||||||
const highlightedHtml = md.options.highlight!(code, 'vue', _attrs || '')
|
const highlightedHtml = md.options.highlight!(code, 'vue', _attrs || '')
|
||||||
|
const highlightedNewYorkHtml = md.options.highlight!(codeNewYork, 'vue', _attrs || '')
|
||||||
const sfcTsHtml = highlightedHtml
|
const sfcTsHtml = highlightedHtml
|
||||||
|
const sfcTsHtmlNewYork = highlightedNewYorkHtml
|
||||||
|
|
||||||
const attrs
|
const attrs
|
||||||
= `sfcTsCode="${encodeURIComponent(code)}"\n`
|
= `sfcTsCode="${encodeURIComponent(code)}"\n`
|
||||||
+ `sfcTsHtml="${encodeURIComponent(sfcTsHtml)}"\n`
|
+ `sfcTsHtml="${encodeURIComponent(sfcTsHtml)}"\n`
|
||||||
|
+ `sfcTsCodeNewYork="${encodeURIComponent(codeNewYork)}"\n`
|
||||||
|
+ `sfcTsHtmlNewYork="${encodeURIComponent(sfcTsHtmlNewYork)}"\n`
|
||||||
+ `v-bind='${JSON.stringify(props)}'\n`
|
+ `v-bind='${JSON.stringify(props)}'\n`
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -29,6 +34,8 @@ export function parse(
|
||||||
highlightedHtml,
|
highlightedHtml,
|
||||||
sfcTsCode: code,
|
sfcTsCode: code,
|
||||||
sfcTsHtml,
|
sfcTsHtml,
|
||||||
|
sfcTsCodeNewYork: codeNewYork,
|
||||||
|
sfcTsHtmlNewYork,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { MagnifyingGlassIcon } from '@radix-icons/vue'
|
import { Search } from 'lucide-vue-next'
|
||||||
import { Input } from '@/lib/registry/default/ui/input'
|
import { Input } from '@/lib/registry/default/ui/input'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -7,7 +7,7 @@ import { Input } from '@/lib/registry/default/ui/input'
|
||||||
<div class="relative w-full max-w-sm items-center">
|
<div class="relative w-full max-w-sm items-center">
|
||||||
<Input id="search" type="text" placeholder="Search..." class="pl-10" />
|
<Input id="search" type="text" placeholder="Search..." class="pl-10" />
|
||||||
<span class="absolute start-0 inset-y-0 flex items-center justify-center px-2">
|
<span class="absolute start-0 inset-y-0 flex items-center justify-center px-2">
|
||||||
<MagnifyingGlassIcon class="size-6 text-muted-foreground" />
|
<Search class="size-6 text-muted-foreground" />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { Minus, Plus } from 'lucide-vue-next'
|
import { MinusIcon, PlusIcon } from '@radix-icons/vue'
|
||||||
import { VisStackedBar, VisXYContainer } from '@unovis/vue'
|
import { VisStackedBar, VisXYContainer } from '@unovis/vue'
|
||||||
import { Button } from '@/lib/registry/new-york/ui/button'
|
import { Button } from '@/lib/registry/new-york/ui/button'
|
||||||
import {
|
import {
|
||||||
|
|
@ -56,7 +56,7 @@ const data = [
|
||||||
:disabled="goal <= 200"
|
:disabled="goal <= 200"
|
||||||
@click="goal -= 10"
|
@click="goal -= 10"
|
||||||
>
|
>
|
||||||
<Minus class="h-4 w-4" />
|
<MinusIcon class="h-4 w-4" />
|
||||||
<span class="sr-only">Decrease</span>
|
<span class="sr-only">Decrease</span>
|
||||||
</Button>
|
</Button>
|
||||||
<div class="flex-1 text-center">
|
<div class="flex-1 text-center">
|
||||||
|
|
@ -74,7 +74,7 @@ const data = [
|
||||||
:disabled="goal >= 400"
|
:disabled="goal >= 400"
|
||||||
@click="goal += 10"
|
@click="goal += 10"
|
||||||
>
|
>
|
||||||
<Plus class="h-4 w-4" />
|
<PlusIcon class="h-4 w-4" />
|
||||||
<span class="sr-only">Increase</span>
|
<span class="sr-only">Increase</span>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user