Skip to content

Commit

Permalink
Update mdbook and catppuccin css
Browse files Browse the repository at this point in the history
  • Loading branch information
salif committed Nov 19, 2024
1 parent b832b6e commit b8d43a5
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 127 deletions.
110 changes: 38 additions & 72 deletions docs/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -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%);

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
25 changes: 9 additions & 16 deletions theme/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<i class=\"tooltiptext\"></i>';
Expand Down Expand Up @@ -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 = '<i class="tooltiptext"></i>';
copyCodeClipboardButton.title = 'Copy to clipboard';
copyCodeClipboardButton.setAttribute('aria-label', copyCodeClipboardButton.title);
Expand Down Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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', {
Expand Down
58 changes: 19 additions & 39 deletions theme/index.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE HTML>
<html lang="{{ language }}" class="{{ default_theme }}" dir="{{ text_direction }}">
<html lang="{{ language }}" class="{{ default_theme }} sidebar-visible" dir="{{ text_direction }}">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
Expand All @@ -11,13 +11,14 @@
<base href="{{ base_url }}">
{{/if}}

<meta name="description" content="{{ description }}: {{ chapter_title }}">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Custom HTML head -->
{{> head}}

<meta name="description" content="{{ description }} : {{ chapter_title }}">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#e1e1db">

{{#if favicon_svg}}
<link rel="icon" href="{{ path_to_root }}favicon.svg">
{{/if}}
Expand Down Expand Up @@ -54,15 +55,17 @@
<!-- MathJax -->
<script async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
{{/if}}
</head>
<body class="sidebar-visible no-js">
<div id="body-container">

<!-- Provide site root to javascript -->
<script>
var path_to_root = "{{ path_to_root }}";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}";
</script>

<!-- Start loading toc.js asap -->
<script src="{{ path_to_root }}toc.js"></script>
</head>
<body>
<div id="body-container">
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script>
try {
Expand All @@ -84,19 +87,16 @@
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
const html = document.documentElement;
html.classList.remove('{{ default_theme }}')
html.classList.add(theme);
var body = document.querySelector('body');
body.classList.remove('no-js')
body.classList.add('js');
html.classList.add("js");
</script>

<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">

<!-- Hide / unhide sidebar before it is displayed -->
<script>
var body = document.querySelector('body');
var sidebar = null;
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
if (document.body.clientWidth >= 1080) {
Expand All @@ -106,41 +106,21 @@
sidebar = 'hidden';
}
sidebar_toggle.checked = sidebar === 'visible';
body.classList.remove('sidebar-visible');
body.classList.add("sidebar-" + sidebar);
html.classList.remove('sidebar-visible');
html.classList.add("sidebar-" + sidebar);
</script>

<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
{{#toc}}{{/toc}}
</div>
<!-- populated by js -->
<mdbook-sidebar-scrollbox class="sidebar-scrollbox"></mdbook-sidebar-scrollbox>
<noscript>
<iframe class="sidebar-iframe-outer" src="{{ path_to_root }}toc.html"></iframe>
</noscript>
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
<div class="sidebar-resize-indicator"></div>
</div>
</nav>

<!-- Track and set sidebar scroll position -->
<script>
var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
sidebarScrollbox.addEventListener('click', function(e) {
if (e.target.tagName === 'A') {
sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
}
}, { passive: true });
var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
sessionStorage.removeItem('sidebar-scroll');
if (sidebarScrollTop) {
// preserve sidebar scroll position when navigating via links within sidebar
sidebarScrollbox.scrollTop = sidebarScrollTop;
} else {
// scroll sidebar to current active section when navigating via "next/previous chapter" buttons
var activeSection = document.querySelector('#sidebar .active');
if (activeSection) {
activeSection.scrollIntoView({ block: 'center' });
}
}
</script>

<div id="page-wrapper" class="page-wrapper">

<div class="page">
Expand Down

0 comments on commit b8d43a5

Please sign in to comment.