Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
00f72e0
Add styles based on the documentation tool
humitos Dec 16, 2024
24d7869
Use a reactive property to add specific classes
humitos Dec 17, 2024
f3477b7
Use `tool=sphinx` `tool-theme=furo` to add CSS rules
humitos Dec 18, 2024
053d931
Remove unused code
humitos Dec 18, 2024
8c337ea
Update furo font size
humitos Dec 18, 2024
9d08961
Update MkDocs Material font size
humitos Dec 18, 2024
12057bf
Useful for Jupyter Book and others
humitos Dec 18, 2024
28bb43c
Style for Antora
humitos Dec 18, 2024
434f187
Update snapshots to match `tool=` and `tool-theme=` attrs
humitos Dec 18, 2024
718b52a
Better comment
humitos Dec 18, 2024
531c7e2
Rename attribute with a `data-` prefix
humitos Jan 8, 2025
7f099cc
Adjust style a little more
humitos Jan 8, 2025
fe1319f
Show example of setting attributes and variables at parent DOM
agjohnson Jan 8, 2025
d6e86c6
Show example of setting attributes and variables at parent DOM (#484)
agjohnson Jan 9, 2025
1446007
Small tweaks to font sizes
humitos Jan 9, 2025
ed87f06
Fix some tests
humitos Jan 9, 2025
4d2a219
Handle error when checking mdBook
humitos Jan 9, 2025
6b5db39
More fixes
agjohnson Jan 9, 2025
12f1b3f
Update font sizes
agjohnson Jan 9, 2025
5d2a33f
Working example of CSS layer defaults
agjohnson Jan 13, 2025
1b2ce13
Merge branch 'main' into agj/css-variable-root-defaults
agjohnson Feb 19, 2025
a348a9e
Hack not needed because this is a native CSSStyleSheet
agjohnson Feb 19, 2025
d6c139b
Bad merge?
agjohnson Feb 19, 2025
047c286
Drop unused doctools.css
agjohnson Feb 19, 2025
f847c0e
Tune var usage and defaults
agjohnson Feb 19, 2025
69dfc0a
Lint
agjohnson Feb 19, 2025
5844acf
Relint
agjohnson Feb 19, 2025
92d9b08
Set global font-size and font-family
agjohnson Mar 21, 2025
dae5c61
Add CSS variable defaults for other addons
agjohnson Mar 22, 2025
7a39c9d
Default CSS to separate file
agjohnson May 1, 2025
78ab863
Add and fix variables for search customization
agjohnson May 1, 2025
9d046a8
Fix lint issues with out of date pre-commit plugin
agjohnson May 5, 2025
4b683a3
Add basic unit test example for flyout styles
agjohnson May 7, 2025
b567494
Lint fix
agjohnson May 7, 2025
f0f760f
Merge branch 'main' into agj/merge/css-variable-root-default-2
agjohnson May 7, 2025
3b252bd
Merge commit 'f0f760f' into agj/css-variable-root-default-2
agjohnson May 7, 2025
73de0c8
Undo temporary file changes for illustration/testing
agjohnson May 7, 2025
82cd5c0
Comment on test
agjohnson May 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
- repo: https://github.com/rbubley/mirrors-prettier
rev: "v3.5.3"
hooks:
- id: prettier
args: ["--ignore-path", ".prettierignore"]
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ <h2 id="notification">Notification</h2>
<readthedocs-notification class="raised toast"></readthedocs-notification>
<readthedocs-notification class="inverted"></readthedocs-notification>
<readthedocs-notification class="inverted raised"></readthedocs-notification>
<readthedocs-notification class="inverted" style="--readthedocs-notification-background-color: purple;"></readthedocs-notification>
<readthedocs-notification class="inverted" style="--readthedocs-notification-inverted-background-color: purple;"></readthedocs-notification>
<readthedocs-notification class="titled raised"></readthedocs-notification>
<readthedocs-notification class="titled inverted raised"></readthedocs-notification>
</body>
Expand Down
8 changes: 2 additions & 6 deletions src/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import * as customscript from "./customscript";
import * as application from "./application";
import { default as objectPath } from "object-path";

import doctoolsStyleSheet from "./doctools.css";
import { defaultStyleSheet } from "./defaults.js";

export class AddonsApplication {
constructor() {
Expand Down Expand Up @@ -125,11 +125,7 @@ export class AddonsApplication {
const elementHtml = document.querySelector("html");
if (elementHtml) {
// Inject styles at the parent DOM to set variables at :root
let styleSheet = doctoolsStyleSheet;
if (doctoolsStyleSheet instanceof CSSResult) {
styleSheet = doctoolsStyleSheet.styleSheet;
}
document.adoptedStyleSheets = [styleSheet];
document.adoptedStyleSheets = [defaultStyleSheet];

// If we detect a documentation tool, set attributes on :root to allow
// for CSS selectors to utilize these values.
Expand Down
27 changes: 27 additions & 0 deletions src/defaults.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@layer defaults {
:root {
--readthedocs-font-family:
"Lato", "proxima-nova", "Helvetica Neue", "Arial", sans-serif;
--readthedocs-font-size: 1rem;
}

:root[data-readthedocs-tool="mkdocs-material"] {
--readthedocs-font-size: 0.58rem;
}

:root[data-readthedocs-tool="antora"] {
--readthedocs-font-size: 0.7rem;
}

:root[data-readthedocs-tool="mdbook"] {
--readthedocs-font-size: 1.3rem;
}

:root[data-readthedocs-tool="sphinx"][data-readthedocs-tool-theme="furo"] {
--readthedocs-font-size: 0.725rem;
}

:root[data-readthedocs-tool="sphinx"][data-readthedocs-tool-theme="immaterial"] {
--readthedocs-font-size: 0.58rem;
}
}
29 changes: 29 additions & 0 deletions src/defaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import styleSheetDefaults from "./defaults.css";
import styleSheetFlyout from "./flyout.css";
import styleSheetFiletreediff from "./filetreediff.css";
import styleSheetNotification from "./notification.css";
import styleSheetSearch from "./search.css";

import { CSSResult } from "lit";

// We use a native construct here as Lit's CSSResult is largely read only.
export const defaultStyleSheet = new CSSStyleSheet();

const styleSheets = [
styleSheetDefaults,
styleSheetFlyout,
styleSheetFiletreediff,
styleSheetNotification,
styleSheetSearch,
];

for (let styleSheet of styleSheets) {
if (styleSheet instanceof CSSResult) {
styleSheet = styleSheet.styleSheet;
}
for (const rule of styleSheet.cssRules) {
if (rule instanceof CSSLayerBlockRule && rule.name == "defaults") {
defaultStyleSheet.insertRule(rule.cssText);
}
}
}
42 changes: 0 additions & 42 deletions src/doctools.css

This file was deleted.

73 changes: 33 additions & 40 deletions src/filetreediff.css
Original file line number Diff line number Diff line change
@@ -1,60 +1,53 @@
/* Using --addons-* prefix variables for consistency and to allow for overrides */
:host {
--addons-filetreediff-color: var(
--readthedocs-filetreediff-color,
rgb(252, 252, 252)
);
--addons-filetreediff-background-color: var(
--readthedocs-filetreediff-background-color,
rgb(39, 39, 37)
);
--addons-filetreediff-border-color: var(
--readthedocs-filetreediff-border-color,
#ddd
);
--addons-filetreediff-font-size: var(
--readthedocs-filetreediff-font-size,
0.85rem
);
--addons-filetreediff-label-color: var(
--readthedocs-filetreediff-label-color,
#333
);
@layer defaults {
:root {
--readthedocs-filetreediff-font-size: calc(
var(--readthedocs-font-size) * 0.85
);
--readthedocs-filetreediff-font-family: var(--readthedocs-font-family);

--readthedocs-filetreediff-color: rgb(252, 252, 252);
--readthedocs-filetreediff-background-color: rgb(39, 39, 37);
--readthedocs-filetreediff-border-color: #ddd;
--readthedocs-filetreediff-label-color: #333;
--readthedocs-filetreediff-chunks-color: #27ae60;
}
}

:host > div {
position: fixed;
top: 0;
right: 1rem;
color: var(--addons-filetreediff-color);
background-color: var(--addons-filetreediff-background-color);
padding: 0.25rem 0.75rem;
box-shadow: 0 0.1rem 0.25rem rgba(0, 0, 0, 0.1);
right: 1em;
color: var(--readthedocs-filetreediff-color);
background-color: var(--readthedocs-filetreediff-background-color);
padding: 0.25em 0.75em;
box-shadow: 0 0.1em 0.25em rgba(0, 0, 0, 0.1);
z-index: 2000;
border-radius: 0 0 0.375rem 0.375rem;
font-size: var(--addons-filetreediff-font-size);
border-radius: 0 0 0.375em 0.375em;
font-size: var(--readthedocs-filetreediff-font-size);
font-family: var(--readthedocs-filetreediff-font-family);
}

:host > div > div {
display: flex;
gap: 0.75rem;
gap: 0.75em;
align-items: center;
}

:host > div > div > select {
flex: 1;
padding: 0.25rem 0.5rem;
padding: 0.25em 0.5em;
border: 0;
color: var(--addons-filetreediff-color);
background-color: var(--addons-filetreediff-background-color);
border-radius: 0.25rem;
color: var(--readthedocs-filetreediff-color);
background-color: var(--readthedocs-filetreediff-background-color);
border-radius: 0.25em;
appearance: revert;
font-size: var(--readthedocs-filetreediff-font-size);
}

:host > div > div > label {
display: flex;
align-items: center;
gap: 0.35rem;
gap: 0.35em;
white-space: nowrap;
cursor: pointer;
}
Expand All @@ -65,15 +58,15 @@

:host > div > div > span:not(.chunks) {
display: flex;
width: 0.5rem;
width: 0.5em;
cursor: pointer;
}

:host > div > div > span.chunks {
color: var(--readthedocs-filetreediff-chunks-color, #27ae60);
color: var(--readthedocs-filetreediff-chunks-color);
font-weight: bold;
display: flex;
min-width: 2.5rem;
min-width: 2.5em;
}

:host > div > div > a {
Expand All @@ -90,11 +83,11 @@
/* Expand to full width on smaller screens */
@media (max-width: 768px) {
:host > div {
width: calc(100% - 1rem);
width: calc(100% - 1em);
margin: 0;
right: 0;
border-radius: 0;
padding: 0.5rem;
padding: 0.5em;
}

:host > div > div > select {
Expand Down
Loading