Skip to content

Commit f8c7c30

Browse files
committed
Flyout: show a caret on flyout (#394)
Small POC to showcase how it could look like #393 ![Peek 2024-10-03 12-29](https://github.com/user-attachments/assets/3632b4d5-ddba-46c8-a17e-0bcbb8d2a1f9) Closes #393 Closes #364
1 parent 481c7f6 commit f8c7c30

File tree

5 files changed

+31
-29
lines changed

5 files changed

+31
-29
lines changed

dist/readthedocs-addons.js

Lines changed: 9 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/readthedocs-addons.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/flyout.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import { ajv } from "./data-validation";
22
import READTHEDOCS_LOGO_WORDMARK from "./images/logo-wordmark-light.svg";
33
import READTHEDOCS_LOGO from "./images/logo-light.svg";
44
import { library, icon } from "@fortawesome/fontawesome-svg-core";
5-
import { faCodeBranch, faLanguage } from "@fortawesome/free-solid-svg-icons";
5+
import {
6+
faCodeBranch,
7+
faCaretDown,
8+
faLanguage,
9+
} from "@fortawesome/free-solid-svg-icons";
610
import { html, nothing, render, LitElement } from "lit";
711
import { classMap } from "lit/directives/class-map.js";
812
import { default as objectPath } from "object-path";
@@ -81,23 +85,28 @@ export class FlyoutElement extends LitElement {
8185
this.config.projects.current.versioning_scheme !==
8286
"single_version_without_translations"
8387
) {
84-
version = html`<span class="version"
85-
>${iconCodeBranch.node[0]} ${this.config.versions.current.slug}</span
86-
>`;
88+
version = html`<span class="version">
89+
${iconCodeBranch.node[0]} ${this.config.versions.current.slug}
90+
</span> `;
8791
}
8892

93+
const iconCaretDown = icon(faCaretDown, {
94+
classes: ["icon"],
95+
});
96+
8997
let translation = nothing;
9098
if (this.config.projects.translations.length > 0) {
91-
translation = html`<span class="language"
92-
>${iconLanguage.node[0]}
99+
translation = html`<span class="language">
100+
${iconLanguage.node[0]}
93101
${this.config.projects.current.language.code}</span
94-
>`;
102+
> `;
95103
}
96104

97105
return html`
98106
<header @click="${this._toggleOpen}">
99107
<img class="logo" src="${this.readthedocsLogo}" alt="Read the Docs" />
100108
${translation} ${version}
109+
<span class="caret">${iconCaretDown.node[0]}</span>
101110
</header>
102111
`;
103112
}

tests/__snapshots__/flyout.test.snap.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ snapshots["Flyout addon snapshot flyout completely"] =
1515
<span class="version">
1616
latest
1717
</span>
18+
<span class="caret">
19+
</span>
1820
</header>
1921
<main class="closed">
2022
<dl class="languages">
@@ -132,6 +134,8 @@ snapshots["Flyout addon snapshot flyout with search disabled"] =
132134
<span class="version">
133135
latest
134136
</span>
137+
<span class="caret">
138+
</span>
135139
</header>
136140
<main class="closed">
137141
<dl class="languages">

tests/flyout.test.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@
243243
<img class="logo" alt="Read the Docs" />
244244
<span class="language">en</span>
245245
<span class="version">latest</span>
246+
<span class="caret"></span>
246247
</header>
247248
`,
248249
{ ignoreAttributes: [{ tags: ["img"], attributes: ["src"] }] },

0 commit comments

Comments
 (0)