Skip to content

Commit eb000d8

Browse files
authored
feat(tile): add content-top and content-bottom slots, deprecate content-start and content-end slots (#8984)
**Related Issue:** #3462 ## Summary This PR adds 2 new slots `content-top` and `content-bottom` to replace the now deprecated `content-start` and `content-end` slots. --------- Co-authored-by: Erik Harper <[email protected]>
1 parent ee72777 commit eb000d8

File tree

6 files changed

+789
-115
lines changed

6 files changed

+789
-115
lines changed

packages/calcite-components/src/components.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5007,6 +5007,10 @@ export namespace Components {
50075007
*/
50085008
"wrap": "soft" | "hard";
50095009
}
5010+
/**
5011+
* @deprecated use `content-top` slot instead
5012+
* @deprecated use `content-bottom` slot instead
5013+
*/
50105014
interface CalciteTile {
50115015
/**
50125016
* When `true`, the component is active.
@@ -7239,6 +7243,10 @@ declare global {
72397243
prototype: HTMLCalciteTextAreaElement;
72407244
new (): HTMLCalciteTextAreaElement;
72417245
};
7246+
/**
7247+
* @deprecated use `content-top` slot instead
7248+
* @deprecated use `content-bottom` slot instead
7249+
*/
72427250
interface HTMLCalciteTileElement extends Components.CalciteTile, HTMLStencilElement {
72437251
}
72447252
var HTMLCalciteTileElement: {
@@ -12620,6 +12628,10 @@ declare namespace LocalJSX {
1262012628
*/
1262112629
"wrap"?: "soft" | "hard";
1262212630
}
12631+
/**
12632+
* @deprecated use `content-top` slot instead
12633+
* @deprecated use `content-bottom` slot instead
12634+
*/
1262312635
interface CalciteTile {
1262412636
/**
1262512637
* When `true`, the component is active.
@@ -13309,6 +13321,10 @@ declare module "@stencil/core" {
1330913321
"calcite-table-row": LocalJSX.CalciteTableRow & JSXBase.HTMLAttributes<HTMLCalciteTableRowElement>;
1331013322
"calcite-tabs": LocalJSX.CalciteTabs & JSXBase.HTMLAttributes<HTMLCalciteTabsElement>;
1331113323
"calcite-text-area": LocalJSX.CalciteTextArea & JSXBase.HTMLAttributes<HTMLCalciteTextAreaElement>;
13324+
/**
13325+
* @deprecated use `content-top` slot instead
13326+
* @deprecated use `content-bottom` slot instead
13327+
*/
1331213328
"calcite-tile": LocalJSX.CalciteTile & JSXBase.HTMLAttributes<HTMLCalciteTileElement>;
1331313329
"calcite-tile-group": LocalJSX.CalciteTileGroup & JSXBase.HTMLAttributes<HTMLCalciteTileGroupElement>;
1331413330
"calcite-tile-select": LocalJSX.CalciteTileSelect & JSXBase.HTMLAttributes<HTMLCalciteTileSelectElement>;

packages/calcite-components/src/components/tile/resources.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ export const CSS = {
22
container: "container",
33
content: "content",
44
contentContainer: "content-container",
5-
contentSlotContainer: "content-slot-container",
65
description: "description",
76
heading: "heading",
87
largeVisual: "large-visual",
98
};
109

1110
export const SLOTS = {
12-
contentStart: "content-start",
11+
contentBottom: "content-bottom",
1312
contentEnd: "content-end",
13+
contentStart: "content-start",
14+
contentTop: "content-top",
1415
};

packages/calcite-components/src/components/tile/tile.scss

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
min-inline-size: 140px;
2222

2323
.container {
24+
align-items: flex-start;
2425
background-color: var(--calcite-tile-background-color);
2526
block-size: var(--calcite-container-size-content-fluid);
2627
box-sizing: border-box;
@@ -36,22 +37,15 @@
3637

3738
.content-container {
3839
display: flex;
40+
gap: var(--calcite-spacing-md);
41+
inline-size: 100%;
3942
outline-color: transparent;
4043
padding: 0;
41-
inline-size: 100%;
4244
}
4345

44-
.content-slot-container {
45-
align-items: center;
46+
.content {
4647
display: flex;
47-
48-
&:first-child {
49-
padding-inline: 0 0.75rem;
50-
}
51-
52-
&:last-child {
53-
padding-inline: 0.75rem 0;
54-
}
48+
flex-direction: column;
5549
}
5650

5751
.heading {
@@ -89,12 +83,17 @@
8983
align-items: center;
9084
text-align: center;
9185
}
86+
slot[name="content-start"]::slotted(*),
87+
slot[name="content-end"]::slotted(*) {
88+
align-self: center;
89+
}
9290
}
9391

9492
:host([scale="s"]) {
9593
max-inline-size: 400px;
9694
min-inline-size: 100px;
97-
.container {
95+
.container,
96+
.content-container {
9897
gap: var(--calcite-spacing-sm);
9998
}
10099
.heading {
@@ -110,7 +109,8 @@
110109
:host([scale="l"]) {
111110
max-inline-size: 520px;
112111
min-inline-size: 160px;
113-
.container {
112+
.container,
113+
.content-container {
114114
gap: var(--calcite-spacing-xl);
115115
}
116116
.heading {

packages/calcite-components/src/components/tile/tile.stories.ts

Lines changed: 379 additions & 35 deletions
Large diffs are not rendered by default.

packages/calcite-components/src/components/tile/tile.tsx

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Element, h, Prop, State, VNode } from "@stencil/core";
1+
import { Component, Element, h, Prop, VNode } from "@stencil/core";
22
import {
33
connectInteractive,
44
disconnectInteractive,
@@ -8,11 +8,12 @@ import {
88
} from "../../utils/interactive";
99
import { CSS, SLOTS } from "./resources";
1010
import { Alignment, Scale } from "../interfaces";
11-
import { slotChangeHasAssignedElement } from "../../utils/dom";
1211

1312
/**
14-
* @slot content-start - A slot for adding non-actionable elements before the component's content.
15-
* @slot content-end - A slot for adding non-actionable elements after the component's content.
13+
* @slot content-top - A slot for adding non-actionable elements above the component's content. Content slotted here will render in place of the `icon` property.
14+
* @slot content-bottom - A slot for adding non-actionable elements below the component's content.
15+
* @slot content-start - [Deprecated] use `content-top` slot instead. A slot for adding non-actionable elements before the component's content.
16+
* @slot content-end - [Deprecated] use `content-bottom` slot instead. A slot for adding non-actionable elements after the component's content.
1617
*/
1718
@Component({
1819
tag: "calcite-tile",
@@ -88,24 +89,6 @@ export class Tile implements InteractiveComponent {
8889

8990
@Element() el: HTMLCalciteTileElement;
9091

91-
@State() hasContentStart = false;
92-
93-
@State() hasContentEnd = false;
94-
95-
// --------------------------------------------------------------------------
96-
//
97-
// Private Methods
98-
//
99-
// --------------------------------------------------------------------------
100-
101-
private handleContentStartSlotChange = (event: Event): void => {
102-
this.hasContentStart = slotChangeHasAssignedElement(event);
103-
};
104-
105-
private handleContentEndSlotChange = (event: Event): void => {
106-
this.hasContentEnd = slotChangeHasAssignedElement(event);
107-
};
108-
10992
// --------------------------------------------------------------------------
11093
//
11194
// Lifecycle
@@ -131,24 +114,22 @@ export class Tile implements InteractiveComponent {
131114
// --------------------------------------------------------------------------
132115

133116
renderTile(): VNode {
134-
const { icon, hasContentStart, hasContentEnd, heading, description, iconFlipRtl } = this;
117+
const { icon, heading, description, iconFlipRtl } = this;
135118
const isLargeVisual = heading && icon && !description;
136119

137120
return (
138121
<div class={{ [CSS.container]: true, [CSS.largeVisual]: isLargeVisual }}>
122+
<slot name={SLOTS.contentTop} />
139123
{icon && <calcite-icon flipRtl={iconFlipRtl} icon={icon} scale="l" />}
140124
<div class={CSS.contentContainer}>
141-
<div class={{ [CSS.contentSlotContainer]: hasContentStart }}>
142-
<slot name={SLOTS.contentStart} onSlotchange={this.handleContentStartSlotChange} />
143-
</div>
125+
<slot name={SLOTS.contentStart} />
144126
<div class={CSS.content}>
145127
{heading && <div class={CSS.heading}>{heading}</div>}
146128
{description && <div class={CSS.description}>{description}</div>}
147129
</div>
148-
<div class={{ [CSS.contentSlotContainer]: hasContentEnd }}>
149-
<slot name={SLOTS.contentEnd} onSlotchange={this.handleContentEndSlotChange} />
150-
</div>
130+
<slot name={SLOTS.contentEnd} />
151131
</div>
132+
<slot name={SLOTS.contentBottom} />
152133
</div>
153134
);
154135
}

0 commit comments

Comments
 (0)