Skip to content
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

feat(card): Use an attribute to signal card is in full screen #669

Merged
merged 3 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions R/card.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ card <- function(..., full_screen = FALSE, height = NULL, max_height = NULL, min
min_height = validateCssUnit(min_height)
),
"data-bslib-card-init" = NA,
"data-full-screen" = if (full_screen) "false",
!!!attribs,
!!!children,
if (full_screen) full_screen_toggle(),
Expand Down
2 changes: 1 addition & 1 deletion inst/components/dist/card/card.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions inst/components/dist/card/card.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions inst/components/dist/card/card.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion inst/components/dist/card/card.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions inst/components/dist/card/card.min.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions inst/components/scss/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
max-height: var(--bslib-card-body-max-height, none);
}

&.bslib-full-screen > .card-body {
&[data-full-screen="true"] > .card-body {
max-height: var(--bslib-card-body-max-height-full-screen, none);
}

Expand Down Expand Up @@ -67,7 +67,7 @@
* Full screen card logic
*************************************************/

.bslib-full-screen {
[data-full-screen="true"] {
position: fixed;
inset: 3.5rem 1rem 1rem;
height: auto !important;
Expand All @@ -93,7 +93,7 @@
z-index: $zindex-popover;
}

.card:hover:not(.bslib-full-screen) > .bslib-full-screen-enter {
.card[data-full-screen="false"]:hover > .bslib-full-screen-enter {
display: block;
}

Expand Down
6 changes: 3 additions & 3 deletions srcts/src/components/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Card {
// eslint-disable-next-line @typescript-eslint/naming-convention
CLASS_CARD: "bslib-card",
// eslint-disable-next-line @typescript-eslint/naming-convention
CLASS_FULL_SCREEN: "bslib-full-screen",
ATTR_FULL_SCREEN: "data-full-screen",
// eslint-disable-next-line @typescript-eslint/naming-convention
CLASS_HAS_FULL_SCREEN: "bslib-has-full-screen",
// eslint-disable-next-line @typescript-eslint/naming-convention
Expand Down Expand Up @@ -133,7 +133,7 @@ class Card {
this.card.focus();
}

this.card.classList.add(Card.attr.CLASS_FULL_SCREEN);
this.card.setAttribute(Card.attr.ATTR_FULL_SCREEN, "true");
document.body.classList.add(Card.attr.CLASS_HAS_FULL_SCREEN);
this.card.insertAdjacentElement("beforebegin", this.overlay.container);
}
Expand All @@ -153,7 +153,7 @@ class Card {

// Remove overlay and remove full screen classes from card
this.overlay.container.remove();
this.card.classList.remove(Card.attr.CLASS_FULL_SCREEN);
this.card.setAttribute(Card.attr.ATTR_FULL_SCREEN, "false");
this.card.removeAttribute("tabindex");
document.body.classList.remove(Card.attr.CLASS_HAS_FULL_SCREEN);
}
Expand Down