From b8d43a543fab56784b5aeaf92aa8c956fb83f689 Mon Sep 17 00:00:00 2001 From: Salif Mehmed Date: Tue, 19 Nov 2024 21:44:18 +0200 Subject: [PATCH] Update mdbook and catppuccin css --- docs/custom.css | 110 +++++++++++++++++------------------------------- theme/book.js | 25 ++++------- theme/index.hbs | 58 +++++++++---------------- 3 files changed, 66 insertions(+), 127 deletions(-) diff --git a/docs/custom.css b/docs/custom.css index e74d886..20fea58 100644 --- a/docs/custom.css +++ b/docs/custom.css @@ -172,10 +172,16 @@ coral: #ff7f50, bg: #1e1e2e */ --search-mark-bg: #e69f67; --color-scheme: light; + + /* Same as `--icons` */ + --copy-button-filter: invert(51%) sepia(10%) saturate(393%) hue-rotate(198deg) brightness(86%) contrast(87%); + /* Same as `--sidebar-active` */ + --copy-button-filter-hover: invert(77%) sepia(16%) saturate(1798%) hue-rotate(328deg) brightness(98%) contrast(83%); } .light-sans, -.light-clr { +.light-clr, +html:not(.js) { --bg: hsl(0, 0%, 100%); --fg: hsl(0, 0%, 0%); @@ -221,8 +227,7 @@ coral: #ff7f50, bg: #1e1e2e */ @media (prefers-color-scheme: dark) { - .light-sans.no-js, - .light-clr.no-js { + html:not(.js) { --bg: hsl(200, 7%, 8%); --fg: #98a3ad; @@ -265,6 +270,14 @@ coral: #ff7f50, bg: #1e1e2e */ } } +.latte :is(h1, h2, h3, h4, h5, h6) a code { + color: #4c4f69; +} + +.latte a code { + color: #1e66f5; +} + .latte code { color: #4c4f69; background: #e6e9ef; @@ -299,38 +312,12 @@ coral: #ff7f50, bg: #1e1e2e */ color: #4c4f69; } -.frappe code { - color: #c6d0f5; - background: #292c3c; -} - -.frappe blockquote blockquote { - border-top: 0.1em solid #626880; - border-bottom: 0.1em solid #626880; -} - -.frappe hr { - border-color: #626880; - border-style: solid; -} - -.frappe del { - color: #949cbb; -} - -.frappe .ace_gutter { - color: #838ba7; - background: #292c3c; -} - -.frappe .ace_gutter-active-line.ace_gutter-cell { - color: #f4b8e4; - background: #292c3c; +.macchiato :is(h1, h2, h3, h4, h5, h6) a code { + color: #cad3f5; } -.frappe .tooltiptext { - background: #292c3c; - color: #c6d0f5; +.macchiato a code { + color: #8aadf4; } .macchiato code { @@ -367,6 +354,18 @@ coral: #ff7f50, bg: #1e1e2e */ color: #cad3f5; } +.mocha-sans :is(h1, h2, h3, h4, h5, h6) a code, +.mocha-clr :is(h1, h2, h3, h4, h5, h6) a code, +.mocha :is(h1, h2, h3, h4, h5, h6) a code { + color: #cdd6f4; +} + +.mocha-sans a code, +.mocha-clr a code, +.mocha a code { + color: #89b4fa; +} + .mocha-sans code, .mocha-clr code, .mocha code { @@ -425,9 +424,9 @@ coral: #ff7f50, bg: #1e1e2e */ --sidebar-spacer: #9ca0b0; --scrollbar: #9ca0b0; --icons: #9ca0b0; - --icons-hover: #8c8fa1; + --icons-hover: #7c7f93; --links: #1e66f5; - --inline-code-color: #fe640b; + --inline-code-color: #4c4f69; --theme-popup-bg: #e6e9ef; --theme-popup-border: #9ca0b0; --theme-hover: #ccd0da; @@ -448,39 +447,6 @@ coral: #ff7f50, bg: #1e1e2e */ --color-scheme: light; } -.frappe { - --bg: #303446; - --fg: #c6d0f5; - --sidebar-bg: #292c3c; - --sidebar-fg: #c6d0f5; - --sidebar-non-existant: #737994; - --sidebar-active: #8caaee; - --sidebar-spacer: #737994; - --scrollbar: #737994; - --icons: #737994; - --icons-hover: #838ba7; - --links: #8caaee; - --inline-code-color: #ef9f76; - --theme-popup-bg: #292c3c; - --theme-popup-border: #737994; - --theme-hover: #414559; - --quote-bg: #292c3c; - --quote-border: #232634; - --table-border-color: #414559; - --table-header-bg: #292c3c; - --table-alternate-bg: #292c3c; - --searchbar-border-color: #414559; - --searchbar-bg: #292c3c; - --searchbar-fg: #c6d0f5; - --searchbar-shadow-color: #232634; - --searchresults-header-fg: #c6d0f5; - --searchresults-border-color: #414559; - --searchresults-li-bg: #303446; - --search-mark-bg: #ef9f76; - --warning-border: #ef9f76; - --color-scheme: dark; -} - .macchiato { --bg: #24273a; --fg: #cad3f5; @@ -491,9 +457,9 @@ coral: #ff7f50, bg: #1e1e2e */ --sidebar-spacer: #6e738d; --scrollbar: #6e738d; --icons: #6e738d; - --icons-hover: #8087a2; + --icons-hover: #939ab7; --links: #8aadf4; - --inline-code-color: #f5a97f; + --inline-code-color: #cad3f5; --theme-popup-bg: #1e2030; --theme-popup-border: #6e738d; --theme-hover: #363a4f; @@ -526,9 +492,9 @@ coral: #ff7f50, bg: #1e1e2e */ --sidebar-spacer: #6c7086; --scrollbar: #6c7086; --icons: #6c7086; - --icons-hover: #7f849c; + --icons-hover: #9399b2; --links: #89b4fa; - --inline-code-color: #fab387; + --inline-code-color: #cdd6f4; --theme-popup-bg: #181825; --theme-popup-border: #6c7086; --theme-hover: #313244; diff --git a/theme/book.js b/theme/book.js index 9249f0f..ce595e6 100644 --- a/theme/book.js +++ b/theme/book.js @@ -222,7 +222,7 @@ function playground_text(playground, hidden = true) { } var clipButton = document.createElement('button'); - clipButton.className = 'fa fa-copy clip-button'; + clipButton.className = 'clip-button'; clipButton.title = 'Copy to clipboard'; clipButton.setAttribute('aria-label', clipButton.title); clipButton.innerHTML = ''; @@ -255,7 +255,7 @@ function playground_text(playground, hidden = true) { if (window.playground_copyable) { var copyCodeClipboardButton = document.createElement('button'); - copyCodeClipboardButton.className = 'fa fa-copy clip-button'; + copyCodeClipboardButton.className = 'clip-button'; copyCodeClipboardButton.innerHTML = ''; copyCodeClipboardButton.title = 'Copy to clipboard'; copyCodeClipboardButton.setAttribute('aria-label', copyCodeClipboardButton.title); @@ -286,6 +286,10 @@ function playground_text(playground, hidden = true) { var themeToggleButton = document.getElementById('theme-toggle'); var themePopup = document.getElementById('theme-list'); var themeColorMetaTag = document.querySelector('meta[name="theme-color"]'); + var themeIds = []; + themePopup.querySelectorAll('button.theme').forEach(function (el) { + themeIds.push(el.id); + }); function showThemes() { themePopup.style.display = 'block'; @@ -309,7 +313,7 @@ function playground_text(playground, hidden = true) { function get_theme() { var theme; try { theme = localStorage.getItem('mdbook-theme'); } catch (e) { } - if (theme === null || theme === undefined) { + if (theme === null || theme === undefined || !themeIds.includes(theme)) { return default_theme; } else { return theme; @@ -433,17 +437,6 @@ function playground_text(playground, hidden = true) { try { localStorage.setItem('mdbook-sidebar', 'visible'); } catch (e) { } } - - var sidebarAnchorToggles = document.querySelectorAll('#sidebar a.toggle'); - - function toggleSection(ev) { - ev.currentTarget.parentElement.classList.toggle('expanded'); - } - - Array.from(sidebarAnchorToggles).forEach(function (el) { - el.addEventListener('click', toggleSection); - }); - function hideSidebar() { body.classList.remove('sidebar-visible') body.classList.add('sidebar-hidden'); @@ -571,12 +564,12 @@ function playground_text(playground, hidden = true) { function hideTooltip(elem) { elem.firstChild.innerText = ""; - elem.className = 'fa fa-copy clip-button'; + elem.className = 'clip-button'; } function showTooltip(elem, msg) { elem.firstChild.innerText = msg; - elem.className = 'fa fa-copy tooltipped'; + elem.className = 'clip-button tooltipped'; } var clipboardSnippets = new ClipboardJS('.clip-button', { diff --git a/theme/index.hbs b/theme/index.hbs index 2bae551..23de1f8 100644 --- a/theme/index.hbs +++ b/theme/index.hbs @@ -1,5 +1,5 @@ - + @@ -11,13 +11,14 @@ {{/if}} - - {{> head}} + + + {{#if favicon_svg}} {{/if}} @@ -54,15 +55,17 @@ {{/if}} - - -
+ - + + + + +
- - -