changed setting structure
This commit is contained in:
parent
7c6293fa41
commit
789ef401c9
64
main.ts
64
main.ts
|
@ -68,42 +68,34 @@ class GridBackgroundSettingTab extends PluginSettingTab {
|
||||||
|
|
||||||
const gridSizeSetting = new Setting(containerEl)
|
const gridSizeSetting = new Setting(containerEl)
|
||||||
.setName('Grid Size')
|
.setName('Grid Size')
|
||||||
.setDesc('Spacing between grid lines (in px)');
|
.setDesc('Spacing between grid lines (in px)')
|
||||||
|
.addSlider(sliderValue =>
|
||||||
const gridSizeSlider = gridSizeSetting.addSlider(sliderValue =>
|
sliderValue
|
||||||
sliderValue
|
.setInstant(true)
|
||||||
.setInstant(true)
|
.setValue(this.plugin.settings.gridSize)
|
||||||
.setValue(this.plugin.settings.gridSize)
|
.setLimits(20, 100, 1)
|
||||||
.setLimits(20, 100, 1)
|
.onChange(async (value) => {
|
||||||
.onChange(async (value) => {
|
this.plugin.settings.gridSize = value || 20;
|
||||||
this.plugin.settings.gridSize = value || 20;
|
await this.plugin.saveSettings();
|
||||||
(gridSizeText.components[0] as TextComponent).setValue(value.toString());
|
}))
|
||||||
await this.plugin.saveSettings();
|
.addText(text =>
|
||||||
})
|
text
|
||||||
);
|
.setPlaceholder('e.g. 20')
|
||||||
|
.setValue(this.plugin.settings.gridSize.toString())
|
||||||
const gridSizeText = gridSizeSetting.addText(text =>
|
.onChange(async (value) => {
|
||||||
text
|
this.plugin.settings.gridSize = parseInt(value) || 20;
|
||||||
.setPlaceholder('e.g. 20')
|
await this.plugin.saveSettings();
|
||||||
.setValue(this.plugin.settings.gridSize.toString())
|
})
|
||||||
.onChange(async (value) => {
|
)
|
||||||
this.plugin.settings.gridSize = parseInt(value) || 20;
|
.addButton(button =>
|
||||||
(gridSizeText.components[0] as TextComponent).setValue(value.toString());
|
button
|
||||||
await this.plugin.saveSettings();
|
.setButtonText('Reset')
|
||||||
})
|
.setCta()
|
||||||
);
|
.onClick(async () => {
|
||||||
|
this.plugin.settings.gridSize = DEFAULT_SETTINGS.gridSize;
|
||||||
gridSizeSetting.addButton(button =>
|
await this.plugin.saveSettings();
|
||||||
button
|
})
|
||||||
.setButtonText('Reset')
|
);
|
||||||
.setCta()
|
|
||||||
.onClick(async () => {
|
|
||||||
this.plugin.settings.gridSize = DEFAULT_SETTINGS.gridSize;
|
|
||||||
(gridSizeText.components[0] as TextComponent).setValue(this.plugin.settings.gridSize.toString());
|
|
||||||
(gridSizeSlider.components[0] as SliderComponent).setValue(this.plugin.settings.gridSize);
|
|
||||||
await this.plugin.saveSettings();
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
new Setting(containerEl)
|
new Setting(containerEl)
|
||||||
.setName('Grid Colour')
|
.setName('Grid Colour')
|
||||||
|
|
Loading…
Reference in New Issue