Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify list icon cells: remove redundant div #815

Merged
merged 2 commits into from
Sep 17, 2023
Merged
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
53 changes: 21 additions & 32 deletions src/fontra/views/editor/panel-designspace-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,47 +889,36 @@ function suggestedSourceNameFromLocation(location) {
function makeIconCellFactory(iconPaths, triggerOnDoubleClick = false) {
return (item, colDesc) => {
const value = item[colDesc.key];
const clickSymbol = triggerOnDoubleClick ? "ondblclick" : "onclick";
const iconElement = html.createDomElement("inline-svg", {
src: iconPaths[boolInt(value)],
});
const clickSymbol = triggerOnDoubleClick ? "ondblclick" : "onclick";
return html.div(
{
style: "width: 1.2em; height: 1.2em;",
ondblclick: (event) => {
event.stopImmediatePropagation();
},
[clickSymbol]: (event) => {
const newValue = !item[colDesc.key];
item[colDesc.key] = newValue;
iconElement.src = iconPaths[boolInt(newValue)];
event.stopImmediatePropagation();
},
style: "width: 1.2em; height: 1.2em;",
ondblclick: (event) => {
event.stopImmediatePropagation();
},
[iconElement]
);
[clickSymbol]: (event) => {
const newValue = !item[colDesc.key];
item[colDesc.key] = newValue;
iconElement.src = iconPaths[boolInt(newValue)];
event.stopImmediatePropagation();
},
});
return iconElement;
};
}

function interpolationErrorCell(item, colDesc) {
const iconElement = html.createDomElement("inline-svg", {
src: "/tabler-icons/bug.svg",
});
return item[colDesc.key]
? html.div(
{
style: "width: 1.2em; height: 1.2em; color: #F36;",
onclick: (event) => {
event.stopImmediatePropagation();
dialog(
"The source has an interpolation incompatibility",
item[colDesc.key],
[{ title: "Okay" }]
);
},
? html.createDomElement("inline-svg", {
src: "/tabler-icons/bug.svg",
style: "width: 1.2em; height: 1.2em; color: #F36;",
onclick: (event) => {
event.stopImmediatePropagation();
dialog("The source has an interpolation incompatibility", item[colDesc.key], [
{ title: "Okay" },
]);
},
[iconElement]
)
})
: "";
}

Expand Down