Skip to content

Commit deebefc

Browse files
committed
refactor: implement tooltip with floating-ui
1 parent 2df8f77 commit deebefc

File tree

13 files changed

+128
-105
lines changed

13 files changed

+128
-105
lines changed

.changeset/strong-camels-grow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@casual-ui/vue": minor
3+
---
4+
5+
refactor: implement tooltip with floating-ui

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "packages/types"]
55
path = packages/types
66
url = https://github.com/Casual-UI/types.git
7+
[submodule "packages/utils"]
8+
path = packages/utils
9+
url = https://github.com/Casual-UI/utils.git

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"license": "MIT",
33
"devDependencies": {
4-
"@casual-ui/eslint-config-vue": "^0.0.5",
5-
"@changesets/cli": "^2.25.2",
6-
"eslint": "^8.27.0"
4+
"@casual-ui/eslint-config-vue": "^0.3.2",
5+
"@changesets/cli": "^2.26.1",
6+
"eslint": "^8.43.0"
77
},
88
"scripts": {
99
"release": "cd packages/ui && pnpm build && cd ../.. && changeset publish"

packages/docs/components/feedback/tooltip.md

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,48 +17,38 @@ componentPath: popup/CTooltip
1717

1818
```vue live
1919
<script setup>
20+
import { ref } from 'vue'
21+
const pos = ref('top-start')
2022
const positions = [
21-
'top-left',
23+
'top-start',
2224
'top',
23-
'top-right',
24-
'right-top',
25+
'top-end',
26+
'right-start',
2527
'right',
26-
'right-bottom',
27-
'bottom-left',
28+
'right-end',
29+
'bottom-start',
2830
'bottom',
29-
'bottom-right',
30-
'left-top',
31+
'bottom-end',
32+
'left-start',
3133
'left',
32-
'left-bottom',
33-
]
34+
'left-end',
35+
].map(p => ({
36+
label: p,
37+
value: p
38+
}))
3439
</script>
3540
3641
<template>
37-
<div class="tooltips">
38-
<c-tooltip
39-
v-for="p in positions"
40-
:key="p"
41-
:content="`A message rom position ${p}`"
42-
:position="p"
43-
>
44-
{{ p }}
42+
<c-radio-group
43+
:options="positions"
44+
v-model="pos"
45+
/>
46+
<div text-center py-8>
47+
<c-tooltip :position="pos" :content="`I'm tooltip content from ${pos}`">
48+
<c-button label="Hover me" />
4549
</c-tooltip>
4650
</div>
4751
</template>
48-
49-
<style scoped>
50-
.tooltips {
51-
display: grid;
52-
grid-template-columns: repeat(3, 1fr);
53-
gap: 24px;
54-
}
55-
.tooltips > div {
56-
line-height: 3em;
57-
text-align: center;
58-
background-color: var(--casual-primary);
59-
color: #eee;
60-
}
61-
</style>
6252
```
6353

6454
### Custom Content
@@ -86,9 +76,7 @@ const positions = [
8676
<style scoped>
8777
.custom-content {
8878
white-space: nowrap;
89-
background: #333;
9079
padding: 12px;
91-
color: #fff;
9280
}
9381
</style>
9482
```

packages/docs/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
"@casual-ui/styles": "latest",
1616
"@casual-ui/vue": "workspace:*",
1717
"@casual-ui/vuepress-plugin-casual-code": "workspace:*",
18-
"@iconify/json": "^2.1.77",
19-
"@quasar/extras": "^1.13.4",
18+
"@iconify/json": "^2.2.82",
19+
"@quasar/extras": "^1.16.4",
2020
"@vuepress/bundler-vite": "2.0.0-beta.51",
2121
"@vuepress/client": "2.0.0-beta.51",
2222
"@vuepress/plugin-docsearch": "2.0.0-beta.51",
2323
"@vuepress/plugin-google-analytics": "2.0.0-beta.51",
2424
"@vuepress/plugin-shiki": "2.0.0-beta.51",
2525
"ali-oss-static-web-deploy": "^0.3.4",
26-
"dayjs": "^1.11.0",
27-
"typedoc": "^0.22.15",
28-
"unocss": "^0.43.1",
29-
"vue": "^3.2.31",
30-
"vue-styleguidist": "^4.44.28",
26+
"dayjs": "^1.11.8",
27+
"typedoc": "^0.24.8",
28+
"unocss": "^0.53.3",
29+
"vue": "^3.3.4",
30+
"vue-styleguidist": "^4.72.4",
3131
"vuepress": "2.0.0-beta.51"
3232
},
3333
"scripts": {

packages/docs/vuepress.config.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/ban-ts-comment */
21
// @ts-nocheck
32
import path from 'path'
43
import { defaultTheme, defineUserConfig } from 'vuepress'
@@ -381,6 +380,9 @@ export default defineUserConfig({
381380
plugins: [
382381
Unocss({ presets: [presetIcons(), presetAttributify(), presetUno()] }),
383382
],
383+
ssr: {
384+
noExternal: ['@casual-ui/utils']
385+
}
384386
},
385387
}),
386388
})

packages/docs/zh-CN/components/feedback/tooltip.md

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,50 +17,41 @@ componentPath: popup/CTooltip
1717

1818
```vue live
1919
<script setup>
20+
import { ref } from 'vue'
21+
const pos = ref('top-start')
2022
const positions = [
21-
'top-left',
23+
'top-start',
2224
'top',
23-
'top-right',
24-
'right-top',
25+
'top-end',
26+
'right-start',
2527
'right',
26-
'right-bottom',
27-
'bottom-left',
28+
'right-end',
29+
'bottom-start',
2830
'bottom',
29-
'bottom-right',
30-
'left-top',
31+
'bottom-end',
32+
'left-start',
3133
'left',
32-
'left-bottom',
33-
]
34+
'left-end',
35+
].map(p => ({
36+
label: p,
37+
value: p
38+
}))
3439
</script>
3540
3641
<template>
37-
<div class="tooltips">
38-
<c-tooltip
39-
v-for="p in positions"
40-
:key="p"
41-
:content="`来自于位置${p}的tooltip信息`"
42-
:position="p"
43-
>
44-
{{ p }}
42+
<c-radio-group
43+
:options="positions"
44+
v-model="pos"
45+
/>
46+
<div text-center py-8>
47+
<c-tooltip :position="pos" :content="`我是一个来自于 ${pos} 位置的提示`">
48+
<c-button label="Hover me" />
4549
</c-tooltip>
4650
</div>
4751
</template>
48-
49-
<style scoped>
50-
.tooltips {
51-
display: grid;
52-
grid-template-columns: repeat(3, 1fr);
53-
gap: 24px;
54-
}
55-
.tooltips > div {
56-
line-height: 3em;
57-
text-align: center;
58-
background-color: var(--casual-primary);
59-
color: #eee;
60-
}
61-
</style>
6252
```
6353

54+
6455
### 自定义内容
6556

6657
```vue live

packages/ui/package.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,24 @@
3030
"vue": "^3.2.31"
3131
},
3232
"devDependencies": {
33-
"@types/node": "^18.11.17",
34-
"@vitejs/plugin-vue": "^4.0.0",
35-
"@vue/tsconfig": "^0.1.3",
36-
"sass": "^1.52.1",
37-
"typescript": "^4.9.3",
38-
"vite": "^4.0.2",
33+
"@types/node": "^20.3.1",
34+
"@vitejs/plugin-vue": "^4.2.3",
35+
"@vue/tsconfig": "^0.4.0",
36+
"sass": "^1.63.6",
37+
"typescript": "^5.1.3",
38+
"vite": "^4.3.9",
3939
"vite-plugin-vue-auto-name": "latest",
40-
"vue": "^3.2.31",
41-
"vue-tsc": "^1.0.16"
40+
"vue": "^3.3.4",
41+
"vue-tsc": "^1.8.1"
4242
},
4343
"dependencies": {
4444
"@casual-ui/i18n": "^0.1.7",
4545
"@casual-ui/styles": "workspace:*",
4646
"@casual-ui/types": "workspace:*",
4747
"@casual-ui/vue": "workspace:*",
48-
"@quasar/extras": "^1.13.4",
49-
"dayjs": "^1.11.0"
48+
"@casual-ui/utils": "workspace:*",
49+
"@quasar/extras": "^1.16.4",
50+
"dayjs": "^1.11.8"
5051
},
5152
"publishConfig": {
5253
"main": "./dist/casual-ui-vue.umd.js",

0 commit comments

Comments
 (0)