-
Notifications
You must be signed in to change notification settings - Fork 20
Flyout: define position="inline"
#500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 14 commits
186fde2
9c8806d
c242b50
ad9fc4e
f95fae5
55ab856
60b9e33
3372883
fa162e5
721cfa7
bf6962c
4af9427
49e6b4e
8acadc3
4e40ec2
bfde1ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ export class FlyoutElement extends LitElement { | |
static properties = { | ||
config: { state: true }, | ||
opened: { type: Boolean }, | ||
floating: { type: Boolean }, | ||
position: { type: String }, | ||
}; | ||
|
||
|
@@ -37,7 +36,6 @@ export class FlyoutElement extends LitElement { | |
|
||
this.config = null; | ||
this.opened = false; | ||
this.floating = true; | ||
this.position = "bottom-right"; | ||
this.readthedocsLogo = READTHEDOCS_LOGO; | ||
} | ||
|
@@ -327,10 +325,33 @@ export class FlyoutElement extends LitElement { | |
} | ||
|
||
updateCSSClasses() { | ||
this.classes = { floating: this.floating, container: true }; | ||
this.classes = { container: true }; | ||
this.classes[this.position] = true; | ||
} | ||
|
||
updated() { | ||
// Update the `margin-bottom` property for the main part of the flyout, | ||
// to display it exactly over the header of the flyout. | ||
// I understand this is not possible to do with CSS, so we use JavaScript for it. | ||
const main = this.renderRoot.querySelector("main"); | ||
const header = this.renderRoot.querySelector("header"); | ||
if (main !== null && header !== null) { | ||
if (this.position.includes("up")) { | ||
main.style.setProperty( | ||
"margin-bottom", | ||
`${header.getBoundingClientRect().height}px`, | ||
); | ||
} | ||
|
||
if (this.position.includes("down")) { | ||
main.style.setProperty( | ||
"margin-top", | ||
`${header.getBoundingClientRect().height}px`, | ||
); | ||
} | ||
} | ||
} | ||
|
||
|
||
render() { | ||
// The element doesn't yet have our config, don't render it. | ||
if (this.config === null) { | ||
|
Uh oh!
There was an error while loading. Please reload this page.