Skip to content

Commit b3cfa57

Browse files
committed
simplify <summary> hover and paddings
1 parent d84f5af commit b3cfa57

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

src/edit/edit.css

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
/* postcss-simple-vars */
2+
$pad025: var(--pad025);
3+
$pad05: var(--pad05);
4+
$pad075: var(--pad075);
25
$pad: var(--pad);
3-
$pad025: calc(0.25 * $pad);
4-
$pad05: calc(0.5 * $pad);
5-
$pad075: calc(0.75 * $pad);
66
$plus-minus-pad: .5rem;
77
$targetGapY: 2px;
88

99
:root {
10+
--pad025: .25rem;
11+
--pad05: .5rem;
12+
--pad075: .75rem;
1013
--pad: 1rem; /* Edge padding for modals/blocks/whatnot. TODO: reuse it in more places */
11-
--pad05: $pad05;
1214
}
1315

1416
#global-progress {
@@ -104,10 +106,6 @@ h1 {
104106
}
105107

106108
/* basic info */
107-
#basic-info {
108-
margin-top: $pad025;
109-
margin-bottom: $pad;
110-
}
111109
#basic-info-name {
112110
display: flex;
113111
align-items: center;
@@ -188,11 +186,6 @@ a.icon {
188186
details {
189187
&[open] {
190188
overflow-y: auto;
191-
margin-top: calc(1.5 * $pad);
192-
> summary {
193-
position: absolute;
194-
margin-top: calc(-1.5 * $pad);
195-
}
196189
}
197190
}
198191
summary {
@@ -892,6 +885,10 @@ a.icon {
892885
#name {
893886
width: 100%;
894887
}
888+
#basic-info {
889+
margin-top: $pad025;
890+
margin-bottom: $pad;
891+
}
895892
#basic-info-enabled {
896893
margin-top: $pad025;
897894
> :nth-last-child(n + 2) {
@@ -1019,14 +1016,11 @@ a.icon {
10191016
flex-direction: row;
10201017
margin: $pad025 $pad025 $pad05;
10211018
> details[open] {
1022-
margin-top: 0;
10231019
z-index: 50;
10241020
&:is(:hover, :focus-within) {
10251021
z-index: 51;
10261022
}
10271023
> summary {
1028-
position: static;
1029-
margin-top: 0;
10301024
+ * {
10311025
position: absolute;
10321026
overflow: hidden auto;

src/edit/editor-header.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,16 @@ function initNameArea() {
5757

5858
async function peekDetails(evt) {
5959
evt.preventDefault();
60-
const elDetails = this.parentNode;
61-
if (!(elDetails.open = !elDetails.open)) return;
62-
while (elDetails.matches(':hover, :active')) {
63-
await sleep(500);
64-
await new Promise(cb => elDetails.on('mouseleave', cb, {once: true}));
60+
const el = this.parentElement;
61+
if (!(el.open = !el.open) || 'peek' in el.dataset)
62+
return;
63+
el.dataset.peek = ''; // also provides a way to style such temporarily open element
64+
while (el.open && el.matches(':hover, :active')) {
65+
await new Promise(cb => el.on('mouseleave', cb, {once: true}));
66+
await sleep(1000);
6567
}
66-
elDetails.open = false;
68+
el.open = false;
69+
delete el.dataset.peek;
6770
}
6871

6972
function showHotkeyInTooltip(_, mapName = prefs.__values['editor.keyMap']) {

0 commit comments

Comments
 (0)