enzostvs HF Staff commited on
Commit
1828161
·
1 Parent(s): 7135353

use braille loading instead + fake loading on billing

Browse files
package.json CHANGED
@@ -52,6 +52,7 @@
52
  "mode-watcher": "^1.1.0",
53
  "svelte-highlight": "^7.9.0",
54
  "svelte-markdown": "^0.4.1",
55
- "tailwind-merge": "^3.4.0"
 
56
  }
57
  }
 
52
  "mode-watcher": "^1.1.0",
53
  "svelte-highlight": "^7.9.0",
54
  "svelte-markdown": "^0.4.1",
55
+ "tailwind-merge": "^3.4.0",
56
+ "unicode-animations": "^1.0.3"
57
  }
58
  }
pnpm-lock.yaml CHANGED
@@ -41,6 +41,9 @@ importers:
41
  tailwind-merge:
42
  specifier: ^3.4.0
43
  version: 3.4.0
 
 
 
44
  devDependencies:
45
  '@eslint/compat':
46
  specifier: ^2.0.2
@@ -2102,6 +2105,10 @@ packages:
2102
  undici-types@7.16.0:
2103
  resolution: {integrity: sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==}
2104
 
 
 
 
 
2105
  uri-js@4.4.1:
2106
  resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
2107
 
@@ -4003,6 +4010,8 @@ snapshots:
4003
 
4004
  undici-types@7.16.0: {}
4005
 
 
 
4006
  uri-js@4.4.1:
4007
  dependencies:
4008
  punycode: 2.3.1
 
41
  tailwind-merge:
42
  specifier: ^3.4.0
43
  version: 3.4.0
44
+ unicode-animations:
45
+ specifier: ^1.0.3
46
+ version: 1.0.3
47
  devDependencies:
48
  '@eslint/compat':
49
  specifier: ^2.0.2
 
2105
  undici-types@7.16.0:
2106
  resolution: {integrity: sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==}
2107
 
2108
+ unicode-animations@1.0.3:
2109
+ resolution: {integrity: sha512-+klB2oWwcYZjYWhwP4Pr8UZffWDFVx6jKeIahE6z0QYyM2dwDeDPyn5nevCYbyotxvtT9lh21cVURO1RX0+YMg==}
2110
+ hasBin: true
2111
+
2112
  uri-js@4.4.1:
2113
  resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
2114
 
 
4010
 
4011
  undici-types@7.16.0: {}
4012
 
4013
+ unicode-animations@1.0.3: {}
4014
+
4015
  uri-js@4.4.1:
4016
  dependencies:
4017
  punycode: 2.3.1
src/lib/components/billing/BillingManagementModal.svelte CHANGED
@@ -4,20 +4,24 @@
4
  import { authState } from '$lib/state/auth.svelte';
5
  import { Save } from '@lucide/svelte';
6
  import Button from '../ui/button/button.svelte';
 
7
 
8
  let { open = $bindable(false) }: { open: boolean } = $props();
9
 
10
- let billingOption = $derived(authState.user?.billingOption || 'personal');
11
  const planColors = {
12
  team: 'bg-purple-500/10 text-purple-600',
13
  enterprise: 'bg-green-500/10 text-green-600'
14
  };
15
-
16
  let selectedOrg = $derived(
17
  authState.user?.orgs?.find((org) => org.preferred_username === billingOption)
18
  );
 
19
 
20
- function saveSettings() {
 
 
 
21
  if (billingOption === 'personal') {
22
  localStorage.removeItem('hf-playground-billing-option');
23
  } else {
@@ -111,12 +115,15 @@
111
  <div class="mt-5 flex items-center justify-end gap-3">
112
  <Button variant="outline" onclick={resetSettings}>Reset</Button>
113
  <Button class="flex-1" onclick={saveSettings}>
114
- <Save />
115
- Save settings
 
 
 
 
 
116
  </Button>
117
  </div>
118
  </Dialog.Description>
119
  </Dialog.Content>
120
  </Dialog.Root>
121
-
122
- <!-- replace to select a billing option (personal or organization) -->
 
4
  import { authState } from '$lib/state/auth.svelte';
5
  import { Save } from '@lucide/svelte';
6
  import Button from '../ui/button/button.svelte';
7
+ import Spinner from '../loading/Spinner.svelte';
8
 
9
  let { open = $bindable(false) }: { open: boolean } = $props();
10
 
 
11
  const planColors = {
12
  team: 'bg-purple-500/10 text-purple-600',
13
  enterprise: 'bg-green-500/10 text-green-600'
14
  };
15
+ let billingOption = $derived(authState.user?.billingOption || 'personal');
16
  let selectedOrg = $derived(
17
  authState.user?.orgs?.find((org) => org.preferred_username === billingOption)
18
  );
19
+ let loading = $state.raw<boolean>(false);
20
 
21
+ async function saveSettings() {
22
+ loading = true;
23
+ await new Promise((resolve) => setTimeout(resolve, 1_000));
24
+ loading = false;
25
  if (billingOption === 'personal') {
26
  localStorage.removeItem('hf-playground-billing-option');
27
  } else {
 
115
  <div class="mt-5 flex items-center justify-end gap-3">
116
  <Button variant="outline" onclick={resetSettings}>Reset</Button>
117
  <Button class="flex-1" onclick={saveSettings}>
118
+ {#if loading}
119
+ <Spinner className="text-lg" />
120
+ Saving...
121
+ {:else}
122
+ <Save />
123
+ Save settings
124
+ {/if}
125
  </Button>
126
  </div>
127
  </Dialog.Description>
128
  </Dialog.Content>
129
  </Dialog.Root>
 
 
src/lib/components/chat/Assistant.svelte CHANGED
@@ -132,10 +132,7 @@
132
  </header>
133
 
134
  {#if loading}
135
- <div class="flex items-center justify-start gap-1">
136
- <Spinner className="size-4!" />
137
- <p class="text-sm text-muted-foreground/70">Reaching out...</p>
138
- </div>
139
  {/if}
140
  {#if message}
141
  <div bind:this={containerRef}>
 
132
  </header>
133
 
134
  {#if loading}
135
+ <Spinner className="text-sm text-muted-foreground/70">Reaching out...</Spinner>
 
 
 
136
  {/if}
137
  {#if message}
138
  <div bind:this={containerRef}>
src/lib/components/flow/actions/PanelRightActions.svelte CHANGED
@@ -18,7 +18,6 @@
18
  import { billingModalState } from '$lib/state/billing-modal.svelte';
19
  import defaultAvatar from '$lib/assets/default-avatar.svg';
20
  import BillingManagementModal from '$lib/components/billing/BillingManagementModal.svelte';
21
- import Spinner from '$lib/components/loading/Spinner.svelte';
22
 
23
  let { canReset }: { canReset: boolean } = $props();
24
 
 
18
  import { billingModalState } from '$lib/state/billing-modal.svelte';
19
  import defaultAvatar from '$lib/assets/default-avatar.svg';
20
  import BillingManagementModal from '$lib/components/billing/BillingManagementModal.svelte';
 
21
 
22
  let { canReset }: { canReset: boolean } = $props();
23
 
src/lib/components/loading/MainLoading.svelte CHANGED
@@ -7,6 +7,6 @@
7
  <img src={HuggingFaceLogo} alt="HF Logo" class="size-16" />
8
  <p class="mt-1 flex items-center justify-center gap-2 text-base text-muted-foreground">
9
  Loading playground...
10
- <Spinner className="size-5" />
11
  </p>
12
  </div>
 
7
  <img src={HuggingFaceLogo} alt="HF Logo" class="size-16" />
8
  <p class="mt-1 flex items-center justify-center gap-2 text-base text-muted-foreground">
9
  Loading playground...
10
+ <Spinner name="braille" />
11
  </p>
12
  </div>
src/lib/components/loading/Spinner.svelte CHANGED
@@ -1,8 +1,29 @@
1
  <script lang="ts">
2
- let { className }: { className?: string } = $props();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  </script>
4
 
5
- <span class="loader {className}"></span>
 
 
 
 
 
6
 
7
  <style>
8
  .loader {
@@ -23,4 +44,4 @@
23
  transform: rotate(1turn);
24
  }
25
  }
26
- </style>
 
1
  <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import spinners, { type BrailleSpinnerName } from 'unicode-animations';
4
+ let {
5
+ className,
6
+ children,
7
+ name = 'braille'
8
+ }: { className?: string; children?: Snippet; name?: BrailleSpinnerName } = $props();
9
+
10
+ let frame = $state.raw<number>(0);
11
+ const spinner = spinners[name];
12
+
13
+ $effect(() => {
14
+ const interval = setInterval(() => {
15
+ frame = (frame + 1) % spinner.frames.length;
16
+ }, spinner.interval);
17
+ return () => clearInterval(interval);
18
+ });
19
  </script>
20
 
21
+ <span class={className}>
22
+ {spinner.frames[frame]}
23
+ {@render children?.()}
24
+ </span>
25
+
26
+ <!-- <span class="loader {className}"></span>
27
 
28
  <style>
29
  .loader {
 
44
  transform: rotate(1turn);
45
  }
46
  }
47
+ </style> -->