Upload folder using huggingface_hub
Browse files- 6.0.0/sidebar/Index.svelte +32 -0
- 6.0.0/sidebar/package.json +34 -0
- 6.0.0/sidebar/shared/Sidebar.svelte +253 -0
- 6.0.0/sidebar/types.ts +11 -0
6.0.0/sidebar/Index.svelte
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import type { SidebarProps, SidebarEvents } from "./types";
|
| 3 |
+
import { Gradio } from "@gradio/utils";
|
| 4 |
+
import Sidebar from "./shared/Sidebar.svelte";
|
| 5 |
+
import { StatusTracker } from "@gradio/statustracker";
|
| 6 |
+
import { BaseColumn } from "@gradio/column";
|
| 7 |
+
|
| 8 |
+
const props = $props();
|
| 9 |
+
const gradio = new Gradio<SidebarEvents, SidebarProps>(props);
|
| 10 |
+
</script>
|
| 11 |
+
|
| 12 |
+
<StatusTracker
|
| 13 |
+
autoscroll={gradio.shared.autoscroll}
|
| 14 |
+
i18n={gradio.i18n}
|
| 15 |
+
{...gradio.shared.loading_status}
|
| 16 |
+
/>
|
| 17 |
+
|
| 18 |
+
{#if gradio.shared.visible}
|
| 19 |
+
<Sidebar
|
| 20 |
+
bind:open={gradio.props.open}
|
| 21 |
+
bind:position={gradio.props.position}
|
| 22 |
+
width={gradio.props.width}
|
| 23 |
+
on:expand={() => gradio.dispatch("expand")}
|
| 24 |
+
on:collapse={() => gradio.dispatch("collapse")}
|
| 25 |
+
elem_classes={gradio.shared.elem_classes}
|
| 26 |
+
elem_id={gradio.shared.elem_id}
|
| 27 |
+
>
|
| 28 |
+
<BaseColumn>
|
| 29 |
+
<slot />
|
| 30 |
+
</BaseColumn>
|
| 31 |
+
</Sidebar>
|
| 32 |
+
{/if}
|
6.0.0/sidebar/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"name": "@gradio/sidebar",
|
| 3 |
+
"version": "0.1.24",
|
| 4 |
+
"description": "Gradio UI packages",
|
| 5 |
+
"type": "module",
|
| 6 |
+
"author": "",
|
| 7 |
+
"license": "ISC",
|
| 8 |
+
"main_changeset": true,
|
| 9 |
+
"dependencies": {
|
| 10 |
+
"@gradio/atoms": "workspace:^",
|
| 11 |
+
"@gradio/column": "workspace:^",
|
| 12 |
+
"@gradio/statustracker": "workspace:^",
|
| 13 |
+
"@gradio/utils": "workspace:^"
|
| 14 |
+
},
|
| 15 |
+
"peerDependencies": {
|
| 16 |
+
"svelte": "^5.43.4"
|
| 17 |
+
},
|
| 18 |
+
"devDependencies": {
|
| 19 |
+
"@gradio/preview": "workspace:^"
|
| 20 |
+
},
|
| 21 |
+
"exports": {
|
| 22 |
+
".": {
|
| 23 |
+
"gradio": "./Index.svelte",
|
| 24 |
+
"svelte": "./dist/Index.svelte",
|
| 25 |
+
"types": "./dist/Index.svelte.d.ts"
|
| 26 |
+
},
|
| 27 |
+
"./package.json": "./package.json"
|
| 28 |
+
},
|
| 29 |
+
"repository": {
|
| 30 |
+
"type": "git",
|
| 31 |
+
"url": "git+https://github.com/gradio-app/gradio.git",
|
| 32 |
+
"directory": "js/sidebar"
|
| 33 |
+
}
|
| 34 |
+
}
|
6.0.0/sidebar/shared/Sidebar.svelte
ADDED
|
@@ -0,0 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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<script lang="ts">
|
| 2 |
+
import { createEventDispatcher, onMount } from "svelte";
|
| 3 |
+
const dispatch = createEventDispatcher<{
|
| 4 |
+
expand: void;
|
| 5 |
+
collapse: void;
|
| 6 |
+
}>();
|
| 7 |
+
|
| 8 |
+
export let open = true;
|
| 9 |
+
export let width: number | string;
|
| 10 |
+
export let position: "left" | "right" = "left";
|
| 11 |
+
export let elem_classes: string[] = [];
|
| 12 |
+
export let elem_id = "";
|
| 13 |
+
|
| 14 |
+
// Using a temporary variable to animate the sidebar opening at the start
|
| 15 |
+
let mounted = false;
|
| 16 |
+
let _open = false;
|
| 17 |
+
let sidebar_div: HTMLElement;
|
| 18 |
+
let overlap_amount = 0;
|
| 19 |
+
|
| 20 |
+
let width_css = typeof width === "number" ? `${width}px` : width;
|
| 21 |
+
let prefersReducedMotion: boolean;
|
| 22 |
+
|
| 23 |
+
// Check if the sidebar overlaps with the main content
|
| 24 |
+
function check_overlap(): void {
|
| 25 |
+
if (!sidebar_div.closest(".wrap")) return;
|
| 26 |
+
const parent_rect = sidebar_div.closest(".wrap")?.getBoundingClientRect();
|
| 27 |
+
if (!parent_rect) return;
|
| 28 |
+
const sidebar_rect = sidebar_div.getBoundingClientRect();
|
| 29 |
+
const available_space =
|
| 30 |
+
position === "left"
|
| 31 |
+
? parent_rect.left
|
| 32 |
+
: window.innerWidth - parent_rect.right;
|
| 33 |
+
overlap_amount = Math.max(0, sidebar_rect.width - available_space + 30);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
onMount(() => {
|
| 37 |
+
sidebar_div.closest(".wrap")?.classList.add("sidebar-parent");
|
| 38 |
+
check_overlap();
|
| 39 |
+
window.addEventListener("resize", check_overlap);
|
| 40 |
+
const update_parent_overlap = (): void => {
|
| 41 |
+
document.documentElement.style.setProperty(
|
| 42 |
+
"--overlap-amount",
|
| 43 |
+
`${overlap_amount}px`
|
| 44 |
+
);
|
| 45 |
+
};
|
| 46 |
+
update_parent_overlap();
|
| 47 |
+
mounted = true;
|
| 48 |
+
const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
|
| 49 |
+
prefersReducedMotion = mediaQuery.matches;
|
| 50 |
+
const updateMotionPreference = (e: MediaQueryListEvent): void => {
|
| 51 |
+
prefersReducedMotion = e.matches;
|
| 52 |
+
};
|
| 53 |
+
mediaQuery.addEventListener("change", updateMotionPreference);
|
| 54 |
+
return () => {
|
| 55 |
+
window.removeEventListener("resize", check_overlap);
|
| 56 |
+
mediaQuery.removeEventListener("change", updateMotionPreference);
|
| 57 |
+
};
|
| 58 |
+
});
|
| 59 |
+
|
| 60 |
+
// We need to wait for the component to be mounted before we can set the open state
|
| 61 |
+
// so that it animates correctly.
|
| 62 |
+
$: if (mounted) _open = open;
|
| 63 |
+
|
| 64 |
+
$: _elem_classes = elem_classes?.join(" ") || "";
|
| 65 |
+
</script>
|
| 66 |
+
|
| 67 |
+
<div
|
| 68 |
+
class="sidebar {_elem_classes}"
|
| 69 |
+
id={elem_id}
|
| 70 |
+
class:open={_open}
|
| 71 |
+
class:right={position === "right"}
|
| 72 |
+
class:reduce-motion={prefersReducedMotion}
|
| 73 |
+
bind:this={sidebar_div}
|
| 74 |
+
style="width: {width_css}; {position}: calc({width_css} * -1)"
|
| 75 |
+
>
|
| 76 |
+
<button
|
| 77 |
+
on:click={() => {
|
| 78 |
+
_open = !_open;
|
| 79 |
+
open = _open;
|
| 80 |
+
if (_open) {
|
| 81 |
+
dispatch("expand");
|
| 82 |
+
} else {
|
| 83 |
+
dispatch("collapse");
|
| 84 |
+
}
|
| 85 |
+
}}
|
| 86 |
+
class="toggle-button"
|
| 87 |
+
aria-label="Toggle Sidebar"
|
| 88 |
+
>
|
| 89 |
+
<div class="chevron">
|
| 90 |
+
<span class="chevron-left"></span>
|
| 91 |
+
</div>
|
| 92 |
+
</button>
|
| 93 |
+
<div class="sidebar-content">
|
| 94 |
+
<slot />
|
| 95 |
+
</div>
|
| 96 |
+
</div>
|
| 97 |
+
|
| 98 |
+
<style>
|
| 99 |
+
/* Mobile styles (≤ 768px) */
|
| 100 |
+
@media (max-width: 768px) {
|
| 101 |
+
.sidebar {
|
| 102 |
+
width: 100vw !important;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.sidebar:not(.right) {
|
| 106 |
+
left: -100vw !important;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
.sidebar.right {
|
| 110 |
+
right: -100vw !important;
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
.sidebar:not(.reduce-motion) {
|
| 114 |
+
transition: transform 0.3s ease-in-out !important;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
:global(.sidebar-parent) {
|
| 118 |
+
padding-left: 0 !important;
|
| 119 |
+
padding-right: 0 !important;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
:global(.sidebar-parent:has(.sidebar.open)) {
|
| 123 |
+
padding-left: 0 !important;
|
| 124 |
+
padding-right: 0 !important;
|
| 125 |
+
}
|
| 126 |
+
.sidebar.open {
|
| 127 |
+
z-index: 1001 !important;
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
:global(.sidebar-parent) {
|
| 132 |
+
display: flex !important;
|
| 133 |
+
padding-left: 0;
|
| 134 |
+
padding-right: 0;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
:global(.sidebar-parent:not(.reduce-motion)) {
|
| 138 |
+
transition:
|
| 139 |
+
padding-left 0.3s ease-in-out,
|
| 140 |
+
padding-right 0.3s ease-in-out;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
:global(.sidebar-parent:has(.sidebar.open:not(.right))) {
|
| 144 |
+
padding-left: var(--overlap-amount);
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
:global(.sidebar-parent:has(.sidebar.open.right)) {
|
| 148 |
+
padding-right: var(--overlap-amount);
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
.sidebar {
|
| 152 |
+
display: flex;
|
| 153 |
+
flex-direction: column;
|
| 154 |
+
position: fixed;
|
| 155 |
+
top: 0;
|
| 156 |
+
height: 100%;
|
| 157 |
+
background-color: var(--background-fill-secondary);
|
| 158 |
+
transform: translateX(0%);
|
| 159 |
+
z-index: 1000;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
.sidebar:not(.reduce-motion) {
|
| 163 |
+
transition: transform 0.3s ease-in-out;
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
.sidebar.open:not(.right) {
|
| 167 |
+
transform: translateX(100%);
|
| 168 |
+
box-shadow: var(--size-1) 0 var(--size-1) rgba(0, 0, 0, 0.05);
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
.sidebar.open.right {
|
| 172 |
+
transform: translateX(-100%);
|
| 173 |
+
box-shadow: calc(var(--size-1) * -1) 0 var(--size-1) rgba(0, 0, 0, 0.05);
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
.toggle-button {
|
| 177 |
+
position: absolute;
|
| 178 |
+
top: var(--size-4);
|
| 179 |
+
background: var(--background-fill-secondary);
|
| 180 |
+
border: 1px solid var(--border-color-primary);
|
| 181 |
+
cursor: pointer;
|
| 182 |
+
padding: var(--size-2);
|
| 183 |
+
display: flex;
|
| 184 |
+
align-items: center;
|
| 185 |
+
justify-content: center;
|
| 186 |
+
width: var(--size-7);
|
| 187 |
+
height: var(--size-8);
|
| 188 |
+
z-index: 1001;
|
| 189 |
+
border-radius: 0;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
.toggle-button:not(.reduce-motion) {
|
| 193 |
+
transition: all 0.3s ease-in-out;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
.sidebar:not(.right) .toggle-button {
|
| 197 |
+
left: 100%;
|
| 198 |
+
border-radius: 0 var(--size-8) var(--size-8) 0;
|
| 199 |
+
border-left: none;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
.sidebar.right .toggle-button {
|
| 203 |
+
right: 100%;
|
| 204 |
+
transform: rotate(180deg);
|
| 205 |
+
border-radius: 0 var(--size-8) var(--size-8) 0;
|
| 206 |
+
border-left: none;
|
| 207 |
+
}
|
| 208 |
+
|
| 209 |
+
.open:not(.right) .toggle-button {
|
| 210 |
+
right: 0;
|
| 211 |
+
left: auto;
|
| 212 |
+
transform: rotate(180deg);
|
| 213 |
+
border-radius: 0 var(--size-8) var(--size-8) 0;
|
| 214 |
+
border-left: none;
|
| 215 |
+
border-right: 1px solid var(--border-color-primary);
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
.open.right .toggle-button {
|
| 219 |
+
left: 0;
|
| 220 |
+
right: auto;
|
| 221 |
+
transform: rotate(0deg);
|
| 222 |
+
border-radius: 0 var(--size-8) var(--size-8) 0;
|
| 223 |
+
border-left: none;
|
| 224 |
+
border-right: 1px solid var(--border-color-primary);
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
.chevron {
|
| 228 |
+
position: relative;
|
| 229 |
+
display: flex;
|
| 230 |
+
align-items: center;
|
| 231 |
+
justify-content: center;
|
| 232 |
+
padding-right: 8px;
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
.chevron-left {
|
| 236 |
+
position: relative;
|
| 237 |
+
width: var(--size-3);
|
| 238 |
+
height: var(--size-3);
|
| 239 |
+
border-top: var(--size-0-5) solid var(--body-text-color);
|
| 240 |
+
border-right: var(--size-0-5) solid var(--body-text-color);
|
| 241 |
+
transform: rotate(45deg);
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
.sidebar-content {
|
| 245 |
+
padding: var(--size-5);
|
| 246 |
+
padding-right: var(--size-8);
|
| 247 |
+
overflow-y: auto;
|
| 248 |
+
}
|
| 249 |
+
|
| 250 |
+
.sidebar.right .sidebar-content {
|
| 251 |
+
padding-left: var(--size-8);
|
| 252 |
+
}
|
| 253 |
+
</style>
|
6.0.0/sidebar/types.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export interface SidebarProps {
|
| 2 |
+
open: boolean;
|
| 3 |
+
position: "left" | "right";
|
| 4 |
+
width: number | string;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
export interface SidebarEvents {
|
| 8 |
+
expand: never;
|
| 9 |
+
collapse: never;
|
| 10 |
+
clear_status: never;
|
| 11 |
+
}
|