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
+
1
5
import { default as ActionButton } from "@spectrum-css/actionbutton/stories/actionbutton.stories.js" ;
2
6
import { default as IconStories } from "@spectrum-css/icon/stories/icon.stories.js" ;
3
7
import { default as Menu } from "@spectrum-css/menu/stories/menu.stories.js" ;
4
8
import { 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" ;
8
11
import { 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" ;
9
16
10
17
/**
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.
12
21
*/
13
22
export default {
14
23
title : "Action menu" ,
15
24
component : "ActionMenu" ,
16
25
argTypes : {
17
26
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
+ } ,
19
36
isOpen,
20
37
iconName : {
21
38
...( IconStories ?. argTypes ?. iconName ?? { } ) ,
@@ -35,7 +52,9 @@ export default {
35
52
args : {
36
53
isOpen : false ,
37
54
withTip : Popover . args . withTip ,
38
- position : Popover . args . position ,
55
+ position : "bottom-start" ,
56
+ iconName : "AddCircle" ,
57
+ label : "Add" ,
39
58
} ,
40
59
parameters : {
41
60
actions : {
@@ -45,36 +64,123 @@ export default {
45
64
...( Menu . parameters ?. actions ?. handles ?? [ ] ) ,
46
65
] ,
47
66
} ,
48
- packageJson,
49
67
docs : {
50
68
story : {
51
69
height : "200px" ,
52
70
}
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
+ } ,
54
81
} ,
82
+ tags : [ "migrated" ] ,
55
83
} ;
56
84
57
85
export const Default = ActionMenuGroup . bind ( { } ) ;
58
86
Default . args = {
59
87
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 ) ,
76
153
] ,
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
+ } ] ,
77
176
} ;
177
+ PlaceholderIcon . tags = [ "!dev" ] ;
178
+ PlaceholderIcon . parameters = {
179
+ chromatic : {
180
+ disableSnapshot : true ,
181
+ } ,
182
+ } ;
183
+
78
184
79
185
// ********* VRT ONLY ********* //
80
186
export const WithForcedColors = ActionMenuGroup . bind ( { } ) ;
0 commit comments