feat: fixed-size chevron fold toggles

Use 30px hit area and 13.5x20 chevron (90% of the previous H2 marker) for every heading level, restore the outlined arrow, and keep it vertically centered to the left of the heading.
This commit is contained in:
2026-10-21 17:20:52 +08:00
parent a6eb39b127
commit b01553e421
6 changed files with 15 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

View File

@@ -421,9 +421,12 @@
btn.setAttribute('aria-expanded', 'true');
btn.title = window.__mdPreviewFoldLabel || 'Collapse / Expand';
btn.setAttribute('aria-label', btn.title);
btn.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" ' +
'stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">' +
'<path d="m6 9 6 6 6-6"/></svg>';
btn.innerHTML = '<svg class="mdp-fold-i-right" viewBox="0 0 12 20" fill="none" ' +
'stroke="currentColor" stroke-width="2.2" stroke-linecap="round" ' +
'stroke-linejoin="round"><path d="M2 2l8 8-8 8"/></svg>' +
'<svg class="mdp-fold-i-down" viewBox="0 0 20 12" fill="none" ' +
'stroke="currentColor" stroke-width="2.2" stroke-linecap="round" ' +
'stroke-linejoin="round"><path d="M2 2l8 8 8-8"/></svg>';
return btn;
}

View File

@@ -1089,13 +1089,18 @@ body.has-tabs {{ --chrome-top: 50px; }}
#preview .mdp-fold > h4,
#preview .mdp-fold > h5,
#preview .mdp-fold > h6 {{ position: relative; }}
/* Fixed 90%-of-H2 size for every heading level. */
#preview .mdp-fold-toggle {{
position: absolute; left: -1.3em; top: .05em;
width: 1.15em; height: 1.15em; padding: 0; border: 0; border-radius: 5px;
position: absolute; left: -34px; top: 50%;
width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%;
transform: translateY(-50%);
display: grid; place-items: center;
background: transparent; color: #999; cursor: pointer;
opacity: 0; transition: opacity .12s ease, background .12s ease;
}}
#preview .mdp-fold-toggle svg {{ grid-area: 1 / 1; overflow: visible; }}
#preview .mdp-fold-toggle .mdp-fold-i-right {{ display: none; width: 13.5px; height: 20px; }}
#preview .mdp-fold-toggle .mdp-fold-i-down {{ display: block; width: 20px; height: 13.5px; }}
#preview h1:hover > .mdp-fold-toggle,
#preview h2:hover > .mdp-fold-toggle,
#preview h3:hover > .mdp-fold-toggle,
@@ -1104,13 +1109,8 @@ body.has-tabs {{ --chrome-top: 50px; }}
#preview h6:hover > .mdp-fold-toggle,
#preview .mdp-fold-toggle:focus-visible {{ opacity: .6; }}
#preview .mdp-fold-toggle:hover {{ opacity: 1; background: rgba(0,0,0,.07); }}
#preview .mdp-fold-toggle svg {{ width: 100%; height: 100%; transition: transform .15s ease; }}
#preview .mdp-fold.collapsed > h1 > .mdp-fold-toggle svg,
#preview .mdp-fold.collapsed > h2 > .mdp-fold-toggle svg,
#preview .mdp-fold.collapsed > h3 > .mdp-fold-toggle svg,
#preview .mdp-fold.collapsed > h4 > .mdp-fold-toggle svg,
#preview .mdp-fold.collapsed > h5 > .mdp-fold-toggle svg,
#preview .mdp-fold.collapsed > h6 > .mdp-fold-toggle svg {{ transform: rotate(-90deg); }}
#preview .mdp-fold.collapsed > :is(h1, h2, h3, h4, h5, h6) > .mdp-fold-toggle .mdp-fold-i-right {{ display: block; }}
#preview .mdp-fold.collapsed > :is(h1, h2, h3, h4, h5, h6) > .mdp-fold-toggle .mdp-fold-i-down {{ display: none; }}
#preview .mdp-fold.collapsed > .mdp-fold-body {{ display: none; }}
#preview code {{ background: #f0f0f0; padding: 2px 6px; border-radius: 4px; font-size: 90%; }}
/* Code blocks stay dark (VS Dark) even in the light app theme. */