Skip to content

feat(shell-panel): Add displayMode and heightScale properties and deprecate detached and detachedHeightScale #6919

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

Merged
merged 37 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1759395
feat(shell-panel): Add overlaid property to overlay the content only.…
driskull May 4, 2023
8f7ef0e
fix resize separator
driskull May 4, 2023
5bd9e2a
test app
driskull May 4, 2023
d75eba6
Merge branch 'master' into dris0000/shell-panel-overlaid
driskull May 5, 2023
9a89722
add displayMode prop
driskull May 5, 2023
d679581
cleanup
driskull May 5, 2023
64727da
test
driskull May 5, 2023
9b83adf
update test apps
driskull May 5, 2023
12c4a6e
story
driskull May 5, 2023
9d29c8b
fix separator
driskull May 6, 2023
7512799
story
driskull May 6, 2023
84173eb
Update display mode demo
macandcheese May 6, 2023
1c73948
Update `detached` spacing when in `layout="horizontal"`
macandcheese May 6, 2023
bf34c6f
Merge branch 'master' into dris0000/shell-panel-overlaid
macandcheese May 6, 2023
d0d4d33
Add directional animation, shadow when overlaid
macandcheese May 8, 2023
37b7d67
Merge branch 'master' into dris0000/shell-panel-overlaid
driskull May 8, 2023
4d4aa3c
Default position to "start"
macandcheese May 8, 2023
cc4d704
Merge branch 'master' into dris0000/shell-panel-overlaid
driskull May 8, 2023
f5587fb
update usage
driskull May 9, 2023
4b786cc
Merge branch 'master' into dris0000/shell-panel-overlaid
driskull May 9, 2023
84919cb
doc update
driskull May 9, 2023
bf127b7
Merge branch 'dris0000/shell-panel-overlaid' of github.com:Esri/calci…
driskull May 9, 2023
3fab75e
rename values
driskull May 9, 2023
d31f5e4
add heightScale and deprecate detachedHeightScale
driskull May 9, 2023
9c5e0ea
cleanup
driskull May 9, 2023
fba2a7a
Merge branch 'master' into dris0000/shell-panel-overlaid
driskull May 9, 2023
5bc9b90
cleanup
driskull May 9, 2023
4385b6f
Merge branch 'dris0000/shell-panel-overlaid' of github.com:Esri/calci…
driskull May 9, 2023
a117a06
Merge branch 'master' into dris0000/shell-panel-overlaid
macandcheese May 10, 2023
c3506db
Update demo and styles
macandcheese May 11, 2023
f226499
Clean up
macandcheese May 12, 2023
da167e2
Merge branch 'master' into dris0000/shell-panel-overlaid
macandcheese May 12, 2023
410ac2c
Disable animation on story
macandcheese May 12, 2023
e388238
Merge branch 'master' into dris0000/shell-panel-overlaid
macandcheese May 12, 2023
4d8b78a
Merge branch 'master' into dris0000/shell-panel-overlaid
macandcheese May 12, 2023
3a6499a
Update z-index for overlay
macandcheese May 12, 2023
317bb1f
Merge branch 'master' into dris0000/shell-panel-overlaid
macandcheese May 15, 2023
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 src/components/shell-panel/interfaces.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type DisplayMode = "dock" | "float" | "overlay";
3 changes: 2 additions & 1 deletion src/components/shell-panel/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export const CSS = {
content: "content",
contentHeader: "content__header",
contentBody: "content__body",
contentDetached: "content--detached",
contentFloat: "content--float",
contentOverlay: "content--overlay",
separator: "separator"
};

Expand Down
79 changes: 75 additions & 4 deletions src/components/shell-panel/shell-panel.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { E2EElement, newE2EPage } from "@stencil/core/testing";
import { accessible, defaults, hidden, renders, slots, t9n } from "../../tests/commonTests";
import { getElementXY } from "../../tests/utils";
import { CSS, SLOTS } from "./resources";
import { CSS_UTILITY } from "../../utils/resources";

describe("calcite-shell-panel", () => {
describe("renders", () => {
Expand All @@ -22,6 +23,14 @@ describe("calcite-shell-panel", () => {
{
propertyName: "resizable",
defaultValue: false
},
{
propertyName: "detached",
defaultValue: false
},
{
propertyName: "displayMode",
defaultValue: "dock"
}
]));

Expand Down Expand Up @@ -136,21 +145,83 @@ describe("calcite-shell-panel", () => {

await page.setContent("<calcite-shell-panel><div>content</div></calcite-shell-panel>");

let detachedElement = await page.find(`calcite-shell-panel >>> .${CSS.contentDetached}`);
let detachedElement = await page.find(`calcite-shell-panel >>> .${CSS.contentFloat}`);

expect(detachedElement).toBeNull();

const panel = await page.find("calcite-shell-panel");

expect(await panel.getProperty("detached")).toBe(false);

panel.setProperty("displayMode", "float");

await page.waitForChanges();

expect(await panel.getProperty("detached")).toBe(true);

detachedElement = await page.find(`calcite-shell-panel >>> .${CSS.contentFloat}`);

expect(detachedElement).not.toBeNull();
});

it("should have overlaid class when overlaid", async () => {
const page = await newE2EPage();

await page.setContent("<calcite-shell-panel><div>content</div></calcite-shell-panel>");

let detachedElement = await page.find(`calcite-shell-panel >>> .${CSS.contentOverlay}`);

expect(detachedElement).toBeNull();

const panel = await page.find("calcite-shell-panel");

panel.setProperty("detached", true);
panel.setProperty("displayMode", "overlay");

await page.waitForChanges();

detachedElement = await page.find(`calcite-shell-panel >>> .${CSS.contentDetached}`);
detachedElement = await page.find(`calcite-shell-panel >>> .${CSS.contentOverlay}`);

expect(detachedElement).not.toBeNull();
});

it("should have correct animation class when overlaid, layout vertical, and ltr", async () => {
const page = await newE2EPage();

await page.setContent("<calcite-shell-panel><div>content</div></calcite-shell-panel>");

const panel = await page.find("calcite-shell-panel");

panel.setProperty("displayMode", "overlay");

await page.waitForChanges();

const animationClassRight = await page.find(`calcite-shell-panel >>> .${CSS_UTILITY.calciteAnimateInRight}`);
const animationClassLeft = await page.find(`calcite-shell-panel >>> .${CSS_UTILITY.calciteAnimateInLeft}`);

expect(animationClassRight).not.toBeNull();
expect(animationClassLeft).toBeNull();
});

it("should have correct animation class when overlaid, layout vertical, and rtl, position start", async () => {
const page = await newE2EPage();

await page.setContent(
"<div dir='rtl'><calcite-shell-panel position='start'><div>content</div></calcite-shell-panel></div>"
);

const panel = await page.find("calcite-shell-panel");

panel.setProperty("displayMode", "overlay");

await page.waitForChanges();

const animationClassRight = await page.find(`calcite-shell-panel >>> .${CSS_UTILITY.calciteAnimateInRight}`);
const animationClassLeft = await page.find(`calcite-shell-panel >>> .${CSS_UTILITY.calciteAnimateInLeft}`);

expect(animationClassRight).toBeNull();
expect(animationClassLeft).not.toBeNull();
});

it("should update width based on the requested CSS variable override", async () => {
const override = "678px";

Expand Down Expand Up @@ -488,7 +559,7 @@ describe("calcite-shell-panel", () => {
const page = await newE2EPage();
await page.setContent(
`<calcite-shell content-behind>
<calcite-shell-panel slot="panel-start" position="start" detached></calcite-shell-panel>
<calcite-shell-panel slot="panel-start" position="start" display-mode="float"></calcite-shell-panel>
<calcite-action text="test" style="height: 100%; width: 100%;" text-enabled></calcite-action>
</calcite-shell>`
);
Expand Down
71 changes: 60 additions & 11 deletions src/components/shell-panel/shell-panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @prop --calcite-shell-panel-height: When `layout` is `"horizontal"`, specifies the height of the component.
* @prop --calcite-shell-panel-max-height: When `layout` is `"horizontal"`, specifies the maximum height of the component.
* @prop --calcite-shell-panel-min-height: When `layout` is `"horizontal"`, specifies the minimum height of the component.
* @prop --calcite-shell-panel-detached-max-height: When `detached` is `true`, specifies the maximum height of the component.
* @prop --calcite-shell-panel-detached-max-height: When `displayMode` is `float`, specifies the maximum height of the component.
* @prop --calcite-shell-panel-z-index: Specifies the z-index value for the component.
*
*/
Expand All @@ -20,8 +20,23 @@
flex
flex-initial
items-stretch;
--calcite-shell-panel-detached-max-height: unset;
z-index: var(--calcite-shell-panel-z-index, theme("zIndex.default"));
--calcite-shell-panel-detached-max-height: unset;
Copy link
Member Author

Choose a reason for hiding this comment

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

@macandcheese should we rename these CSS props to not use detached and float instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah we should update to the final value name. At some point we can probably look to combine this with the other css vars, maybe when we look at the content-behind / Shell cases.

--calcite-shell-panel-shadow-block-start-internal: 0 4px 8px -1px rgba(0, 0, 0, 0.08),
0 2px 4px -1px rgba(0, 0, 0, 0.04);
--calcite-shell-panel-shadow-block-end-internal: 0 -4px 8px -1px rgba(0, 0, 0, 0.08),
0 -2px 4px -1px rgba(0, 0, 0, 0.04);
--calcite-shell-panel-shadow-inline-start-internal: 4px 0 8px -1px rgba(0, 0, 0, 0.08),
2px 0 4px -1px rgba(0, 0, 0, 0.04);
--calcite-shell-panel-shadow-inline-end-internal: -4px 0 8px -1px rgba(0, 0, 0, 0.08),
-2px 0 4px -1px rgba(0, 0, 0, 0.04);
}

.calcite--rtl.content--overlay {
--calcite-shell-panel-shadow-inline-start-internal: -4px 0 8px -1px rgba(0, 0, 0, 0.08),
-2px 0 4px -1px rgba(0, 0, 0, 0.04);
--calcite-shell-panel-shadow-inline-end-internal: 4px 0 8px -1px rgba(0, 0, 0, 0.08),
2px 0 4px -1px rgba(0, 0, 0, 0.04);
}

:host([layout="vertical"]) {
Expand Down Expand Up @@ -52,15 +67,15 @@
--calcite-shell-panel-min-width-internal: var(--calcite-shell-panel-min-width, 340px);
}

:host([detached-height-scale="s"]) .content--detached {
:host([detached-height-scale="s"]) .content--float {
Copy link
Member Author

Choose a reason for hiding this comment

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

Should we update this detached prop to say float as well? deprecate and add new?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or could we just deprecate this prop and use a CSS var instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we could look at changing how this behaves in the future, there’s a need for a “full” and “auto” height. “Float” sounds a bit weird in this context but if that’s the value name we should update to match.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jcfranco should we deprecate detatchedHeightScale in favor of a new prop?

Copy link
Member

Choose a reason for hiding this comment

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

Good point. I believe we should once we have the new prop in place.

Copy link
Contributor

@macandcheese macandcheese May 9, 2023

Choose a reason for hiding this comment

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

I wonder if we need this at all with the available css variables to constrain and set height, especially if it only affects the one mode.

Detached shell panel in vertical layout could be height: auto to fit content, and could set a max height of 100% (minus margin). Not sure how common having a defined height that is less than 100% but more than the height of the content is.

cc @asangma for general Shell FYI / use cases

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 added it but if we want to remove we can.

Copy link
Member Author

Choose a reason for hiding this comment

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

@macandcheese do you want me to remove the heightScale prop and just make it so a user can control the height via a CSS variable?

--calcite-shell-panel-detached-max-height-internal: var(--calcite-shell-panel-detached-max-height, 40vh);
}

:host([detached-height-scale="m"]) .content--detached {
:host([detached-height-scale="m"]) .content--float {
--calcite-shell-panel-detached-max-height-internal: var(--calcite-shell-panel-detached-max-height, 60vh);
}

:host([detached-height-scale="l"]) .content--detached {
:host([detached-height-scale="l"]) .content--float {
--calcite-shell-panel-detached-max-height-internal: var(--calcite-shell-panel-detached-max-height, 80vh);
}

Expand Down Expand Up @@ -194,26 +209,60 @@
overflow-hidden;
}

.content--detached {
.content--overlay {
@apply absolute
shadow-0;
}

:host([layout="vertical"]) .content--overlay {
@apply top-0 h-full;
}

:host([layout="horizontal"]) .content--overlay {
@apply left-0 w-full;
}

:host([layout="vertical"][position="start"]) .content--overlay {
inset-inline-start: 100%;
box-shadow: var(--calcite-shell-panel-shadow-inline-start-internal);
}

:host([layout="vertical"][position="end"]) .content--overlay {
inset-inline-end: 100%;
box-shadow: var(--calcite-shell-panel-shadow-inline-end-internal);
}

:host([layout="horizontal"][position="start"]) .content--overlay {
inset-block-start: 100%;
box-shadow: var(--calcite-shell-panel-shadow-block-start-internal);
}

:host([layout="horizontal"][position="end"]) .content--overlay {
inset-block-end: 100%;
box-shadow: var(--calcite-shell-panel-shadow-block-end-internal);
}

.content--float {
@apply shadow-0
mx-2
mt-2
mb-auto
h-auto
overflow-hidden
rounded;
}

.content--detached {
max-block-size: var(--calcite-shell-panel-detached-max-height-internal);
::slotted(calcite-panel),
::slotted(calcite-flow) {
max-block-size: unset;
}
}

:host([position="start"]) .content--detached,
:host([position="end"]) .content--detached {
:host([layout="horizontal"]) .content--float {
@apply my-2;
}

:host([position="start"]) .content--float,
:host([position="end"]) .content--float {
::slotted(calcite-panel),
::slotted(calcite-flow) {
@apply border-none;
Expand Down
Loading