Skip to content

Commit 4e6b305

Browse files
zanderlehumitos
andauthored
Recreating flyout as a webcomponent (#86)
Building on top of the work started in #66 Closes #70 --------- Co-authored-by: Manuel Kaufmann <[email protected]>
1 parent db4f5b2 commit 4e6b305

7 files changed

+414
-13
lines changed

dist/readthedocs-addons.js

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/readthedocs-addons.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/_/readthedocs-addons.json

+15-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,13 @@
7979
"inject_styles": true
8080
},
8181
"flyout": {
82-
"translations": [],
82+
"enabled": true,
83+
"translations": [
84+
{
85+
"slug": "es",
86+
"url": "/es/"
87+
}
88+
],
8389
"versions": [
8490
{
8591
"slug": "stable",
@@ -102,9 +108,16 @@
102108
"url": "/en/v2.0/"
103109
}
104110
],
105-
"downloads": [],
111+
"downloads": [
112+
{
113+
"name": "PDF",
114+
"url": "/_/downloads/en/latest/"
115+
}
116+
],
106117
"vcs": {
107118
"url": "https://github.com",
119+
"name": "GitHub",
120+
"view_url": "https://github.com/readthedocs/readthedocs-client",
108121
"username": "readthedocs",
109122
"repository": "reathedocs-client",
110123
"branch": "main",

src/images/logo-wordmark-light.svg

+19
Loading

src/index.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { getReadTheDocsConfig } from "./readthedocs-config";
22
import * as notification from "./notification";
33
import * as analytics from "./analytics";
44
import * as search from "./search";
5+
import * as newflyout from "./new-flyout";
56
import * as ethicalads from "./ethicalads";
67
import { domReady, isReadTheDocsEmbedPresent } from "./utils";
78

@@ -18,11 +19,17 @@ export function setup() {
1819
})
1920
.then((config) => {
2021
let promises = [];
21-
let addons = [analytics.AnalyticsAddon, notification.NotificationAddon];
22+
let addons = [
23+
analytics.AnalyticsAddon,
24+
notification.NotificationAddon,
25+
newflyout.FlyoutAddon,
26+
];
2227

2328
if (!IS_PRODUCTION) {
24-
addons.push(search.SearchAddon);
29+
// Addons that are only available on development
2530
addons.push(ethicalads.EthicalAdsAddon);
31+
// NOTE: Disabling search for now because it's incompatible with Flyout
32+
// addons.push(search.SearchAddon);
2633
}
2734

2835
for (const addon of addons) {

src/new-flyout.css

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/* New */
2+
3+
.container {
4+
position: fixed;
5+
max-width: 300px;
6+
width: auto;
7+
height: auto;
8+
}
9+
10+
.container.bottom-right {
11+
right: 20px;
12+
bottom: 50px;
13+
}
14+
15+
.container.bottom-left {
16+
left: 20px;
17+
bottom: 50px;
18+
}
19+
20+
.container.top-left {
21+
left: 20px;
22+
top: 50px;
23+
}
24+
25+
.container.top-right {
26+
right: 20px;
27+
top: 50px;
28+
}
29+
30+
:host > div {
31+
font-family: var(
32+
--readthedocs-flyout-font-family,
33+
"Lato",
34+
"proxima-nova",
35+
"Helvetica Neue",
36+
"Arial",
37+
"sans-serif"
38+
);
39+
font-size: var(--readthedocs-flyout-font-size, 0.8rem);
40+
color: var(--readthedocs-flyout-color, rgb(128, 128, 128));
41+
background-color: var(--readthedocs-flyout-background-color, rgb(39, 39, 37));
42+
z-index: 3000;
43+
padding: 10px;
44+
overflow-y: auto;
45+
}
46+
47+
header {
48+
display: flex;
49+
flex-flow: row wrap;
50+
justify-content: space-between;
51+
align-items: center;
52+
cursor: pointer;
53+
}
54+
55+
header > span {
56+
color: var(--readthedocs-flyout-current-version-color, #27ae60);
57+
font-size: var(--readthedocs-flyout-header-font-size, 0.9rem);
58+
}
59+
60+
header > img.logo {
61+
text-align: center;
62+
width: 106px;
63+
margin-right: 20px;
64+
}
65+
66+
main {
67+
padding: 5px;
68+
margin-top: 5px;
69+
}
70+
71+
main.closed {
72+
display: none;
73+
}
74+
75+
dl {
76+
margin: 0;
77+
padding: 0;
78+
}
79+
80+
dl > dt {
81+
font-size: var(--readthedocs-flyout-dt-font-size, 0.9rem);
82+
color: var(--readthedocs-flyout-section-heading-color, rgb(128, 128, 128));
83+
}
84+
85+
dl > dd {
86+
display: inline-block;
87+
margin: 0;
88+
font-size: var(--readthedocs-flyout-dd-font-size, 0.9rem);
89+
}
90+
91+
dd > a {
92+
text-decoration: none;
93+
color: var(--readthedocs-flyout-item-link-color, rgb(252, 252, 252));
94+
padding: 6px;
95+
display: inline-block;
96+
}
97+
98+
dd form {
99+
padding: 6px;
100+
margin: 0;
101+
}
102+
103+
dd input {
104+
padding: 6px;
105+
font-size: 80%;
106+
}
107+
108+
hr {
109+
display: block;
110+
height: 1px;
111+
border: 0;
112+
margin: 20px 0;
113+
padding: 0;
114+
border-top-width: 1px;
115+
border-top-style: solid;
116+
border-top-color: var(--readthedocs-flyout-divider-color, #413d3d);
117+
}
118+
119+
small a {
120+
text-decoration: none;
121+
color: var(--readthedocs-flyout-link-color, rgb(42, 128, 185));
122+
}

0 commit comments

Comments
 (0)