Skip to content

Commit 24287b8

Browse files
committed
Flyout: use theme default for position (#482)
Initial POC to prove if this idea is possible and how we feel about it. I put together an example of what I understand we want to build here 😅 . In this example, the theme author will make explicitly how they want to use `readthedocs-flyout` HTML tag: ```html <readthedocs-flyout position="top-right"></readthedocs-flyout> ``` That will add the class `top-right` and show the flyout as follows: ![Screenshot_2025-01-08_12-44-20](https://github.com/user-attachments/assets/14ed7946-a1ab-4c44-84dc-d2a9ee456b8c) However, the project author can change the `position` value from the dashboard if they prefer to override the theme's default value: ![Peek 2025-01-08 12-46](https://github.com/user-attachments/assets/d8ab340b-2fc1-4704-ac0e-4a12bfe0ae07) * Related #51 * Requires readthedocs/ext-theme#554 * Requires readthedocs/readthedocs.org#11891 * Example using https://test-builds.readthedocs.io/en/addons-theme-defaults/ * Closes #434
1 parent 928ecdc commit 24287b8

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/flyout.js

+13
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ export class FlyoutElement extends LitElement {
5252
return;
5353
}
5454
this.config = config;
55+
56+
// The "position" is a value that can be defined from the dashboard.
57+
// There are two main options: "Default" or a specific value.
58+
// When "Default" is used, the value will be grabbed from the HTML element (e.g. explicitly set by the theme author).
59+
// In case it's not defined, the value defined in the `constructor` will be used ("bottom-right")
60+
const dashboardPosition = objectPath.get(
61+
this.config,
62+
"addons.flyout.position",
63+
null,
64+
);
65+
if (dashboardPosition) {
66+
this.position = dashboardPosition;
67+
}
5568
}
5669

5770
_close() {

0 commit comments

Comments
 (0)