diff --git a/.storybook/Welcome/__welcome-story.js b/.storybook/Welcome/__welcome-story.js index 8516fb83a..da6405bba 100644 --- a/.storybook/Welcome/__welcome-story.js +++ b/.storybook/Welcome/__welcome-story.js @@ -1,10 +1,10 @@ import { storiesOf } from '@storybook/vue3'; import SvWelcome from './sv-welcome.vue'; -const stories = storiesOf('Welcome', module); +const stories = storiesOf('Carbon', module); stories.add( - 'default', + 'Welcome', () => { // ---------------------------------------------------------------- const templateViewString = ``; diff --git a/.storybook/preview.js b/.storybook/preview.js index 6a8db6842..47158269c 100644 --- a/.storybook/preview.js +++ b/.storybook/preview.js @@ -198,7 +198,7 @@ export const parameters = { }; configureActions({ - depth: 3, + clearOnStoryChange: true, limit: 10, }); export const decorators = [ diff --git a/src/components/CvOverflowMenu/CvOverflowMenu.stories.mdx b/src/components/CvOverflowMenu/CvOverflowMenu.stories.mdx new file mode 100644 index 000000000..a88d88ef2 --- /dev/null +++ b/src/components/CvOverflowMenu/CvOverflowMenu.stories.mdx @@ -0,0 +1,119 @@ +import { Canvas, Meta, Story } from '@storybook/addon-docs'; +import { CvOverflowMenu } from '.'; +import { sbCompPrefix } from '@/global/storybook-utils'; +import { action } from '@storybook/addon-actions'; +import CvOverflowMenuItem from './CvOverflowMenuItem.vue'; +import { Meter20 as MeterIcon } from '@carbon/icons-vue' + + + +export const Template = args => ({ + // Components used in your story `template` are defined in the `components` object + components: { + CvOverflowMenu, + CvOverflowMenuItem, + MeterIcon, + }, + // The story's `args` need to be mapped into the template through the `setup()` method + setup() { + return { + ...args, + onChange: action('change', {clearOnStoryChange:true}), + }; + }, + // And then the `args` are bound to your component with `v-bind="args"` + template: args.template, +}); +const defaultTemplate = ` + + list item 1 + list item 2 + list item 3 + +`; +const slotsTemplate = ` + + + list item 1 + list item 2 + list item 3 + +`; + + +# CvOverflowMenu + +**Migration notes:** + +- The component now emits the "change" event when an item in the menu is clicked +- The `flipMenu` parameter is supported but does not appear to work in Vue 2 or here + + + + {Template.bind({})} + + + +Use slots for more control over the display. + + + + {Template.bind({})} + + diff --git a/src/components/CvOverflowMenu/CvOverflowMenu.vue b/src/components/CvOverflowMenu/CvOverflowMenu.vue new file mode 100644 index 000000000..7f3c12bf9 --- /dev/null +++ b/src/components/CvOverflowMenu/CvOverflowMenu.vue @@ -0,0 +1,287 @@ + + + diff --git a/src/components/CvOverflowMenu/CvOverflowMenuItem.vue b/src/components/CvOverflowMenu/CvOverflowMenuItem.vue new file mode 100644 index 000000000..bdc3c7a0e --- /dev/null +++ b/src/components/CvOverflowMenu/CvOverflowMenuItem.vue @@ -0,0 +1,52 @@ + + + diff --git a/src/components/CvOverflowMenu/index.js b/src/components/CvOverflowMenu/index.js new file mode 100644 index 000000000..a177abe0c --- /dev/null +++ b/src/components/CvOverflowMenu/index.js @@ -0,0 +1,3 @@ +import CvOverflowMenu from './CvOverflowMenu.vue'; +export { CvOverflowMenu }; +export default CvOverflowMenu; diff --git a/src/global/component-utils/event-bus.js b/src/global/component-utils/event-bus.js new file mode 100644 index 000000000..b9ad1288c --- /dev/null +++ b/src/global/component-utils/event-bus.js @@ -0,0 +1,22 @@ +import { EventEmitter } from 'events'; + +class EventBus extends EventEmitter {} + +const busses = {}; +/** + * Get an event bus + * @param {string} id unique id + * @returns {EventBus} + */ +export function getBus(id) { + if (!(id in busses)) busses[id] = new EventBus(); + return busses[id]; +} +/** + * Remove a previously created event bus + * @param {string} id unique id + * @returns {EventBus} + */ +export function removeBus(id) { + delete busses[id]; +}