mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-08 11:11:53 +08:00
Expand the Web Components Storybook template with comprehensive component support: - Add Button, Header, and Page components for JavaScript and TypeScript (4.9) - Support multiple configurations for Vite and Webpack5 - Include stories, components, and CSS files - Add ESLint configuration to disable import/extensions rule - Implement Storybook best practices with autodocs and component testing
33 lines
947 B
TypeScript
33 lines
947 B
TypeScript
import { html } from 'lit';
|
|
import { styleMap } from 'lit/directives/style-map.js';
|
|
|
|
import './button.css';
|
|
|
|
export interface ButtonProps {
|
|
/** Is this the principal call to action on the page? */
|
|
primary?: boolean;
|
|
/** What background color to use */
|
|
backgroundColor?: string;
|
|
/** How large should the button be? */
|
|
size?: 'small' | 'medium' | 'large';
|
|
/** Button contents */
|
|
label: string;
|
|
/** Optional click handler */
|
|
onClick?: () => void;
|
|
}
|
|
/** Primary UI component for user interaction */
|
|
export const Button = ({ primary, backgroundColor, size, label, onClick }: ButtonProps) => {
|
|
const mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary';
|
|
|
|
return html`
|
|
<button
|
|
type="button"
|
|
class=${['storybook-button', `storybook-button--${size || 'medium'}`, mode].join(' ')}
|
|
style=${styleMap({ backgroundColor })}
|
|
@click=${onClick}
|
|
>
|
|
${label}
|
|
</button>
|
|
`;
|
|
};
|