@beydesign/storybook 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { ComponentsProps, ToggleButtonGroupProps } from './types/toggle-button-group';
3
+ export declare const ToggleButtonGroup: React.FC<ToggleButtonGroupProps>;
4
+ export declare const Components: React.FC<ComponentsProps>;
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ToggleButtonGroupSize, } from './types/toggle-button-group';
3
+ import { Box } from '@mui/material';
4
+ import { MainButton } from './Button';
5
+ import { ButtonHierarchy, ButtonSize, ButtonType, } from './types/button';
6
+ export const ToggleButtonGroup = ({ onChange, options, selectedOption, disabled, size = ToggleButtonGroupSize.lg, }) => {
7
+ const selectedOptionStyle = {
8
+ backgroundColor: 'var(--colors-light-background-bg-card-highlight-hover)',
9
+ color: 'var(--colors-light-text-text-accent)',
10
+ };
11
+ const unselectedOptionStyle = {
12
+ backgroundColor: 'transparent',
13
+ };
14
+ const getButtonSize = () => {
15
+ switch (size) {
16
+ case ToggleButtonGroupSize.sm:
17
+ return ButtonSize.sm;
18
+ case ToggleButtonGroupSize.md:
19
+ return ButtonSize.md;
20
+ case ToggleButtonGroupSize.lg:
21
+ return ButtonSize.lg;
22
+ default:
23
+ return ButtonSize.md;
24
+ }
25
+ };
26
+ return (_jsx(Box, { display: "flex", flexDirection: "row", sx: {
27
+ borderRadius: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)',
28
+ overflow: 'hidden',
29
+ backgroundColor: 'var(--colors-light-background-bg-component)',
30
+ }, gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)', padding: 'var(--spacing-tokens-size-in-px-spacing-spacing-xs)', border: `1px solid var(--colors-light-border-border-component)`, children: options.map((option) => {
31
+ const isSelected = option === selectedOption;
32
+ return (_jsx(MainButton, { text: option, onClick: () => onChange(option), size: getButtonSize(), hierarchy: ButtonHierarchy.Tetriary, type: ButtonType.Button, style: isSelected ? selectedOptionStyle : unselectedOptionStyle, disabled: disabled }, option));
33
+ }) }));
34
+ };
35
+ export const Components = () => {
36
+ return (_jsxs("div", { style: { padding: '20px' }, children: [_jsx("h1", { children: "Toggle Buttons" }), _jsx("div", { style: { display: 'flex', gap: '1rem', flexDirection: 'column' }, children: _jsx(ToggleButtonGroup, { options: ['Option 1', 'Option 2', 'Option 3'], selectedOption: "Option 1", onChange: () => { } }) })] }));
37
+ };
@@ -0,0 +1,9 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { ToggleButtonGroup } from './ToggleButtonGroup';
3
+ declare const meta: Meta<typeof ToggleButtonGroup>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof ToggleButtonGroup>;
6
+ export declare const Default: Story;
7
+ export declare const Size_SM: Story;
8
+ export declare const Size_MD: Story;
9
+ export declare const Size_LG: Story;
@@ -0,0 +1,78 @@
1
+ import { ToggleButtonGroup } from './ToggleButtonGroup';
2
+ import { ToggleButtonGroupSize } from './types/toggle-button-group';
3
+ const meta = {
4
+ title: 'Design System/Components/ToggleButtonGroup',
5
+ component: ToggleButtonGroup,
6
+ parameters: {
7
+ layout: 'centered',
8
+ design: {
9
+ type: 'figspec',
10
+ url: '',
11
+ },
12
+ },
13
+ tags: ['autodocs'],
14
+ argTypes: {
15
+ options: {
16
+ control: 'radio',
17
+ description: 'Options for the toggle button',
18
+ table: {
19
+ type: { summary: 'string[]' },
20
+ },
21
+ },
22
+ selectedOption: {
23
+ control: 'text',
24
+ description: 'Selected option for the toggle button',
25
+ table: {
26
+ type: { summary: 'string' },
27
+ },
28
+ },
29
+ disabled: {
30
+ control: 'boolean',
31
+ description: 'Whether the toggle button is disabled',
32
+ table: {
33
+ type: { summary: 'boolean' },
34
+ },
35
+ },
36
+ size: {
37
+ control: 'select',
38
+ options: Object.values(ToggleButtonGroupSize),
39
+ description: 'Size of the toggle button',
40
+ table: {
41
+ type: { summary: 'string' },
42
+ defaultValue: { summary: ToggleButtonGroupSize.md },
43
+ },
44
+ },
45
+ },
46
+ };
47
+ export default meta;
48
+ export const Default = {
49
+ args: {
50
+ options: ['Option 1', 'Option 2', 'Option 3'],
51
+ selectedOption: 'Option 1',
52
+ onChange: () => { },
53
+ },
54
+ };
55
+ export const Size_SM = {
56
+ args: {
57
+ options: ['Option 1', 'Option 2', 'Option 3'],
58
+ selectedOption: 'Option 1',
59
+ onChange: () => { },
60
+ size: ToggleButtonGroupSize.sm,
61
+ },
62
+ };
63
+ export const Size_MD = {
64
+ args: {
65
+ options: ['Option 1', 'Option 2', 'Option 3'],
66
+ selectedOption: 'Option 1',
67
+ onChange: () => { },
68
+ size: ToggleButtonGroupSize.md,
69
+ },
70
+ };
71
+ export const Size_LG = {
72
+ args: {
73
+ options: ['Option 1', 'Option 2', 'Option 3'],
74
+ selectedOption: 'Option 1',
75
+ onChange: () => { },
76
+ size: ToggleButtonGroupSize.lg,
77
+ },
78
+ };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Toggle button size variants
3
+ */
4
+ export declare enum ToggleButtonGroupSize {
5
+ lg = "lg",
6
+ md = "md",
7
+ sm = "sm"
8
+ }
9
+ /**
10
+ * Toggle button component props
11
+ */
12
+ export type ToggleButtonGroupProps = {
13
+ /** Size variant of the toggle button */
14
+ size?: ToggleButtonGroupSize;
15
+ /** Selected option of the toggle button */
16
+ selectedOption: string;
17
+ /** Options of the toggle button */
18
+ options: string[];
19
+ /** Whether the toggle button is disabled */
20
+ disabled?: boolean;
21
+ /** Callback function when the toggle button is selected */
22
+ onChange: (option: string) => void;
23
+ };
24
+ /**
25
+ * Props for the Components wrapper
26
+ */
27
+ export interface ComponentsProps {
28
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Toggle button size variants
3
+ */
4
+ export var ToggleButtonGroupSize;
5
+ (function (ToggleButtonGroupSize) {
6
+ ToggleButtonGroupSize["lg"] = "lg";
7
+ ToggleButtonGroupSize["md"] = "md";
8
+ ToggleButtonGroupSize["sm"] = "sm";
9
+ })(ToggleButtonGroupSize || (ToggleButtonGroupSize = {}));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@beydesign/storybook",
3
3
  "private": false,
4
- "version": "0.0.7",
4
+ "version": "0.0.9",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",