From 969a2eb7e5c9be5bfeedffcd12c48104a43e2c2c Mon Sep 17 00:00:00 2001
From: Adam Tirella
Date: Thu, 15 Dec 2022 15:22:39 -0800
Subject: [PATCH] refactor(button, fab, split-button)!: Update properties and
values (#6062)
BREAKING CHANGE: Removed deprecated properties and values.
- `button`: Removed the property `form`, this property is no longer
needed if the component is placed inside a form.
- `button`, `fab`, `split-button`: Renamed the property `color`, use
`kind` instead.
- `button`, `fab`, `split-button`: Updated the accepted values of `kind`
to `brand` (default), `danger`, `inverse`, and `neutral`.
- `button`, `split-button`: Updated the accepted values of `appearance`
to `outline`, `outline-fill` and `solid` (default).
- `fab`: Updated the accepted values of `appearance` to `outline-fill`
and `solid` (default).
---
src/05-custom-theme.stories.mdx | 2 +-
src/components/button/button.e2e.ts | 20 +-
src/components/button/button.scss | 56 +-
src/components/button/button.stories.ts | 28 +-
src/components/button/button.tsx | 26 +-
src/components/button/interfaces.ts | 2 -
src/components/button/usage/Basic.md | 2 +-
src/components/button/usage/With-icons.md | 4 +-
.../button/usage/With-loader-disabled.md | 2 +-
src/components/card/card.stories.ts | 14 +-
src/components/color-picker/color-picker.tsx | 4 +-
src/components/fab/fab.e2e.ts | 22 +-
src/components/fab/fab.stories.ts | 2 +-
src/components/fab/fab.tsx | 16 +-
src/components/flow-item/flow-item.stories.ts | 2 +-
src/components/flow/flow.stories.ts | 2 +-
.../inline-editable/inline-editable.tsx | 6 +-
src/components/interfaces.ts | 4 +-
src/components/modal/modal.e2e.ts | 2 +-
src/components/modal/modal.stories.ts | 6 +-
src/components/panel/panel.stories.ts | 2 +-
src/components/pick-list/pick-list.stories.ts | 2 +-
src/components/shell/shell.stories.ts | 16 +-
.../split-button/split-button.e2e.ts | 6 +-
src/components/split-button/split-button.scss | 51 +-
.../split-button/split-button.stories.ts | 14 +-
src/components/split-button/split-button.tsx | 18 +-
src/components/tooltip/tooltip.stories.ts | 2 +-
.../value-list/value-list.stories.ts | 2 +-
src/demos/_assets/demo-template.html | 2 +-
src/demos/alert.html | 126 ++--
src/demos/animation/animation.html | 5 +-
src/demos/button.html | 667 +++++++++---------
src/demos/card.html | 44 +-
src/demos/fab.html | 177 +++--
src/demos/modal.html | 52 +-
src/demos/shell/block-configurations.html | 6 +-
.../demo-app-advanced-2-shell-header.html | 14 +-
src/demos/shell/demo-app-advanced-2.html | 14 +-
src/demos/shell/demo-app-advanced-3.html | 14 +-
src/demos/shell/demo-app-advanced.html | 4 +-
.../shell/demo-app-full-window-reversed.html | 4 +-
src/demos/shell/demo-app-full-window.html | 2 +-
src/demos/shell/nesting-testing-flow.html | 4 +-
src/demos/shell/nesting-testing.html | 2 +-
src/demos/shell/popup-config-example.html | 4 +-
src/demos/split-button.html | 600 ++++++++--------
src/demos/theme/auto.html | 4 +-
src/index.html | 6 +-
49 files changed, 1072 insertions(+), 1014 deletions(-)
diff --git a/src/05-custom-theme.stories.mdx b/src/05-custom-theme.stories.mdx
index 280a772f7b0..4b7ebbee642 100644
--- a/src/05-custom-theme.stories.mdx
+++ b/src/05-custom-theme.stories.mdx
@@ -144,7 +144,7 @@ export const Template = () =>
Outline
- Red
+ Red
-
-
+
+
@@ -205,7 +205,7 @@ export const thumbnailRounded = (): string => html`
{
},
{
propertyName: "appearance",
- defaultValue: "outline"
+ defaultValue: "solid"
}
]));
@@ -86,20 +86,20 @@ describe("calcite-fab", () => {
expect(await calciteButton.getProperty("label")).toBe("hi");
});
- it("should have appearance=outline", async () => {
+ it("should have appearance=solid", async () => {
const page = await newE2EPage();
await page.setContent(``);
const fab = await page.find(`calcite-fab >>> .${CSS.button}`);
- expect(fab.getAttribute("appearance")).toBe("outline");
+ expect(fab.getAttribute("appearance")).toBe("solid");
});
- it("should have appearance=solid", async () => {
+ it("should have appearance=outline-fill", async () => {
const page = await newE2EPage();
- await page.setContent(``);
+ await page.setContent(``);
const fab = await page.find(`calcite-fab >>> .${CSS.button}`);
- expect(fab.getAttribute("appearance")).toBe("solid");
+ expect(fab.getAttribute("appearance")).toBe("outline-fill");
});
it("should be accessible", async () => {
@@ -109,7 +109,7 @@ describe("calcite-fab", () => {
describe("when invalid appearance values are passed", () => {
describe("when value is 'transparent'", () => {
- it("should render with default 'outline' appearance", async () => {
+ it("should render with default 'outline-fill' appearance", async () => {
const page = await newE2EPage({
html: `
{
`
});
const fab = await page.find(`calcite-fab >>> .${CSS.button}`);
- expect(fab.getAttribute("appearance")).toBe("outline");
+ expect(fab.getAttribute("appearance")).toBe("outline-fill");
});
});
describe("when value is 'clear'", () => {
- it("should render with default 'outline' appearance", async () => {
+ it("should render with default 'outline-fill' appearance", async () => {
const page = await newE2EPage({
html: `
`
});
const fab = await page.find(`calcite-fab >>> .${CSS.button}`);
- expect(fab.getAttribute("appearance")).toBe("outline");
+ expect(fab.getAttribute("appearance")).toBe("outline-fill");
});
});
});
diff --git a/src/components/fab/fab.stories.ts b/src/components/fab/fab.stories.ts
index 21a916ed8cd..10abecb0c04 100644
--- a/src/components/fab/fab.stories.ts
+++ b/src/components/fab/fab.stories.ts
@@ -27,7 +27,7 @@ const createAttributes: (options?: { exceptions: string[] }) => Attributes = ({
{
name: "appearance",
commit(): Attribute {
- this.value = select("appearance", ["solid", "outline"], "outline");
+ this.value = select("appearance", ["solid", "outline-fill"], "outline-fill");
delete this.build;
return this;
}
diff --git a/src/components/fab/fab.tsx b/src/components/fab/fab.tsx
index d0d578022c1..5cecdc62e70 100755
--- a/src/components/fab/fab.tsx
+++ b/src/components/fab/fab.tsx
@@ -1,6 +1,5 @@
import { Component, Element, Method, Prop, h, VNode } from "@stencil/core";
-import { Appearance, Scale } from "../interfaces";
-import { ButtonColor } from "../button/interfaces";
+import { Appearance, Kind, Scale } from "../interfaces";
import { CSS, ICONS } from "./resources";
import { focusElement } from "../../utils/dom";
import { InteractiveComponent, updateHostInteraction } from "../../utils/interactive";
@@ -26,12 +25,13 @@ export class Fab implements InteractiveComponent, LoadableComponent {
/**
* Specifies the appearance style of the component.
*/
- @Prop({ reflect: true }) appearance: Extract<"solid" | "outline", Appearance> = "outline";
+ @Prop({ reflect: true }) appearance: Extract<"solid" | "outline-fill", Appearance> = "solid";
/**
- * Specifies the color of the component.
+ * Specifies the kind of the component (will apply to border and background).
*/
- @Prop({ reflect: true }) color: ButtonColor = "neutral";
+ @Prop({ reflect: true }) kind: Extract<"brand" | "danger" | "inverse" | "neutral", Kind> =
+ "brand";
/**
* When `true`, interaction is prevented and the component is displayed with lower opacity.
@@ -119,16 +119,16 @@ export class Fab implements InteractiveComponent, LoadableComponent {
// --------------------------------------------------------------------------
render(): VNode {
- const { appearance, color, disabled, loading, scale, textEnabled, icon, label, text } = this;
+ const { appearance, kind, disabled, loading, scale, textEnabled, icon, label, text } = this;
const title = !textEnabled ? label || text || null : null;
return (
{
diff --git a/src/components/flow-item/flow-item.stories.ts b/src/components/flow-item/flow-item.stories.ts
index aa1715dde45..0490a9d017f 100644
--- a/src/components/flow-item/flow-item.stories.ts
+++ b/src/components/flow-item/flow-item.stories.ts
@@ -98,7 +98,7 @@ const contentHTML = html`
`;
const footerHTML = html`
- Naw.
+ Naw.
Yeah!
`;
diff --git a/src/components/flow/flow.stories.ts b/src/components/flow/flow.stories.ts
index a8eff1fb61e..6627f2b2e8b 100644
--- a/src/components/flow/flow.stories.ts
+++ b/src/components/flow/flow.stories.ts
@@ -71,7 +71,7 @@ const menuActionsHTML = html`
`;
const footerActionsHTML = html`
- Cancel
+ Cancel
Save
`;
diff --git a/src/components/inline-editable/inline-editable.tsx b/src/components/inline-editable/inline-editable.tsx
index 67d9c6e4552..79ed08c24a3 100644
--- a/src/components/inline-editable/inline-editable.tsx
+++ b/src/components/inline-editable/inline-editable.tsx
@@ -170,9 +170,9 @@ export class InlineEditable
(this.enableEditingButton = el)}
@@ -188,9 +188,9 @@ export class InlineEditable
(this.cancelEditingButton = el)}
@@ -201,9 +201,9 @@ export class InlineEditable
{
Title of the modal
The actual content of the modal
-
+
Back
Cancel
diff --git a/src/components/modal/modal.stories.ts b/src/components/modal/modal.stories.ts
index 5d5a3bdd1ab..bc2375dfc9e 100644
--- a/src/components/modal/modal.stories.ts
+++ b/src/components/modal/modal.stories.ts
@@ -30,7 +30,7 @@ export const simple = (): string => html`
The small modal is perfect for short confirmation dialogs or very compact interfaces with few elements.
- Back
Cancel
@@ -58,7 +58,7 @@ export const darkThemeRTLCustomSize_TestOnly = (): string => html`
customize the size using the width attribute.
- Back
Cancel
@@ -80,7 +80,7 @@ export const withTooltips_TestOnly = (): string => html`
et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.
- Back
Cancel
diff --git a/src/components/panel/panel.stories.ts b/src/components/panel/panel.stories.ts
index a18a8160ff5..6d7b9fe8a91 100644
--- a/src/components/panel/panel.stories.ts
+++ b/src/components/panel/panel.stories.ts
@@ -98,7 +98,7 @@ const contentHTML = html`
`;
const footerHTML = html`
- Naw.
+ Naw.
Yeah!
`;
diff --git a/src/components/pick-list/pick-list.stories.ts b/src/components/pick-list/pick-list.stories.ts
index 8e8de27583e..2118655fa7c 100644
--- a/src/components/pick-list/pick-list.stories.ts
+++ b/src/components/pick-list/pick-list.stories.ts
@@ -73,7 +73,7 @@ const action = html`
slot="actions-end"
label="click-me"
onClick="console.log('clicked');"
- appearance="clear"
+ appearance="outline"
scale="s"
icon="information"
>
diff --git a/src/components/shell/shell.stories.ts b/src/components/shell/shell.stories.ts
index 456619e0929..5b5133807a4 100644
--- a/src/components/shell/shell.stories.ts
+++ b/src/components/shell/shell.stories.ts
@@ -257,7 +257,7 @@ const advancedTrailingPanelHTMl = html`
- Cancel
+ Cancel
Save
@@ -291,7 +291,7 @@ const advancedTrailingPanelHTMl = html`
- Cancel
+ Cancel
Save
@@ -441,9 +441,9 @@ background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
Cancel
@@ -453,7 +453,7 @@ background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
width="half"
alignment="center"
appearance="solid"
- color="blue"
+ kind="brand"
scale="m"
>
Save
@@ -501,9 +501,9 @@ background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
Cancel
@@ -513,7 +513,7 @@ background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
width="half"
alignment="center"
appearance="solid"
- color="blue"
+ kind="brand"
scale="m"
>
Save
diff --git a/src/components/split-button/split-button.e2e.ts b/src/components/split-button/split-button.e2e.ts
index 10825114b7b..a649700f3b0 100644
--- a/src/components/split-button/split-button.e2e.ts
+++ b/src/components/split-button/split-button.e2e.ts
@@ -63,7 +63,7 @@ describe("calcite-split-button", () => {
`);
const element = await page.find("calcite-split-button");
expect(element).toEqualAttribute("scale", "m");
- expect(element).toEqualAttribute("color", "blue");
+ expect(element).toEqualAttribute("kind", "brand");
expect(element).toEqualAttribute("dropdown-icon-type", "chevron");
expect(element).toEqualAttribute("width", "auto");
});
@@ -87,7 +87,7 @@ describe("calcite-split-button", () => {
await page.setContent(`
{
const primaryButton = await page.find("calcite-split-button >>> calcite-button");
const dropdownButton = await page.find("calcite-split-button >>> calcite-dropdown calcite-button");
expect(element).toEqualAttribute("scale", "s");
- expect(element).toEqualAttribute("color", "red");
+ expect(element).toEqualAttribute("kind", "danger");
expect(element).toEqualAttribute("dropdown-icon-type", "caret");
expect(element).toHaveAttribute("loading");
expect(element).toHaveAttribute("disabled");
diff --git a/src/components/split-button/split-button.scss b/src/components/split-button/split-button.scss
index 6b4c38e560f..466a4179795 100644
--- a/src/components/split-button/split-button.scss
+++ b/src/components/split-button/split-button.scss
@@ -12,60 +12,60 @@
}
:host {
- &:host([color="blue"]) {
+ &:host([kind="brand"]) {
--calcite-split-button-background: theme("colors.brand");
--calcite-split-button-divider: theme("colors.background.foreground.1");
}
- &:host([color="red"]) {
+ &:host([kind="danger"]) {
--calcite-split-button-background: theme("colors.danger");
--calcite-split-button-divider: theme("colors.background.foreground.1");
}
- &:host([color="neutral"]) {
+ &:host([kind="neutral"]) {
--calcite-split-button-background: theme("colors.background.foreground.3");
--calcite-split-button-divider: theme("colors.color.1");
}
- &:host([color="inverse"]) {
+ &:host([kind="inverse"]) {
--calcite-split-button-background: var(--calcite-ui-inverse);
--calcite-split-button-divider: theme("colors.background.foreground.1");
}
}
:host([appearance="transparent"]) {
- &:host([color="blue"]) {
+ &:host([kind="brand"]) {
--calcite-split-button-divider: theme("colors.brand");
}
- &:host([color="red"]) {
+ &:host([kind="danger"]) {
--calcite-split-button-divider: theme("colors.danger");
}
- &:host([color="neutral"]) {
+ &:host([kind="neutral"]) {
--calcite-split-button-divider: theme("colors.color.1");
}
- &:host([color="inverse"]) {
+ &:host([kind="inverse"]) {
--calcite-split-button-divider: theme("colors.background.foreground.1");
}
}
-:host([appearance="clear"]),
+:host([appearance="outline"]),
:host([appearance="transparent"]) {
--calcite-split-button-background: transparent;
}
-:host([appearance="outline"]) {
+:host([appearance="outline-fill"]) {
--calcite-split-button-background: theme("colors.background.foreground.1");
}
-:host([appearance="clear"]),
-:host([appearance="outline"]) {
- &:host([color="blue"]) {
+:host([appearance="outline"]),
+:host([appearance="outline-fill"]) {
+ &:host([kind="brand"]) {
--calcite-split-button-divider: theme("colors.brand");
}
- &:host([color="red"]) {
+ &:host([kind="danger"]) {
--calcite-split-button-divider: theme("colors.danger");
}
- &:host([color="neutral"]) {
+ &:host([kind="neutral"]) {
--calcite-split-button-divider: theme("colors.background.foreground.3");
}
- &:host([color="inverse"]) {
+ &:host([kind="inverse"]) {
--calcite-split-button-divider: var(--calcite-ui-inverse);
}
}
@@ -92,9 +92,8 @@
background-color: var(--calcite-split-button-divider);
}
-:host([appearance="outline"]),
-:host([appearance="clear"]),
-:host([appearance="minimal"]) {
+:host([appearance="outline-fill"]),
+:host([appearance="outline"]) {
.split-button__divider-container {
border-block: 1px solid var(--calcite-split-button-divider);
}
@@ -103,21 +102,19 @@
}
}
-:host([appearance="outline"]:hover),
-:host([appearance="clear"]:hover),
-:host([appearance="minimal"]):hover {
+:host([appearance="outline-fill"]:hover),
+:host([appearance="outline"]:hover) {
.split-button__divider-container {
background-color: var(--calcite-split-button-divider);
}
}
-:host([appearance="outline"]:focus-within),
-:host([appearance="clear"]:focus-within),
-:host([appearance="minimal"]:focus-within) {
- &:host([color="blue"]) {
+:host([appearance="outline-fill"]:focus-within),
+:host([appearance="outline"]:focus-within) {
+ &:host([kind="brand"]) {
--calcite-split-button-divider: theme("colors.brand-press");
}
- &:host([color="red"]) {
+ &:host([kind="danger"]) {
--calcite-split-button-divider: theme("colors.danger-press");
}
.split-button__divider-container {
diff --git a/src/components/split-button/split-button.stories.ts b/src/components/split-button/split-button.stories.ts
index 778d66ca2ac..b355bd66d28 100644
--- a/src/components/split-button/split-button.stories.ts
+++ b/src/components/split-button/split-button.stories.ts
@@ -16,8 +16,8 @@ export const simple = (): string => html`
html`
export const iconEnd_TestOnly = (): string => html`
html`
export const iconStartAndIconEnd = (): string => html`
html`
export const darkThemeRTL_TestOnly = (): string => html`
= "solid";
- /** Specifies the color of the component. */
- @Prop({ reflect: true }) color: ButtonColor = "blue";
+ /** Specifies the kind of the component (will apply to border and background if applicable). */
+ @Prop({ reflect: true }) kind: Extract<"brand" | "danger" | "inverse" | "neutral", Kind> =
+ "brand";
/** When `true`, interaction is prevented and the component is displayed with lower opacity. */
@Prop({ reflect: true }) disabled = false;
@@ -125,11 +129,11 @@ export class SplitButton implements InteractiveComponent {
nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.`;
+const referenceElementHTML = `Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.`;
export default {
title: "Components/Tooltip",
diff --git a/src/components/value-list/value-list.stories.ts b/src/components/value-list/value-list.stories.ts
index 7268874a063..df0b9806693 100644
--- a/src/components/value-list/value-list.stories.ts
+++ b/src/components/value-list/value-list.stories.ts
@@ -80,7 +80,7 @@ const action = html`
slot="actions-end"
label="click-me"
onClick="console.log('clicked');"
- appearance="clear"
+ appearance="outline"
scale="s"
icon="ellipsis"
>
diff --git a/src/demos/_assets/demo-template.html b/src/demos/_assets/demo-template.html
index c3841f879fc..1a111c855b7 100644
--- a/src/demos/_assets/demo-template.html
+++ b/src/demos/_assets/demo-template.html
@@ -3,7 +3,7 @@