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

fix(panel): apply custom styles correctly to header actions #11495

Merged
merged 20 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2b314be
chore(accordion): deprecate accordion-item tokens
alisonailea Jan 27, 2025
1af7a1c
fix(panel): solution 1 - CSS parts
alisonailea Feb 7, 2025
ca25807
chore(panel): clean up PARTS
alisonailea Feb 7, 2025
9e588ac
fix(panel): solution 2 - correct targeting of all calcite-actions in …
alisonailea Feb 7, 2025
b6da073
fix(panel): unnecessary fallback
alisonailea Feb 7, 2025
68b10a9
fix(panel): solution 1 - CSS parts
alisonailea Feb 7, 2025
f9ba8db
chore(panel): clean up PARTS
alisonailea Feb 7, 2025
b2bfdc8
fix(panel): solution 2 - correct targeting of all calcite-actions in …
alisonailea Feb 7, 2025
268be2b
fix(panel): unnecessary fallback
alisonailea Feb 7, 2025
dd6a471
Merge branch 'astump/panel-header' of github.com:Esri/calcite-design-…
alisonailea Feb 10, 2025
dd25cc8
chore(panel): clean up based on comments - remove :parts
alisonailea Feb 10, 2025
c9510fc
Merge branch 'dev' into astump/panel-header
alisonailea Feb 10, 2025
5a4b35d
fix(panel): update action token assignments per @macandcheese comments
alisonailea Feb 12, 2025
fe9aecd
fix(panel): pass corner radius through
alisonailea Feb 12, 2025
e4f8ad1
chore(panel): fix border radius tests
alisonailea Feb 14, 2025
b208eeb
drop unnecessary style (handled by util)
jcfranco Feb 26, 2025
4047849
revert unrelated changes
jcfranco Feb 26, 2025
a8d3351
drop unused internal CSS prop
jcfranco Feb 26, 2025
6b2862d
add panel to custom-theme story
jcfranco Feb 26, 2025
6c543b2
restore border: inherit as display: contents has no effect on inherit…
jcfranco Feb 26, 2025
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
21 changes: 13 additions & 8 deletions packages/calcite-components/src/components/action/action.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@
@extend %component-host;
@apply flex bg-transparent cursor-pointer;
--calcite-internal-action-text-color: var(--calcite-color-text-3);

border-radius: var(
--calcite-action-corner-radius,
var(--calcite-action-corner-radius-start-start, var(--calcite-corner-radius))
var(--calcite-action-corner-radius-start-end, var(--calcite-corner-radius))
var(--calcite-action-corner-radius-end-end, var(--calcite-corner-radius))
var(--calcite-action-corner-radius-end-start, var(--calcite-corner-radius))
);
}

.interaction-container {
Copy link
Member

Choose a reason for hiding this comment

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

This isn't needed since interaction-container uses display: contents and doesn't produce a box.

Copy link
Member

@jcfranco jcfranco Feb 26, 2025

Choose a reason for hiding this comment

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

For posterity: I restored this override as I was completely wrong on this one. display: contents doesn't have any effect on inheritance, so my suggestion broke styling.

border-radius: inherit;
}

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

:host,
.button {
border-radius: var(
--calcite-action-corner-radius,
var(--calcite-action-corner-radius-start-start, var(--calcite-corner-radius))
var(--calcite-action-corner-radius-start-end, var(--calcite-corner-radius))
var(--calcite-action-corner-radius-end-end, var(--calcite-corner-radius))
var(--calcite-action-corner-radius-end-start, var(--calcite-corner-radius))
);
border-radius: inherit;
}

@mixin action-indicator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,6 @@ describe("calcite-panel", () => {
</calcite-panel>`,
{
"--calcite-panel-corner-radius": {
shadowSelector: `.${CSS.container}`,
targetProp: "borderRadius",
},
"--calcite-panel-heading-text-color": {
Expand Down
61 changes: 18 additions & 43 deletions packages/calcite-components/src/components/panel/panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,26 @@
* @prop --calcite-panel-border-color: Specifies the component's border color.
* @prop --calcite-panel-background-color: Specifies the component's background color.
* @prop --calcite-panel-header-background-color: Specifies the background color of the component's header.
* @prop --calcite-panel-header-action-background-color: Specifies the background color of Panel's `closable`, `collapsible`, and elements slotted in `header-menu-actions`.
* @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.
* @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.
* @prop --calcite-panel-header-action-text-color: Specifies the text color of Panel's `closable`, `collapsible`, and elements slotted in `header-menu-actions`.
* @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.
* @prop --calcite-panel-footer-background-color: Specifies the background color of the component's footer.
* @prop --calcite-panel-space: Specifies the padding of the component's `"unnamed (default)"` slot.
* @prop --calcite-panel-header-content-space: Specifies the padding of the `"header-content"` slot.
* @prop --calcite-panel-footer-space: Specifies the padding of the component's footer.
* @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.
* @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.
* @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.
* @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.
* @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.
* @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.
* @prop --calcite-panel-content-space: [Deprecated] Use `--calcite-panel-space` instead. Specifies the padding of the component's content.
* @prop --calcite-panel-footer-padding: [Deprecated] Use `--calcite-panel-footer-space` instead. Specifies the padding of the component's footer.
* @prop --calcite-panel-header-border-block-end: [Deprecated] Use `--calcite-panel-border-color` instead. Specifies the component header's block end border.
* @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.
* @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.
* @prop --calcite-panel-header-action-background-color: Specifies the background color of the component's `calcite-action` items in the panel header.
* @prop --calcite-panel-header-action-indicator-color: Specifies the color of the component's `calcite-action` items' indicator in the panel header.
* @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.
* @prop --calcite-panel-header-action-text-color: Specifies the text color of the component's `calcite-action` items in the panel header.
*/

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

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

@include disabled();
Expand Down Expand Up @@ -98,7 +93,6 @@
transition:
max-block-size var(--calcite-animation-timing),
inline-size var(--calcite-animation-timing);
border-radius: var(--calcite-panel-corner-radius, var(--calcite-corner-radius-none));
box-sizing: border-box;
font-size: var(--calcite-font-size--1);
}
Expand All @@ -113,8 +107,7 @@

.header {
@apply flex flex-col z-header;
border-radius: var(--calcite-panel-corner-radius, var(--calcite-corner-radius-none))
var(--calcite-panel-corner-radius, var(--calcite-corner-radius-none)) 0 0;

background-color: var(--calcite-panel-header-background-color, var(--calcite-color-foreground-1));
border-block-end: 1px solid
var(--calcite-panel-border-color, var(--calcite-panel-header-border-block-end, var(--calcite-color-border-3)));
Expand Down Expand Up @@ -149,15 +142,6 @@
margin-inline-end: auto;
justify-content: center;

.header-actions {
--calcite-action-background-color-hover: var(--calcite-panel-header-action-background-color-hover);
--calcite-action-background-color-press: var(--calcite-panel-header-action-background-color-press);
--calcite-action-background-color: var(--calcite-panel-header-action-background-color);
--calcite-action-indicator-color: var(--calcite-panel-header-action-indicator-color);
--calcite-action-text-color-press: var(--calcite-panel-header-action-text-color-press);
--calcite-action-text-color: var(--calcite-panel-header-action-text-color);
}

.heading,
.description {
@apply block
Expand All @@ -181,6 +165,17 @@
}
}

#close,
#collapse,
.back-button,
calcite-action-menu {
--calcite-action-background-color: var(--calcite-panel-header-action-background-color);
--calcite-action-background-color-hover: var(--calcite-panel-header-action-background-color-hover);
--calcite-action-background-color-press: var(--calcite-panel-header-action-background-color-press);
--calcite-action-text-color: var(--calcite-panel-header-action-text-color);
--calcite-action-text-color-pressed: var(--calcite-panel-header-action-text-color-pressed);
}
Copy link
Member

Choose a reason for hiding this comment

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

Does --calcite-action-corner-radius need to be set here? Possibly by --calcite-internal-panel-corner-radius?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No this is covered by the corner radius of the action containers.


.back-button {
@apply border-0
border-solid;
Expand All @@ -199,24 +194,6 @@
margin-inline-start: theme("margin.auto");
}

#close,
#collapse,
.back-button,
calcite-action-menu {
}

#close,
#collapse,
calcite-action-menu {
&:last-child {
--calcite-action-corner-radius-start-end: var(--calcite-panel-corner-radius);
}
}

.back-button {
--calcite-action-corner-radius-start-start: var(--calcite-panel-corner-radius);
}

.content-wrapper {
@apply flex
flex-auto
Expand Down Expand Up @@ -257,8 +234,6 @@ calcite-action-menu {
var(--calcite-panel-footer-padding, var(--calcite-internal-panel-default-space))
);
background-color: var(--calcite-panel-footer-background-color, var(--calcite-color-foreground-1));
border-radius: 0 0 var(--calcite-panel-corner-radius, var(--calcite-corner-radius-none))
var(--calcite-panel-corner-radius, var(--calcite-corner-radius-none));
}

.footer-content {
Expand Down
4 changes: 3 additions & 1 deletion packages/calcite-components/src/custom-theme.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { navigationUserTokens, navigationUsers } from "./custom-theme/navigation
import { tileTokens, tile } from "./custom-theme/tile";
import { navigationTokens, navigation } from "./custom-theme/navigation";
import { menuItem, menuItemTokens } from "./custom-theme/menu-item";
import { panel, panelTokens } from "./custom-theme/panel";

const globalTokens = {
calciteColorBrand: "#007ac2",
Expand Down Expand Up @@ -146,7 +147,7 @@ const kitchenSink = (args: Record<string, string>, useTestValues = false) =>
${avatarThumbnail} ${progress} ${handle} ${graph} ${textArea} ${popover} ${tile} ${tooltip} ${comboboxItem}
</div>
<div class="demo-column">
${navigation} ${navigationLogos} ${navigationUsers} ${blockSection} ${block} ${rating}
${navigation} ${navigationLogos} ${navigationUsers} ${blockSection} ${block} ${rating} ${panel}
</div>
<div class="demo-column"><div class="demo-column">${alert}</div></div>
<div class="demo-column">${menuItem}</div>
Expand Down Expand Up @@ -189,6 +190,7 @@ const componentTokens = {
...navigationUserTokens,
...noticeTokens,
...paginationTokens,
...panelTokens,
...popoverTokens,
...progressTokens,
...segmentedControlTokens,
Expand Down
37 changes: 37 additions & 0 deletions packages/calcite-components/src/custom-theme/panel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { html } from "../../support/formatting";

export const panelTokens = {
calcitePanelBackgroundColor: "",
calcitePanelBorderColor: "",
calcitePanelContentSpace: "",
calcitePanelCornerRadius: "",
calcitePanelDescriptionTextColor: "",
calcitePanelFooterBackgroundColor: "",
calcitePanelFooterSpace: "",
calcitePanelHeaderActionBackgroundColorHover: "",
calcitePanelHeaderActionBackgroundColorPress: "",
calcitePanelHeaderActionBackgroundColor: "",
calcitePanelHeaderActionTextColorPress: "",
calcitePanelHeaderActionTextColor: "",
calcitePanelHeaderBackgroundColor: "",
calcitePanelHeaderContentSpace: "",
calcitePanelHeadingTextColor: "",
calcitePanelSpace: "",
};

export const panel = html`
<calcite-panel heading="Panel Heading" description="Panel description" closable collapsible>
<calcite-action text="Action 1" text-enabled icon="icon1" slot="header-menu-actions"></calcite-action>
<calcite-action text="Action 2" text-enabled icon="icon2" slot="header-menu-actions"></calcite-action>
<calcite-action text="Action 3" icon="icon3" slot="header-actions-end"></calcite-action>
<div slot="content-top">Content at the top</div>
<calcite-label slot="content-bottom" layout="inline-space-between" style="--calcite-label-margin-bottom: 0">
<calcite-checkbox></calcite-checkbox>Agree to terms
</calcite-label>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante
dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris.
</p>
<calcite-button slot="footer-end">Done</calcite-button>
</calcite-panel>
`;
24 changes: 16 additions & 8 deletions packages/calcite-components/src/demos/panel.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,27 @@
--calcite-panel-corner-radius: 12px;
--calcite-panel-heading-text-color: darkgreen;
--calcite-panel-description-text-color: lightgreen;
--calcite-panel-border-color: blue;
--calcite-panel-background-color: yellow;
--calcite-panel-header-background-color: orange;
--calcite-panel-footer-background-color: red;

--calcite-panel-border-color: lime;

--calcite-panel-space: 2rem;
--calcite-panel-header-content-space: 0;
--calcite-panel-footer-space: 0;
--calcite-panel-content-space: 12px;
--calcite-panel-footer-padding: 3rem;
--calcite-panel-header-border-block-end: rgb(13, 242, 204);

--calcite-panel-header-action-background-color: blue;
--calcite-panel-header-action-background-color-hover: blue;
--calcite-panel-header-action-background-color-press: blue;
}

--calcite-action-background-color: lime;
--calcite-action-background-color-hover: lime;
--calcite-action-background-color-pressed: lime;
--calcite-action-text-color: blue;
--calcite-action-text-color-pressed: blue;
--calcite-popover-border-color: blue;
.themed-panel calcite-action[slot="header-actions-end"] {
--calcite-action-background-color: red;
--calcite-action-background-color-hover: red;
--calcite-action-background-color-press: red;
}
</style>

Expand Down Expand Up @@ -330,6 +335,7 @@
<calcite-action text="measure" text-enabled icon="measure" slot="header-menu-actions"></calcite-action>
<calcite-action text="Layers" icon="question" slot="header-actions-end"></calcite-action>
<div slot="content-top">To continue, you must agree to the terms</div>

<calcite-label slot="content-bottom" layout="inline-space-between" style="--calcite-label-margin-bottom: 0">
<calcite-checkbox></calcite-checkbox>I agree to the terms
</calcite-label>
Expand All @@ -341,6 +347,7 @@
tortor, a iaculis elit mi sed lectus. Morbi in congue metus, non imperdiet ex. Nunc et neque tempor,
porttitor est sed, vestibulum risus. Integer non erat libero.
</p>

<p>
Cras sagittis vel neque sed efficitur. Vestibulum mattis diam eget urna condimentum tempus. Donec
malesuada velit sit amet metus faucibus pharetra. Sed sit amet massa facilisis, porttitor nunc vitae,
Expand Down Expand Up @@ -423,6 +430,7 @@
<calcite-label slot="content-bottom" layout="inline-space-between" style="--calcite-label-margin-bottom: 0">
<calcite-checkbox></calcite-checkbox>I agree to the terms
</calcite-label>
<p><calcite-action text="banana" text-enabled icon="banana"></calcite-action></p>
<p>
Curabitur mauris quam, tempor sit amet massa sed, mattis blandit diam. Proin dignissim leo vitae quam
fringilla viverra. Ut eget gravida magna, et tincidunt dui. Nullam a finibus ante, eu dignissim eros.
Expand Down
Loading