|
20 | 20 | ); |
21 | 21 |
|
22 | 22 | # Wrap example in showcase page (source left, rendered right) |
| 23 | + exampleNames = builtins.sort builtins.lessThan ( |
| 24 | + builtins.filter (name: if name == "docs" then isLinux else true) exampleDirs |
| 25 | + ); |
| 26 | + |
23 | 27 | showcaseStyles = '' |
24 | 28 | * { box-sizing: border-box; margin: 0; padding: 0; } |
25 | | - body { display: flex; height: 100vh; font-family: system-ui, sans-serif; background: #1a1a2e; color: #eee; } |
| 29 | + body { display: flex; flex-direction: column; height: 100vh; font-family: system-ui, sans-serif; background: #1a1a2e; color: #ccc; } |
| 30 | + .topbar { padding: 0.6rem 1rem; background: #151525; border-bottom: 1px solid #333; font-size: 0.85rem; letter-spacing: 0.01em; } |
| 31 | + .topbar a { color: #6ab0ff; text-decoration: none; } |
| 32 | + .topbar a:hover { text-decoration: underline; } |
| 33 | + .topbar .current { color: #fff; text-decoration: underline; text-underline-offset: 3px; } |
| 34 | + .content { display: flex; flex: 1; min-height: 0; } |
26 | 35 | .source { flex: 1; overflow: auto; padding: 1rem; border-right: 1px solid #333; } |
27 | | - .source h1 { font-size: 1rem; margin-bottom: 0.5rem; color: #999; } |
28 | | - .source h1 a { color: #6ab0ff; text-decoration: none; } |
29 | 36 | .source pre { margin: 0; font-size: 0.8rem; line-height: 1.4; white-space: pre-wrap; word-break: break-word; } |
30 | 37 | .source code { font-family: ui-monospace, monospace; } |
31 | 38 | .preview { flex: 1; } |
32 | 39 | .preview iframe { width: 100%; height: 100%; border: none; } |
33 | 40 | ''; |
34 | 41 |
|
| 42 | + exampleLink = current: name: |
| 43 | + if name == current |
| 44 | + then [ "span.current" name ] |
| 45 | + else [ "a" { href = "../${name}/"; } name ]; |
| 46 | + |
| 47 | + navBar = current: [ "nav.topbar" |
| 48 | + [ "a" { href = "../../"; } "niccup docs" ] |
| 49 | + " | Examples: " |
| 50 | + (builtins.tail (pkgs.lib.concatMap (name: [ " - " (exampleLink current name) ]) exampleNames)) |
| 51 | + ]; |
| 52 | + |
35 | 53 | wrapExample = name: drv: |
36 | 54 | let |
37 | 55 | source = builtins.readFile ./examples/${name}/build.nix; |
|
42 | 60 | [ "style" (h.raw showcaseStyles) ] |
43 | 61 | ] |
44 | 62 | [ "body" |
45 | | - [ "div.source" |
46 | | - [ "h1" [ "a" { href = "../../"; } "← niccup" ] " / ${name}" ] |
47 | | - [ "pre" [ "code" source ] ] |
48 | | - ] |
49 | | - [ "div.preview" |
50 | | - [ "iframe" { src = "demo/"; } ] |
| 63 | + (navBar name) |
| 64 | + [ "div.content" |
| 65 | + [ "div.source" [ "pre" [ "code" source ] ] ] |
| 66 | + [ "div.preview" [ "iframe" { src = "demo/"; } ] ] |
51 | 67 | ] |
52 | 68 | ] |
53 | 69 | ]; |
|
0 commit comments