From e7987655fef6abf0ef88d3ccfc4985d509473a81 Mon Sep 17 00:00:00 2001
From: Matt Driscoll
Date: Mon, 28 Aug 2023 14:48:15 -0700
Subject: [PATCH] feat(shell): Add "Sheets" Slot (#7579)
**Related Issue:** #7154
## Summary
- depends on #7561
- Adds `sheets` slot to the shell where users can place `calcite-sheet`
components
- Adds screenshot test
- Adds example HTML
cc @macandcheese
---------
Co-authored-by: Adam
---
.../src/components/sheet/sheet.scss | 21 +-
.../src/components/shell/resources.ts | 1 +
.../src/components/shell/shell.stories.ts | 182 ++++++++++++++++++
.../src/components/shell/shell.tsx | 21 ++
.../demos/shell/basic-slotted-elements.html | 17 ++
5 files changed, 236 insertions(+), 6 deletions(-)
diff --git a/packages/calcite-components/src/components/sheet/sheet.scss b/packages/calcite-components/src/components/sheet/sheet.scss
index 23720d8eb3b..56d5fd9f11d 100644
--- a/packages/calcite-components/src/components/sheet/sheet.scss
+++ b/packages/calcite-components/src/components/sheet/sheet.scss
@@ -69,19 +69,22 @@
--calcite-sheet-hidden-position-internal: translate3d(0, 1rem, 0);
}
-:host([display-mode="float"][position="inline-start"]) .container {
+:host([display-mode="float"]) .container {
+ @apply shadow-2;
+}
+:host([display-mode="overlay"][position="inline-start"]) .container {
box-shadow: var(--calcite-scrim-shadow-inline-start-internal);
}
-:host([display-mode="float"][position="inline-end"]) .container {
+:host([display-mode="overlay"][position="inline-end"]) .container {
box-shadow: var(--calcite-scrim-shadow-inline-end-internal);
}
-:host([display-mode="float"][position="block-start"]) .container {
+:host([display-mode="overlay"][position="block-start"]) .container {
box-shadow: var(--calcite-scrim-shadow-block-start-internal);
}
-:host([display-mode="float"][position="block-end"]) .container {
+:host([display-mode="overlay"][position="block-end"]) .container {
box-shadow: var(--calcite-scrim-shadow-block-end-internal);
}
@@ -176,7 +179,7 @@
}
:host([display-mode="float"]) .container {
- @apply m-3;
+ @apply p-3;
}
.container--open {
@@ -205,8 +208,14 @@
/**
* Conditional styles for when Sheet is slotted in Shell
*/
-.container--slotted-in-shell {
+:host([position]) .container--slotted-in-shell {
@apply absolute pointer-events-auto;
+ inline-size: 100%;
+ max-inline-size: 100%;
+ min-inline-size: 100%;
+ block-size: 100%;
+ max-block-size: 100%;
+ min-block-size: 100%;
calcite-scrim {
@apply absolute;
}
diff --git a/packages/calcite-components/src/components/shell/resources.ts b/packages/calcite-components/src/components/shell/resources.ts
index 7f774cb974a..c066203bf9b 100644
--- a/packages/calcite-components/src/components/shell/resources.ts
+++ b/packages/calcite-components/src/components/shell/resources.ts
@@ -17,5 +17,6 @@ export const SLOTS = {
header: "header",
footer: "footer",
alerts: "alerts",
+ sheets: "sheets",
modals: "modals",
};
diff --git a/packages/calcite-components/src/components/shell/shell.stories.ts b/packages/calcite-components/src/components/shell/shell.stories.ts
index 73dcfe242f7..ee7fbec9a26 100644
--- a/packages/calcite-components/src/components/shell/shell.stories.ts
+++ b/packages/calcite-components/src/components/shell/shell.stories.ts
@@ -628,6 +628,188 @@ export const slottedModalAndAlert = (): string =>
`);
+export const slottedSheetOverlay = (): string =>
+ html(`
+
+ Other page content outside of shell
+ Master cleanse occupy lo-fi meh. Green juice williamsburg XOXO man bun ascot fit. Knausgaard heirloom four dollar
+ toast DSA chicharrones, typewriter chia raw denim. Bicycle rights mustache humblebrag, mixtape slow-carb retro
+ vibecession franzen chia. Bespoke coloring book hot chicken literally bushwick succulents wayfarers. Dreamcatcher
+ taiyaki celiac pork belly migas, fashion axe beard shabby chic. Forage chia twee bushwick readymade yuccie praxis
+ enamel pin cred mukbang bicycle rights VHS iPhone pour-over subway tile.
+
+
+ Header Example
+
+
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
+ dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
+ ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
+ fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
+ deserunt mollit anim id est laborum.
+
+ tincidunt lobortis
+ amet porttitor
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Panel content
Padding is fake.
+
+
+
+
+ Add layers
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Flow 01 content
Padding is fake.
+
+
+ Flow 02 content
Padding is fake.
+
+
+
+
+ The borders are only applied to "known" components.
Padding is fake.
+
+
+
+
+ Notice outside of shell
+ Edison bulb iceland narwhal fit DSA. Activated charcoal dreamcatcher shabby chic, microdosing gluten-free locavore
+ chambray tumblr hella sus ugh cronut tofu. Vibecession air plant etsy, vape church-key narwhal activated charcoal
+ offal kombucha hella. Actually mumblecore butcher, iceland man bun prism blog taiyaki roof party portland hashtag.
+
+
+`);
+
+export const slottedSheetFloat = (): string =>
+ html(`
+
+ Other page content outside of shell
+ Master cleanse occupy lo-fi meh. Green juice williamsburg XOXO man bun ascot fit. Knausgaard heirloom four dollar
+ toast DSA chicharrones, typewriter chia raw denim. Bicycle rights mustache humblebrag, mixtape slow-carb retro
+ vibecession franzen chia. Bespoke coloring book hot chicken literally bushwick succulents wayfarers. Dreamcatcher
+ taiyaki celiac pork belly migas, fashion axe beard shabby chic. Forage chia twee bushwick readymade yuccie praxis
+ enamel pin cred mukbang bicycle rights VHS iPhone pour-over subway tile.
+
+
+ Header Example
+
+
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
+ dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
+ ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
+ fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
+ deserunt mollit anim id est laborum.
+
+ tincidunt lobortis
+ amet porttitor
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Panel content
Padding is fake.
+
+
+
+
+ Add layers
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Flow 01 content
Padding is fake.
+
+
+ Flow 02 content
Padding is fake.
+
+
+
+
+ The borders are only applied to "known" components.
Padding is fake.
+
+
+
+
+ Notice outside of shell
+ Edison bulb iceland narwhal fit DSA. Activated charcoal dreamcatcher shabby chic, microdosing gluten-free locavore
+ chambray tumblr hella sus ugh cronut tofu. Vibecession air plant etsy, vape church-key narwhal activated charcoal
+ offal kombucha hella. Actually mumblecore butcher, iceland man bun prism blog taiyaki roof party portland hashtag.
+
+
+`);
+
export const contentBehind = (): string =>
html(`
${headerHTML}
diff --git a/packages/calcite-components/src/components/shell/shell.tsx b/packages/calcite-components/src/components/shell/shell.tsx
index 0f7840e4473..c8567dfa8e0 100755
--- a/packages/calcite-components/src/components/shell/shell.tsx
+++ b/packages/calcite-components/src/components/shell/shell.tsx
@@ -18,6 +18,7 @@ import { CSS, SLOTS } from "./resources";
* @slot center-row - [Deprecated] Use the `"panel-bottom"` slot instead. A slot for adding the bottom `calcite-shell-center-row`.
* @slot modals - A slot for adding `calcite-modal` components. When placed in this slot, the modal position will be constrained to the extent of the shell.
* @slot alerts - A slot for adding `calcite-alert` components. When placed in this slot, the alert position will be constrained to the extent of the shell.
+ * @slot sheets - A slot for adding `calcite-sheet` components. When placed in this slot, the alert position will be constrained to the extent of the shell.
*/
@Component({
@@ -53,6 +54,8 @@ export class Shell implements ConditionalSlotComponent {
@State() hasModals = false;
+ @State() hasSheets = false;
+
// --------------------------------------------------------------------------
//
// Lifecycle
@@ -90,6 +93,15 @@ export class Shell implements ConditionalSlotComponent {
});
};
+ handleSheetsSlotChange = (event: Event): void => {
+ this.hasSheets = !!slotChangeHasAssignedElement(event);
+ slotChangeGetAssignedElements(event)?.map((el) => {
+ if (el.nodeName === "CALCITE-SHEET") {
+ (el as HTMLCalciteSheetElement).slottedInShell = true;
+ }
+ });
+ };
+
handleModalsSlotChange = (event: Event): void => {
this.hasModals = !!slotChangeHasAssignedElement(event);
slotChangeGetAssignedElements(event)?.map((el) => {
@@ -129,6 +141,14 @@ export class Shell implements ConditionalSlotComponent {
);
}
+ renderSheets(): VNode {
+ return (
+
+
+
+ );
+ }
+
renderModals(): VNode {
return (
@@ -191,6 +211,7 @@ export class Shell implements ConditionalSlotComponent {
{this.renderAlerts()}
{this.renderModals()}
+ {this.renderSheets()}
);
}
diff --git a/packages/calcite-components/src/demos/shell/basic-slotted-elements.html b/packages/calcite-components/src/demos/shell/basic-slotted-elements.html
index ff0eece0e5d..0c7d529cd4b 100644
--- a/packages/calcite-components/src/demos/shell/basic-slotted-elements.html
+++ b/packages/calcite-components/src/demos/shell/basic-slotted-elements.html
@@ -47,6 +47,19 @@
Alert slotted in Shell
+
+
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et
+ dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip
+ ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu
+ fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia
+ deserunt mollit anim id est laborum.
+
+ tincidunt lobortis
+ amet porttitor
+
+
@@ -243,6 +256,10 @@ Test custom modal sizes in slotted modal in shell
customSizeModal.style.setProperty("--calcite-modal-height", heightInput.value);
customSizeModal.style.setProperty("--calcite-modal-width", widthInput.value);
});
+
+ document.addEventListener("calcitePanelClose", () => {
+ document.querySelector("calcite-sheet").open = false;
+ });