Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 18 additions & 0 deletions packages/calcite-components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4562,6 +4562,10 @@ export namespace Components {
* Accessible name for the dropdown menu.
*/
"dropdownLabel": string;
/**
* Defines the available placements that can be used when a flip occurs.
*/
"flipPlacements": FlipPlacement[];
/**
* Specifies the kind of the component, which will apply to border and background, if applicable.
*/
Expand All @@ -4574,6 +4578,11 @@ export namespace Components {
* Determines the type of positioning to use for the overlaid content. Using `"absolute"` will work for most cases. The component will be positioned inside of overflowing parent containers and will affect the container's layout. `"fixed"` should be used to escape an overflowing parent container, or when the reference element's `position` CSS property is `"fixed"`.
*/
"overlayPositioning": OverlayPositioning;
/**
* Determines where the component will be positioned relative to the container element.
* @default "bottom-end"
*/
"placement": MenuPlacement;
/**
* Specifies an icon to display at the end of the primary button.
*/
Expand Down Expand Up @@ -12509,6 +12518,10 @@ declare namespace LocalJSX {
* Accessible name for the dropdown menu.
*/
"dropdownLabel"?: string;
/**
* Defines the available placements that can be used when a flip occurs.
*/
"flipPlacements"?: FlipPlacement[];
/**
* Specifies the kind of the component, which will apply to border and background, if applicable.
*/
Expand All @@ -12529,6 +12542,11 @@ declare namespace LocalJSX {
* Determines the type of positioning to use for the overlaid content. Using `"absolute"` will work for most cases. The component will be positioned inside of overflowing parent containers and will affect the container's layout. `"fixed"` should be used to escape an overflowing parent container, or when the reference element's `position` CSS property is `"fixed"`.
*/
"overlayPositioning"?: OverlayPositioning;
/**
* Determines where the component will be positioned relative to the container element.
* @default "bottom-end"
*/
"placement"?: MenuPlacement;
/**
* Specifies an icon to display at the end of the primary button.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { hidden, renders, disabled, defaults } from "../../tests/commonTests";
import { html } from "../../../support/formatting";
import { hidden, renders, disabled, defaults, themed } from "../../tests/commonTests";
import { ComponentTestTokens } from "../../tests/commonTests/themed";
import { CSS } from "./resources";

describe("calcite-list-item-group", () => {
describe("renders", () => {
Expand Down Expand Up @@ -33,4 +36,33 @@ describe("calcite-list-item-group", () => {
},
]);
});

describe("themed", () => {
const tokens: ComponentTestTokens = {
"--calcite-list-item-group-background-color": {
selector: "calcite-list-item-group",
targetProp: "backgroundColor",
},
"--calcite-list-item-group-text-color": {
selector: "calcite-list-item-group",
shadowSelector: `.${CSS.container}`,
targetProp: "color",
},
};
themed(
html`<calcite-list selection-mode="single">
<calcite-list-item-group>
<calcite-list-item label="Apples" description="Apples are cool" value="apples" open></calcite-list-item>
<calcite-list-item
label="Oranges"
description="Oranges are cool"
value="oranges"
selected
></calcite-list-item>
<calcite-list-item label="Pears" description="Pears are cool" value="pears"></calcite-list-item>
</calcite-list-item-group>
</calcite-list>`,
tokens,
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,27 @@
* These properties can be overridden using the component's tag as selector.
*
* @prop --calcite-list-item-group-background-color: Specifies the background color of the component.
* @prop --calcite-list-item-group-border-color: Specifies the border color of the component.
* @prop --calcite-list-item-heading-text-color: Specifies the text color of the component's heading.
* @prop --calcite-list-item-group-text-color: Specifies the text color of the component.
*/

:host {
display: flex;
flex-direction: column;
@apply flex flex-col;
background-color: var(--calcite-list-item-group-background-color, var(--calcite-color-foreground-1));
}

:host([filter-hidden]) {
display: none;
@apply hidden;
}

@include disabled();

.container {
@apply text-n1 m-0 flex flex-1 p-3 font-medium;

color: var(--calcite-list-item-group-heading-text-color, var(--calcite-color-text-2));
color: var(--calcite-list-item-group-text-color, var(--calcite-color-text-2));
}

.heading {
@apply p-0;
padding-inline-start: calc(
var(--calcite-internal-list-item-spacing-indent, var(--calcite-spacing-xl)) *
var(--calcite-internal-list-item-spacing-indent-multiplier)
);
}

::slotted(calcite-list-item) {
border-block-start: var(--calcite-border-width-sm) solid
var(--calcite-list-item-group-border-color, var(--calcite-color-border-3));
}

// removes border for the first item of the group for both filtered and unfiltered items.
::slotted(calcite-list-item:nth-child(1 of :not([hidden]))) {
border: none;
}

@include base-component();
148 changes: 147 additions & 1 deletion packages/calcite-components/src/components/list-item/list-item.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { newE2EPage } from "@stencil/core/testing";
import { defaults, disabled, focusable, hidden, renders, slots } from "../../tests/commonTests";
import { defaults, disabled, focusable, hidden, renders, slots, themed } from "../../tests/commonTests";
import { html } from "../../../support/formatting";
import { ComponentTestTokens } from "../../tests/commonTests/themed";
import { CSS, SLOTS } from "./resources";

describe("calcite-list-item", () => {
Expand Down Expand Up @@ -341,4 +342,149 @@ describe("calcite-list-item", () => {
expect(await listItem.getProperty("dragSelected")).toBe(false);
expect(calciteListItemDragHandleChange).toHaveReceivedEventTimes(2);
});

describe("theme", () => {
describe("default", () => {
const tokens: ComponentTestTokens = {
"--calcite-list-item-background-color-active": {
selector: "calcite-list-item",
shadowSelector: `.${CSS.container}`,
targetProp: "backgroundColor",
state: { press: { attribute: "class", value: CSS.container } },
},
"--calcite-list-item-background-color-hover": {
selector: "calcite-list-item",
shadowSelector: `.${CSS.containerHover}`,
targetProp: "backgroundColor",
state: "hover",
},
"--calcite-list-item-background-color": [
{
selector: "calcite-list-item",
targetProp: "backgroundColor",
},
{
selector: "calcite-list-item",
shadowSelector: `.${CSS.container}`,
targetProp: "backgroundColor",
},
],
"--calcite-list-item-border-color": {
selector: "calcite-list-item",
shadowSelector: `.${CSS.nestedContainer}`,
targetProp: "borderBlockEndColor",
},
"--calcite-list-item-description-text-color-selected": {
selector: "calcite-list-item[selected]",
shadowSelector: `.${CSS.description}`,
targetProp: "color",
},
"--calcite-list-item-description-text-color": {
selector: "calcite-list-item",
shadowSelector: `.${CSS.description}`,
targetProp: "color",
},
"--calcite-list-item-label-text-color": {
selector: "calcite-list-item",
shadowSelector: `.${CSS.label}`,
targetProp: "color",
},
"--calcite-list-item-spacing-indent": {
selector: "calcite-list-item",
targetProp: "marginInlineStart",
shadowSelector: `.${CSS.nestedContainer}`,
},
"--calcite-list-item-indicator-color": {
selector: "calcite-list-item",
shadowSelector: `.${CSS.selectionContainer}`,
targetProp: "color",
},
"--calcite-list-item-indicator-color-hover": {
selector: "calcite-list-item",
shadowSelector: `.${CSS.selectionContainer}`,
targetProp: "color",
state: "hover",
},
"--calcite-list-item-indicator-color-selected": {
selector: "calcite-list-item[selected]",
shadowSelector: `.${CSS.selectionContainer}`,
targetProp: "color",
},
};
themed(
html`<calcite-list selection-mode="single">
<calcite-list-item label="Apples" description="Apples are cool" value="apples" open>
<calcite-list>
<calcite-list-item label="Red" description="Red is cool" value="red"></calcite-list-item>
<calcite-list-item label="Green" description="Green is cool" value="green"></calcite-list-item>
<calcite-list-item label="Yellow" description="Yellow is cool" value="yellow"></calcite-list-item>
</calcite-list>
</calcite-list-item>
<calcite-list-item
label="Oranges"
description="Oranges are cool"
value="oranges"
selected
></calcite-list-item>
<calcite-list-item label="Pears" description="Pears are cool" value="pears"></calcite-list-item>
</calcite-list>`,
tokens,
);
});
describe("border", () => {
const tokens: ComponentTestTokens = {
"--calcite-list-item-border-color": {
selector: "calcite-list-item[selected]",
shadowSelector: `.${CSS.wrapperBordered}`,
targetProp: "borderBlockEndColor",
},
"--calcite-list-item-indicator-color": {
selector: "calcite-list-item[selected]",
shadowSelector: `.${CSS.containerBorder}`,
targetProp: "borderInlineStartColor",
},
"--calcite-list-item-indicator-color-hover": {
selector: "calcite-list-item[selected]",
shadowSelector: `.${CSS.containerBorder}`,
targetProp: "borderInlineStartColor",
state: "hover",
},
"--calcite-list-item-indicator-color-selected": {
selector: "calcite-list-item[selected]",
shadowSelector: `.${CSS.containerBorder}`,
targetProp: "borderInlineStartColor",
},
};
themed(
html`<calcite-list selection-appearance="border" selection-mode="single">
<calcite-list-item label="Apples" description="Apples are cool" value="apples" open selected>
<calcite-list>
<calcite-list-item label="Red" description="Red is cool" value="red"></calcite-list-item>
<calcite-list-item label="Green" description="Green is cool" value="green"></calcite-list-item>
<calcite-list-item label="Yellow" description="Yellow is cool" value="yellow"></calcite-list-item>
</calcite-list>
</calcite-list-item>
<calcite-list-item label="Oranges" description="Oranges are cool" value="oranges"></calcite-list-item>
<calcite-list-item label="Pears" description="Pears are cool" value="pears"></calcite-list-item>
</calcite-list>`,
tokens,
);
});
describe("filtered fallback", () => {
const tokens: ComponentTestTokens = {
"--calcite-list-background-color": {
selector: "calcite-list-item",
targetProp: "backgroundColor",
},
};
themed(
html`<calcite-list>
<calcite-list-item label="Apples" value="apples"></calcite-list-item>
<calcite-list-item label="Oranges" value="oranges"></calcite-list-item>
<calcite-list-item label="Pears" value="pears"></calcite-list-item>
</calcite-list>`,
tokens,
);
});
});
});
Loading