Skip to content

Commit e233b3c

Browse files
committed
fix: Error when bundling in the docs workspace.
resolve #7
1 parent a24beee commit e233b3c

File tree

6 files changed

+106
-60
lines changed

6 files changed

+106
-60
lines changed

docs/.vitepress/config.ts

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,65 @@
1-
import { defineConfig } from 'vitepress'
1+
import { defineConfig } from "vitepress";
22

33
// https://vitepress.dev/reference/site-config
44
export default defineConfig({
5-
title: 'NextUI Vue',
6-
description: '基于NextUI Theme构建的Vue组件库',
7-
head: [
8-
['link', { rel: 'icon', href: '/logo.png' }],
9-
],
5+
title: "NextUI Vue",
6+
description: "基于NextUI Theme构建的Vue组件库",
7+
head: [["link", { rel: "icon", href: "/logo.png" }]],
8+
ignoreDeadLinks: true,
109

1110
themeConfig: {
12-
logo: '/logo.png',
11+
logo: "/logo.png",
1312
search: {
14-
provider: 'local',
13+
provider: "local",
1514
},
16-
outline: 'deep',
15+
outline: "deep",
1716
nav: [
18-
{ text: '首页', link: '/' },
19-
{ text: '组件', link: '/markdown-examples' },
17+
{ text: "首页", link: "/" },
18+
{ text: "组件", link: "/markdown-examples" },
2019
{
21-
text: '相关链接',
20+
text: "相关链接",
2221
items: [
2322
{
24-
text: 'NextUI',
25-
link: 'https://nextui.org/',
23+
text: "NextUI",
24+
link: "https://nextui.org/",
2625
},
2726
{
28-
text: 'Radix Vue',
29-
link: 'https://www.radix-vue.com/',
27+
text: "Radix Vue",
28+
link: "https://www.radix-vue.com/",
3029
},
3130
{
32-
text: 'IKUNUI',
33-
link: 'https://laine001.github.io/ikun-ui/',
31+
text: "IKUNUI",
32+
link: "https://laine001.github.io/ikun-ui/",
3433
},
3534
],
3635
},
3736
],
3837

3938
sidebar: [
4039
{
41-
text: '起步',
40+
text: "起步",
4241
items: [
43-
{ text: '安装', link: '/guide/installation' },
44-
{ text: '配置', link: '/guide/configuration' },
42+
{ text: "安装", link: "/guide/installation" },
43+
{ text: "配置", link: "/guide/configuration" },
4544
],
4645
},
4746
{
48-
text: '组件',
47+
text: "组件",
4948
collapsed: true,
5049
items: [
51-
{ text: '按钮', link: '/components/button' },
52-
{ text: 'alert', link: '/components/alert' },
50+
{ text: "按钮", link: "/components/button" },
51+
{ text: "alert", link: "/components/alert" },
5352
],
5453
},
5554
],
5655

5756
socialLinks: [
58-
{ icon: 'github', link: 'https://github.com/hotdogc1017/nextui-vue' },
57+
{ icon: "github", link: "https://github.com/hotdogc1017/nextui-vue" },
5958
],
6059

6160
footer: {
62-
message: 'MIT Licensed',
63-
copyright: '©hotdogc1017',
61+
message: "MIT Licensed",
62+
copyright: "©hotdogc1017",
6463
},
6564
},
66-
})
65+
});

docs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"private": true,
66
"packageManager": "pnpm@9.0.0",
77
"scripts": {
8-
"dev": "vitepress dev"
8+
"dev": "vitepress dev",
9+
"build": "vitepress build"
910
},
1011
"devDependencies": {
1112
"@heroui/theme": "^2.4.6",

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"dev": "pnpm --filter \"./packages/components/*\" run dev",
99
"doc": "pnpm run -C docs dev",
1010
"build": "pnpm -r build",
11+
"build:doc": "pnpm -C docs build",
1112
"clean": "rimraf -g node_modules */node_modules **/node_modules **/dist",
1213
"lint": "eslint . --cache",
1314
"lint:fix": "eslint . --cache --fix",

packages/components/shared/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@vueuse/core": "^11.2.0"
3333
},
3434
"devDependencies": {
35-
"@vue/tsconfig": "^0.5.1"
35+
"@vue/tsconfig": "^0.5.1",
36+
"vue": "^3.5.13"
3637
}
3738
}
Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import { useEventListener, type MaybeRefOrGetter } from "@vueuse/core";
1+
import { onBeforeMount, ref } from 'vue'
2+
import { type MaybeRefOrGetter, useEventListener } from '@vueuse/core'
23

3-
const rippleElement = document.createElement('span')
4+
const rippleElement = ref()
45

56
function setCSSStyle(el: HTMLElement, style: CSSStyleDeclaration) {
67
for (const [key, value] of Object.entries(style)) {
7-
// @ts-ignore
8-
el.style[key] = value
8+
el.style[key as any] = value
99
}
1010
}
1111

1212
function ripple(event: MouseEvent) {
13-
const target = event.currentTarget as HTMLElement;
13+
const target = event.currentTarget as HTMLElement
1414
const { x, y, width, height } = target.getBoundingClientRect()
1515
const { clientX, clientY } = event
1616

17-
const newElement = rippleElement.cloneNode() as HTMLSpanElement
17+
const newElement = rippleElement.value?.cloneNode() as HTMLSpanElement
1818
const style = {
19-
position:'absolute',
19+
position: 'absolute',
2020
left: `${clientX - x}px`,
21-
top:`${clientY - y}px`,
21+
top: `${clientY - y}px`,
2222
borderRadius: '50%',
2323
background: 'white',
2424
transform: `translate(-50%, -50%)`,
@@ -28,23 +28,31 @@ function ripple(event: MouseEvent) {
2828
setCSSStyle(newElement, style)
2929

3030
const radius = Math.round(Math.hypot(width, height)) * 2
31-
const animate = newElement.animate({
32-
opacity: [0.5, 0],
33-
width: ['0', `${radius}px`],
34-
height: ['0', `${radius}px`],
35-
}, {
36-
duration: 400,
37-
easing: 'ease-in',
38-
fill: 'forwards',
39-
})
31+
const animate = newElement.animate(
32+
{
33+
opacity: [0.5, 0],
34+
width: ['0', `${radius}px`],
35+
height: ['0', `${radius}px`],
36+
},
37+
{
38+
duration: 400,
39+
easing: 'ease-in',
40+
fill: 'forwards',
41+
},
42+
)
4043
animate.addEventListener('finish', () => {
4144
target.removeChild(newElement)
4245
})
4346
target.appendChild(newElement)
4447
}
4548

46-
export function useRipple(target: MaybeRefOrGetter<HTMLElement | null | undefined>) {
47-
useEventListener(target, 'click', ripple);
49+
export function useRipple(
50+
target: MaybeRefOrGetter<HTMLElement | null | undefined>,
51+
) {
52+
onBeforeMount(() => {
53+
rippleElement.value = document.createElement('span')
54+
})
55+
useEventListener(target, 'click', ripple)
4856
}
4957

5058
export default useRipple

pnpm-lock.yaml

Lines changed: 47 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)