-
Notifications
You must be signed in to change notification settings - Fork 19
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`, | ||
); | ||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we should always avoid doing anything with JS, especially with What value do we not know that we need to perform calculations in JS to get? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know, but I did it in JS to show this is possible at least. I wrote what I need to do in #500 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know how to do that with pure CSS? 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In CSS this seems like it should just be addition. If we're mixing units, we should change them all to
This isn't clear to me still, so maybe I'm missing something here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I need to calculate the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to calculate it because we should know this value.
This doesn't seem correct. If the parent element is 10em, we get this effect if we try to fill vertical space with 100% height: We instead want the header to be static height, and derived from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I thought we wanted height and width to be dynamic and based on its container. If we want a fixed height, that should be easier to calculate, yeah. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. I added |
||
|
||
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.