Skip to content

Commit 8b1d8dd

Browse files
authored
feat(web): enhance ui interactions and improve code quality (#2078)
This PR enhances the web interface with improved keyboard navigation and modal interactions, strengthens type safety by migrating from Svelte's on:click to onclick handlers, fixes message count calculation in partition view, adds the missing max_topic_size field to topic schema, and removes unused imports for cleaner code organization.
1 parent 2e57d58 commit 8b1d8dd

54 files changed

Lines changed: 1029 additions & 496 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

web/package-lock.json

Lines changed: 527 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/src/lib/actions/tooltip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function tooltip(
5151
let cleanup: VoidFunction | undefined;
5252

5353
const unsub = openId.subscribe((val) => (val === id ? showTooltip() : hideTooltip()));
54-
const openTooltip = () => openId.set(id);
54+
5555
const closeTooltip = () => openId.set(null);
5656
const toggleOpen = () => openId.update((val) => (val === id ? null : id));
5757

web/src/lib/api/ApiSchema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ type Topics =
137137
name: string;
138138
message_expiry: number;
139139
compression_algorithm: number;
140+
max_topic_size: number;
140141
};
141142
}
142143
| {
Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
<!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot making the component unusable -->
2-
<!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot making the component unusable -->
3-
<!-- // TODO: check it - Error while migrating Svelte code: This migration would change the name of a slot making the component unusable -->
41
<script lang="ts">
52
import { tooltip } from '$lib/actions/tooltip';
63
import type { Placement } from '@floating-ui/dom';
@@ -33,49 +30,39 @@
3330
xl: 'px-7 py-4 text-lg'
3431
};
3532
36-
interface $$Props extends HTMLButtonAttributes {
33+
interface Props extends HTMLButtonAttributes {
3734
variant: keyof typeof variants;
3835
tooltipPlacement?: Placement;
3936
size?: keyof typeof sizes;
4037
class?: string;
38+
children?: import('svelte').Snippet;
39+
tooltip?: import('svelte').Snippet;
4140
}
4241
43-
export let variant: keyof typeof variants;
44-
export let tooltipPlacement: Placement = 'right';
45-
export let size: keyof typeof sizes = 'md';
46-
let className = '';
47-
export { className as class };
42+
let {
43+
variant,
44+
tooltipPlacement = 'right',
45+
size = 'md',
46+
class: className = '',
47+
children,
48+
tooltip: tooltipSnippet,
49+
onclick,
50+
...restProps
51+
}: Props = $props();
4852
</script>
4953

50-
<!-- <div use:tooltip={{ placement: tooltipPlacement }} class="w-full">
51-
<button
52-
on:click
53-
data-trigger
54-
class={twMerge(baseClasses, disabledClasses, variants[variant], sizes[size], className)}
55-
{...$$restProps}
56-
>
57-
<slot />
58-
</button>
59-
60-
{#if $$slots.tooltip}
61-
<div role="tooltip" class="tooltip">
62-
<slot name="tooltip" />
63-
</div>
64-
{/if}
65-
</div> -->
66-
6754
<button
68-
on:click
55+
{onclick}
6956
data-trigger
7057
use:tooltip={{ placement: tooltipPlacement, isTrigger: true }}
7158
class={twMerge(baseClasses, variants[variant], sizes[size], disabledClasses, className, ' ')}
72-
{...$$restProps}
59+
{...restProps}
7360
>
74-
<slot />
61+
{@render children?.()}
7562

76-
{#if $$slots.tooltip}
63+
{#if tooltipSnippet}
7764
<div role="tooltip" class="tooltip ring-bl">
78-
<slot name="tooltip" />
65+
{@render tooltipSnippet()}
7966
</div>
8067
{/if}
8168
</button>

web/src/lib/components/Checkbox.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
name?: string | undefined;
1313
bindGroup?: string[] | undefined;
1414
disabled?: boolean;
15+
onclick?: (e: Event) => void;
1516
}
1617
1718
let {
@@ -20,7 +21,8 @@
2021
id = '',
2122
name = undefined,
2223
bindGroup = $bindable(undefined),
23-
disabled = false
24+
disabled = false,
25+
onclick
2426
}: Props = $props();
2527
2628
function onChange(e: Event) {
@@ -47,6 +49,7 @@
4749
{id}
4850
{disabled}
4951
onchange={handlers(onChange, bubble('change'))}
52+
onclick={onclick}
5053
onmousedown={() => (isMouseDown = true)}
5154
onmouseup={() => (isMouseDown = false)}
5255
onmouseleave={() => (isMouseDown = false)}

web/src/lib/components/Combobox.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
<div class="flex flex-col gap-2">
6969
{#if label}
70-
<label class="text-sm ml-1 text-color">
70+
<label for="combobox-input" class="text-sm ml-1 text-color">
7171
{label}
7272
</label>
7373
{/if}
@@ -77,6 +77,7 @@
7777
class="rounded-md dark:bg-shadeD400 ring-1 text-color ring-gray-300 dark:ring-gray-500 flex items-center h-[40px] text-color relative focus-within:ring-2 focus-within:ring-gray-400 transition group"
7878
>
7979
<input
80+
id="combobox-input"
8081
use:combobox.input
8182
onselect={(e) => {
8283
selectedValue = noTypeCheck(e).detail.selected;

web/src/lib/components/DeleteButtonWithConfirmation.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
</script>
3232

3333
<div bind:this={wrapperRef} use:tooltip={{ placement: 'top' }}>
34-
<Button variant="containedRed" on:click={() => (isTooltipOpen = true)}>Delete</Button>
34+
<Button variant="containedRed" onclick={() => (isTooltipOpen = true)}>Delete</Button>
3535

3636
<div class="tooltip">
3737
<div class="flex flex-col gap-4 items-center justify-center p-2">
3838
<span>Are you sure? </span>
3939
<div class="flex flex-row gap-2">
40-
<Button variant="text" type="button" on:click={() => (isTooltipOpen = false)} size="sm"
40+
<Button variant="text" type="button" onclick={() => (isTooltipOpen = false)} size="sm"
4141
>No</Button
4242
>
4343
<Button

web/src/lib/components/DropdownMenu/DropdownMenu.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<div class="px-1 py-1">
3737
{#each group as { action, icon, className, label }}
3838
<button
39-
on:click={() => {
39+
onclick={() => {
4040
if (action) {
4141
action(() => tooltipRef.dispatchEvent(new Event('closeTooltip')));
4242
}

web/src/lib/components/Input.svelte

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,3 @@
1-
<!-- <script lang="ts">
2-
import type { HTMLInputAttributes, HTMLInputTypeAttribute } from 'svelte/elements';
3-
import { twMerge } from 'tailwind-merge';
4-
import type { iconType } from './Icon.svelte';
5-
import Icon from './Icon.svelte';
6-
7-
interface $$Props extends HTMLInputAttributes {
8-
name: string;
9-
id?: string;
10-
label?: string;
11-
value: string | number;
12-
errorMessage?: string;
13-
type?: HTMLInputTypeAttribute;
14-
}
15-
16-
export let name: string;
17-
export let id: string = crypto.randomUUID();
18-
export let leadingIcon: iconType | undefined = undefined;
19-
export let label: string | undefined = undefined;
20-
export let value: string | number;
21-
export let type: HTMLInputTypeAttribute = 'text';
22-
</script>
23-
24-
<div class="flex flex-col gap-1">
25-
{#if label}
26-
<label for={id} class="text-sm ml-1 text-color">
27-
{label}
28-
</label>
29-
{/if}
30-
31-
<div
32-
class={twMerge(
33-
'rounded-md border border-gray-300 dark:border-none outline-none dark:bg-shadeD400 text-color px-3 w-full relative',
34-
error && 'border-red-600 text-red-600 border-none outline-red-600',
35-
leadingIcon && 'pl-8',
36-
$$restProps.class
37-
)}
38-
>
39-
{#if leadingIcon}
40-
<Icon
41-
name={leadingIcon}
42-
className="absolute text-gray-400 left-2 top-1/2 -translate-y-1/2 w-[18px]"
43-
/>
44-
{/if}
45-
46-
<input
47-
bind:value
48-
{...$$restProps}
49-
autocomplete="off"
50-
{id}
51-
{name}
52-
class="w-full h-full bg-transparent py-2 outline-none"
53-
/>
54-
</div>
55-
56-
{#if errorMe}
57-
<span class="text-red-600 text-xs ml-1 mt-1">
58-
{error}
59-
</span>
60-
{/if}
61-
</div> -->
62-
631
<script lang="ts">
642
import { createBubbler } from 'svelte/legacy';
653

web/src/lib/components/Layouts/SettingsLayout.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
</div>
5252

5353
<div class="flex gap-12 border-b px-10">
54-
{#each tabs as { icon, name, tab, href }, idx (idx)}
54+
{#each tabs as { icon, name, href }, idx (idx)}
5555
{@const isActive = activeTab === href.split('/').slice(-1)[0]}
5656
<a
5757
{href}

0 commit comments

Comments
 (0)