Skip to content

Commit

Permalink
simplify icon construction: remov redundant div
Browse files Browse the repository at this point in the history
  • Loading branch information
justvanrossum committed Sep 17, 2023
1 parent cd17e46 commit 46a1d6a
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/fontra/views/editor/panel-designspace-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -889,25 +889,21 @@ 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;
};
}

Expand Down

0 comments on commit 46a1d6a

Please sign in to comment.