Skip to content

Commit b6ed5e8

Browse files
committed
chore: apply code review feedback awesomeness
1 parent 321dc81 commit b6ed5e8

File tree

12 files changed

+167
-132
lines changed

12 files changed

+167
-132
lines changed

.changeset/brave-bikes-teach.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ Example markup:
4444

4545
Updates `@spectrum-css/menu` styles to align with latest Spectrum 2 design specifications and improve accessibility.
4646

47-
- Focus indicator tokens wired through: width, color, gap/offset, and outline style.
48-
- CJK line-height tokens applied for labels, descriptions, and section headers.
49-
- External link and drill‑in icon sizing variables exposed; thumbnail sizing and alignment refined.
50-
- Forced-colors improvements and readability adjustments.
47+
- Added this not to prevent clash with the `.is-selectable` placement.
5148
- Non-breaking; no class or DOM changes required.
5249

5350
### Action button refinements

components/actionbar/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
opacity: 1;
3535
}
3636

37+
/* Maps to the .spectrum-Popover component */
3738
.spectrum-Popover {
3839
/* popover is ActionBar height */
3940
block-size: var(--spectrum-action-bar-height);

components/actionbutton/dist/metadata.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
".spectrum-ActionButton-label",
1515
".spectrum-ActionButton-label:empty",
1616
".spectrum-ActionButton.is-disabled",
17-
".spectrum-ActionButton.spectrum-ActionButton--emphasized:where(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])",
17+
".spectrum-ActionButton.spectrum-ActionButton--emphasized:is(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])",
1818
".spectrum-ActionButton.spectrum-ActionButton--quiet",
19+
".spectrum-ActionButton.spectrum-ActionButton--quiet:is(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])",
1920
".spectrum-ActionButton.spectrum-ActionButton--quiet:is(:disabled, .is-disabled, [aria-disabled=\"true\"]):not(:where(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"]))",
20-
".spectrum-ActionButton.spectrum-ActionButton--quiet:where(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])",
2121
".spectrum-ActionButton.spectrum-ActionButton--staticBlack",
2222
".spectrum-ActionButton.spectrum-ActionButton--staticBlack.spectrum-ActionButton--quiet",
23-
".spectrum-ActionButton.spectrum-ActionButton--staticBlack:where(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])",
23+
".spectrum-ActionButton.spectrum-ActionButton--staticBlack:is(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])",
2424
".spectrum-ActionButton.spectrum-ActionButton--staticWhite",
2525
".spectrum-ActionButton.spectrum-ActionButton--staticWhite.spectrum-ActionButton--quiet",
26-
".spectrum-ActionButton.spectrum-ActionButton--staticWhite:where(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])",
26+
".spectrum-ActionButton.spectrum-ActionButton--staticWhite:is(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])",
2727
".spectrum-ActionButton::-moz-focus-inner",
2828
".spectrum-ActionButton:active",
2929
".spectrum-ActionButton:after",
@@ -35,9 +35,8 @@
3535
".spectrum-ActionButton:has(.spectrum-ActionButton-icon)",
3636
".spectrum-ActionButton:hover",
3737
".spectrum-ActionButton:is(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])",
38+
".spectrum-ActionButton:is(:disabled, .is-disabled, [aria-disabled=\"true\"])",
3839
".spectrum-ActionButton:not(:has(.spectrum-ActionButton-label))",
39-
".spectrum-ActionButton:where(.is-selected, [aria-pressed=\"true\"], [aria-expanded=\"true\"])",
40-
".spectrum-ActionButton:where(:disabled, .is-disabled, [aria-disabled=\"true\"])",
4140
"a.spectrum-ActionButton"
4241
],
4342
"modifiers": [

components/actionbutton/index.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ governing permissions and limitations under the License.
6363
--spectrum-actionbutton-background-color-focus: var(--spectrum-gray-200);
6464
--spectrum-actionbutton-background-color-disabled: transparent;
6565

66-
&:where(.is-selected, [aria-pressed="true"], [aria-expanded="true"]) {
66+
&:is(.is-selected, [aria-pressed="true"], [aria-expanded="true"]) {
6767
--spectrum-actionbutton-background-color-disabled: var(--spectrum-disabled-background-color);
6868
}
6969
}
@@ -117,7 +117,7 @@ governing permissions and limitations under the License.
117117
}
118118

119119
/* expanded is specific to action menu when the menu is open */
120-
&:where(.is-selected, [aria-pressed="true"], [aria-expanded="true"]) {
120+
&:is(.is-selected, [aria-pressed="true"], [aria-expanded="true"]) {
121121
--mod-actionbutton-background-color-default: var(--mod-actionbutton-background-color-default-selected, var(--spectrum-neutral-background-color-selected-default));
122122
--mod-actionbutton-background-color-hover: var(--mod-actionbutton-background-color-hover-selected, var(--spectrum-neutral-background-color-selected-hover));
123123
--mod-actionbutton-background-color-down: var(--mod-actionbutton-background-color-down-selected, var(--spectrum-neutral-background-color-selected-down));
@@ -342,7 +342,7 @@ governing permissions and limitations under the License.
342342
}
343343

344344
/* ideal when we want to disable the button but still allow it's content to be focused */
345-
&:where(:disabled, .is-disabled, [aria-disabled="true"]) {
345+
&:is(:disabled, .is-disabled, [aria-disabled="true"]) {
346346
background-color: var(--highcontrast-actionbutton-background-color-disabled, var(--mod-actionbutton-background-color-disabled, var(--spectrum-actionbutton-background-color-disabled)));
347347
color: var(--highcontrast-actionbutton-content-color-disabled, var(--mod-actionbutton-content-color-disabled, var(--spectrum-actionbutton-content-color-disabled)));
348348
}

components/actionbutton/stories/actionbutton.stories.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default {
107107
},
108108
parameters: {
109109
actions: {
110-
handles: ["click .spectrum-ActionButton:not([disabled])"],
110+
handles: ["click .spectrum-ActionButton:not([disabled])", "mousedown .spectrum-ActionButton:not([disabled])", "mouseup .spectrum-ActionButton:not([disabled])", "touchstart .spectrum-ActionButton:not([disabled])", "touchend .spectrum-ActionButton:not([disabled])"],
111111
},
112112
design: {
113113
type: "figma",
@@ -198,8 +198,8 @@ Quiet.parameters = {
198198

199199
/**
200200
* An action button can have a hold icon (a small corner triangle). This icon indicates that holding down the action button for a
201-
* short amount of time can reveal a [popover](/docs/components-popover--docs) menu, which can be used, for example, to switch
202-
* between related actions. Note that this popover menu is not demonstrated herethis would be handled by the implementation.
201+
* short amount of time (currently the standard is 300ms) can reveal a [popover](/docs/components-popover--docs) menu, which can be used, for example, to switch
202+
* between related actions. Note that this popover menu is not demonstrated here; this would be handled by the implementation.
203203
* Because of the way padding is calculated, the hold icon must be placed before the workflow icon in the markup.
204204
*/
205205
export const HoldIcon = IconOnlyOption.bind({});

components/actionbutton/stories/template.js

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export const Template = ({
6969
role = "button",
7070
} = {}, context = {}) => {
7171
const { updateArgs } = context;
72+
7273
return html`
7374
<button
7475
aria-label=${ifDefined(hideLabel ? label : undefined)}
@@ -77,31 +78,36 @@ export const Template = ({
7778
aria-pressed=${ifDefined(isSelected ? "true" : undefined)}
7879
aria-expanded=${ifDefined(hasPopup && hasPopup !== "false" ? isOpen ? "true" : "false" : undefined)}
7980
class=${classMap({
80-
[rootClass]: true,
81-
[`${rootClass}--size${size?.toUpperCase()}`]:
82-
typeof size !== "undefined",
83-
[`${rootClass}--quiet`]: isQuiet,
84-
[`${rootClass}--emphasized`]: isEmphasized,
85-
[`${rootClass}--static${capitalize(staticColor)}`]:
86-
typeof staticColor !== "undefined",
87-
["is-disabled"]: isDisabled,
88-
["is-hover"]: isHovered,
89-
["is-focus-visible"]: isFocused,
90-
["is-active"]: isActive,
91-
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
92-
})}
81+
[rootClass]: true,
82+
[`${rootClass}--size${size?.toUpperCase()}`]:
83+
typeof size !== "undefined",
84+
[`${rootClass}--quiet`]: isQuiet,
85+
[`${rootClass}--emphasized`]: isEmphasized,
86+
[`${rootClass}--static${capitalize(staticColor)}`]:
87+
typeof staticColor !== "undefined",
88+
["is-disabled"]: isDisabled,
89+
["is-hover"]: isHovered,
90+
["is-focus-visible"]: isFocused,
91+
["is-active"]: isActive,
92+
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
93+
})}
9394
id=${id}
9495
data-testid=${testId ?? id}
9596
popovertarget=${ifDefined(hasPopup && hasPopup !== "false" ? popupId : undefined)}
9697
role=${ifDefined(role)}
9798
style=${styleMap(customStyles)}
9899
?disabled=${isDisabled}
99-
@click=${onclick ?? function() {
100-
updateArgs({
101-
isSelected: !isSelected
102-
});
100+
@click=${function () {
101+
if (isDisabled) return;
102+
if (typeof onclick === "function") onclick();
103+
else {
104+
updateArgs({
105+
isSelected: !isSelected,
106+
isOpen: !isOpen,
107+
});
108+
}
103109
}}
104-
@focusin=${function() {
110+
@focusin=${function () {
105111
updateArgs({ isFocused: true });
106112
}}
107113
@focusout=${function() {

components/actionmenu/stories/actionmenu.stories.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,6 @@ export default {
7575
tags: ["migrated"],
7676
};
7777

78-
/**
79-
* Action menu allows users to access and execute various commands or tasks related to their current workflow. It's typically triggered from an action button by user interaction.
80-
*
81-
* Note that the accessibility roles are different for an action menu compared to a normal menu. The action menu is a combination of a menu, popover, and action button.
82-
*/
8378
export const Default = ActionMenuGroup.bind({});
8479
Default.args = {
8580
triggerArgs: {
@@ -130,6 +125,8 @@ Default.args = {
130125
* By default, the menu is opened by pressing the trigger element or activating it via the <kbd>Space</kbd> or <kbd>Enter</kbd> keys. However, there may be cases where the trigger should perform a separate action on press such as selection, and should only display the menu when long pressed. For this use-case, the menu will only be opened when pressing and holding the trigger or by using the <kbd>Option</kbd> (Alt on Windows) + <kbd>Down arrow</kbd>/<kbd>Up arrow</kbd> keys while focusing the trigger.
131126
*
132127
* This example illustrates the expected visuals and states of the action menu for a trigger with both long press and short press behaviors.
128+
*
129+
* Please note that the long press functionality is not implemented in this documentation and the example serves only as a visual reference.
133130
*/
134131
export const LongPress = Template.bind({});
135132
LongPress.args = {
@@ -165,7 +162,7 @@ LongPress.parameters = {
165162
};
166163

167164
/**
168-
* Action menus can be positioned in four locals relative to the trigger but <u>only one menu can be triggered at a single time</u>.
165+
* Action menus can be positioned in four locals relative to the trigger but <em>only one menu can be triggered at a single time</em>.
169166
*/
170167
export const PlacementOptions = (args, context) => ArgGrid({
171168
Template,

components/actionmenu/stories/template.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { Template as Menu } from "@spectrum-css/menu/stories/template.js";
33
import { Template as Popover } from "@spectrum-css/popover/stories/template.js";
44
import { getRandomId } from "@spectrum-css/preview/decorators";
55

6+
import "../index.css";
7+
68
export const Template = (
79
{
810
rootClass = "spectrum-ActionMenu",
@@ -22,8 +24,6 @@ export const Template = (
2224
} = {},
2325
context = {},
2426
) => {
25-
const { updateArgs } = context;
26-
2727
return Popover(
2828
{
2929
...popoverArgs,
@@ -40,12 +40,9 @@ export const Template = (
4040
hasPopup: "menu",
4141
hasLongPress,
4242
id: triggerId,
43+
isOpen,
44+
isSelected: isOpen,
4345
customClasses: [`${rootClass}-trigger`],
44-
onclick: hasLongPress
45-
? undefined
46-
: () => {
47-
updateArgs({ isOpen: !isOpen });
48-
},
4946
},
5047
context,
5148
),

components/coachmark/stories/coachmark.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,10 @@ export const CoachMarkGroup = Variants({
4848
testHeading: "With action menu",
4949
hasPagination: false,
5050
hasActionMenu: true,
51-
isOpen: true,
5251
},
5352
{
5453
testHeading: "With action menu + media",
5554
hasPagination: false,
56-
isOpen: true,
5755
hasImage: true,
5856
hasActionMenu: true,
5957
},

components/coachmark/stories/template.js

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Template as ActionMenu } from "@spectrum-css/actionmenu/stories/template.js";
1+
import { Template as ActionButton } from "@spectrum-css/actionbutton/stories/template.js";
22
import { Template as ButtonGroup } from "@spectrum-css/buttongroup/stories/template.js";
33
import { Template as CoachIndicator } from "@spectrum-css/coachindicator/stories/template.js";
44
import { Template as Popover } from "@spectrum-css/popover/stories/template.js";
@@ -22,7 +22,6 @@ export const CoachContainer = (
2222
content = "Pixel brushes use pixels to create brush strokes, just like in other design and drawing tools. Start drawing, and zoom in to see the pixels in each stroke.",
2323
currentStep = 2,
2424
totalStepCount = 8,
25-
isOpen = false,
2625
alt = "",
2726
} = {},
2827
context = {},
@@ -52,33 +51,19 @@ export const CoachContainer = (
5251
<div class="spectrum-CoachMark-header" style=${styleMap({
5352
"--mod-popover-width": "0px",
5453
"--mod-popover-height": "0px",
55-
"--mod-popover-wrapper-spacing": "0px",
54+
"--spectrum-popover-animation-distance": "0px",
5655
})}>
5756
<div class="spectrum-CoachMark-title">${title}</div>
57+
<!-- This only demonstrates the presence of the action button but not the popover menu -->
5858
${when(
5959
hasActionMenu,
60-
() => ActionMenu(
60+
() => ActionButton(
6161
{
62-
isOpen,
63-
position: "bottom-start",
64-
triggerArgs: {
65-
iconName: "More",
66-
size: scale === "large" ? "s" : "m",
67-
label: "More actions",
68-
hideLabel: true,
69-
},
62+
iconName: "More",
63+
size: scale === "large" ? "s" : "m",
64+
label: "More actions",
65+
hideLabel: true,
7066
customClasses: [`${rootClass}-action-menu`],
71-
menuArgs: {
72-
size: scale === "large" ? "s" : "m",
73-
items: [
74-
{
75-
label: "Skip tour",
76-
},
77-
{
78-
label: "Reset tour",
79-
},
80-
],
81-
},
8267
},
8368
context,
8469
),
@@ -179,7 +164,6 @@ export const CoachmarkMenuStatesTemplate = (args, context) =>
179164
...args,
180165
hasImage: false,
181166
hasActionMenu: true,
182-
isOpen: true
183167
},
184168
context,
185169
),

0 commit comments

Comments
 (0)