Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions src/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,19 @@ async function getFont(id: string): Promise<Font | null> {
return font;
}

function reenableMutedSliders(font: Font, container: Element) {
(container as HTMLElement).addEventListener(
"mousedown",
async () => {
if (!font.inherit) return;
container.classList.remove("mute");
font.inherit = false;
await updateFont(font);
},
{ once: true }
);
}

async function applyNamedInstance(e: Event) {
const sel = e.target as HTMLSelectElement;
const parent = sel.closest(".font") as HTMLFieldSetElement;
Expand All @@ -326,13 +339,9 @@ async function applyNamedInstance(e: Event) {

font.inherit = sel.value == "--inherit--";

sliders.querySelectorAll(".variable-slider").forEach(slider => {
let input = slider.querySelector("input");
input.disabled = font.inherit;
});

if (font.inherit) {
sliders.classList.add("mute");
reenableMutedSliders(font, sliders);
await updateFont(font);
return;
}
Expand Down Expand Up @@ -367,6 +376,9 @@ async function addVariableSliders(font: Font, el: HTMLElement) {
// If we start with inherit, we start muted
if (font.inherit) {
container.classList.add("mute");
// If a user clicks muted sliders, assume they want to
// go into custom axes mode
reenableMutedSliders(font, container);
}
}

Expand All @@ -380,8 +392,6 @@ function addSlider(font: Font, axis: Axis, parent: HTMLElement) {
const label: HTMLLabelElement = el.querySelector("label");
const value: HTMLSpanElement = el.querySelector(".slider-value");

input.disabled = font.inherit;

label.innerText = axis.name;

input.name = `var-${axis.id}`;
Expand Down
5 changes: 5 additions & 0 deletions src/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ textarea:focus {
opacity: 0.5;
}

.variable-sliders-container.mute input {
accent-color: var(--gray-2);
opacity: 0.5;
}

.variable-slider {
display: flex;
margin-top: 0.125rem;
Expand Down