Upload folder using huggingface_hub
Browse files- 5.49.1/tooltip/package.json +26 -0
- 5.49.1/tooltip/src/Tooltip.svelte +42 -0
- 5.49.1/tooltip/src/index.ts +1 -0
- 5.49.1/tooltip/src/tooltip.ts +49 -0
5.49.1/tooltip/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/tooltip",
|
| 3 |
+
"version": "0.1.2",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"main": "src/index.ts",
|
| 7 |
+
"author": "",
|
| 8 |
+
"license": "ISC",
|
| 9 |
+
"main_changeset": true,
|
| 10 |
+
"repository": {
|
| 11 |
+
"type": "git",
|
| 12 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 13 |
+
"directory": "js/tooltip"
|
| 14 |
+
},
|
| 15 |
+
"peerDependencies": {
|
| 16 |
+
"svelte": "^4.0.0"
|
| 17 |
+
},
|
| 18 |
+
"exports": {
|
| 19 |
+
".": {
|
| 20 |
+
"gradio": "./src/index.js",
|
| 21 |
+
"svelte": "./dist/src/index.js",
|
| 22 |
+
"types": "./dist/src/index.d.ts"
|
| 23 |
+
},
|
| 24 |
+
"./package.json": "./package.json"
|
| 25 |
+
}
|
| 26 |
+
}
|
5.49.1/tooltip/src/Tooltip.svelte
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
export let text: string;
|
| 3 |
+
export let x: number;
|
| 4 |
+
export let y: number;
|
| 5 |
+
export let color: string;
|
| 6 |
+
|
| 7 |
+
let w: number;
|
| 8 |
+
let h: number;
|
| 9 |
+
</script>
|
| 10 |
+
|
| 11 |
+
<div
|
| 12 |
+
bind:offsetWidth={w}
|
| 13 |
+
bind:offsetHeight={h}
|
| 14 |
+
style="
|
| 15 |
+
top: {y - h / 2}px;
|
| 16 |
+
left: {x - w - 7}px;"
|
| 17 |
+
>
|
| 18 |
+
<span style="background: {color}" />
|
| 19 |
+
{text}
|
| 20 |
+
</div>
|
| 21 |
+
|
| 22 |
+
<style>
|
| 23 |
+
div {
|
| 24 |
+
display: flex;
|
| 25 |
+
position: absolute;
|
| 26 |
+
justify-content: center;
|
| 27 |
+
align-items: center;
|
| 28 |
+
border-radius: var(--radius-sm);
|
| 29 |
+
background-color: rgba(0, 0, 0, 0.8);
|
| 30 |
+
padding: var(--size-1) 0.4rem;
|
| 31 |
+
color: white;
|
| 32 |
+
font-size: var(--text-sm);
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
span {
|
| 36 |
+
display: inline-block;
|
| 37 |
+
margin-right: var(--size-1);
|
| 38 |
+
border-radius: var(--radius-xs);
|
| 39 |
+
width: var(--size-3);
|
| 40 |
+
height: var(--size-3);
|
| 41 |
+
}
|
| 42 |
+
</style>
|
5.49.1/tooltip/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
export { tooltip } from "./tooltip";
|
5.49.1/tooltip/src/tooltip.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Tooltip from "./Tooltip.svelte";
|
| 2 |
+
|
| 3 |
+
interface ActionArgs {
|
| 4 |
+
color: string;
|
| 5 |
+
text: string;
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
export function tooltip(
|
| 9 |
+
element: HTMLElement | SVGElement,
|
| 10 |
+
{ color, text }: ActionArgs
|
| 11 |
+
): any {
|
| 12 |
+
let tooltipComponent: Tooltip;
|
| 13 |
+
function mouse_over(event: MouseEvent): MouseEvent {
|
| 14 |
+
tooltipComponent = new Tooltip({
|
| 15 |
+
props: {
|
| 16 |
+
text,
|
| 17 |
+
x: event.pageX,
|
| 18 |
+
y: event.pageY,
|
| 19 |
+
color
|
| 20 |
+
},
|
| 21 |
+
target: document.body
|
| 22 |
+
});
|
| 23 |
+
|
| 24 |
+
return event;
|
| 25 |
+
}
|
| 26 |
+
function mouseMove(event: MouseEvent): void {
|
| 27 |
+
tooltipComponent.$set({
|
| 28 |
+
x: event.pageX,
|
| 29 |
+
y: event.pageY
|
| 30 |
+
});
|
| 31 |
+
}
|
| 32 |
+
function mouseLeave(): void {
|
| 33 |
+
tooltipComponent.$destroy();
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
const el = element as HTMLElement;
|
| 37 |
+
|
| 38 |
+
el.addEventListener("mouseover", mouse_over);
|
| 39 |
+
el.addEventListener("mouseleave", mouseLeave);
|
| 40 |
+
el.addEventListener("mousemove", mouseMove);
|
| 41 |
+
|
| 42 |
+
return {
|
| 43 |
+
destroy() {
|
| 44 |
+
el.removeEventListener("mouseover", mouse_over);
|
| 45 |
+
el.removeEventListener("mouseleave", mouseLeave);
|
| 46 |
+
el.removeEventListener("mousemove", mouseMove);
|
| 47 |
+
}
|
| 48 |
+
};
|
| 49 |
+
}
|