Skip to content

Commit

Permalink
Merge pull request #778 from googlefonts/issue-767
Browse files Browse the repository at this point in the history
 Styling + behavior of checkboxes in the source list
  • Loading branch information
justvanrossum authored Sep 13, 2023
2 parents 63a2ad6 + f956fbe commit 13cd3b0
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/fontra/client/tabler-icons/circle-dot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/fontra/client/tabler-icons/circle-dotted.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/fontra/client/tabler-icons/eye-closed.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/fontra/client/tabler-icons/eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 44 additions & 2 deletions src/fontra/views/editor/panel-designspace-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
import { showMenu } from "/web-components/menu-panel.js";
import { dialogSetup } from "/web-components/modal-dialog.js";
import { IconButton } from "/web-components/icon-button.js";
import { InlineSVG } from "/web-components/inline-svg.js";

import { NumberFormatter } from "/web-components/ui-list.js";
import Panel from "./panel.js";

Expand Down Expand Up @@ -174,14 +176,14 @@ export default class DesignspaceNavigationPanel extends Panel {
{
title: "on",
key: "active",
cellFactory: checkboxListCell,
cellFactory: circleDotListCell,
width: "2em",
},
{ key: "name", title: "Source name", width: "12em" },
{
title: "bg",
key: "visible",
cellFactory: checkboxListCell,
cellFactory: eyeOnOffListCell,
width: "2em",
},
];
Expand Down Expand Up @@ -313,6 +315,7 @@ export default class DesignspaceNavigationPanel extends Panel {
delete backgroundLayers[layerName];
}
this.sceneController.backgroundLayers = backgroundLayers;
this._updateSources();
});
sourceController.addKeyListener("status", async (event) => {
await this.sceneController.editGlyphAndRecordChanges((glyph) => {
Expand Down Expand Up @@ -864,6 +867,45 @@ function suggestedSourceNameFromLocation(location) {
);
}

function circleDotListCell(item, colDesc) {
const value = item[colDesc.key];
return html.div(
{
style: "width: 1.2em; height: 1.2em;",
ondblclick: (event) => {
item[colDesc.key] = !item[colDesc.key];
event.stopImmediatePropagation();
},
},
[
html.createDomElement("inline-svg", {
src: value ? "/tabler-icons/circle-dot.svg" : "/tabler-icons/circle-dotted.svg",
}),
]
);
}

function eyeOnOffListCell(item, colDesc) {
const value = item[colDesc.key];
return html.div(
{
style: "width: 1.2em; height: 1.2em;",
onclick: (event) => {
item[colDesc.key] = !item[colDesc.key];
event.stopImmediatePropagation();
},
ondblclick: (event) => {
event.stopImmediatePropagation();
},
},
[
html.createDomElement("inline-svg", {
src: value ? "/tabler-icons/eye.svg" : "/tabler-icons/eye-closed.svg",
}),
]
);
}

function checkboxListCell(item, colDesc) {
const value = item[colDesc.key];
return html.input({
Expand Down

0 comments on commit 13cd3b0

Please sign in to comment.