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(shell): Add "Sheets" Slot #7579

Merged
merged 38 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f860608
feat(sheet): Add Sheet component. #6391
driskull Aug 11, 2023
73e3f08
WIP
driskull Aug 22, 2023
2478913
cleanup
driskull Aug 22, 2023
1c00f2a
cleanup
driskull Aug 22, 2023
cb90f65
docs, demos, cleanup
driskull Aug 22, 2023
de30b9e
cleanup
driskull Aug 22, 2023
c6239ef
WIP
driskull Aug 22, 2023
97af598
cleanup
driskull Aug 22, 2023
8df0829
cleanup
driskull Aug 22, 2023
37a20ba
cleanup
driskull Aug 22, 2023
c9c3545
cleanup
driskull Aug 22, 2023
0dea3a0
cleanup examples
driskull Aug 22, 2023
00e7d63
Merge branch 'main' into dris0000/sheet
driskull Aug 22, 2023
e7bff53
feat(shell): Add "Sheets" Slot #7154
driskull Aug 22, 2023
7640da7
cleanup
driskull Aug 22, 2023
fb7f9e8
cleanup
driskull Aug 23, 2023
25fd3af
wip - Add animation and height / width
macandcheese Aug 23, 2023
fb9c311
Merge branch 'main' into dris0000/sheet
driskull Aug 23, 2023
2bf6be8
Merge branch 'dris0000/sheet' into dris0000/shell-sheet-slot
driskull Aug 23, 2023
adf1d77
Merge branch 'macandcheese/sheet-animation' into dris0000/sheet
macandcheese Aug 24, 2023
3db2b55
fix tests
driskull Aug 24, 2023
d1cf0cb
fix test
driskull Aug 24, 2023
7574ff5
cleanup + add CSS rtl util class
driskull Aug 24, 2023
f1baa65
test + bg color restore
driskull Aug 24, 2023
89b9210
cleanup
driskull Aug 24, 2023
6ac3516
cleanup beforeClose
driskull Aug 24, 2023
718a94f
test
driskull Aug 24, 2023
0f1f80b
fix test
driskull Aug 24, 2023
310ecc0
Merge branch 'dris0000/sheet' into dris0000/shell-sheet-slot
driskull Aug 24, 2023
f36cea4
beforeClose fixes
driskull Aug 25, 2023
5c960cb
review fixes
driskull Aug 25, 2023
b886d0b
partial review fixes
driskull Aug 28, 2023
7895b45
review fixes
driskull Aug 28, 2023
60672b5
Merge branch 'dris0000/sheet' into dris0000/shell-sheet-slot
driskull Aug 28, 2023
c08851a
Merge branch 'main' into dris0000/shell-sheet-slot
driskull Aug 28, 2023
5ef3197
fix slotted in shell scrim styles.
driskull Aug 28, 2023
f1ac1f3
add screenshot test
driskull Aug 28, 2023
61b0667
review fixes
driskull Aug 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 15 additions & 6 deletions packages/calcite-components/src/components/sheet/sheet.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -176,7 +179,7 @@
}

:host([display-mode="float"]) .container {
@apply m-3;
@apply p-3;
}

.container--open {
Expand Down Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export const SLOTS = {
header: "header",
footer: "footer",
alerts: "alerts",
sheets: "sheets",
modals: "modals",
};
182 changes: 182 additions & 0 deletions packages/calcite-components/src/components/shell/shell.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,188 @@ export const slottedModalAndAlert = (): string =>
</p>
</main>`);

export const slottedSheetOverlay = (): string =>
html(`
<p class="padded-content">
<calcite-notice width="full" open><span slot="title">Other page content outside of shell</span></calcite-notice>
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.
</p>
<calcite-shell
style="
width:100%;
height:500px;
max-height:80%;
position:relative;
"
>
<div class="gnav" slot="header">Header Example</div>
<calcite-sheet open slot="sheets" label="libero nunc" position="inline-start" display-mode="overlay">
<calcite-panel closable heading="Ultrices neque"
><p>
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.
</p>
<calcite-button slot="footer" width="half" appearance="outline">tincidunt lobortis</calcite-button>
<calcite-button slot="footer" width="half" appearance="outline">amet porttitor</calcite-button>
</calcite-panel>
</calcite-sheet>
<calcite-shell-panel id="primary-panel" slot="panel-start" position="start">
<calcite-action-bar slot="action-bar">
<calcite-action-group>
<calcite-action text="Save" icon="save" indicator> </calcite-action>
<calcite-action text-enabled icon="map" text="New" slot="menu-actions"> </calcite-action>
<calcite-action text-enabled icon="collection" text="Open" slot="menu-actions"> </calcite-action>
</calcite-action-group>
<calcite-action-group>
<calcite-action icon="layers" text="Layers" active> </calcite-action>
<calcite-action icon="basemap" text="Basemaps"> </calcite-action>
<calcite-action icon="legend" text="Legend"> </calcite-action>
<calcite-action icon="bookmark" text="Bookmarks"> </calcite-action>
</calcite-action-group>
</calcite-action-bar>
<calcite-panel heading="Panel">
<div class="padded-content">Panel content<br />Padding is fake.</div>
</calcite-panel>
</calcite-shell-panel>
<calcite-shell-panel slot="panel-end" position="end">
<calcite-action-bar slot="action-bar">
<calcite-tooltip slot="expand-tooltip" label="tooltip" disable-pointer>Add layers</calcite-tooltip>
<calcite-action-group>
<calcite-action text="Layer properties" icon="sliders-horizontal"> </calcite-action>
<calcite-action text="Styles" icon="shapes"> </calcite-action>
<calcite-action text="Filter" icon="layer-filter"> </calcite-action>
<calcite-action text="Configure pop-ups" icon="popup" active> </calcite-action>
<calcite-action text-enabled text="Configure attributes" icon="feature-details" slot="menu-actions">
</calcite-action>
<calcite-action text-enabled text="Labels" icon="label" slot="menu-actions"> </calcite-action>
<calcite-action text-enabled text="Tablew" icon="table" slot="menu-actions"> </calcite-action>
</calcite-action-group>
</calcite-action-bar>
<calcite-flow>
<calcite-flow-item heading="Flow 01">
<div class="padded-content">Flow 01 content<br />Padding is fake.</div>
</calcite-flow-item>
<calcite-flow-item heading="Flow 02">
<div class="padded-content">Flow 02 content<br />Padding is fake.</div>
</calcite-flow-item>
</calcite-flow>
</calcite-shell-panel>
<calcite-panel heading="Main content">
<div class="padded-content">The borders are only applied to "known" components.<br />Padding is fake.</div>
</calcite-panel>
<footer slot="footer">Footer Example</footer>
</calcite-shell>
<p class="padded-content">
<calcite-notice width="full" open><span slot="title">Notice outside of shell</span></calcite-notice>
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.
</p>
<script>
document.addEventListener("calcitePanelClose", () => {
document.querySelector("calcite-sheet").open = false;
});
</script>
`);

export const slottedSheetFloat = (): string =>
html(`
<p class="padded-content">
<calcite-notice width="full" open><span slot="title">Other page content outside of shell</span></calcite-notice>
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.
</p>
<calcite-shell
style="
width:100%;
height:500px;
max-height:80%;
position:relative;
"
>
<div class="gnav" slot="header">Header Example</div>
<calcite-sheet open slot="sheets" label="libero nunc" position="inline-start" display-mode="float">
<calcite-panel closable heading="Ultrices neque"
><p>
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.
</p>
<calcite-button slot="footer" width="half" appearance="outline">tincidunt lobortis</calcite-button>
<calcite-button slot="footer" width="half" appearance="outline">amet porttitor</calcite-button>
</calcite-panel>
</calcite-sheet>
<calcite-shell-panel id="primary-panel" slot="panel-start" position="start">
<calcite-action-bar slot="action-bar">
<calcite-action-group>
<calcite-action text="Save" icon="save" indicator> </calcite-action>
<calcite-action text-enabled icon="map" text="New" slot="menu-actions"> </calcite-action>
<calcite-action text-enabled icon="collection" text="Open" slot="menu-actions"> </calcite-action>
</calcite-action-group>
<calcite-action-group>
<calcite-action icon="layers" text="Layers" active> </calcite-action>
<calcite-action icon="basemap" text="Basemaps"> </calcite-action>
<calcite-action icon="legend" text="Legend"> </calcite-action>
<calcite-action icon="bookmark" text="Bookmarks"> </calcite-action>
</calcite-action-group>
</calcite-action-bar>
<calcite-panel heading="Panel">
<div class="padded-content">Panel content<br />Padding is fake.</div>
</calcite-panel>
</calcite-shell-panel>
<calcite-shell-panel slot="panel-end" position="end">
<calcite-action-bar slot="action-bar">
<calcite-tooltip slot="expand-tooltip" label="tooltip" disable-pointer>Add layers</calcite-tooltip>
<calcite-action-group>
<calcite-action text="Layer properties" icon="sliders-horizontal"> </calcite-action>
<calcite-action text="Styles" icon="shapes"> </calcite-action>
<calcite-action text="Filter" icon="layer-filter"> </calcite-action>
<calcite-action text="Configure pop-ups" icon="popup" active> </calcite-action>
<calcite-action text-enabled text="Configure attributes" icon="feature-details" slot="menu-actions">
</calcite-action>
<calcite-action text-enabled text="Labels" icon="label" slot="menu-actions"> </calcite-action>
<calcite-action text-enabled text="Tablew" icon="table" slot="menu-actions"> </calcite-action>
</calcite-action-group>
</calcite-action-bar>
<calcite-flow>
<calcite-flow-item heading="Flow 01">
<div class="padded-content">Flow 01 content<br />Padding is fake.</div>
</calcite-flow-item>
<calcite-flow-item heading="Flow 02">
<div class="padded-content">Flow 02 content<br />Padding is fake.</div>
</calcite-flow-item>
</calcite-flow>
</calcite-shell-panel>
<calcite-panel heading="Main content">
<div class="padded-content">The borders are only applied to "known" components.<br />Padding is fake.</div>
</calcite-panel>
<footer slot="footer">Footer Example</footer>
</calcite-shell>
<p class="padded-content">
<calcite-notice width="full" open><span slot="title">Notice outside of shell</span></calcite-notice>
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.
</p>
<script>
document.addEventListener("calcitePanelClose", () => {
document.querySelector("calcite-sheet").open = false;
});
</script>
`);

export const contentBehind = (): string =>
html(`<calcite-shell content-behind>
${headerHTML}
Expand Down
21 changes: 21 additions & 0 deletions packages/calcite-components/src/components/shell/shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -53,6 +54,8 @@ export class Shell implements ConditionalSlotComponent {

@State() hasModals = false;

@State() hasSheets = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: can this be hasSheet or hasSlottedSheet instead of hasSheets.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to maintain consistency with the above hasModals. It can be multiple sheets.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. wasn't aware that users will slot multiple sheets.


// --------------------------------------------------------------------------
//
// Lifecycle
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -129,6 +141,14 @@ export class Shell implements ConditionalSlotComponent {
);
}

renderSheets(): VNode {
return (
<div hidden={!this.hasSheets}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: is hidden required here considering slotted elements are rendered only if user parses them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because we don't want to display the div if no content is slotted here.

<slot key="sheets" name={SLOTS.sheets} onSlotchange={this.handleSheetsSlotChange} />
</div>
);
}

renderModals(): VNode {
return (
<div hidden={!this.hasModals}>
Expand Down Expand Up @@ -191,6 +211,7 @@ export class Shell implements ConditionalSlotComponent {
<div class={CSS.positionedSlotWrapper}>
{this.renderAlerts()}
{this.renderModals()}
{this.renderSheets()}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@
<calcite-alert open slot="alerts" placement="top-end"
><span slot="title">Alert slotted in Shell</span>
</calcite-alert>
<calcite-sheet open slot="sheets" label="libero nunc" position="inline-start" display-mode="overlay">
<calcite-panel closable heading="Ultrices neque"
><p>
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.
</p>
<calcite-button slot="footer" width="half" appearance="outline">tincidunt lobortis</calcite-button>
<calcite-button slot="footer" width="half" appearance="outline">amet porttitor</calcite-button>
</calcite-panel>
</calcite-sheet>
<calcite-shell-panel id="primary-panel" slot="panel-start" position="start">
<calcite-action-bar slot="action-bar">
<calcite-action-group>
Expand Down Expand Up @@ -243,6 +256,10 @@ <h3 slot="header">Test custom modal sizes in slotted modal in shell</h3>
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;
});
</script>
</body>
</html>