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(action-pad): fix E2E tests #9073

Merged
merged 10 commits into from
Apr 12, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
renders,
slots,
t9n,
themed,
} from "../../tests/commonTests";
import { CSS, SLOTS } from "./resources";
import { html } from "../../../support/formatting";
Expand Down Expand Up @@ -316,4 +317,128 @@ describe("calcite-action-pad", () => {

expect(await group.getProperty("layout")).toBe("vertical");
});

describe("theme", () => {
describe("default", () => {
const tokens = {
"--calcite-action-pad-background-color": {
selector: "calcite-action-pad",
shadowSelector: ".container",
targetProp: "backgroundColor",
},
"--calcite-action-pad-corner-radius": {
selector: "calcite-action-pad",
shadowSelector: ".container",
targetProp: "borderRadius",
},
"--calcite-action-pad-shadow": {
selector: "calcite-action-pad",
shadowSelector: ".container",
targetProp: "boxShadow",
},
"--calcite-action-pad-trigger-background-color-active": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> .button",
targetProp: "backgroundColor",
state: { press: { attribute: "class", value: CSS.expandToggle } },
},
"--calcite-action-pad-trigger-background-color-focus": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> .button",
targetProp: "backgroundColor",
state: "focus",
},
"--calcite-action-pad-trigger-background-color-hover": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> .button",
targetProp: "backgroundColor",
state: "hover",
},
"--calcite-action-pad-trigger-background-color": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> .button",
targetProp: "backgroundColor",
},
"--calcite-action-pad-trigger-icon-color-active": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> calcite-icon",
targetProp: "color",
state: { press: { attribute: "class", value: CSS.expandToggle } },
},
"--calcite-action-pad-trigger-icon-color-focus": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> calcite-icon",
targetProp: "color",
state: "focus",
},
"--calcite-action-pad-trigger-icon-color-hover": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> calcite-icon",
targetProp: "color",
state: "hover",
},
"--calcite-action-pad-trigger-icon-color": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> calcite-icon",
targetProp: "color",
},
"--calcite-action-pad-trigger-shadow-active": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> .button",
targetProp: "boxShadow",
state: { press: { attribute: "title", value: "Expand" } },
},
"--calcite-action-pad-trigger-shadow-focus": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> .button",
targetProp: "boxShadow",
state: "focus",
},
"--calcite-action-pad-trigger-shadow-hover": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> .button",
targetProp: "boxShadow",
state: "hover",
},
"--calcite-action-pad-trigger-shadow": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> .button",
targetProp: "boxShadow",
},
"--calcite-action-pad-trigger-text-color-active": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> .button",
targetProp: "color",
state: { press: { attribute: "class", value: CSS.expandToggle } },
},
"--calcite-action-pad-trigger-text-color-focus": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> .button",
targetProp: "color",
state: "focus",
},
"--calcite-action-pad-trigger-text-color-hover": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> .button",
targetProp: "color",
state: "hover",
},
"--calcite-action-pad-trigger-text-color": {
selector: "calcite-action-pad",
shadowSelector: ".container calcite-action >>> .button",
targetProp: "color",
},
} as const;
themed("calcite-action-pad", tokens);
});
describe("expanded", () => {
const tokens = {
"--calcite-action-pad-expanded-max-width": {
selector: "calcite-action-pad",
targetProp: "maxWidth",
},
} as const;
themed(`<calcite-action-pad expanded></calcite-action-pad>`, tokens);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,8 @@
* These properties can be overridden using the component's tag as selector.
*
* @prop --calcite-action-pad-background-color: Specifies the background color of the component.
* @prop --calcite-action-pad-border-color: Specifies the border color of the component.
* @prop --calcite-action-pad-corner-radius: Specifies the corner radius of the component.
* @prop --calcite-action-pad-expanded-max-width: When `layout` is `"vertical"`, specifies the expanded max width of the component.
* @prop --calcite-action-pad-popover-background-color: Specifies the background color of the popover in the component.
* @prop --calcite-action-pad-popover-border-color: Specifies the border color of the popover in the component.
* @prop --calcite-action-pad-popover-corner-radius: Specifies the corner radius of the popover in the component.
* @prop --calcite-action-pad-popover-shadow: Specifies the shadow of the popover in the component.
* @prop --calcite-action-pad-shadow: Specifies the shadow of the component.
* @prop --calcite-action-pad-trigger-background-color-active: Specifies the background color of the nested trigger when active in the component.
* @prop --calcite-action-pad-trigger-background-color-focus: Specifies the background color of the nested trigger when focused in the component.
Expand All @@ -20,8 +15,6 @@
* @prop --calcite-action-pad-trigger-icon-color-focus: Specifies the icon color of the nested trigger when focused in the component.
* @prop --calcite-action-pad-trigger-icon-color-hover: Specifies the icon color of the nested trigger when hovered in the component.
* @prop --calcite-action-pad-trigger-icon-color: Specifies the icon color of the nested trigger in the component.
* @prop --calcite-action-pad-trigger-indicator-color: Specifies the indicator color of the nested trigger in the component.
* @prop --calcite-action-pad-trigger-loader-color: Specifies the loader color of the nested trigger in the component component.
* @prop --calcite-action-pad-trigger-shadow-active: Specifies the shadow of the nested trigger when active in the component.
* @prop --calcite-action-pad-trigger-shadow-focus: Specifies the shadow of the nested trigger when focused in the component.
* @prop --calcite-action-pad-trigger-shadow-hover: Specifies the shadow of the nested trigger when hovered in the component.
Expand All @@ -38,33 +31,30 @@
background: transparent;
}

calcite-action-group {
--calcite-action-group-border-color: var(--calcite-action-pad-border-color);
--calcite-action-group-popover-background-color: var(--calcite-action-pad-popover-background-color);
--calcite-action-group-popover-border-color: var(--calcite-action-pad-popover-border-color);
--calcite-action-group-popover-corner-radius: var(--calcite-action-pad-corner-radius);
--calcite-action-group-popover-shadow: var(--calcite-action-pad-popover-shadow, var(--calcite-action-pad-shadow));
--calcite-action-group-trigger-background-color-active: var(--calcite-action-pad-trigger-background-color-active);
--calcite-action-group-trigger-background-color-focus: var(--calcite-action-pad-trigger-background-color-focus);
--calcite-action-group-trigger-background-color-hover: var(--calcite-action-pad-trigger-background-color-hover);
--calcite-action-group-trigger-background-color: var(
--calcite-action-pad-trigger-background-color,
var(--calcite-action-pad-background-color)
);
--calcite-action-group-trigger-icon-color-active: var(--calcite-action-pad-trigger-icon-color-active);
--calcite-action-group-trigger-icon-color-focus: var(--calcite-action-pad-trigger-icon-color-focus);
--calcite-action-group-trigger-icon-color-hover: var(--calcite-action-pad-trigger-icon-color-hover);
--calcite-action-group-trigger-icon-color: var(--calcite-action-pad-trigger-icon-color);
--calcite-action-group-trigger-indicator-color: var(--calcite-action-pad-trigger-indicator-color);
--calcite-action-group-trigger-loader-color: var(--calcite-action-pad-trigger-loader-color);
--calcite-action-group-trigger-shadow-active: var(--calcite-action-pad-trigger-shadow-active);
--calcite-action-group-trigger-shadow-focus: var(--calcite-action-pad-trigger-shadow-focus);
--calcite-action-group-trigger-shadow-hover: var(--calcite-action-pad-trigger-shadow-hover);
--calcite-action-group-trigger-shadow: var(--calcite-action-pad-trigger-shadow);
--calcite-action-group-trigger-text-color-active: var(--calcite-action-pad-trigger-text-color-active);
--calcite-action-group-trigger-text-color-focus: var(--calcite-action-pad-trigger-text-color-focus);
--calcite-action-group-trigger-text-color-hover: var(--calcite-action-pad-trigger-text-color-hover);
--calcite-action-group-trigger-text-color: var(--calcite-action-pad-trigger-text-color);
calcite-action {
--calcite-action-background-color: var(--calcite-action-pad-trigger-background-color);
--calcite-action-text-color: var(--calcite-action-pad-trigger-text-color);
--calcite-action-icon-color: var(--calcite-action-pad-trigger-icon-color);
--calcite-action-shadow: var(--calcite-action-pad-trigger-shadow);

&:hover {
--calcite-action-background-color: var(--calcite-action-pad-trigger-background-color-hover);
--calcite-action-text-color: var(--calcite-action-pad-trigger-text-color-hover);
--calcite-action-icon-color: var(--calcite-action-pad-trigger-icon-color-hover);
--calcite-action-shadow: var(--calcite-action-pad-trigger-shadow-hover);
}
&:focus {
--calcite-action-background-color: var(--calcite-action-pad-trigger-background-color-focus);
--calcite-action-text-color: var(--calcite-action-pad-trigger-text-color-focus);
--calcite-action-icon-color: var(--calcite-action-pad-trigger-icon-color-focus);
--calcite-action-shadow: var(--calcite-action-pad-trigger-shadow-focus);
}
&:active {
--calcite-action-background-color: var(--calcite-action-pad-trigger-background-color-active);
--calcite-action-text-color: var(--calcite-action-pad-trigger-text-color-active);
--calcite-action-icon-color: var(--calcite-action-pad-trigger-icon-color-active);
--calcite-action-shadow: var(--calcite-action-pad-trigger-shadow-active);
}
}

:host([expanded][layout="vertical"]) .container {
Expand Down Expand Up @@ -104,33 +94,6 @@ calcite-action-group {
}
}
::slotted(calcite-action-group) {
--calcite-action-group-border-color: var(--calcite-action-pad-border-color);
--calcite-action-group-popover-background-color: var(--calcite-action-pad-popover-background-color);
--calcite-action-group-popover-border-color: var(--calcite-action-pad-popover-border-color);
--calcite-action-group-popover-corner-radius: var(--calcite-action-pad-corner-radius);
--calcite-action-group-popover-shadow: var(--calcite-action-pad-popover-shadow, var(--calcite-action-pad-shadow));
--calcite-action-group-trigger-background-color-active: var(--calcite-action-pad-trigger-background-color-active);
--calcite-action-group-trigger-background-color-focus: var(--calcite-action-pad-trigger-background-color-focus);
--calcite-action-group-trigger-background-color-hover: var(--calcite-action-pad-trigger-background-color-hover);
--calcite-action-group-trigger-background-color: var(
--calcite-action-pad-trigger-background-color,
var(--calcite-action-pad-background-color)
);
--calcite-action-group-trigger-icon-color-active: var(--calcite-action-pad-trigger-icon-color-active);
--calcite-action-group-trigger-icon-color-focus: var(--calcite-action-pad-trigger-icon-color-focus);
--calcite-action-group-trigger-icon-color-hover: var(--calcite-action-pad-trigger-icon-color-hover);
--calcite-action-group-trigger-icon-color: var(--calcite-action-pad-trigger-icon-color);
--calcite-action-group-trigger-indicator-color: var(--calcite-action-pad-trigger-indicator-color);
--calcite-action-group-trigger-loader-color: var(--calcite-action-pad-trigger-loader-color);
--calcite-action-group-trigger-shadow-active: var(--calcite-action-pad-trigger-shadow-active);
--calcite-action-group-trigger-shadow-focus: var(--calcite-action-pad-trigger-shadow-focus);
--calcite-action-group-trigger-shadow-hover: var(--calcite-action-pad-trigger-shadow-hover);
--calcite-action-group-trigger-shadow: var(--calcite-action-pad-trigger-shadow);
--calcite-action-group-trigger-text-color-active: var(--calcite-action-pad-trigger-text-color-active);
--calcite-action-group-trigger-text-color-focus: var(--calcite-action-pad-trigger-text-color-focus);
--calcite-action-group-trigger-text-color-hover: var(--calcite-action-pad-trigger-text-color-hover);
--calcite-action-group-trigger-text-color: var(--calcite-action-pad-trigger-text-color);

border-block-end-style: none;
border-inline-end-style: solid;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ export class ActionPad

const expandToggleNode = !expandDisabled ? (
<ExpandToggle
class={CSS.expandToggle}
collapseText={messages.collapse}
el={el}
expandText={messages.expand}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const CSS = {
actionGroupEnd: "action-group--end",
container: "container",
expandToggle: "expand-toggle",
};

export const SLOTS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const setTooltipReference = ({
return referenceElement;
};

export const ExpandToggle: FunctionalComponent<ExpandToggleProps> = ({
export const ExpandToggle: FunctionalComponent<ExpandToggleProps & any> = ({
Copy link
Member

Choose a reason for hiding this comment

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

ExpandToggleProps should extend JSXBase.HTMLAttributes instead of using any here (see example).

expanded,
expandText,
collapseText,
Expand All @@ -72,6 +72,7 @@ export const ExpandToggle: FunctionalComponent<ExpandToggleProps> = ({
tooltip,
ref,
scale,
...props
}) => {
const rtl = getElementDir(el) === "rtl";

Expand All @@ -98,6 +99,7 @@ export const ExpandToggle: FunctionalComponent<ExpandToggleProps> = ({
ref={(referenceElement): HTMLCalciteActionElement =>
setTooltipReference({ tooltip, referenceElement, expanded, ref })
}
{...props}
/>
);

Expand Down
Loading