Skip to content

Commit

Permalink
Allow targeting specific settings with CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed Jul 13, 2021
1 parent ea63705 commit c39fbbf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-style-settings",
"name": "Style Settings",
"version": "0.2.6",
"version": "0.2.7",
"minAppVersion": "0.11.5",
"description": "Offers controls for adjusting theme, plugin, and snippet CSS variables.",
"author": "mgmeyers",
Expand Down
20 changes: 20 additions & 0 deletions src/settingHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export function createHeading(opts: {
.then((setting) => {
if (opts.config.collapsed) setting.settingEl.addClass("is-collapsed");
setting.settingEl.dataset.level = opts.config.level.toString();
setting.settingEl.dataset.id = opts.config.id;

const iconContainer = createSpan({
cls: "style-settings-collapse-indicator",
Expand Down Expand Up @@ -120,6 +121,9 @@ export function createClassToggle(opts: {
document.body.classList.remove(config.id);
}
});
})
.then((setting) => {
setting.settingEl.dataset.id = opts.config.id;
});
}

Expand Down Expand Up @@ -166,6 +170,9 @@ export function createVariableText(opts: {
settingsManager.clearSetting(sectionId, config.id);
});
b.setTooltip(resetTooltip);
})
.then((setting) => {
setting.settingEl.dataset.id = opts.config.id;
});
}

Expand Down Expand Up @@ -220,6 +227,9 @@ export function createVariableNumber(opts: {
settingsManager.clearSetting(sectionId, config.id);
});
b.setTooltip(resetTooltip);
})
.then((setting) => {
setting.settingEl.dataset.id = opts.config.id;
});
}

Expand Down Expand Up @@ -272,6 +282,9 @@ export function createVariableNumberSlider(opts: {
settingsManager.clearSetting(sectionId, config.id);
});
b.setTooltip(resetTooltip);
})
.then((setting) => {
setting.settingEl.dataset.id = opts.config.id;
});
}

Expand Down Expand Up @@ -316,6 +329,9 @@ export function createVariableSelect(opts: {
settingsManager.clearSetting(sectionId, config.id);
});
b.setTooltip(resetTooltip);
})
.then((setting) => {
setting.settingEl.dataset.id = opts.config.id;
});
}

Expand Down Expand Up @@ -409,6 +425,8 @@ export function createVariableColor(opts: {
.setName(config.title)
.setDesc(createDescription(config.description, config.default))
.then((setting) => {
setting.settingEl.dataset.id = opts.config.id;

pickr = Pickr.create(
getPickrSettings({
el: setting.controlEl.createDiv({ cls: "picker" }),
Expand Down Expand Up @@ -519,6 +537,8 @@ export function createVariableThemedColor(opts: {
new Setting(containerEl)
.setName(config.title)
.then((setting) => {
setting.settingEl.dataset.id = opts.config.id;

// Construct description
setting.descEl.createSpan({}, (span) => {
if (config.description) {
Expand Down

0 comments on commit c39fbbf

Please sign in to comment.