Skip to content

Commit 7638ec4

Browse files
authored
feat(tile): add visual scales (#8496)
**Related Issue:** #4759 ## Summary This PR adds a `scale` property to control visual display for small, medium and large scales. --------- Co-authored-by: Erik Harper <[email protected]>
1 parent 6e643e2 commit 7638ec4

File tree

6 files changed

+399
-55
lines changed

6 files changed

+399
-55
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4950,6 +4950,10 @@ export namespace Components {
49504950
* When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`).
49514951
*/
49524952
"iconFlipRtl": boolean;
4953+
/**
4954+
* Specifies the size of the component.
4955+
*/
4956+
"scale": Scale;
49534957
}
49544958
interface CalciteTileSelect {
49554959
/**
@@ -12424,6 +12428,10 @@ declare namespace LocalJSX {
1242412428
* When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`).
1242512429
*/
1242612430
"iconFlipRtl"?: boolean;
12431+
/**
12432+
* Specifies the size of the component.
12433+
*/
12434+
"scale"?: Scale;
1242712435
}
1242812436
interface CalciteTileSelect {
1242912437
/**

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

Lines changed: 75 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,31 @@
99

1010
.container {
1111
@apply pointer-events-none
12-
grid
13-
grid-cols-1
14-
gap-2;
12+
grid
13+
grid-cols-1;
14+
gap: var(--calcite-spacing-md);
1515
}
1616

1717
.content {
1818
@apply flex
19-
flex-auto
20-
flex-col
21-
justify-center
22-
gap-2;
23-
// set width handles slotted content and heading word wrap
19+
flex-auto
20+
flex-col
21+
justify-center;
2422
inline-size: 10%;
2523
}
2624

2725
.content-container {
2826
@apply focus-base
29-
text-color-2
30-
flex
31-
w-full
32-
flex-auto
33-
items-stretch
34-
p-0;
27+
text-color-2
28+
flex
29+
w-full
30+
flex-auto
31+
items-stretch
32+
p-0;
3533
}
3634

3735
.content-slot-container {
38-
@apply bg-foreground-1 flex items-center;
36+
@apply flex items-center;
3937

4038
&:first-child {
4139
padding-inline: 0 0.75rem;
@@ -47,36 +45,71 @@
4745
}
4846

4947
.heading {
50-
@apply text-n1-wrap
51-
text-color-2
52-
pointer-events-none
53-
break-words
54-
font-medium
55-
duration-150
56-
ease-in-out;
48+
@apply pointer-events-none
49+
break-words;
50+
color: var(--calcite-color-text-2);
51+
font-size: var(--calcite-font-size--1);
52+
font-weight: 500;
53+
line-height: 1.20313rem;
5754
}
5855
.large-visual {
5956
@apply items-center
6057
text-center;
6158
min-block-size: theme("spacing.48");
62-
.icon {
63-
@apply flex
64-
justify-center
65-
self-end;
59+
calcite-icon {
60+
align-self: self-end;
61+
block-size: 64px;
62+
inline-size: 64px;
63+
justify-self: center;
6664
}
6765
.content-container {
6866
@apply self-center;
6967
}
7068
}
7169
.description {
72-
@apply text-n2-wrap
73-
text-color-3
74-
break-words
75-
pointer-events-none
76-
duration-150
77-
ease-in-out;
70+
@apply break-words
71+
pointer-events-none;
72+
color: var(--calcite-color-text-3);
73+
font-size: var(--calcite-font-size--2);
74+
font-weight: 400;
75+
line-height: 1.03125rem;
76+
}
77+
}
78+
79+
:host([scale="s"]) {
80+
.container {
81+
gap: var(--calcite-spacing-sm);
82+
}
83+
.heading {
84+
font-size: var(--calcite-font-size--2);
85+
line-height: 1.03125rem;
86+
}
87+
.description {
88+
font-size: var(--calcite-font-size--3);
89+
line-height: 0.85938rem;
90+
}
91+
}
92+
93+
:host([scale="l"]) {
94+
.container {
95+
gap: var(--calcite-spacing-xl);
96+
}
97+
.heading {
98+
font-size: var(--calcite-font-size-0);
99+
line-height: 1.375rem;
100+
}
101+
.description {
102+
font-size: var(--calcite-font-size--1);
103+
line-height: 1.20313rem;
104+
}
105+
}
106+
107+
:host(:not([href])) {
108+
calcite-icon {
109+
color: var(--calcite-color-text-3);
78110
}
79111
}
112+
80113
:host([href]),
81114
:host([href]:hover) {
82115
.heading {
@@ -85,8 +118,14 @@
85118
}
86119
}
87120
:host(:not([embed])) {
88-
@apply p-3;
89121
box-shadow: 0 0 0 1px var(--calcite-color-border-2);
122+
padding: var(--calcite-spacing-md);
123+
}
124+
:host(:not([embed])[scale="s"]) {
125+
padding: var(--calcite-spacing-sm);
126+
}
127+
:host(:not([embed])[scale="l"]) {
128+
padding: var(--calcite-spacing-xl);
90129
}
91130
:host(:not([embed])[href]:hover) {
92131
@apply cursor-pointer;
@@ -96,26 +135,18 @@
96135
box-shadow: 0 0 0 3px var(--calcite-color-brand);
97136
}
98137
:host([icon][heading]:not([description]):not([embed])) {
99-
@apply p-0;
100-
}
101-
:host([icon][heading]:not([description])) {
102-
.icon {
103-
@apply flex justify-center;
104-
}
105-
.large-visual {
106-
@apply text-center;
107-
}
138+
padding: 0px;
108139
}
109140

110141
@include disabled();
111142

112143
:host(:hover),
113144
:host([active]) {
114145
.heading {
115-
@apply text-color-1;
146+
color: var(--calcite-color-text-1);
116147
}
117148
.description {
118-
@apply text-color-2;
149+
color: var(--calcite-color-text-2);
119150
}
120151
}
121152

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,46 @@ export const simple = (): string => html`
2424
${boolean("hidden", false)}
2525
href="${text("href", "#")}"
2626
icon="${select("icon", iconNames, "layer")}"
27+
scale="${select("scale", ["s", "m", "l"], "m")}"
2728
>
2829
</calcite-tile>
2930
`;
3031

32+
export const scales = (): string => html`
33+
<div style="width: 300px">
34+
<calcite-label scale="s"
35+
>small
36+
<calcite-tile
37+
description="Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collab on thinking to further the overall."
38+
heading="Tile title lorem ipsum"
39+
icon="layers"
40+
scale="s"
41+
>
42+
</calcite-tile>
43+
</calcite-label>
44+
<calcite-label scale="m"
45+
>medium
46+
<calcite-tile
47+
description="Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collab on thinking to further the overall."
48+
heading="Tile title lorem ipsum"
49+
icon="layers"
50+
scale="m"
51+
>
52+
</calcite-tile>
53+
</calcite-label>
54+
<calcite-label scale="l"
55+
>large
56+
<calcite-tile
57+
description="Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collab on thinking to further the overall."
58+
heading="Tile title lorem ipsum"
59+
icon="layers"
60+
scale="l"
61+
>
62+
</calcite-tile>
63+
</calcite-label>
64+
</div>
65+
`;
66+
3167
export const largeTile = (): string => html`
3268
<calcite-tile
3369
${boolean("active", false)}

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
updateHostInteraction,
1414
} from "../../utils/interactive";
1515
import { SLOTS } from "./resources";
16+
import { Scale } from "../interfaces";
1617

1718
/**
1819
* @slot content-start - A slot for adding non-actionable elements before the component's content.
@@ -75,6 +76,11 @@ export class Tile implements ConditionalSlotComponent, InteractiveComponent {
7576

7677
@Prop({ reflect: true }) iconFlipRtl = false;
7778

79+
/**
80+
* Specifies the size of the component.
81+
*/
82+
@Prop({ reflect: true }) scale: Scale = "m";
83+
7884
// --------------------------------------------------------------------------
7985
//
8086
// Private Properties
@@ -112,20 +118,10 @@ export class Tile implements ConditionalSlotComponent, InteractiveComponent {
112118
renderTile(): VNode {
113119
const { icon, el, heading, description, iconFlipRtl } = this;
114120
const isLargeVisual = heading && icon && !description;
115-
const iconStyle = isLargeVisual
116-
? {
117-
height: "64px",
118-
width: "64px",
119-
}
120-
: undefined;
121121

122122
return (
123123
<div class={{ container: true, "large-visual": isLargeVisual }}>
124-
{icon && (
125-
<div class="icon">
126-
<calcite-icon flipRtl={iconFlipRtl} icon={icon} scale="l" style={iconStyle} />
127-
</div>
128-
)}
124+
{icon && <calcite-icon flipRtl={iconFlipRtl} icon={icon} scale="l" />}
129125
<div class="content-container">
130126
{getSlotted(el, SLOTS.contentStart) ? (
131127
<div class="content-slot-container">

0 commit comments

Comments
 (0)