Skip to content

Commit 0676fa5

Browse files
committed
Add component demos in json-rpc-settings.md
1 parent 393f89d commit 0676fa5

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

json-rpc-settings.md

+34-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ You might need to have some settings in your plugins that are easily changeable
44

55

66
### SettingsTemplate.yaml
7-
This is a YAML files that contains the settings page layout for your plugin. It contains an object with a single property called `body`. The `body` property contains an array of objects that define the layout of the settings page. Each object in the `body` array is a section of the settings page. Each section takes up the entire width of the page, which means you can't have one input on the left and one on the right. The layout of each section is always static: input description on the left, input on the right. Every object in the `body` array has the same structure: a `type` property that defines the type of this input (text input, textarea etc.), and an `attributes` property that contains everything else the object needs to render, such as label, description, or default value. The following is a list of the different types of inputs that can be used in the `SettingsTemplate.yaml` file.
7+
This is a YAML file that contains the settings page layout for your plugin. It contains an object with a single property called `body`. The `body` property contains an array of objects that define the layout of the settings page. Each object in the `body` array is a section of the settings page. Each section takes up the entire width of the page, which means you can't have one input on the left and one on the right. The layout of each section is always static: input description on the left, input on the right. Every object in the `body` array has the same structure: a `type` property that defines the type of this input (text input, textarea etc.), and an `attributes` property that contains everything else the object needs to render, such as label, description, or default value. The following is a list of the different input types that can be used in the `SettingsTemplate.yaml` file.
88

99
---
1010

@@ -15,6 +15,8 @@ type: textBlock
1515
attributes:
1616
description: This is a block of text.
1717
```
18+
<settings-component-demo type="textBlock" description="This is a block of text."></settings-component-demo>
19+
1820
| Property name | Property description |
1921
|---------------|----------------------|
2022
| `description` | The text to display. |
@@ -29,6 +31,8 @@ attributes:
2931
description: Description of the input
3032
defaultValue: Hello there
3133
```
34+
<settings-component-demo type="input" label="This is a text input" description="Description of the input" value="Hello there"></settings-component-demo>
35+
3236
| Property name | Property description |
3337
|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
3438
| `name` | The name of the input. This is the key that you will use to access the value of the input in the settings object. |
@@ -46,6 +50,8 @@ attributes:
4650
description: Description of the input
4751
defaultValue: Hello there
4852
```
53+
<settings-component-demo type="inputWithFileBtn" label="This is a text input with a Browse button" description="Description of the input" value="Hello there"></settings-component-demo>
54+
4955
| Property name | Property description |
5056
|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
5157
| `name` | The name of the input. This is the key that you will use to access the value of the input in the settings object. |
@@ -64,6 +70,8 @@ attributes:
6470
description: Description of the input
6571
defaultValue: Hello there
6672
```
73+
<settings-component-demo type="textarea" label="This is a multiline text input" description="Description of the input" value="Hello there"></settings-component-demo>
74+
6775
| Property name | Property description |
6876
|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
6977
| `name` | The name of the input. This is the key that you will use to access the value of the input in the settings object. |
@@ -81,6 +89,8 @@ attributes:
8189
description: Description of the input
8290
defaultValue: secret password
8391
```
92+
<settings-component-demo type="passwordBox" label="This is a password input" description="Description of the input" value="secret password"></settings-component-demo>
93+
8494
| Property name | Property description |
8595
|----------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
8696
| `name` | The name of the input. This is the key that you will use to access the value of the input in the settings object. |
@@ -102,6 +112,8 @@ attributes:
102112
- Option 2
103113
- Option 3
104114
```
115+
<settings-component-demo type="dropdown" label="This is a dropdown input" description="Description of the input" value="Option 1" options='["Option 1", "Option 2", "Option 3"]'></settings-component-demo>
116+
105117
| Property name | Property description |
106118
|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
107119
| `name` | The name of the input. This is the key that you will use to access the value of the input in the settings object. |
@@ -120,6 +132,8 @@ attributes:
120132
description: Description of the checkbox
121133
defaultValue: true
122134
```
135+
<settings-component-demo type="checkbox" label="This is a checkbox" description="Description of the checkbox" value="true"></settings-component-demo>
136+
123137
| Property name | Property description |
124138
|----------------|-------------------------------------------------------------------------------------------------------------------------|
125139
| `name` | The name of the checkbox. This is the key that you will use to access the value of the checkbox in the settings object. |
@@ -158,10 +172,27 @@ body:
158172
- "C#"
159173
- type: checkbox
160174
attributes:
161-
name: Prefer shorter answers
175+
name: preferShorterAnswers
176+
label: Prefer shorter answers
162177
description: If checked, the plugin will try to give answer much shorter than the usual ones.
163178
defaultValue: false
164179
```
180+
<settings-component-demo type="textBlock" description="Welcome to the settings page for my plugin. Here you can configure the plugin to your liking."></settings-component-demo>
181+
<settings-component-demo type="input" label="How should I call you?" value="the user"></settings-component-demo>
182+
<settings-component-demo type="textarea" label="Text to prepend to result output" description='This text will be added to the beginning of the result output. For example, if you set this to "The result is: ", and the result is "42", the output will be "The result is: 42".'></settings-component-demo>
183+
<settings-component-demo type="dropdown" label="Programming language to prefer for answers" value="TypeScript" options='["JavaScript", "TypeScript", "Python", "C#"]'></settings-component-demo>
184+
<settings-component-demo type="checkbox" label="Prefer shorter answers" description="If checked, the plugin will try to give answer much shorter than the usual ones."></settings-component-demo>
165185

166186
### Visual editor for `SettingsTemplate.yaml`
167-
You can use a [visual editor](https://flow-launcher-plugin-settings-generator.pages.dev/) for creating the `SettingsTemplate.yaml` file. When you're done editing, click the `Generate SettingsTemplate.yaml` file and copy-paste its contents into your `SettingsTemplate.yaml` file. Optionally, you can also copy the generated typings for your settings object in your preferred programming language.
187+
You can use a [visual editor](https://flow-launcher-plugin-settings-generator.pages.dev/) for creating the `SettingsTemplate.yaml` file. When you're done editing, click the `Generate SettingsTemplate.yaml` file and copy-paste its contents into your `SettingsTemplate.yaml` file. Optionally, you can also copy the generated typings for your settings object in your preferred programming language.
188+
189+
<script>
190+
const element = document.querySelector('#__settings-script__');
191+
if (!element) {
192+
const script = document.createElement('script');
193+
script.id = '__settings-script__';
194+
script.src = 'https://www.flowlauncher.com/docs/webcomponents/dist/flow-launcher-docs-web-components.js';
195+
script.type = 'module';
196+
document.body.appendChild(script);
197+
}
198+
</script>

0 commit comments

Comments
 (0)