mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-26 00:01:37 +00:00
21ac344c1e
* feature(frontend): WIP Prop picker v2 * feature(frontend): add PropPicker context * feature(frontend): prop picker working * feature(frontend): restore connect button * feature(frontend): Fix wording + fix height to avoid content shift * feature(frontend): Fix upTo preview + adapt style * feature(frontend): Preview results cleanup * feature(frontend): Remove test logs * feature(frontend): Revert wrong changes * feature(frontend): Restore shared preview args * feature(frontend): Reduce ObjectViewer font size + remove useless space * feature(frontend): Wording * feature(frontend): Fix Split panel scrolling issues
40 lines
921 B
Svelte
40 lines
921 B
Svelte
<script context="module" lang="ts">
|
|
export type ToggleButtonContext = {
|
|
selected: Writable<string[]>
|
|
select: (value: string) => void
|
|
}
|
|
</script>
|
|
|
|
<script lang="ts">
|
|
import { setContext } from 'svelte'
|
|
import { writable, type Writable } from 'svelte/store'
|
|
|
|
export let exclusive: boolean = true
|
|
export let selected: string[] = []
|
|
|
|
const selectedContent = writable(selected)
|
|
|
|
setContext<ToggleButtonContext>('ToggleButtonGroup', {
|
|
selected: selectedContent,
|
|
select: (value: string) => {
|
|
if (exclusive) {
|
|
selectedContent.set([value])
|
|
} else {
|
|
selectedContent.update((selected) => {
|
|
const index = selected.findIndex((val: string) => val === value)
|
|
if (index !== -1) {
|
|
selected.splice(index, 1)
|
|
return selected
|
|
} else {
|
|
return [value, ...selected]
|
|
}
|
|
})
|
|
}
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<div class="inline-flex rounded-md shadow-sm" role="group">
|
|
<slot />
|
|
</div>
|