Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

nugu/mdbook.nu

Raw
use nugu.nu

# Map semantic Nugu roles to mdBook's native light/dark theme slots.
def variables [theme: record, mode: string] {
    let p = $theme.palette
    let values = {
        color-scheme: $mode
        --color-scheme: $mode
        --bg: $p.content.backdrop
        --fg: $p.content.normal
        --sidebar-bg: $p.ui.backdrop
        --sidebar-fg: $p.ui.normal
        --sidebar-non-existant: $p.ui.minor
        --sidebar-active: $p.ui.accent
        --sidebar-spacer: $p.ui.unfocus
        --sidebar-header-border-color: $p.ui.important_local
        --scrollbar: $p.ui.minor
        --icons: $p.ui.normal
        --icons-hover: $p.ui.accent
        --links: $p.content.accent
        --inline-code-color: $p.ui.important_local
        --theme-popup-bg: $p.ui.backdrop
        --theme-popup-border: $p.ui.minor
        --theme-hover: $p.content.backdrop
        --quote-bg: $p.ui.backdrop
        --quote-border: $p.ui.important_global
        --warning-border: $p.warning
        --table-border-color: $"($p.ui.minor)66"
        --table-header-bg: $p.ui.backdrop
        --table-alternate-bg: $p.ui.backdrop
        --searchbar-border-color: $p.ui.minor
        --searchbar-bg: $p.ui.backdrop
        --searchbar-fg: $p.ui.normal
        --searchbar-shadow-color: transparent
        --searchresults-header-fg: $p.ui.normal
        --searchresults-border-color: $p.ui.minor
        --searchresults-li-bg: $p.ui.backdrop
        --search-mark-bg: $p.content.important_local
        --footnote-highlight: $"($p.content.focus)26"
        --overlay-bg: $"($p.content.backdrop)cc"
        --blockquote-note-color: $p.info
        --blockquote-tip-color: $p.content.focus
        --blockquote-important-color: $p.content.important_local
        --blockquote-warning-color: $p.warning
        --blockquote-caution-color: $p.error
        --copy-button-filter: (if $mode == dark { 'invert(1)' } else { 'none' })
        --copy-button-filter-hover: (if $mode == dark { 'invert(1)' } else { 'none' })
        --nugu-code-bg: $p.ui.backdrop
        --nugu-code-fg: $p.content.normal
        --nugu-code-keyword: $p.content.minor
        --nugu-code-string: $p.content.focus
        --nugu-code-value: $p.ui.important_local
        --nugu-mark-fg: $p.content.backdrop
    }
    $values | transpose name value | each { |entry|
        $"    ($entry.name): ($entry.value);"
    } | str join (char nl)
}

export def css [] {
    let light = (variables (nugu light) light)
    let dark = (variables (nugu dark) dark)
    $"/* Generated from Nugu mdbook.nu + nugu.nu + base.toml. Do not edit.
   Regenerate with: just mdbook <destination.css>
   Light/Rust select Nugu light; Navy/Coal/Ayu select Nugu dark. */
:root, html.light, html.rust, html:not\(.js\) {
($light)
}

html.navy, html.coal, html.ayu {
($dark)
}

html .hljs {
    color: var\(--nugu-code-fg\);
    background: var\(--nugu-code-bg\);
}
html .hljs-keyword, html .hljs-comment, html .hljs-meta {
    color: var\(--nugu-code-keyword\);
}
html .hljs-string, html .hljs-regexp, html .hljs-addition {
    color: var\(--nugu-code-string\);
}
html .hljs-attr, html .hljs-attribute, html .hljs-number,
html .hljs-literal, html .hljs-title, html .hljs-type {
    color: var\(--nugu-code-value\);
}
html .hljs-deletion { color: var\(--blockquote-caution-color\); }
html mark { color: var\(--nugu-mark-fg\); background: var\(--search-mark-bg\); }
"
}