Static Site
This commit is contained in:
42
Static/package/dist/collection/components/switch/switch.stories.js
vendored
Normal file
42
Static/package/dist/collection/components/switch/switch.stories.js
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
import { action } from "@storybook/addon-actions";
|
||||
export default {
|
||||
title: 'Components/Switch',
|
||||
tags: ['autodocs'],
|
||||
args: {
|
||||
value: false,
|
||||
disabled: false,
|
||||
label: "Switch"
|
||||
},
|
||||
argTypes: {
|
||||
ifxChange: {
|
||||
description: 'Custom event emitted on change',
|
||||
table: {
|
||||
type: {
|
||||
summary: 'Framework integration',
|
||||
detail: 'React: onIfxChange={handleChange}\nVue:@ifxChange="handleChange"\nAngular:(ifxChange)="handleChange()"\nVanillaJs:.addEventListener("ifxChange", (event) => {//handle change});',
|
||||
},
|
||||
},
|
||||
action: 'ifxChange'
|
||||
},
|
||||
}
|
||||
};
|
||||
const DefaultTemplate = (args) => {
|
||||
const element = document.createElement('ifx-switch');
|
||||
// Set the attributes
|
||||
element.setAttribute('disabled', args.disabled);
|
||||
element.setAttribute('value', args.value);
|
||||
// Add the event listener
|
||||
// element.addEventListener('ifxChange', action('ifxChange'));
|
||||
// Inside your story, add an event listener for the custom event
|
||||
element.addEventListener('ifxChange', (event) => {
|
||||
const customEvent = event;
|
||||
const newValue = customEvent.detail;
|
||||
action('ifxChange')(customEvent);
|
||||
args.value = newValue;
|
||||
});
|
||||
const slotContent = document.createTextNode(args.label);
|
||||
element.appendChild(slotContent);
|
||||
return element;
|
||||
};
|
||||
export const Default = DefaultTemplate.bind({});
|
||||
//# sourceMappingURL=switch.stories.js.map
|
Reference in New Issue
Block a user