Thomas G. Lopes
commited on
Commit
·
c1646a5
1
Parent(s):
f77d645
improve tooltip
Browse files- package.json +2 -1
- pnpm-lock.yaml +8 -5
- src/lib/components/tooltip.svelte +11 -3
package.json
CHANGED
@@ -16,6 +16,7 @@
|
|
16 |
"devDependencies": {
|
17 |
"@eslint/eslintrc": "^3.3.0",
|
18 |
"@eslint/js": "^9.22.0",
|
|
|
19 |
"@huggingface/hub": "^1.0.1",
|
20 |
"@huggingface/inference": "^3.5.1",
|
21 |
"@huggingface/tasks": "^0.17.1",
|
@@ -36,7 +37,7 @@
|
|
36 |
"globals": "^16.0.0",
|
37 |
"highlight.js": "^11.10.0",
|
38 |
"jiti": "^2.4.2",
|
39 |
-
"melt": "^0.
|
40 |
"postcss": "^8.4.38",
|
41 |
"prettier": "^3.1.1",
|
42 |
"prettier-plugin-svelte": "^3.2.6",
|
|
|
16 |
"devDependencies": {
|
17 |
"@eslint/eslintrc": "^3.3.0",
|
18 |
"@eslint/js": "^9.22.0",
|
19 |
+
"@floating-ui/dom": "^1.6.13",
|
20 |
"@huggingface/hub": "^1.0.1",
|
21 |
"@huggingface/inference": "^3.5.1",
|
22 |
"@huggingface/tasks": "^0.17.1",
|
|
|
37 |
"globals": "^16.0.0",
|
38 |
"highlight.js": "^11.10.0",
|
39 |
"jiti": "^2.4.2",
|
40 |
+
"melt": "^0.20.2",
|
41 |
"postcss": "^8.4.38",
|
42 |
"prettier": "^3.1.1",
|
43 |
"prettier-plugin-svelte": "^3.2.6",
|
pnpm-lock.yaml
CHANGED
@@ -21,6 +21,9 @@ importers:
|
|
21 |
'@eslint/js':
|
22 |
specifier: ^9.22.0
|
23 |
version: 9.22.0
|
|
|
|
|
|
|
24 |
'@huggingface/hub':
|
25 |
specifier: ^1.0.1
|
26 |
version: 1.0.1
|
@@ -82,8 +85,8 @@ importers:
|
|
82 |
specifier: ^2.4.2
|
83 |
version: 2.4.2
|
84 |
melt:
|
85 |
-
specifier: ^0.
|
86 |
-
version: 0.
|
87 |
postcss:
|
88 |
specifier: ^8.4.38
|
89 |
version: 8.5.3
|
@@ -1545,8 +1548,8 @@ packages:
|
|
1545 | |
1546 |
resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==}
|
1547 |
|
1548 |
-
melt@0.
|
1549 |
-
resolution: {integrity: sha512-
|
1550 |
peerDependencies:
|
1551 |
'@floating-ui/dom': ^1.6.0
|
1552 |
svelte: ^5.0.0
|
@@ -3471,7 +3474,7 @@ snapshots:
|
|
3471 |
dependencies:
|
3472 |
'@jridgewell/sourcemap-codec': 1.5.0
|
3473 |
|
3474 |
-
melt@0.
|
3475 |
dependencies:
|
3476 |
'@floating-ui/dom': 1.6.13
|
3477 |
jest-axe: 9.0.0
|
|
|
21 |
'@eslint/js':
|
22 |
specifier: ^9.22.0
|
23 |
version: 9.22.0
|
24 |
+
'@floating-ui/dom':
|
25 |
+
specifier: ^1.6.13
|
26 |
+
version: 1.6.13
|
27 |
'@huggingface/hub':
|
28 |
specifier: ^1.0.1
|
29 |
version: 1.0.1
|
|
|
85 |
specifier: ^2.4.2
|
86 |
version: 2.4.2
|
87 |
melt:
|
88 |
+
specifier: ^0.20.2
|
89 |
+
version: 0.20.2(@floating-ui/[email protected])([email protected])
|
90 |
postcss:
|
91 |
specifier: ^8.4.38
|
92 |
version: 8.5.3
|
|
|
1548 | |
1549 |
resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==}
|
1550 |
|
1551 |
+
melt@0.20.2:
|
1552 |
+
resolution: {integrity: sha512-vINBKFVqFN8LVU6K7AbEwlGTOzSi5BQulxhKkIroxPWnCA3LVsQEIDZabtf9TtnzFa/th0Rm8J0N+hW1v7VJDw==}
|
1553 |
peerDependencies:
|
1554 |
'@floating-ui/dom': ^1.6.0
|
1555 |
svelte: ^5.0.0
|
|
|
3474 |
dependencies:
|
3475 |
'@jridgewell/sourcemap-codec': 1.5.0
|
3476 |
|
3477 |
+
melt@0.20.2(@floating-ui/[email protected])([email protected]):
|
3478 |
dependencies:
|
3479 |
'@floating-ui/dom': 1.6.13
|
3480 |
jest-axe: 9.0.0
|
src/lib/components/tooltip.svelte
CHANGED
@@ -1,19 +1,27 @@
|
|
1 |
<script lang="ts">
|
2 |
-
import { Tooltip, type TooltipProps } from "melt/builders";
|
3 |
import { type ComponentProps, type Extracted } from "melt";
|
|
|
4 |
import type { Snippet } from "svelte";
|
5 |
|
|
|
|
|
6 |
interface Props {
|
7 |
children: Snippet;
|
8 |
trigger: Snippet<[Tooltip]>;
|
9 |
-
placement?: NonNullable<
|
10 |
openDelay?: ComponentProps<TooltipProps>["openDelay"];
|
11 |
}
|
12 |
const { children, trigger, placement = "top", openDelay = 500 }: Props = $props();
|
13 |
|
14 |
const tooltip = new Tooltip({
|
15 |
forceVisible: true,
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
openDelay: () => openDelay,
|
18 |
});
|
19 |
</script>
|
|
|
1 |
<script lang="ts">
|
|
|
2 |
import { type ComponentProps, type Extracted } from "melt";
|
3 |
+
import { Tooltip, type TooltipProps } from "melt/builders";
|
4 |
import type { Snippet } from "svelte";
|
5 |
|
6 |
+
type FloatingConfig = NonNullable<Extracted<TooltipProps["floatingConfig"]>>;
|
7 |
+
|
8 |
interface Props {
|
9 |
children: Snippet;
|
10 |
trigger: Snippet<[Tooltip]>;
|
11 |
+
placement?: NonNullable<FloatingConfig["computePosition"]>["placement"];
|
12 |
openDelay?: ComponentProps<TooltipProps>["openDelay"];
|
13 |
}
|
14 |
const { children, trigger, placement = "top", openDelay = 500 }: Props = $props();
|
15 |
|
16 |
const tooltip = new Tooltip({
|
17 |
forceVisible: true,
|
18 |
+
floatingConfig: () => ({
|
19 |
+
computePosition: { placement },
|
20 |
+
flip: {
|
21 |
+
fallbackPlacements: ["bottom"],
|
22 |
+
padding: 10,
|
23 |
+
},
|
24 |
+
}),
|
25 |
openDelay: () => openDelay,
|
26 |
});
|
27 |
</script>
|