Skip to content

Commit 5e84892

Browse files
alisonaileajcfranco
authored andcommitted
fix(panel): apply custom styles correctly to header actions (#11495)
**Related Issue:** #11491 #8675 #7180 ## Summary Allow calcite-actions to be styled specific to the panel-header. include `::slotted(calcite-action)` in selectors and set proper variable fallbacks Correctly pass corner-radius through the component --------- Co-authored-by: JC Franco <[email protected]>
1 parent efe53c6 commit 5e84892

File tree

6 files changed

+87
-61
lines changed

6 files changed

+87
-61
lines changed

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

+13-8
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@
2222
@extend %component-host;
2323
@apply flex bg-transparent cursor-pointer;
2424
--calcite-internal-action-text-color: var(--calcite-color-text-3);
25+
26+
border-radius: var(
27+
--calcite-action-corner-radius,
28+
var(--calcite-action-corner-radius-start-start, var(--calcite-corner-radius))
29+
var(--calcite-action-corner-radius-start-end, var(--calcite-corner-radius))
30+
var(--calcite-action-corner-radius-end-end, var(--calcite-corner-radius))
31+
var(--calcite-action-corner-radius-end-start, var(--calcite-corner-radius))
32+
);
33+
}
34+
35+
.interaction-container {
36+
border-radius: inherit;
2537
}
2638

2739
:host([drag-handle]) {
@@ -30,15 +42,8 @@
3042
--calcite-internal-action-padding-inline: var(--calcite-spacing-xxs);
3143
}
3244

33-
:host,
3445
.button {
35-
border-radius: var(
36-
--calcite-action-corner-radius,
37-
var(--calcite-action-corner-radius-start-start, var(--calcite-corner-radius))
38-
var(--calcite-action-corner-radius-start-end, var(--calcite-corner-radius))
39-
var(--calcite-action-corner-radius-end-end, var(--calcite-corner-radius))
40-
var(--calcite-action-corner-radius-end-start, var(--calcite-corner-radius))
41-
);
46+
border-radius: inherit;
4247
}
4348

4449
@mixin action-indicator() {

packages/calcite-components/src/components/panel/panel.e2e.ts

-1
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,6 @@ describe("calcite-panel", () => {
721721
</calcite-panel>`,
722722
{
723723
"--calcite-panel-corner-radius": {
724-
shadowSelector: `.${CSS.container}`,
725724
targetProp: "borderRadius",
726725
},
727726
"--calcite-panel-heading-text-color": {

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

+18-43
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,26 @@
99
* @prop --calcite-panel-border-color: Specifies the component's border color.
1010
* @prop --calcite-panel-background-color: Specifies the component's background color.
1111
* @prop --calcite-panel-header-background-color: Specifies the background color of the component's header.
12+
* @prop --calcite-panel-header-action-background-color: Specifies the background color of Panel's `closable`, `collapsible`, and elements slotted in `header-menu-actions`.
13+
* @prop --calcite-panel-header-action-background-color-hover: Specifies the background color of Panel's `closable`, `collapsible`, and elements slotted in `header-menu-actions` when hovered.
14+
* @prop --calcite-panel-header-action-background-color-press: Specifies the background color of Panel's `closable`, `collapsible`, and elements slotted in `header-menu-actions` when pressed.
15+
* @prop --calcite-panel-header-action-text-color: Specifies the text color of Panel's `closable`, `collapsible`, and elements slotted in `header-menu-actions`.
16+
* @prop --calcite-panel-header-action-text-color-press: Specifies the text color of Panel's `closable`, `collapsible`, and elements slotted in `header-menu-actions` when pressed.
1217
* @prop --calcite-panel-footer-background-color: Specifies the background color of the component's footer.
1318
* @prop --calcite-panel-space: Specifies the padding of the component's `"unnamed (default)"` slot.
1419
* @prop --calcite-panel-header-content-space: Specifies the padding of the `"header-content"` slot.
1520
* @prop --calcite-panel-footer-space: Specifies the padding of the component's footer.
16-
* @prop --calcite-action-background-color: Specifies the background color of the component's `closable`, `collapsible`, and `back` `calcite-action`s. Applies to any slotted `calcite-action`s.
17-
* @prop --calcite-action-background-color-hover: Specifies the background color of the component's `closable`, `collapsible`, and `back` `calcite-action`s when hovered. Applies to any slotted `calcite-action`s.
18-
* @prop --calcite-action-background-color-pressed: Specifies the background color of the component's `closable`, `collapsible`, and `back` `calcite-action`s when pressed. Applies to any slotted `calcite-action`s.
19-
* @prop --calcite-action-text-color-hover: Specifies the text and icon color of the component's `closable`, `collapsible`, and `back` `calcite-action`s when hovered. Applies to any slotted `calcite-action`s.
20-
* @prop --calcite-action-text-color-pressed: Specifies the text and icon color of the component's `closable`, `collapsible`, and `back` `calcite-action`s when pressed. Applies to any slotted `calcite-action`s.
2121
* @prop --calcite-popover-border-color: Specifies the border color of the component's internally rendered `calcite-popover`, which is rendered within a `calcite-action` menu when slotted `calcite-action`s are present in the `header-actions-end` slot. Applies to any slotted `calcite-popover`s.
2222
* @prop --calcite-panel-content-space: [Deprecated] Use `--calcite-panel-space` instead. Specifies the padding of the component's content.
2323
* @prop --calcite-panel-footer-padding: [Deprecated] Use `--calcite-panel-footer-space` instead. Specifies the padding of the component's footer.
2424
* @prop --calcite-panel-header-border-block-end: [Deprecated] Use `--calcite-panel-border-color` instead. Specifies the component header's block end border.
25-
* @prop --calcite-panel-header-action-background-color-hover: Specifies the background color of the component's `calcite-action` items in the panel header when hovered.
26-
* @prop --calcite-panel-header-action-background-color-press: Specifies the background color of the component's `calcite-action` items in the panel header when pressed.
27-
* @prop --calcite-panel-header-action-background-color: Specifies the background color of the component's `calcite-action` items in the panel header.
28-
* @prop --calcite-panel-header-action-indicator-color: Specifies the color of the component's `calcite-action` items' indicator in the panel header.
29-
* @prop --calcite-panel-header-action-text-color-press: Specifies the text color of the component's `calcite-action` items in the panel header when pressed.
30-
* @prop --calcite-panel-header-action-text-color: Specifies the text color of the component's `calcite-action` items in the panel header.
3125
*/
3226

3327
:host {
3428
@apply relative flex w-full h-full flex-auto overflow-hidden box-border;
3529

3630
--calcite-min-header-height: calc(var(--calcite-icon-size) * 3);
31+
border-radius: var(--calcite-panel-corner-radius, var(--calcite-corner-radius-sharp));
3732
}
3833

3934
@include disabled();
@@ -98,7 +93,6 @@
9893
transition:
9994
max-block-size var(--calcite-animation-timing),
10095
inline-size var(--calcite-animation-timing);
101-
border-radius: var(--calcite-panel-corner-radius, var(--calcite-corner-radius-none));
10296
box-sizing: border-box;
10397
font-size: var(--calcite-font-size--1);
10498
}
@@ -113,8 +107,7 @@
113107

114108
.header {
115109
@apply flex flex-col z-header;
116-
border-radius: var(--calcite-panel-corner-radius, var(--calcite-corner-radius-none))
117-
var(--calcite-panel-corner-radius, var(--calcite-corner-radius-none)) 0 0;
110+
118111
background-color: var(--calcite-panel-header-background-color, var(--calcite-color-foreground-1));
119112
border-block-end: 1px solid
120113
var(--calcite-panel-border-color, var(--calcite-panel-header-border-block-end, var(--calcite-color-border-3)));
@@ -149,15 +142,6 @@
149142
margin-inline-end: auto;
150143
justify-content: center;
151144

152-
.header-actions {
153-
--calcite-action-background-color-hover: var(--calcite-panel-header-action-background-color-hover);
154-
--calcite-action-background-color-press: var(--calcite-panel-header-action-background-color-press);
155-
--calcite-action-background-color: var(--calcite-panel-header-action-background-color);
156-
--calcite-action-indicator-color: var(--calcite-panel-header-action-indicator-color);
157-
--calcite-action-text-color-press: var(--calcite-panel-header-action-text-color-press);
158-
--calcite-action-text-color: var(--calcite-panel-header-action-text-color);
159-
}
160-
161145
.heading,
162146
.description {
163147
@apply block
@@ -181,6 +165,17 @@
181165
}
182166
}
183167

168+
#close,
169+
#collapse,
170+
.back-button,
171+
calcite-action-menu {
172+
--calcite-action-background-color: var(--calcite-panel-header-action-background-color);
173+
--calcite-action-background-color-hover: var(--calcite-panel-header-action-background-color-hover);
174+
--calcite-action-background-color-press: var(--calcite-panel-header-action-background-color-press);
175+
--calcite-action-text-color: var(--calcite-panel-header-action-text-color);
176+
--calcite-action-text-color-pressed: var(--calcite-panel-header-action-text-color-pressed);
177+
}
178+
184179
.back-button {
185180
@apply border-0
186181
border-solid;
@@ -199,24 +194,6 @@
199194
margin-inline-start: theme("margin.auto");
200195
}
201196

202-
#close,
203-
#collapse,
204-
.back-button,
205-
calcite-action-menu {
206-
}
207-
208-
#close,
209-
#collapse,
210-
calcite-action-menu {
211-
&:last-child {
212-
--calcite-action-corner-radius-start-end: var(--calcite-panel-corner-radius);
213-
}
214-
}
215-
216-
.back-button {
217-
--calcite-action-corner-radius-start-start: var(--calcite-panel-corner-radius);
218-
}
219-
220197
.content-wrapper {
221198
@apply flex
222199
flex-auto
@@ -257,8 +234,6 @@ calcite-action-menu {
257234
var(--calcite-panel-footer-padding, var(--calcite-internal-panel-default-space))
258235
);
259236
background-color: var(--calcite-panel-footer-background-color, var(--calcite-color-foreground-1));
260-
border-radius: 0 0 var(--calcite-panel-corner-radius, var(--calcite-corner-radius-none))
261-
var(--calcite-panel-corner-radius, var(--calcite-corner-radius-none));
262237
}
263238

264239
.footer-content {

packages/calcite-components/src/custom-theme.stories.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { navigationUserTokens, navigationUsers } from "./custom-theme/navigation
5454
import { tileTokens, tile } from "./custom-theme/tile";
5555
import { navigationTokens, navigation } from "./custom-theme/navigation";
5656
import { menuItem, menuItemTokens } from "./custom-theme/menu-item";
57+
import { panel, panelTokens } from "./custom-theme/panel";
5758

5859
const globalTokens = {
5960
calciteColorBrand: "#007ac2",
@@ -146,7 +147,7 @@ const kitchenSink = (args: Record<string, string>, useTestValues = false) =>
146147
${avatarThumbnail} ${progress} ${handle} ${graph} ${textArea} ${popover} ${tile} ${tooltip} ${comboboxItem}
147148
</div>
148149
<div class="demo-column">
149-
${navigation} ${navigationLogos} ${navigationUsers} ${blockSection} ${block} ${rating}
150+
${navigation} ${navigationLogos} ${navigationUsers} ${blockSection} ${block} ${rating} ${panel}
150151
</div>
151152
<div class="demo-column"><div class="demo-column">${alert}</div></div>
152153
<div class="demo-column">${menuItem}</div>
@@ -192,6 +193,7 @@ const componentTokens = {
192193
...navigationUserTokens,
193194
...noticeTokens,
194195
...paginationTokens,
196+
...panelTokens,
195197
...popoverTokens,
196198
...progressTokens,
197199
...segmentedControlTokens,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { html } from "../../support/formatting";
2+
3+
export const panelTokens = {
4+
calcitePanelBackgroundColor: "",
5+
calcitePanelBorderColor: "",
6+
calcitePanelContentSpace: "",
7+
calcitePanelCornerRadius: "",
8+
calcitePanelDescriptionTextColor: "",
9+
calcitePanelFooterBackgroundColor: "",
10+
calcitePanelFooterSpace: "",
11+
calcitePanelHeaderActionBackgroundColorHover: "",
12+
calcitePanelHeaderActionBackgroundColorPress: "",
13+
calcitePanelHeaderActionBackgroundColor: "",
14+
calcitePanelHeaderActionTextColorPress: "",
15+
calcitePanelHeaderActionTextColor: "",
16+
calcitePanelHeaderBackgroundColor: "",
17+
calcitePanelHeaderContentSpace: "",
18+
calcitePanelHeadingTextColor: "",
19+
calcitePanelSpace: "",
20+
};
21+
22+
export const panel = html`
23+
<calcite-panel heading="Panel Heading" description="Panel description" closable collapsible>
24+
<calcite-action text="Action 1" text-enabled icon="icon1" slot="header-menu-actions"></calcite-action>
25+
<calcite-action text="Action 2" text-enabled icon="icon2" slot="header-menu-actions"></calcite-action>
26+
<calcite-action text="Action 3" icon="icon3" slot="header-actions-end"></calcite-action>
27+
<div slot="content-top">Content at the top</div>
28+
<calcite-label slot="content-bottom" layout="inline-space-between" style="--calcite-label-margin-bottom: 0">
29+
<calcite-checkbox></calcite-checkbox>Agree to terms
30+
</calcite-label>
31+
<p>
32+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante
33+
dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris.
34+
</p>
35+
<calcite-button slot="footer-end">Done</calcite-button>
36+
</calcite-panel>
37+
`;

packages/calcite-components/src/demos/panel.html

+16-8
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,27 @@
3737
--calcite-panel-corner-radius: 12px;
3838
--calcite-panel-heading-text-color: darkgreen;
3939
--calcite-panel-description-text-color: lightgreen;
40+
--calcite-panel-border-color: blue;
4041
--calcite-panel-background-color: yellow;
4142
--calcite-panel-header-background-color: orange;
4243
--calcite-panel-footer-background-color: red;
43-
4444
--calcite-panel-border-color: lime;
45-
4645
--calcite-panel-space: 2rem;
4746
--calcite-panel-header-content-space: 0;
4847
--calcite-panel-footer-space: 0;
48+
--calcite-panel-content-space: 12px;
49+
--calcite-panel-footer-padding: 3rem;
50+
--calcite-panel-header-border-block-end: rgb(13, 242, 204);
51+
52+
--calcite-panel-header-action-background-color: blue;
53+
--calcite-panel-header-action-background-color-hover: blue;
54+
--calcite-panel-header-action-background-color-press: blue;
55+
}
4956

50-
--calcite-action-background-color: lime;
51-
--calcite-action-background-color-hover: lime;
52-
--calcite-action-background-color-pressed: lime;
53-
--calcite-action-text-color: blue;
54-
--calcite-action-text-color-pressed: blue;
55-
--calcite-popover-border-color: blue;
57+
.themed-panel calcite-action[slot="header-actions-end"] {
58+
--calcite-action-background-color: red;
59+
--calcite-action-background-color-hover: red;
60+
--calcite-action-background-color-press: red;
5661
}
5762
</style>
5863

@@ -330,6 +335,7 @@
330335
<calcite-action text="measure" text-enabled icon="measure" slot="header-menu-actions"></calcite-action>
331336
<calcite-action text="Layers" icon="question" slot="header-actions-end"></calcite-action>
332337
<div slot="content-top">To continue, you must agree to the terms</div>
338+
333339
<calcite-label slot="content-bottom" layout="inline-space-between" style="--calcite-label-margin-bottom: 0">
334340
<calcite-checkbox></calcite-checkbox>I agree to the terms
335341
</calcite-label>
@@ -341,6 +347,7 @@
341347
tortor, a iaculis elit mi sed lectus. Morbi in congue metus, non imperdiet ex. Nunc et neque tempor,
342348
porttitor est sed, vestibulum risus. Integer non erat libero.
343349
</p>
350+
344351
<p>
345352
Cras sagittis vel neque sed efficitur. Vestibulum mattis diam eget urna condimentum tempus. Donec
346353
malesuada velit sit amet metus faucibus pharetra. Sed sit amet massa facilisis, porttitor nunc vitae,
@@ -423,6 +430,7 @@
423430
<calcite-label slot="content-bottom" layout="inline-space-between" style="--calcite-label-margin-bottom: 0">
424431
<calcite-checkbox></calcite-checkbox>I agree to the terms
425432
</calcite-label>
433+
<p><calcite-action text="banana" text-enabled icon="banana"></calcite-action></p>
426434
<p>
427435
Curabitur mauris quam, tempor sit amet massa sed, mattis blandit diam. Proin dignissim leo vitae quam
428436
fringilla viverra. Ut eget gravida magna, et tincidunt dui. Nullam a finibus ante, eu dignissim eros.

0 commit comments

Comments
 (0)