@trimble-oss/moduswebcomponents
Version:
Modus Web Components is a modern, accessible UI library built with Stencil JS that provides reusable web components following Trimble's Modus design system. This updated version focuses on improved flexibility, enhanced theming options, comprehensive cust
172 lines (166 loc) • 5.3 kB
JavaScript
import { withActions } from "@storybook/addon-actions/decorator";
import { html } from "lit";
import { ifDefined } from "lit/directives/if-defined.js";
const meta = {
title: 'Components/Button',
component: 'modus-wc-button',
args: {
color: 'primary',
disabled: false,
'full-width': false,
pressed: false,
shape: 'rectangle',
size: 'md',
type: 'button',
variant: 'filled',
},
argTypes: {
color: {
control: { type: 'select' },
options: ['primary', 'secondary', 'tertiary', 'warning', 'danger'],
},
shape: {
control: { type: 'select' },
options: ['circle', 'rectangle', 'square'],
},
size: {
control: { type: 'select' },
options: ['xs', 'sm', 'md', 'lg'],
},
type: {
control: { type: 'select' },
options: ['button', 'submit', 'reset'],
},
variant: {
control: { type: 'select' },
options: ['borderless', 'filled', 'outlined'],
},
},
decorators: [withActions],
parameters: {
actions: {
handles: ['buttonClick'],
},
},
};
export default meta;
const Template = {
render: (args) => {
// prettier-ignore
return html `
<modus-wc-button
aria-label="Click me button"
color="${args.color}"
custom-class="${ifDefined(args['custom-class'])}"
?disabled="${args.disabled}"
?full-width="${args['full-width']}"
?pressed="${args.pressed}"
shape="${args.shape}"
size="${args.size}"
type="${args.type}"
variant="${args.variant}"
>
Click me
</modus-wc-button>
`;
},
};
export const Default = Object.assign({}, Template);
export const ButtonShapes = {
render: () => {
// prettier-ignore
return html `
<modus-wc-button
aria-label="Circle button"
shape="circle"
>
Circle
</modus-wc-button>
<modus-wc-button
aria-label="Square button"
shape="square"
>
Square
</modus-wc-button>
`;
},
};
export const IconOnlyButton = {
render: () => {
// prettier-ignore
return html `
<modus-wc-button aria-label="Notification button">
<modus-wc-icon decorative name="notifications"></modus-wc-icon>
</modus-wc-button>
`;
},
};
export const IconLeftButton = {
render: () => {
// prettier-ignore
return html `
<modus-wc-button aria-label="Download button">
<modus-wc-icon decorative name="download"></modus-wc-icon>
Download
</modus-wc-button>
`;
},
};
export const IconRightButton = {
render: () => {
// prettier-ignore
return html `
<modus-wc-button aria-label="Details button">
Details
<modus-wc-icon decorative name="launch"></modus-wc-icon>
</modus-wc-button>
`;
},
};
export const IconLeftAndRightButton = {
render: () => {
// prettier-ignore
return html `
<modus-wc-button aria-label="Checkout button">
<modus-wc-icon decorative name="shopping_cart"></modus-wc-icon>
Checkout
<modus-wc-icon decorative name="shopping_cart"></modus-wc-icon>
</modus-wc-button>
`;
},
};
export const Migration = {
parameters: {
docs: {
description: {
story: `
#### Breaking Changes
- In 1.0 buttons had specific properties for adding icons (\`icon-only\`, \`left-icon\`, \`right-icon\`). In 2.0, icons are added via slots using the \`modus-wc-icon\` component.
- The \`button-style\` property has been renamed to \`variant\` with similar options.
- Size values have changed from verbose names (\`small\`, \`medium\`, \`large\`) to abbreviations (\`sm\`, \`md\`, \`lg\`).
#### Prop Mapping
| 1.0 Prop | 2.0 Prop | Notes |
|-----------------|------------|-------------------------------------------------------------|
| aria-label | aria-label | |
| button-style | variant | \`fill\` → \`filled\`, \`outline\` → \`outlined\` |
| color | color | \`dark\` and \`special\` removed, \`warning\` added |
| critical-action | | Not carried over |
| disabled | disabled | |
| icon-only | | Not carried over, use \`icon\` slot |
| left-icon | | Not carried over, use \`icon\` slot |
| right-icon | | Not carried over, use \`icon\` slot |
| show-caret | | Not carried over |
| size | size | \`small\` → \`sm\`, \`medium\` → \`md\`, \`large\` → \`lg\` |
| type | type | |
#### Event Mapping
| 1.0 Event | 2.0 Event | Notes |
|--------------|--------------|------------------|
| buttonClick | buttonClick | |
`,
},
},
controls: { disable: true },
canvas: { disable: true },
},
render: () => html `<div></div>`,
};