diff --git a/packages/calcite-components/src/components/tooltip/tooltip.e2e.ts b/packages/calcite-components/src/components/tooltip/tooltip.e2e.ts index dc77696ef27..bb0f8719f7e 100644 --- a/packages/calcite-components/src/components/tooltip/tooltip.e2e.ts +++ b/packages/calcite-components/src/components/tooltip/tooltip.e2e.ts @@ -1,8 +1,9 @@ import { newE2EPage, E2EPage } from "@arcgis/lumina-compiler/puppeteerTesting"; import { describe, expect, it } from "vitest"; -import { accessible, defaults, floatingUIOwner, hidden, openClose, renders } from "../../tests/commonTests"; +import { accessible, defaults, floatingUIOwner, hidden, openClose, renders, themed } from "../../tests/commonTests"; import { html } from "../../../support/formatting"; import { getElementXY, GlobalTestProps, skipAnimations } from "../../tests/utils"; +import { FloatingCSS } from "../../utils/floating-ui"; import { TOOLTIP_OPEN_DELAY_MS, TOOLTIP_CLOSE_DELAY_MS, CSS } from "./resources"; import type { Tooltip } from "./tooltip"; @@ -1202,4 +1203,56 @@ describe("calcite-tooltip", () => { expect(await tooltip.getProperty("open")).toBe(false); }); }); + + describe("theme", () => { + describe("default", () => { + themed( + html` + + Lorem Ipsum + + `, + { + "--calcite-tooltip-background-color": [ + { + shadowSelector: `.${FloatingCSS.animation}`, + targetProp: "backgroundColor", + }, + { + shadowSelector: `.${FloatingCSS.arrow}`, + targetProp: "fill", + }, + ], + "--calcite-tooltip-border-color": [ + { + shadowSelector: `.${FloatingCSS.animation}`, + targetProp: "borderColor", + }, + { + shadowSelector: `.${FloatingCSS.arrowStroke}`, + targetProp: "stroke", + }, + ], + "--calcite-tooltip-corner-radius": [ + { + shadowSelector: `.${CSS.container}`, + targetProp: "borderRadius", + }, + { + shadowSelector: `.${FloatingCSS.animation}`, + targetProp: "borderRadius", + }, + ], + "--calcite-tooltip-text-color": { + shadowSelector: `.${CSS.container}`, + targetProp: "color", + }, + "--calcite-tooltip-z-index": { + shadowSelector: `.${CSS.positionContainer}`, + targetProp: "zIndex", + }, + }, + ); + }); + }); }); diff --git a/packages/calcite-components/src/components/tooltip/tooltip.scss b/packages/calcite-components/src/components/tooltip/tooltip.scss index cb068052ceb..1a667a7ed5f 100644 --- a/packages/calcite-components/src/components/tooltip/tooltip.scss +++ b/packages/calcite-components/src/components/tooltip/tooltip.scss @@ -3,6 +3,10 @@ * * These properties can be overridden using the component's tag as selector. * + * @prop --calcite-tooltip-background-color: Specifies the background color of the component. + * @prop --calcite-tooltip-border-color: Specifies the border color of the component. + * @prop --calcite-tooltip-corner-radius: Specifies the corner radius of the component. + * @prop --calcite-tooltip-text-color: Specifies the text color of the component. * @prop --calcite-tooltip-z-index: Sets the z-index value for the component. */ @@ -20,29 +24,33 @@ @include floating-ui-arrow(); .container { - @apply text-color-1 - text-n2-wrap + @apply text-n2-wrap relative overflow-hidden - rounded py-3 px-4 font-medium; + border-radius: var(--calcite-tooltip-corner-radius, var(--calcite-corner-radius-round)); + color: var(--calcite-tooltip-text-color, var(--calcite-color-text-1)); max-inline-size: 20rem; max-block-size: 20rem; text-align: start; } -.calcite-floating-ui-anim { - @apply bg-foreground-1 - border-color-3 - rounded - border +.position-container .calcite-floating-ui-anim { + @apply border border-solid; + background-color: var(--calcite-tooltip-background-color, var(--calcite-color-foreground-1)); + border-color: var(--calcite-tooltip-border-color, var(--calcite-color-border-3)); + border-radius: var(--calcite-tooltip-corner-radius, var(--calcite-corner-radius-round)); } -.arrow::before { - outline: 1px solid var(--calcite-color-border-3); +.calcite-floating-ui-arrow { + fill: var(--calcite-tooltip-background-color, var(--calcite-color-foreground-1)); +} + +.calcite-floating-ui-arrow__stroke { + stroke: var(--calcite-tooltip-border-color, var(--calcite-color-border-3)); } @include base-component(); diff --git a/packages/calcite-components/src/custom-theme.stories.ts b/packages/calcite-components/src/custom-theme.stories.ts index 8fc516563b2..d41f6101304 100644 --- a/packages/calcite-components/src/custom-theme.stories.ts +++ b/packages/calcite-components/src/custom-theme.stories.ts @@ -34,6 +34,7 @@ import { segmentedControl } from "./custom-theme/segmented-control"; import { slider } from "./custom-theme/slider"; import { tabs } from "./custom-theme/tabs"; import { textArea, textAreaTokens } from "./custom-theme/text-area"; +import { tooltip, tooltipTokens } from "./custom-theme/tooltip"; import { avatarIcon, avatarInitials, avatarThumbnail, avatarTokens } from "./custom-theme/avatar"; import { tileTokens, tile } from "./custom-theme/tile"; import { navigationTokens, navigation } from "./custom-theme/navigation"; @@ -119,7 +120,7 @@ const kitchenSink = (args: Record, useTestValues = false) =>
${datePicker} ${tabs} ${loader} ${calciteSwitch} ${avatarIcon} ${avatarInitials} ${avatarThumbnail} ${progress} - ${handle} ${textArea} ${popover} ${tile} + ${handle} ${textArea} ${popover} ${tile} ${tooltip}
${alert} ${navigation} @@ -144,6 +145,7 @@ const componentTokens = { ...progressTokens, ...inputTokens, ...textAreaTokens, + ...tooltipTokens, ...tileTokens, ...navigationTokens, }; diff --git a/packages/calcite-components/src/custom-theme/tooltip.ts b/packages/calcite-components/src/custom-theme/tooltip.ts new file mode 100644 index 00000000000..7da183f0f94 --- /dev/null +++ b/packages/calcite-components/src/custom-theme/tooltip.ts @@ -0,0 +1,18 @@ +import { html } from "../../support/formatting"; + +export const tooltipTokens = { + calciteTooltipBackgroundColor: "", + calciteTooltipBorderColor: "", + calciteTooltipCornerRadius: "", + calciteTooltipTextColor: "", + calciteTooltipZIndex: "", +}; + +export const tooltip = html` + + nostrud exercitation + + these 🥨s are making me thirsty + + +`; diff --git a/packages/calcite-components/src/demos/tooltip.html b/packages/calcite-components/src/demos/tooltip.html index 59bc75ee721..155c4eb3227 100644 --- a/packages/calcite-components/src/demos/tooltip.html +++ b/packages/calcite-components/src/demos/tooltip.html @@ -188,6 +188,30 @@

Tooltip

+ +
+
themed
+ + + +
+ + +

placement: auto

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et + dolore magna aliqua. +
+
+
+