Skip to content

Commit 90d0830

Browse files
authored
Merge pull request #89 from Flow-Launcher/add-new-settingstemplate-field
Add a new SettingsTemplate.yml input type: inputWithFolderBtn
2 parents dcf3165 + 1f98a53 commit 90d0830

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

json-rpc-settings.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ attributes:
4040
| `description` | The description for the input. If set, it's displayed to the left of the input, right below the label. |
4141
| `defaultValue` | The default value for the input. It's the value your plugin will receive in the settings for that input until the user changes that value in settings. |
4242

43-
#### `inputWithFileBtn`
44-
This is a text input with a "Browse" button for selecting a file.
43+
#### `inputWithFileBtn` and `inputWithFolderBtn`
44+
This is a text input with a "Browse" button for selecting a file or a folder respectively. They look the same, the only difference is that one only allows selecting a file and the other only allows selecting a folder.
4545
```yaml
4646
type: inputWithFileBtn
4747
attributes:

webcomponents/src/components/PasteHandler.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const emit = createEventDispatcher<{
77
setData: ComponentData[];
88
}>();
99
10-
const types: ComponentType[] = ['textBlock', 'input', 'inputWithFileBtn', 'passwordBox', 'textarea', 'dropdown', 'checkbox'];
10+
const types: ComponentType[] = ['textBlock', 'input', 'inputWithFileBtn', 'inputWithFolderBtn', 'passwordBox', 'textarea', 'dropdown', 'checkbox'];
1111
function verifyData(parsed: { body?: ComponentData[] }): boolean {
1212
return parsed?.body && Array.isArray(parsed.body) && parsed.body.every(v => types.includes(v.type) && v.attributes);
1313
}

webcomponents/src/components/SettingsEditDialog.svelte

+3-2
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ $: {
4747
const inputTypes: Record<ComponentType, string> = {
4848
textBlock: "Block of text",
4949
input: "Text input",
50-
inputWithFileBtn: "Text input with 'Browse' button",
50+
inputWithFileBtn: "Text input with 'Browse' button for selecting a file",
51+
inputWithFolderBtn: "Text input with 'Browse' button for selecting a folder",
5152
textarea: "Textarea",
5253
passwordBox: "Password input",
5354
dropdown: "Dropdown",
@@ -145,7 +146,7 @@ $: {
145146
<SettingsCheckbox {theme} bind:value={checkbox}/>
146147
{/if}
147148
</div>
148-
{#if data.type === 'input' || data.type === 'inputWithFileBtn' || data.type === 'passwordBox'}
149+
{#if data.type === 'input' || data.type === 'inputWithFileBtn' || data.type === 'inputWithFolderBtn' || data.type === 'passwordBox'}
149150
<SettingsInput {theme} bind:value={data.attributes.defaultValue}/>
150151
{:else if data.type === 'textarea'}
151152
<SettingsInput {theme} multiline bind:value={data.attributes.defaultValue}/>

webcomponents/src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export type ComponentType =
22
| 'textBlock'
33
| 'input'
44
| 'inputWithFileBtn'
5+
| 'inputWithFolderBtn'
56
| 'textarea'
67
| 'passwordBox'
78
| 'dropdown'

webcomponents/src/webcomponents/SettingsComponentDemo.svelte

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ $: full = type === 'textBlock';
4848
{#if type !== 'textBlock'}
4949
<div
5050
class="right"
51-
class:with-button={type === 'inputWithFileBtn'}
51+
class:with-button={type === 'inputWithFileBtn' || type === 'inputWithFolderBtn'}
5252
class:checkbox={type === 'checkbox'}
5353
>
5454
{#if type === 'input'}
5555
<SettingsInput {theme} {readonly} bind:value={value}/>
56-
{:else if type === 'inputWithFileBtn'}
56+
{:else if type === 'inputWithFileBtn' || type === 'inputWithFolderBtn'}
5757
<SettingsInput {theme} {readonly} bind:value={value}/>
5858
<SettingsButton {theme}>Browse</SettingsButton>
5959
{:else if type === 'passwordBox'}

0 commit comments

Comments
 (0)