Skip to content
Open
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
13 changes: 7 additions & 6 deletions components/actionbutton/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
".spectrum-ActionButton-label",
".spectrum-ActionButton-label:empty",
".spectrum-ActionButton.is-disabled",
".spectrum-ActionButton.is-selected",
".spectrum-ActionButton.is-selected.spectrum-ActionButton--emphasized",
".spectrum-ActionButton.is-selected.spectrum-ActionButton--staticBlack",
".spectrum-ActionButton.is-selected.spectrum-ActionButton--staticWhite",
".spectrum-ActionButton.spectrum-ActionButton--emphasized:is([aria-pressed=\"true\"], [aria-expanded=\"true\"])",
".spectrum-ActionButton.spectrum-ActionButton--quiet",
".spectrum-ActionButton.spectrum-ActionButton--quiet.is-selected",
".spectrum-ActionButton.spectrum-ActionButton--quiet:disabled:not(.is-selected)",
".spectrum-ActionButton.spectrum-ActionButton--quiet:is(:disabled, .is-disabled, [aria-disabled=\"true\"]):not(:is([aria-pressed=\"true\"], [aria-expanded=\"true\"]))",
".spectrum-ActionButton.spectrum-ActionButton--quiet:is([aria-pressed=\"true\"], [aria-expanded=\"true\"])",
".spectrum-ActionButton.spectrum-ActionButton--staticBlack",
".spectrum-ActionButton.spectrum-ActionButton--staticBlack.spectrum-ActionButton--quiet",
".spectrum-ActionButton.spectrum-ActionButton--staticBlack:is([aria-pressed=\"true\"], [aria-expanded=\"true\"])",
".spectrum-ActionButton.spectrum-ActionButton--staticWhite",
".spectrum-ActionButton.spectrum-ActionButton--staticWhite.spectrum-ActionButton--quiet",
".spectrum-ActionButton.spectrum-ActionButton--staticWhite:is([aria-pressed=\"true\"], [aria-expanded=\"true\"])",
".spectrum-ActionButton::-moz-focus-inner",
".spectrum-ActionButton:active",
".spectrum-ActionButton:after",
Expand All @@ -35,6 +34,8 @@
".spectrum-ActionButton:focus-visible:after",
".spectrum-ActionButton:has(.spectrum-ActionButton-icon)",
".spectrum-ActionButton:hover",
".spectrum-ActionButton:is(:disabled, .is-disabled, [aria-disabled=\"true\"])",
".spectrum-ActionButton:is([aria-pressed=\"true\"], [aria-expanded=\"true\"])",
".spectrum-ActionButton:not(:has(.spectrum-ActionButton-label))",
"a.spectrum-ActionButton"
],
Expand Down
73 changes: 35 additions & 38 deletions components/actionbutton/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ governing permissions and limitations under the License.
--spectrum-actionbutton-line-height: var(--spectrum-actionbutton-height);

--spectrum-actionbutton-text-to-visual: var(--spectrum-text-to-visual-100);
--spectrum-actionbutton-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-medium);
--spectrum-actionbutton-edge-to-hold-icon: var(--mod-actionbutton-edge-to-hold-icon, var(--spectrum-action-button-edge-to-hold-icon-medium));
--spectrum-actionbutton-edge-to-visual: var(--spectrum-component-edge-to-visual-100);
--spectrum-actionbutton-edge-to-text: var(--spectrum-component-edge-to-text-100);
--spectrum-actionbutton-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-100);
Expand All @@ -65,7 +65,7 @@ governing permissions and limitations under the License.
--spectrum-actionbutton-background-color-focus: var(--spectrum-gray-200);
--spectrum-actionbutton-background-color-disabled: transparent;

&.is-selected {
&:is([aria-pressed="true"], [aria-expanded="true"]) {
--spectrum-actionbutton-background-color-disabled: var(--spectrum-disabled-background-color);
}
}
Expand Down Expand Up @@ -118,7 +118,8 @@ governing permissions and limitations under the License.
}
}

&.is-selected {
/* expanded is specific to action menu when the menu is open */
&:is([aria-pressed="true"], [aria-expanded="true"]) {
--mod-actionbutton-background-color-default: var(--mod-actionbutton-background-color-default-selected, var(--spectrum-neutral-background-color-selected-default));
--mod-actionbutton-background-color-hover: var(--mod-actionbutton-background-color-hover-selected, var(--spectrum-neutral-background-color-selected-hover));
--mod-actionbutton-background-color-down: var(--mod-actionbutton-background-color-down-selected, var(--spectrum-neutral-background-color-selected-down));
Expand Down Expand Up @@ -178,7 +179,7 @@ governing permissions and limitations under the License.
--spectrum-actionbutton-icon-size: var(--spectrum-workflow-icon-size-50);
--spectrum-actionbutton-font-size: var(--spectrum-font-size-50);
--spectrum-actionbutton-text-to-visual: var(--spectrum-text-to-visual-50);
--spectrum-actionbutton-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-extra-small);
--spectrum-actionbutton-edge-to-hold-icon: var(--mod-actionbutton-edge-to-hold-icon, var(--spectrum-action-button-edge-to-hold-icon-extra-small));
--spectrum-actionbutton-edge-to-visual: var(--spectrum-component-edge-to-visual-50);
--spectrum-actionbutton-edge-to-text: var(--spectrum-component-edge-to-text-50);
--spectrum-actionbutton-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-50);
Expand All @@ -195,7 +196,7 @@ governing permissions and limitations under the License.
--spectrum-actionbutton-icon-size: var(--spectrum-workflow-icon-size-75);
--spectrum-actionbutton-font-size: var(--spectrum-font-size-75);
--spectrum-actionbutton-text-to-visual: var(--spectrum-text-to-visual-75);
--spectrum-actionbutton-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-small);
--spectrum-actionbutton-edge-to-hold-icon: var(--mod-actionbutton-edge-to-hold-icon, var(--spectrum-action-button-edge-to-hold-icon-small));
--spectrum-actionbutton-edge-to-visual: var(--spectrum-component-edge-to-visual-75);
--spectrum-actionbutton-edge-to-text: var(--spectrum-component-edge-to-text-75);
--spectrum-actionbutton-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-75);
Expand All @@ -212,7 +213,7 @@ governing permissions and limitations under the License.
--spectrum-actionbutton-icon-size: var(--spectrum-workflow-icon-size-200);
--spectrum-actionbutton-font-size: var(--spectrum-font-size-200);
--spectrum-actionbutton-text-to-visual: var(--spectrum-text-to-visual-200);
--spectrum-actionbutton-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-large);
--spectrum-actionbutton-edge-to-hold-icon: var(--mod-actionbutton-edge-to-hold-icon, var(--spectrum-action-button-edge-to-hold-icon-large));
--spectrum-actionbutton-edge-to-visual: var(--spectrum-component-edge-to-visual-200);
--spectrum-actionbutton-edge-to-text: var(--spectrum-component-edge-to-text-200);
--spectrum-actionbutton-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-200);
Expand All @@ -227,7 +228,7 @@ governing permissions and limitations under the License.
--spectrum-actionbutton-icon-size: var(--spectrum-workflow-icon-size-300);
--spectrum-actionbutton-font-size: var(--spectrum-font-size-300);
--spectrum-actionbutton-text-to-visual: var(--spectrum-text-to-visual-300);
--spectrum-actionbutton-edge-to-hold-icon: var(--spectrum-action-button-edge-to-hold-icon-extra-large);
--spectrum-actionbutton-edge-to-hold-icon: var(--mod-actionbutton-edge-to-hold-icon, var(--spectrum-action-button-edge-to-hold-icon-extra-large));
--spectrum-actionbutton-edge-to-visual: var(--spectrum-component-edge-to-visual-300);
--spectrum-actionbutton-edge-to-text: var(--spectrum-component-edge-to-text-300);
--spectrum-actionbutton-edge-to-visual-only: var(--spectrum-component-edge-to-visual-only-300);
Expand All @@ -252,6 +253,18 @@ governing permissions and limitations under the License.
background-color: var(--highcontrast-actionbutton-background-color-default, var(--mod-actionbutton-background-color-default, var(--spectrum-actionbutton-background-color-default)));
color: var(--highcontrast-actionbutton-content-color-default, var(--mod-actionbutton-content-color-default, var(--spectrum-actionbutton-content-color-default)));

transition: border-color var(--highcontrast-actionbutton-animation-duration, var(--mod-actionbutton-animation-duration, var(--spectrum-actionbutton-animation-duration))) ease-in-out;

&::after {
position: absolute;
inset: 0;
margin: calc((var(--mod-actionbutton-focus-indicator-gap, var(--spectrum-actionbutton-focus-indicator-gap)) + var(--spectrum-actionbutton-border-width)) * -1);
border-radius: var(--mod-actionbutton-focus-indicator-border-radius, var(--spectrum-actionbutton-focus-indicator-border-radius));
transition: box-shadow var(--highcontrast-actionbutton-animation-duration, var(--mod-actionbutton-animation-duration, var(--spectrum-actionbutton-animation-duration))) ease-in-out;
pointer-events: none;
content: "";
}

&:hover {
background-color: var(--highcontrast-actionbutton-background-color-default, var(--mod-actionbutton-background-color-hover, var(--spectrum-actionbutton-background-color-hover)));
color: var(--highcontrast-actionbutton-content-color-default, var(--mod-actionbutton-content-color-hover, var(--spectrum-actionbutton-content-color-hover)));
Expand All @@ -260,6 +273,13 @@ governing permissions and limitations under the License.
&:focus-visible {
background-color: var(--highcontrast-actionbutton-background-color-default, var(--mod-actionbutton-background-color-focus, var(--spectrum-actionbutton-background-color-focus)));
color: var(--highcontrast-actionbutton-content-color-default, var(--mod-actionbutton-content-color-focus, var(--spectrum-actionbutton-content-color-focus)));

box-shadow: none;
outline: none;

&::after {
box-shadow: 0 0 0 var(--mod-actionbutton-focus-indicator-thickness, var(--spectrum-actionbutton-focus-indicator-thickness)) var(--highcontrast-actionbutton-focus-indicator-color, var(--mod-actionbutton-focus-indicator-color, var(--spectrum-actionbutton-focus-indicator-color)));
}
}

&:active {
Expand All @@ -268,8 +288,9 @@ governing permissions and limitations under the License.
transform: perspective(var(--spectrum-actionbutton-downstate-perspective)) translateZ(var(--spectrum-component-size-difference-down));
}

&:disabled,
&.is-disabled {
/* ideal when we want to disable the button but still allow it's content to be focused */
&:is(:disabled, .is-disabled, [aria-disabled="true"]) {
/* @todo: should pointer events be disabled? */
background-color: var(--highcontrast-actionbutton-background-color-disabled, var(--mod-actionbutton-background-color-disabled, var(--spectrum-actionbutton-background-color-disabled)));
color: var(--highcontrast-actionbutton-content-color-disabled, var(--mod-actionbutton-content-color-disabled, var(--spectrum-actionbutton-content-color-disabled)));
}
Expand Down Expand Up @@ -313,36 +334,13 @@ a.spectrum-ActionButton {

.spectrum-ActionButton-hold {
position: absolute;
inset-inline-end: calc(var(--mod-actionbutton-edge-to-hold-icon, var(--spectrum-actionbutton-edge-to-hold-icon)) - var(--spectrum-actionbutton-border-width));
inset-block-end: calc(var(--mod-actionbutton-edge-to-hold-icon, var(--spectrum-actionbutton-edge-to-hold-icon)) - var(--spectrum-actionbutton-border-width));
inset-inline-end: calc(var(--spectrum-actionbutton-edge-to-hold-icon) - var(--spectrum-actionbutton-border-width));
inset-block-end: calc(var(--spectrum-actionbutton-edge-to-hold-icon) - var(--spectrum-actionbutton-border-width));
display: block;
color: inherit;
transform: var(--spectrum-logical-rotation);
}

/* Focus indicator */
.spectrum-ActionButton {
transition: border-color var(--highcontrast-actionbutton-animation-duration, var(--mod-actionbutton-animation-duration, var(--spectrum-actionbutton-animation-duration))) ease-in-out;

&::after {
position: absolute;
inset: 0;
margin: calc((var(--mod-actionbutton-focus-indicator-gap, var(--spectrum-actionbutton-focus-indicator-gap)) + var(--spectrum-actionbutton-border-width)) * -1);
border-radius: var(--mod-actionbutton-focus-indicator-border-radius, var(--spectrum-actionbutton-focus-indicator-border-radius));
transition: box-shadow var(--highcontrast-actionbutton-animation-duration, var(--mod-actionbutton-animation-duration, var(--spectrum-actionbutton-animation-duration))) ease-in-out;
pointer-events: none;
content: "";
}

&:focus-visible {
box-shadow: none;
outline: none;

&::after {
box-shadow: 0 0 0 var(--mod-actionbutton-focus-indicator-thickness, var(--spectrum-actionbutton-focus-indicator-thickness)) var(--highcontrast-actionbutton-focus-indicator-color, var(--mod-actionbutton-focus-indicator-color, var(--spectrum-actionbutton-focus-indicator-color)));
}
}
}

@media (forced-colors: active) {
.spectrum-ActionButton {
/**
Expand Down Expand Up @@ -388,7 +386,7 @@ a.spectrum-ActionButton {
--highcontrast-actionbutton-background-color-disabled: Canvas;
--highcontrast-actionbutton-content-color-default: CanvasText;

&:disabled:not(.is-selected) {
&:is(:disabled, .is-disabled, [aria-disabled="true"]):not(:is([aria-pressed="true"], [aria-expanded="true"])) {
--highcontrast-actionbutton-border-color: Canvas;
}
}
Expand All @@ -400,8 +398,7 @@ a.spectrum-ActionButton {
--highcontrast-actionbutton-border-color: Highlight;
}

/* Selected always shows as a solid highlighted color. */
&.is-selected {
&:is([aria-pressed="true"], [aria-expanded="true"]) {
--highcontrast-actionbutton-border-color: Highlight;
--highcontrast-actionbutton-background-color-default: Highlight;
--highcontrast-actionbutton-content-color-default: HighlightText;
Expand Down
29 changes: 24 additions & 5 deletions components/actionbutton/stories/actionbutton.stories.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { default as IconStories } from "@spectrum-css/icon/stories/icon.stories.js";
import { Sizes, withDownStateDimensionCapture } from "@spectrum-css/preview/decorators";
import { disableDefaultModes } from "@spectrum-css/preview/modes";
import { isActive, isDisabled, isEmphasized, isFocused, isHovered, isQuiet, isSelected, size, staticColor } from "@spectrum-css/preview/types";
import metadata from "../dist/metadata.json";
import packageJson from "../package.json";
import { isActive, isDisabled, isEmphasized, isFocused, isHovered, isOpen, isQuiet, isSelected, size, staticColor } from "@spectrum-css/preview/types";
import { ActionButtonGroup } from "./actionbutton.test.js";
import { ActionButtonsWithIconOptions, IconOnlyOption, Template, TreatmentTemplate } from "./template.js";

// Local assets to render the component styles and structure
import metadata from "../dist/metadata.json";
import packageJson from "../package.json";

/**
* The action button component represents an action a user can take.
*
Expand Down Expand Up @@ -56,8 +58,8 @@ export default {
control: "boolean",
},
hasPopup: {
name: "Has popup",
description: "If the button triggers a popup action, this should be set to reflect the type of element that pops-up.",
name: "Has pop-up",
description: "If the button triggers a pop-up action, this should be set to reflect the type of element that pops-up.",
type: { name: "string" },
table: {
type: { summary: "string" },
Expand All @@ -66,6 +68,22 @@ export default {
control: "select",
options: ["true", "menu", "listbox", "tree", "grid", "dialog", "false"],
},
hasLongPress: {
name: "Long press",
description: "If the trigger supports a long-press action which triggers the menu, this should be set to true.",
type: { name: "boolean" },
table: {
type: { summary: "boolean" },
category: "Accessibility",
},
control: "boolean",
},
isOpen: {
...isOpen,
name: "Pop-up is open",
description: "When the button triggers a pop-up, this should be true when the pop-up is open.",
if: { arg: "hasPopup", truthy: true },
},
staticColor: {
...staticColor,
if: { arg: "isEmphasized", truthy: false },
Expand All @@ -77,6 +95,7 @@ export default {
isQuiet: false,
isEmphasized: false,
hasPopup: "false",
hasLongPress: false,
isActive: false,
isFocused: false,
isHovered: false,
Expand Down
2 changes: 2 additions & 0 deletions components/actionbutton/stories/actionbutton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ export const ActionButtons = (args, context) => {
${Template({
...args,
hasPopup: "true",
hasLongPress: true,
hideLabel: true,
}, context)}
${Template({
...args,
iconName: undefined,
hasPopup: "true",
hasLongPress: true,
}, context)}
</div>
`;
Expand Down
17 changes: 12 additions & 5 deletions components/actionbutton/stories/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ export const Template = ({
isFocused = false,
isActive = false,
isDisabled = false,
isOpen = false,
hasPopup = "false",
hasLongPress = false,
popupId,
hideLabel = false,
staticColor,
Expand All @@ -72,7 +74,8 @@ export const Template = ({
aria-label=${ifDefined(hideLabel ? label : undefined)}
aria-haspopup=${ifDefined(hasPopup && hasPopup !== "false" ? hasPopup : undefined)}
aria-controls=${hasPopup && hasPopup !== "false" ? popupId : undefined}
aria-pressed=${isSelected ? "true" : "false"}
aria-pressed=${ifDefined(isSelected ? "true" : undefined)}
aria-expanded=${ifDefined(hasPopup && hasPopup !== "false" ? isOpen ? "true" : "false" : undefined)}
class=${classMap({
[rootClass]: true,
[`${rootClass}--size${size?.toUpperCase()}`]:
Expand All @@ -82,14 +85,14 @@ export const Template = ({
[`${rootClass}--static${capitalize(staticColor)}`]:
typeof staticColor !== "undefined",
["is-disabled"]: isDisabled,
["is-selected"]: isSelected,
["is-hover"]: isHovered,
["is-focus-visible"]: isFocused,
["is-active"]: isActive,
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
})}
id=${id}
data-testid=${testId ?? id}
popovertarget=${ifDefined(hasPopup && hasPopup !== "false" ? popupId : undefined)}
role=${ifDefined(role)}
style=${styleMap(customStyles)}
?disabled=${isDisabled}
Expand All @@ -105,7 +108,7 @@ export const Template = ({
updateArgs({ isFocused: false });
}}
>
${when(hasPopup && hasPopup !== "false", () =>
${when(hasLongPress && hasPopup && hasPopup !== "false", () =>
Icon({
size,
iconName: "CornerTriangle" + ({
Expand Down Expand Up @@ -138,7 +141,7 @@ export const Template = ({

/**
* Displays multiple action buttons in a row, with different combinations of
* label, icon, and hold button (has popup).
* label, icon, and hold button (has pop-up).
*/
export const ActionButtonsWithIconOptions = (args, context) => Container({
withBorder: false,
Expand All @@ -162,19 +165,21 @@ export const ActionButtonsWithIconOptions = (args, context) => Container({
...args,
hideLabel: true,
hasPopup: "true",
hasLongPress: true,
}, context),
Template({
...args,
iconName: undefined,
hasPopup: "true",
hasLongPress: true,
}, context)
],
}, context);

/**
* Displays two action buttons in a row:
* - icon only action button
* - icon only action button with hold button (has popup)
* - icon only action button with hold button (has pop-up)
*/
export const IconOnlyOption = (args, context) => Container({
withBorder: false,
Expand All @@ -187,12 +192,14 @@ export const IconOnlyOption = (args, context) => Container({
...args,
hideLabel: true,
hasPopup: "true",
hasLongPress: true,
}, context),
Template({
...args,
hideLabel: true,
isQuiet: true,
hasPopup: "true",
hasLongPress: true,
}, context),
],
}, context);
Expand Down
2 changes: 1 addition & 1 deletion components/actiongroup/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item",
".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item + .spectrum-ActionGroup-item",
".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item .spectrum-ActionButton-label",
".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item.is-selected",
".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item:first-child",
".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item:focus-visible",
".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item:hover",
".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item:is([aria-pressed=\"true\"], [aria-expanded=\"true\"])",
".spectrum-ActionGroup--compact:not(.spectrum-ActionGroup--quiet) .spectrum-ActionGroup-item:last-child",
".spectrum-ActionGroup--justified .spectrum-ActionGroup-item",
".spectrum-ActionGroup--sizeL",
Expand Down
2 changes: 1 addition & 1 deletion components/actiongroup/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
margin-inline-end: var(--mod-actiongroup-border-radius-reset, var(--spectrum-actiongroup-border-radius-reset));
}

&.is-selected {
&:is([aria-pressed="true"], [aria-expanded="true"]) {
z-index: 1;
}

Expand Down
Loading
Loading