1+ import { ArgGrid , Container } from "@spectrum-css/preview/decorators/utilities.js" ;
2+ import { disableDefaultModes } from "@spectrum-css/preview/modes" ;
3+ import { isOpen } from "@spectrum-css/preview/types" ;
4+
15import { default as ActionButton } from "@spectrum-css/actionbutton/stories/actionbutton.stories.js" ;
26import { default as IconStories } from "@spectrum-css/icon/stories/icon.stories.js" ;
37import { default as Menu } from "@spectrum-css/menu/stories/menu.stories.js" ;
48import { default as Popover } from "@spectrum-css/popover/stories/popover.stories.js" ;
5- import { disableDefaultModes } from "@spectrum-css/preview/modes" ;
6- import { isOpen } from "@spectrum-css/preview/types" ;
7- import packageJson from "../package.json" ;
9+
10+ import { Template as IconTemplate } from "@spectrum-css/icon/stories/template.js" ;
811import { ActionMenuGroup } from "./actionmenu.test.js" ;
12+ import { Template } from "./template.js" ;
13+
14+ import metadata from "../dist/metadata.json" ;
15+ import packageJson from "../package.json" ;
916
1017/**
11- * The action menu component is an action button with a popover. The `is-selected` class should be applied to the button when the menu is open. Note that the accessibility roles are different for an action menu compared to a normal menu.
18+ * 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.
19+ *
20+ * 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.
1221 */
1322export default {
1423 title : "Action menu" ,
1524 component : "ActionMenu" ,
1625 argTypes : {
1726 withTip : Popover . argTypes . withTip ,
18- position : Popover . argTypes . position ,
27+ position : {
28+ ...Popover . argTypes . position ,
29+ options : [
30+ "bottom-start" ,
31+ "bottom-end" ,
32+ "start-top" ,
33+ "end-top" ,
34+ ]
35+ } ,
1936 isOpen,
2037 iconName : {
2138 ...( IconStories ?. argTypes ?. iconName ?? { } ) ,
@@ -35,7 +52,9 @@ export default {
3552 args : {
3653 isOpen : false ,
3754 withTip : Popover . args . withTip ,
38- position : Popover . args . position ,
55+ position : "bottom-start" ,
56+ iconName : "AddCircle" ,
57+ label : "Add" ,
3958 } ,
4059 parameters : {
4160 actions : {
@@ -45,36 +64,123 @@ export default {
4564 ...( Menu . parameters ?. actions ?. handles ?? [ ] ) ,
4665 ] ,
4766 } ,
48- packageJson,
4967 docs : {
5068 story : {
5169 height : "200px" ,
5270 }
53- }
71+ } ,
72+ design : {
73+ type : "figma" ,
74+ url : "https://www.figma.com/design/eoZHKJH9a3LJkHYCGt60Vb/S2-token-specs?node-id=19758-3424" ,
75+ } ,
76+ packageJson,
77+ metadata,
78+ status : {
79+ type : "migrated" ,
80+ } ,
5481 } ,
82+ tags : [ "migrated" ] ,
5583} ;
5684
5785export const Default = ActionMenuGroup . bind ( { } ) ;
5886Default . args = {
5987 isOpen : true ,
60- position : "bottom" ,
61- label : "More actions" ,
62- iconName : "More" ,
63- items : [
64- {
65- label : "Action 1" ,
66- } ,
67- {
68- label : "Action 2" ,
69- } ,
70- {
71- label : "Action 3" ,
72- } ,
73- {
74- label : "Action 4" ,
75- } ,
88+ iconName : "AddCircle" ,
89+ label : "Add" ,
90+ items : [ {
91+ heading : "Add new page" ,
92+ items : [
93+ {
94+ label : "Same size" ,
95+ iconName : "Copy"
96+ } ,
97+ {
98+ label : "Custom size" ,
99+ iconName : "Properties"
100+ } ,
101+ {
102+ label : "Duplicate" ,
103+ iconName : "Duplicate"
104+ }
105+ ]
106+ } , {
107+ type : "divider"
108+ } , {
109+ heading : "Edit page" ,
110+ items : [ {
111+ label : "Edit timeline" ,
112+ iconName : "Clock" ,
113+ description : "Add time to this page"
114+ } ] ,
115+ } ] ,
116+ } ;
117+
118+ // ********* DOCS ONLY ********* //
119+
120+ /**
121+ * 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>.
122+ */
123+ export const PlacementOptions = ( args , context ) => ArgGrid ( {
124+ Template,
125+ argKey : "position" ,
126+ widthBorder : false ,
127+ ...args ,
128+ } , context ) ;
129+ PlacementOptions . args = Default . args ;
130+ PlacementOptions . tags = [ "!dev" ] ;
131+ PlacementOptions . parameters = {
132+ chromatic : {
133+ disableSnapshot : true ,
134+ } ,
135+ } ;
136+
137+ /**
138+ * Icon used is a placeholder and can be swapped with any other from icon set along with corresponding label.
139+ */
140+ export const PlaceholderIcon = ( args , context ) => Container ( {
141+ withBorder : false ,
142+ content : [
143+ Template ( args , context ) ,
144+ IconTemplate ( {
145+ iconName : "ArrowRight400" ,
146+ setName : "ui" ,
147+ fill : "var(--spectrum-gray-400)" ,
148+ customStyles : {
149+ "margin-block-start" : "var(--spectrum-spacing-200)" ,
150+ } ,
151+ } , context ) ,
152+ Template ( Default . args , context ) ,
76153 ] ,
154+ } ) ;
155+ PlaceholderIcon . args = {
156+ iconName : "More" ,
157+ label : "" ,
158+ isOpen : true ,
159+ items : [ {
160+ heading : "Menu section header" ,
161+ items : [
162+ {
163+ label : "Menu item" ,
164+ iconName : "Circle"
165+ } ,
166+ {
167+ label : "Menu item" ,
168+ iconName : "Circle"
169+ } ,
170+ {
171+ label : "Menu item" ,
172+ iconName : "Circle"
173+ }
174+ ]
175+ } ] ,
77176} ;
177+ PlaceholderIcon . tags = [ "!dev" ] ;
178+ PlaceholderIcon . parameters = {
179+ chromatic : {
180+ disableSnapshot : true ,
181+ } ,
182+ } ;
183+
78184
79185// ********* VRT ONLY ********* //
80186export const WithForcedColors = ActionMenuGroup . bind ( { } ) ;
0 commit comments