PNG: Update styling; slightly usable now

This commit is contained in:
Evan Hahn 2023-08-02 12:35:48 -05:00
parent 92098e69b6
commit 28b9c28538
3 changed files with 116 additions and 4 deletions

View File

@ -1,3 +1,24 @@
:root {
--foreground-color: #111;
--background-color: #fff;
--activated-color: #333;
--tree-border-color: #ccc;
--tree-activated-border-color: #000;
--button-color: #fff;
--button-background-color: #495;
--button-background-color-hover: limegreen;
}
@media (prefers-color-scheme: dark) {
:root {
--foreground-color: #f0f0f0;
--background-color: #222;
--activated-color: #ddd;
--tree-border-color: #444;
--tree-activated-border-color: #fff;
}
}
* { * {
box-sizing: border-box; box-sizing: border-box;
} }
@ -6,12 +27,15 @@ html {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-size: 18pt; font-size: 18pt;
line-height: 1.5em; line-height: 1.5em;
color: var(--foreground-color);
background: var(--background-color);
} }
a { a {
color: mediumblue; color: inherit;
} }
input, textarea { input,
textarea {
font: inherit; font: inherit;
} }

View File

@ -0,0 +1,87 @@
#explorer {
display: flex;
overflow: hidden;
}
#explorer .bytes {
max-width: 15em;
font-family: Inconsolata, Consolas, Monaco, monospace;
font-size: 80%;
line-height: 1.5em;
white-space: pre-wrap;
}
#explorer .bytes span {
cursor: pointer;
}
#explorer .bytes span.activated {
background: var(--activated-color);
color: var(--background-color);
}
#explorer .tree {
padding-left: 0.5rem;
scrollbar-gutter: stable;
}
#explorer .tree details.activated {
outline-width: 3px;
outline-color: var(--tree-activated-border-color);
}
#explorer .tree details {
outline: 1px solid var(--tree-border-color);
border-radius: 10px;
padding: 0 0.5rem 0 0.5rem;
transition: outline ease-out 0.1s;
margin: 3px 3px 0.5rem 3px;
}
#explorer .tree details[open] {
padding-bottom: 6px;
}
#explorer .tree details p:last-child {
margin-bottom: 0;
}
#explorer .tree details .children {
margin-left: 0.5rem;
}
#explorer .tree details summary {
cursor: pointer;
user-select: none;
display: flex;
}
#explorer .tree details summary:before {
content: "▶";
margin-right: 0.2em;
transition: transform ease-out 0.1s;
}
#explorer .tree details[open]>summary:before {
transform: rotate(90deg);
}
#explorer .tree details summary:focus {
outline: none;
}
#explorer .tree details summary .title {
flex: 1;
font-weight: bold;
}
#explorer .tree details summary .bytecount {
margin-left: 0.5em;
font-size: 75%;
opacity: 0.5;
}
#explorer .tree details:not(.activated) {
background: var(--background-color);
color: var(--foreground-color);
}

View File

@ -32,7 +32,7 @@ class Explorer {
const description = "TODO: Description"; const description = "TODO: Description";
const nodeTreeEl = crel( const nodeTreeEl = crel(
"details", "details",
{ "data-path": path, open: isRoot }, { "data-path": path, ...(isRoot ? { open: "open" } : {}) },
crel( crel(
"summary", "summary",
{}, {},
@ -53,6 +53,7 @@ class Explorer {
child, child,
path.concat(index), path.concat(index),
); );
if (index > 0) nodeBytesEl.append(" ");
nodeBytesEl.append(childBytesEl); nodeBytesEl.append(childBytesEl);
treeChildrenEl.append(childTreeEl); treeChildrenEl.append(childTreeEl);
}); });
@ -61,7 +62,7 @@ class Explorer {
// TODO: Update this formatting // TODO: Update this formatting
nodeBytesEl.innerHTML = [...node.bytes].map((b) => nodeBytesEl.innerHTML = [...node.bytes].map((b) =>
b.toString(16).padStart(2, "0") b.toString(16).padStart(2, "0")
).join(""); ).join(" ");
} }
return [nodeBytesEl, nodeTreeEl]; return [nodeBytesEl, nodeTreeEl];