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(panel, flow-item): add scale property #9730

Merged
merged 14 commits into from
Jul 8, 2024
114 changes: 114 additions & 0 deletions packages/calcite-components/src/components.d.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { HeadingLevel } from "../functional/Heading";
import { SLOTS as PANEL_SLOTS } from "../panel/resources";
import { OverlayPositioning } from "../../utils/floating-ui";
import { CollapseDirection } from "../interfaces";
import { Scale } from "../interfaces";
import { FlowItemMessages } from "./assets/flow-item/t9n";
import { CSS, ICONS, SLOTS } from "./resources";

Expand Down Expand Up @@ -155,6 +156,9 @@ export class FlowItem
*/
@Prop({ reflect: true }) overlayPositioning: OverlayPositioning = "absolute";

/** Specifies the size of the component. */
@Prop({ reflect: true }) scale: Scale = "m";

/**
* When `true`, displays a back button in the component's header.
*
Expand Down Expand Up @@ -382,6 +386,7 @@ export class FlowItem
onCalcitePanelToggle={this.handlePanelToggle}
overlayPositioning={overlayPositioning}
ref={this.setContainerRef}
scale={this.scale}
>
{this.renderBackButton()}
<slot name={SLOTS.actionBar} slot={PANEL_SLOTS.actionBar} />
Expand Down
14 changes: 14 additions & 0 deletions packages/calcite-components/src/components/flow/flow.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,17 @@ export const noDoubleScrollbars_TestOnly = (): string => html`
</calcite-flow>
</div>
`;

export const scales = (): string => html`
<calcite-flow style="height: 100px; width: 300px;">
<calcite-flow-item heading="Flow-item heading" description="Flow-item description" scale="s" />
</calcite-flow>

<calcite-flow style="height: 100px">
<calcite-flow-item heading="Flow-item heading" description="Flow-item description" scale="m" />
</calcite-flow>

<calcite-flow style="height: 100px">
<calcite-flow-item heading="Flow-item heading" description="Flow-item description" scale="l" />
</calcite-flow>
`;
50 changes: 44 additions & 6 deletions packages/calcite-components/src/components/panel/panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,55 @@

:host([scale="s"]) {
.content-top,
.content-bottom {
.content-bottom,
.footer {
padding: var(--calcite-spacing-sm);
}

.header-content {
.heading {
font-size: theme("fontSize.n1h");
}

.description {
font-size: theme("fontSize.n2h");
}
}
}

:host([scale="m"]) {
.content-top,
.content-bottom {
.content-bottom,
.footer {
padding: var(--calcite-spacing-md);
}

.header-content {
.heading {
font-size: theme("fontSize.0h");
}

.description {
font-size: theme("fontSize.n1h");
}
}
}

:host([scale="l"]) {
.content-top,
.content-bottom {
padding: var(--calcite-spacing-xl);
.content-bottom,
.footer {
padding: var(--calcite-spacing-lg);
}

.header-content {
.heading {
font-size: theme("fontSize.1h");
}

.description {
font-size: theme("fontSize.0h");
}
}
}

Expand Down Expand Up @@ -90,21 +123,26 @@
overflow-hidden
px-3
py-3.5;

margin-inline-end: auto;

.heading,
.description {
@apply block
break-words
p-0;
}

.heading {
@apply text-0h mx-0 mt-0 mb-1 font-medium;
@apply mx-0 mt-0 mb-1 font-medium text-color-1;

&:only-child {
@apply mb-0;
}
}

.description {
@apply text-color-2 text-n1h;
@apply text-color-2;
}
}

Expand Down
36 changes: 36 additions & 0 deletions packages/calcite-components/src/components/panel/panel.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,3 +431,39 @@ export const footerSlotPrecedence = (): string => html`
${footerHTML}
</calcite-panel>
`;

export const scalesFontAndPadding = (): string => html`
<calcite-panel
heading="This is a heading"
description="And that's a description"
scale="s"
style="height: 220px; margin: 50px;"
>
<div slot="content-top">Content Top</div>
<div>Instead of the mahi mahi, may I just get the one mahi because I’m not that hungry?</div>
<div slot="content-bottom">Content Bottom</div>
${footerHTML}
</calcite-panel>
<calcite-panel
heading="This is a heading"
description="And that's a description"
scale="m"
style="height: 250px; margin: 50px;"
>
<div slot="content-top">Content Top</div>
<div>Instead of the mahi mahi, may I just get the one mahi because I’m not that hungry?</div>
<div slot="content-bottom">Content Bottom</div>
${footerHTML}
</calcite-panel>
<calcite-panel
heading="This is a heading"
description="And that's a description"
scale="l"
style="height: 260px; margin: 50px;"
>
<div slot="content-top">Content Top</div>
<div>Instead of the mahi mahi, may I just get the one mahi because I’m not that hungry?</div>
<div slot="content-bottom">Content Bottom</div>
${footerHTML}
</calcite-panel>
`;
7 changes: 7 additions & 0 deletions packages/calcite-components/src/components/panel/panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
} from "../../utils/t9n";
import { OverlayPositioning } from "../../utils/floating-ui";
import { CollapseDirection } from "../interfaces";
import { Scale } from "../interfaces";
import { PanelMessages } from "./assets/panel/t9n";
import { CSS, ICONS, SLOTS } from "./resources";

Expand Down Expand Up @@ -156,6 +157,9 @@ export class Panel
*/
@Prop({ reflect: true }) overlayPositioning: OverlayPositioning = "absolute";

/** Specifies the size of the component. */
@Prop({ reflect: true }) scale: Scale = "m";

//--------------------------------------------------------------------------
//
// Lifecycle
Expand Down Expand Up @@ -471,6 +475,7 @@ export class Panel
data-test="collapse"
icon={collapsed ? icons[0] : icons[1]}
onClick={this.collapse}
scale={this.scale}
text={collapse}
title={collapsed ? expand : collapse}
/>
Expand All @@ -482,6 +487,7 @@ export class Panel
data-test="close"
icon={ICONS.close}
onClick={this.close}
scale={this.scale}
text={close}
title={close}
/>
Expand Down Expand Up @@ -522,6 +528,7 @@ export class Panel
>
<calcite-action
icon={ICONS.menu}
scale={this.scale}
slot={ACTION_MENU_SLOTS.trigger}
text={messages.options}
/>
Expand Down
12 changes: 5 additions & 7 deletions packages/calcite-components/src/demos/flow.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@

<div class="child">
<calcite-flow custom-item-selectors="custom-flow-item">
<calcite-flow-item heading="flow-item-1">
<calcite-flow-item heading="flow-item-1" description="description" scale="m">
<div slot="content-top">Slot for a content-top.</div>
<img width="250" height="250" src="./_assets/images/placeholder.svg" />
<div slot="content-bottom">Content bottom!</div>
<div slot="footer">Footer!</div>
</calcite-flow-item>
<custom-flow-item heading="custom-flow-item">
<custom-flow-item heading="custom-flow-item" description="description" scale="m">
<div slot="content-top">Slot for a content-top.</div>
<img width="250" height="250" src="./_assets/images/placeholder.svg" />
<div slot="content-bottom">Content bottom!</div>
<div slot="footer">Footer!</div>
</custom-flow-item>
<calcite-flow-item heading="flow-item-2">
<calcite-flow-item heading="flow-item-2" description="description" scale="m">
<div slot="content-top">Slot for a content-top.</div>
<img width="250" height="250" src="./_assets/images/placeholder.svg" />
<div slot="content-bottom">Content bottom!</div>
Expand All @@ -64,10 +64,6 @@
icon-start="check"
></calcite-button>
<div slot="footer-end">
<calcite-button type="button" scale="s" kind="neutral" id="card-icon-test-2" icon-start="stairs">
</calcite-button>
<calcite-button type="button" scale="s" kind="neutral" id="card-icon-test-3" icon-start="ellipsis">
</calcite-button>
<calcite-dropdown type="hover">
<calcite-button id="card-icon-test-4" slot="trigger" scale="s" kind="neutral" icon-start="caret-down">
</calcite-button>
Expand Down Expand Up @@ -103,6 +99,8 @@

connectedCallback() {
this.flowItemEl.setAttribute("heading", this.getAttribute("heading"));
this.flowItemEl.setAttribute("description", this.getAttribute("description"));
this.flowItemEl.setAttribute("scale", this.getAttribute("scale"));
this.flowItemEl.setAttribute("show-back-button", this.getAttribute("show-back-button"));
this.flowItemEl.setAttribute("menu-open", this.getAttribute("menu-open"));
}
Expand Down
Loading