|
| 1 | +import DropdownActions from './DropdownActions.vue'; |
| 2 | +import {within, userEvent} from '@storybook/test'; |
| 3 | + |
| 4 | +export default { |
| 5 | + title: 'Components/DropdownActions', |
| 6 | + component: DropdownActions, |
| 7 | + render: (args) => ({ |
| 8 | + components: {DropdownActions}, |
| 9 | + setup() { |
| 10 | + return {args}; |
| 11 | + }, |
| 12 | + template: '<DropdownActions v-bind="args" />', |
| 13 | + }), |
| 14 | + argTypes: { |
| 15 | + direction: { |
| 16 | + control: {type: 'select'}, |
| 17 | + options: ['left', 'right'], |
| 18 | + }, |
| 19 | + }, |
| 20 | + decorators: [ |
| 21 | + () => ({ |
| 22 | + template: |
| 23 | + '<div style="height: 300px; padding: 10px;" class="text-center"><story/></div>', |
| 24 | + }), |
| 25 | + ], |
| 26 | +}; |
| 27 | + |
| 28 | +const downloadActions = [ |
| 29 | + { |
| 30 | + label: 'Author-Only Sections Displayed (PDF)', |
| 31 | + name: 'authorPdf', |
| 32 | + }, |
| 33 | + { |
| 34 | + label: 'Author-Only Sections Displayed (XML)', |
| 35 | + name: 'authorXml', |
| 36 | + }, |
| 37 | + { |
| 38 | + label: 'Editor Forms Shows All Review Sections (PDF)', |
| 39 | + name: 'editorPdf', |
| 40 | + }, |
| 41 | + { |
| 42 | + label: 'Editor Forms Shows All Review Sections (XML)', |
| 43 | + name: 'editorXml', |
| 44 | + }, |
| 45 | +]; |
| 46 | + |
| 47 | +export const Default = { |
| 48 | + args: { |
| 49 | + actions: downloadActions, |
| 50 | + label: 'Download Review Form', |
| 51 | + ariaLabel: 'Click to download content in the available formats', |
| 52 | + direction: 'left', |
| 53 | + }, |
| 54 | + play: async ({canvasElement}) => { |
| 55 | + // Assigns canvas to the component root element |
| 56 | + const canvas = within(canvasElement); |
| 57 | + const user = userEvent.setup(); |
| 58 | + |
| 59 | + await user.click(canvas.getByText('Download Review Form')); |
| 60 | + }, |
| 61 | +}; |
| 62 | + |
| 63 | +export const EllipsisMenu = { |
| 64 | + args: { |
| 65 | + actions: [ |
| 66 | + { |
| 67 | + label: 'View', |
| 68 | + url: '#', |
| 69 | + icon: 'View', |
| 70 | + }, |
| 71 | + { |
| 72 | + label: 'Email', |
| 73 | + url: '#', |
| 74 | + icon: 'Email', |
| 75 | + }, |
| 76 | + { |
| 77 | + label: 'Login As', |
| 78 | + url: '#', |
| 79 | + icon: 'LoginAs', |
| 80 | + }, |
| 81 | + { |
| 82 | + label: 'Remove User', |
| 83 | + url: '#', |
| 84 | + icon: 'Cancel', |
| 85 | + isWarnable: true, |
| 86 | + }, |
| 87 | + { |
| 88 | + label: 'Disable User', |
| 89 | + url: '#', |
| 90 | + icon: 'DisableUser', |
| 91 | + isWarnable: true, |
| 92 | + }, |
| 93 | + { |
| 94 | + label: 'Merge User', |
| 95 | + url: '#', |
| 96 | + icon: 'MergeUser', |
| 97 | + }, |
| 98 | + ], |
| 99 | + label: 'User management options', |
| 100 | + displayAsEllipsis: true, |
| 101 | + direction: 'left', |
| 102 | + }, |
| 103 | + play: async ({canvasElement}) => { |
| 104 | + // Assigns canvas to the component root element |
| 105 | + const canvas = within(canvasElement); |
| 106 | + const user = userEvent.setup(); |
| 107 | + |
| 108 | + await user.click(canvas.getByText('User management options')); |
| 109 | + }, |
| 110 | +}; |
| 111 | + |
| 112 | +export const RightAlignedMenu = { |
| 113 | + args: { |
| 114 | + actions: downloadActions, |
| 115 | + label: 'Right Aligned Menu', |
| 116 | + direction: 'right', |
| 117 | + }, |
| 118 | + play: async ({canvasElement}) => { |
| 119 | + // Assigns canvas to the component root element |
| 120 | + const canvas = within(canvasElement); |
| 121 | + const user = userEvent.setup(); |
| 122 | + |
| 123 | + await user.click(canvas.getByText('Right Aligned Menu')); |
| 124 | + }, |
| 125 | +}; |
0 commit comments