gradio-pr-bot commited on
Commit
670f9de
·
verified ·
1 Parent(s): 010c7f3

Upload folder using huggingface_hub

Browse files
6.3.0/sidebar/Index.svelte CHANGED
@@ -20,8 +20,8 @@
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
  >
 
20
  bind:open={gradio.props.open}
21
  bind:position={gradio.props.position}
22
  width={gradio.props.width}
23
+ onexpand={() => gradio.dispatch("expand")}
24
+ oncollapse={() => gradio.dispatch("collapse")}
25
  elem_classes={gradio.shared.elem_classes}
26
  elem_id={gradio.shared.elem_id}
27
  >
6.3.0/sidebar/shared/Sidebar.svelte CHANGED
@@ -1,24 +1,32 @@
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 {
@@ -59,9 +67,11 @@
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
@@ -74,13 +84,13 @@
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"
 
1
  <script lang="ts">
2
+ import { onMount } from "svelte";
3
+
4
+ let {
5
+ open = $bindable(true),
6
+ width,
7
+ position = $bindable<"left" | "right">("left"),
8
+ elem_classes = [],
9
+ elem_id = "",
10
+ onexpand = () => {},
11
+ oncollapse = () => {}
12
+ }: {
13
+ open?: boolean;
14
+ width: number | string;
15
+ position?: "left" | "right";
16
+ elem_classes?: string[];
17
+ elem_id?: string;
18
+ onexpand?: () => void;
19
+ oncollapse?: () => void;
20
+ } = $props();
21
 
22
  // Using a temporary variable to animate the sidebar opening at the start
23
+ let mounted = $state(false);
24
+ let _open = $state(false);
25
  let sidebar_div: HTMLElement;
26
+ let overlap_amount = $state(0);
27
 
28
+ let width_css = $derived(typeof width === "number" ? `${width}px` : width);
29
+ let prefersReducedMotion = $state(false);
30
 
31
  // Check if the sidebar overlaps with the main content
32
  function check_overlap(): void {
 
67
 
68
  // We need to wait for the component to be mounted before we can set the open state
69
  // so that it animates correctly.
70
+ $effect(() => {
71
+ if (mounted) _open = open;
72
+ });
73
 
74
+ let _elem_classes = $derived(elem_classes?.join(" ") || "");
75
  </script>
76
 
77
  <div
 
84
  style="width: {width_css}; {position}: calc({width_css} * -1)"
85
  >
86
  <button
87
+ onclick={() => {
88
  _open = !_open;
89
  open = _open;
90
  if (_open) {
91
+ onexpand?.();
92
  } else {
93
+ oncollapse?.();
94
  }
95
  }}
96
  class="toggle-button"