Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): Add inline script picker to apps (#945)
* feat(frontend): Add inline script picker
- Loading branch information
Showing
3 changed files
with
48 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
frontend/src/lib/components/apps/editor/settingsPanel/PickInlineScript.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script lang="ts"> | ||
import ItemPicker from '$lib/components/ItemPicker.svelte' | ||
import { createEventDispatcher } from 'svelte' | ||
import Button from '$lib/components/common/button/Button.svelte' | ||
export let scripts: Item[] | ||
type Item = { summary: string } | ||
let itemPicker: ItemPicker | ||
const dispatch = createEventDispatcher() | ||
async function loadItems(): Promise<Item[]> { | ||
return scripts | ||
} | ||
</script> | ||
|
||
<ItemPicker | ||
bind:this={itemPicker} | ||
pickCallback={(path, summary) => { | ||
dispatch('pick', { path, summary }) | ||
}} | ||
itemName={'Script'} | ||
extraField="summary" | ||
noItemMessage={`There are no inline scripts.<br> | ||
Click '<span class="font-semibold">Add script</span>' on the left panel to create one.`} | ||
{loadItems} | ||
/> | ||
|
||
<Button size="xs" color="dark" on:click={() => itemPicker.openDrawer()}> | ||
Pick an inline script | ||
</Button> |