-
Notifications
You must be signed in to change notification settings - Fork 78
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
Changes from all commits
f860608
73e3f08
2478913
1c00f2a
cb90f65
de30b9e
c6239ef
97af598
8df0829
37a20ba
c9c3545
0dea3a0
00e7d63
e7bff53
7640da7
fb7f9e8
25fd3af
fb9c311
2bf6be8
adf1d77
3db2b55
d1cf0cb
7574ff5
f1baa65
89b9210
6ac3516
718a94f
0f1f80b
310ecc0
f36cea4
5c960cb
b886d0b
7895b45
60672b5
c08851a
5ef3197
f1ac1f3
61b0667
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 |
---|---|---|
|
@@ -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 ( | ||
<div hidden={!this.hasSheets}> | ||
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. Q: is hidden required here considering slotted elements are rendered only if user parses them. 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. 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}> | ||
|
@@ -191,6 +211,7 @@ export class Shell implements ConditionalSlotComponent { | |
<div class={CSS.positionedSlotWrapper}> | ||
{this.renderAlerts()} | ||
{this.renderModals()} | ||
{this.renderSheets()} | ||
</div> | ||
); | ||
} | ||
|
There was a problem hiding this comment.
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
orhasSlottedSheet
instead ofhasSheets
.There was a problem hiding this comment.
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.There was a problem hiding this comment.
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.