Skip to content

Commit cf136fb

Browse files
feat: psturtle.com <details> support ( Fixes #165 )
1 parent 7e4246e commit cf136fb

File tree

1 file changed

+103
-53
lines changed

1 file changed

+103
-53
lines changed

psturtle.com/layout.ps1

Lines changed: 103 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -129,22 +129,70 @@ body {
129129
max-width: 100vw;
130130
height: 100vh;
131131
font-family: '$Font', sans-serif;
132-
margin: 3em;
132+
margin: 1em;
133133
}
134+
134135
header, footer {
135136
text-align: center;
136-
margin: 2em;
137137
}
138138
139+
header > svg {
140+
display: block;
141+
text-align: center;
142+
}
143+
144+
$(
145+
if ($HeaderMenu) {
146+
# If the device is in landscape mode, use larger padding and gaps
147+
"@media (orientation: landscape) {"
148+
".header-menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 0.5em }"
149+
".header-menu-item { text-align: center; padding: 0.5em; }"
150+
"}"
151+
152+
# If the device is in portrait mode, use smaller padding and gaps
153+
"@media (orientation: portrait) {"
154+
".header-menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(66px, 1fr)); gap: 0.25em }"
155+
".header-menu-item { text-align: center; padding: 0.25em; }"
156+
"}"
157+
}
158+
)
159+
160+
$(
161+
if ($FooterMenu) {
162+
"@media (orientation: landscape) {"
163+
".footer-menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 0.5em }"
164+
".footer-menu-item { text-align: center; padding: 0.5em; }"
165+
"}"
166+
167+
"@media (orientation: portrait) {"
168+
".footer-menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 0.25em }"
169+
".footer-menu-item { text-align: center; padding: 0.25em; }"
170+
"}"
171+
}
172+
)
173+
174+
.logo {
175+
display: inline;
176+
height: 4.2rem;
177+
}
178+
179+
.expandInline { display: flex; flex-direction: row; }
180+
139181
@media (orientation: landscape) {
140-
.logo { height: 7em; }
182+
.logo { height: 4.2rem; }
183+
.site-title, .page-title {
184+
font-size: 1.23rem;
185+
line-height: .75rem
186+
}
141187
}
142188
143189
@media (orientation: portrait) {
144-
.logo { height: 3em; }
190+
.logo { height: 2.3rem; }
145191
.site-title, .page-title {
146192
font-size: 0.84em;
193+
line-height: .66rem
147194
}
195+
.expandInline { display: flex; flex-direction: column; }
148196
}
149197
150198
pre, code { font-family: '$CodeFont', monospace; }
@@ -163,26 +211,28 @@ a:hover, a:focus {
163211
} elseif ($site.FontSize) {
164212
"font-size: $($site.FontSize);"
165213
} else {
166-
"font-size: 1.21em;"
214+
"font-size: 1.23em;"
167215
})
168216
}
169217
170218
.taskbar {
171-
position: fixed;
219+
float: right;
220+
position: absolute;
172221
top: 0; right: 0; z-index: 10;
173-
text-align: right;
174-
display: flex; flex-direction: row-reverse;
175-
align-content: right; align-items: center;
222+
display: flex; flex-direction: row-reverse;
223+
align-content: right; align-items: flex-start;
176224
margin: 1em; gap: 0.5em;
177225
}
178226
179-
.taskbar * {
180-
vertical-align: middle;
227+
.taskbar summary {
228+
color: var(--cyan);
229+
list-style-type: none;
181230
}
182231
183232
.background {
184-
position: fixed;
233+
position: fixed;
185234
top: 0; left: 0;
235+
margin-bottom: 0;
186236
min-width: 100%; height:100%;
187237
}
188238
@@ -278,10 +328,43 @@ $bodyElements = @(
278328
}
279329
"</svg>"
280330
"<canvas id='background backdrop-canvas' width='0' height='0'></canvas>"
281-
331+
if ($taskbar) {
332+
# * Our taskbar
333+
"<div class='taskbar'>"
334+
foreach ($taskbarItem in $taskbar.GetEnumerator()) {
335+
$itemIconAndOrName =
336+
if ($page -and $page.Icon."$($taskbarItem.Key)") {
337+
$page.Icon[$taskbarItem.Key]
338+
if ($site.ShowTaskbarIconText -or $page.ShowTaskbarIconText) {
339+
$taskbarItem.Key
340+
}
341+
}
342+
elseif ($site -and $site.Icon."$($taskbarItem.Key)") {
343+
$site.Icon[$taskbarItem.Key]
344+
if ($site.ShowTaskbarIconText -or $page.ShowTaskbarIconText) {
345+
$taskbarItem.Key
346+
}
347+
}
348+
else { $taskbarItem.Key }
349+
if ($taskbarItem.Value -match '[<>]') {
350+
"<details>"
351+
"<summary>"
352+
$itemIconAndOrName
353+
"</summary>"
354+
$taskbarItem.Value
355+
"</details>"
356+
} else {
357+
"<a href='$($taskbarItem.Value)' class='icon-link' target='_blank'>"
358+
$itemIconAndOrName
359+
"</a>"
360+
}
361+
362+
}
363+
"</div>"
364+
}
282365

283366
# * The header
284-
"<header>"
367+
"<header>"
285368
if ($page.Header) {
286369
$page.Header -join [Environment]::NewLine
287370
} elseif ($site.Header) {
@@ -310,53 +393,20 @@ $bodyElements = @(
310393
}
311394
}
312395

313-
if ($headerMenu) {
314-
"<style>"
315-
# If the device is in landscape mode, use larger padding and gaps
316-
"@media (orientation: landscape) {"
317-
".header-menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 1em }"
318-
".header-menu-item { text-align: center; padding: 1em; }"
319-
"}"
320-
321-
# If the device is in portrait mode, use smaller padding and gaps
322-
"@media (orientation: portrait) {"
323-
".header-menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 0.25em }"
324-
".header-menu-item { text-align: center; padding: 0.25em; }"
325-
"}"
326-
"</style>"
396+
if ($headerMenu) {
327397
"<nav class='header-menu'>"
328398
foreach ($menuItem in $headerMenu.GetEnumerator()) {
329-
"<a href='$($menuItem.Value)' class='header-menu-item'>$([Web.HttpUtility]::HtmlEncode($menuItem.Key))</a>"
399+
if ($menuItem.Value -notmatch '[<>]') {
400+
"<a href='$($menuItem.Value)' class='header-menu-item'>$([Web.HttpUtility]::HtmlEncode($menuItem.Key))</a>"
401+
}
402+
330403
}
331404
"</nav>"
332405
}
333406
"</header>"
334407

335408
# * The main content
336-
"<div class='main'>$outputHtml</div>"
337-
338-
if ($taskbar) {
339-
# * Our taskbar
340-
"<div class='taskbar'>"
341-
foreach ($taskbarItem in $taskbar.GetEnumerator()) {
342-
"<a href='$($taskbarItem.Value)' class='icon-link' target='_blank'>"
343-
if ($page -and $page.Icon."$($taskbarItem.Key)") {
344-
$page.Icon[$taskbarItem.Key]
345-
if ($site.ShowTaskbarIconText -or $page.ShowTaskbarIconText) {
346-
$taskbarItem.Key
347-
}
348-
}
349-
elseif ($site -and $site.Icon."$($taskbarItem.Key)") {
350-
$site.Icon[$taskbarItem.Key]
351-
if ($site.ShowTaskbarIconText -or $page.ShowTaskbarIconText) {
352-
$taskbarItem.Key
353-
}
354-
}
355-
else { $taskbarItem.Key }
356-
"</a>"
357-
}
358-
"</div>"
359-
}
409+
"<div class='main'>$outputHtml</div>"
360410

361411
# * The footer
362412
"<footer>"

0 commit comments

Comments
 (0)