@beydesign/storybook 0.2.5 → 0.2.7

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.
@@ -4,7 +4,7 @@ import { Box } from '@mui/material';
4
4
  import { Typography, TypographySize, TypographyWeight } from '../Typography';
5
5
  import { HintBubble, HintBubbleSize } from '../UI';
6
6
  import { getIconComponent } from '../../utils';
7
- export const TextInput = ({ label, value, onChange, placeholder, type = 'text', hintText, errorText, disabled, trailingText, style, hintBubbleText, hintBubbleProps, required, labelTrailingElement, labelContainerStyle, showPasswordToggle = true, fullWidth = false, }) => {
7
+ export const TextInput = ({ label, value, onChange, placeholder, type = 'text', hintText, errorText, disabled, trailingText, style, hintBubbleText, hintBubbleProps, required, labelTrailingElement, labelContainerStyle, showPasswordToggle = true, fullWidth = false, leadingIcon, }) => {
8
8
  const [focused, setFocused] = useState(false);
9
9
  const [showPassword, setShowPassword] = useState(false);
10
10
  const isPassword = type === 'password';
@@ -30,7 +30,13 @@ export const TextInput = ({ label, value, onChange, placeholder, type = 'text',
30
30
  ? '1px solid var(--color-border-border-error)'
31
31
  : focused
32
32
  ? '1px solid var(--color-border-border-component-active)'
33
- : 'transparent'}`, children: [_jsx("input", { type: inputType, value: value, onChange: (e) => onChange(e.target.value), placeholder: placeholder, disabled: disabled, style: {
33
+ : 'transparent'}`, children: [leadingIcon &&
34
+ getIconComponent(leadingIcon, {
35
+ width: '20px',
36
+ height: '20px',
37
+ color: iconColor,
38
+ 'aria-hidden': 'true',
39
+ }), _jsx("input", { type: inputType, value: value, onChange: (e) => onChange(e.target.value), placeholder: placeholder, disabled: disabled, style: {
34
40
  border: 'none',
35
41
  outline: 'none',
36
42
  width: '100%',
@@ -157,11 +157,21 @@ declare const meta: {
157
157
  };
158
158
  };
159
159
  };
160
+ leadingIcon: {
161
+ control: "text";
162
+ description: string;
163
+ table: {
164
+ type: {
165
+ summary: string;
166
+ };
167
+ };
168
+ };
160
169
  };
161
170
  };
162
171
  export default meta;
163
172
  type Story = StoryObj<typeof meta>;
164
173
  export declare const Default: Story;
174
+ export declare const WithLeadingIcon: Story;
165
175
  export declare const Password: Story;
166
176
  export declare const PasswordWithoutToggle: Story;
167
177
  export declare const Email: Story;
@@ -122,6 +122,13 @@ const meta = {
122
122
  defaultValue: { summary: 'false' },
123
123
  },
124
124
  },
125
+ leadingIcon: {
126
+ control: 'text',
127
+ description: 'Icon rendered before the input value (e.g. a search glass). Accepts a Phosphor icon name.',
128
+ table: {
129
+ type: { summary: 'IconName' },
130
+ },
131
+ },
125
132
  },
126
133
  };
127
134
  export default meta;
@@ -133,6 +140,14 @@ export const Default = {
133
140
  hintBubbleText: 'This is a hint bubble',
134
141
  },
135
142
  };
143
+ export const WithLeadingIcon = {
144
+ args: {
145
+ value: '',
146
+ placeholder: 'Search',
147
+ leadingIcon: 'MagnifyingGlass',
148
+ onChange: () => { },
149
+ },
150
+ };
136
151
  export const Password = {
137
152
  args: {
138
153
  label: 'Password',
@@ -85,6 +85,8 @@ export type TextInputProps = {
85
85
  * min-width. Use for side-by-side fields in a flex row. Defaults to `false`.
86
86
  */
87
87
  fullWidth?: boolean;
88
+ /** Icon rendered before the input value (e.g. a search glass). */
89
+ leadingIcon?: IconName;
88
90
  };
89
91
  /**
90
92
  * Toggle position variants
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { MobileNavBarProps } from './types';
3
+ export declare const MobileNavBar: React.FC<MobileNavBarProps>;
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { Box, Drawer as MuiDrawer } from '@mui/material';
4
+ import { Logo } from '../UI';
5
+ import { Drawer } from '../Drawer';
6
+ import { getIconComponent } from '../../utils';
7
+ const shadowXs = 'var(--global-shadows-shadow-xs-offset-x) ' +
8
+ 'var(--global-shadows-shadow-xs-offset-y) ' +
9
+ 'var(--global-shadows-shadow-xs-blur) ' +
10
+ 'var(--global-shadows-shadow-xs-spread) ' +
11
+ 'var(--global-shadows-shadow-xs-color)';
12
+ const NavIconButton = ({ icon, ariaLabel, onClick, }) => (_jsx(Box, { component: 'button', type: 'button', onClick: onClick, "aria-label": ariaLabel, display: 'flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0, padding: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', border: '1px solid var(--color-border-border-component)', borderRadius: 'var(--spacing-tokens-size-in-px-radius-radius-xs)', sx: {
13
+ backgroundColor: 'transparent',
14
+ cursor: 'pointer',
15
+ boxShadow: shadowXs,
16
+ '&:focus-visible': {
17
+ outline: '2px solid var(--color-border-border-component-active)',
18
+ outlineOffset: '2px',
19
+ },
20
+ }, children: getIconComponent(icon, {
21
+ width: '20px',
22
+ height: '20px',
23
+ color: 'var(--color-foreground-fg-secondary)',
24
+ 'aria-hidden': 'true',
25
+ }) }));
26
+ export const MobileNavBar = ({ onSearchClick, drawerProps, showSearch = true, logoProps, style, className, }) => {
27
+ const [open, setOpen] = useState(false);
28
+ const handleMenuClick = () => {
29
+ if (drawerProps)
30
+ setOpen(true);
31
+ };
32
+ const closeDrawer = () => setOpen(false);
33
+ const navItems = drawerProps?.navItems.map((item) => ({
34
+ ...item,
35
+ onClick: () => {
36
+ item.onClick?.();
37
+ closeDrawer();
38
+ },
39
+ }));
40
+ return (_jsxs(_Fragment, { children: [_jsxs(Box, { className: className, sx: style, boxSizing: 'border-box', display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', width: '100%', height: '60px', paddingX: 'var(--spacing-tokens-size-in-px-spacing-spacing-xl)', borderBottom: '1px solid var(--color-border-border-component)', bgcolor: 'var(--color-background-bg-page)', children: [_jsx(Box, { display: 'flex', alignItems: 'center', sx: { '& svg': { display: 'block', height: '20px', width: 'auto' } }, children: _jsx(Logo, { color: 'var(--color-foreground-fg-brand-logo)', ...logoProps }) }), _jsxs(Box, { display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'flex-end', gap: 'var(--spacing-tokens-size-in-px-spacing-spacing-md)', children: [showSearch && (_jsx(NavIconButton, { icon: 'MagnifyingGlass', ariaLabel: 'Search', onClick: onSearchClick })), _jsx(NavIconButton, { icon: 'List', ariaLabel: 'Open menu', onClick: handleMenuClick })] })] }), drawerProps && navItems && (_jsx(MuiDrawer, { anchor: 'left', open: open, onClose: closeDrawer, PaperProps: {
41
+ sx: { backgroundColor: 'transparent', boxShadow: 'none' },
42
+ }, children: _jsx(Drawer, { ...drawerProps, navItems: navItems, showToggle: false }) }))] }));
43
+ };
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { MobileNavBar } from './MobileNavBar';
3
+ declare const meta: Meta<typeof MobileNavBar>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof meta>;
6
+ export declare const Default: Story;
7
+ export declare const WithoutDrawer: Story;
8
+ export declare const MenuOnly: Story;
@@ -0,0 +1,75 @@
1
+ import { MobileNavBar } from './MobileNavBar';
2
+ const navItems = [
3
+ { key: 'home', text: 'Home', icon: 'House' },
4
+ { key: 'avatars', text: 'Avatars', icon: 'UserFocus' },
5
+ { key: 'agents', text: 'My Agents', icon: 'Headset' },
6
+ { key: 'ttv', text: 'Text-to-Video', icon: 'VideoCamera' },
7
+ { key: 'kb', text: 'Knowledge Base', icon: 'Book' },
8
+ { key: 'conversations', text: 'Conversations', icon: 'ChatTeardropDots' },
9
+ { key: 'analytics', text: 'Analytics', icon: 'ChartBar' },
10
+ { key: 'api', text: 'API keys', icon: 'Key' },
11
+ { key: 'developers', text: 'Developers', icon: 'BracketsCurly' },
12
+ ];
13
+ const drawerProps = {
14
+ navItems,
15
+ activeKey: 'kb',
16
+ credits: { usedCredits: 500, maxCredits: 2000 },
17
+ profile: {
18
+ name: 'Emma Novak',
19
+ email: 'emma@example.com',
20
+ },
21
+ };
22
+ const meta = {
23
+ title: 'Design System/Components/Navigation/MobileNavBar',
24
+ component: MobileNavBar,
25
+ parameters: {
26
+ layout: 'fullscreen',
27
+ design: {
28
+ type: 'figspec',
29
+ url: 'https://www.figma.com/design/mIhjz2yJjcpLlIqw6oUivt/Beyond-Presence?node-id=7079-12927',
30
+ },
31
+ },
32
+ tags: ['autodocs'],
33
+ argTypes: {
34
+ onSearchClick: {
35
+ description: 'Callback fired when the search button is clicked',
36
+ table: { type: { summary: 'function' } },
37
+ },
38
+ drawerProps: {
39
+ control: false,
40
+ description: 'Drawer config. When provided, the menu button opens the navigation drawer as an overlay.',
41
+ table: { type: { summary: 'DrawerProps' } },
42
+ },
43
+ showSearch: {
44
+ control: 'boolean',
45
+ description: 'Whether to show the search button',
46
+ table: {
47
+ type: { summary: 'boolean' },
48
+ defaultValue: { summary: 'true' },
49
+ },
50
+ },
51
+ logoProps: {
52
+ control: 'object',
53
+ description: 'Logo customization props',
54
+ table: { type: { summary: 'object' } },
55
+ },
56
+ },
57
+ };
58
+ export default meta;
59
+ export const Default = {
60
+ args: {
61
+ showSearch: true,
62
+ drawerProps,
63
+ },
64
+ };
65
+ export const WithoutDrawer = {
66
+ args: {
67
+ showSearch: true,
68
+ },
69
+ };
70
+ export const MenuOnly = {
71
+ args: {
72
+ showSearch: false,
73
+ drawerProps,
74
+ },
75
+ };
@@ -1,4 +1,5 @@
1
1
  export * from './Header';
2
+ export * from './MobileNavBar';
2
3
  export * from './NavItem';
3
4
  export * from './Sidebar';
4
5
  export * from './types';
@@ -1,4 +1,5 @@
1
1
  export * from './Header';
2
+ export * from './MobileNavBar';
2
3
  export * from './NavItem';
3
4
  export * from './Sidebar';
4
5
  export * from './types';
@@ -2,6 +2,7 @@ import { SxProps, Theme } from '@mui/material';
2
2
  import { IconName } from '../../utils';
3
3
  import { AvatarProps } from '../UI';
4
4
  import { CreditsCardProps } from '../Credits';
5
+ import { DrawerProps } from '../Drawer';
5
6
  /**
6
7
  * Header component props
7
8
  */
@@ -184,3 +185,27 @@ export interface ProcessHeaderProps {
184
185
  /** The class name to apply to the component */
185
186
  className?: string;
186
187
  }
188
+ /**
189
+ * Mobile navigation bar props
190
+ */
191
+ export interface MobileNavBarProps {
192
+ /** Callback fired when the search button is clicked */
193
+ onSearchClick?: () => void;
194
+ /**
195
+ * Drawer configuration. When provided, clicking the menu button slides the
196
+ * navigation drawer in as an overlay.
197
+ */
198
+ drawerProps?: DrawerProps;
199
+ /** Whether to show the search button */
200
+ showSearch?: boolean;
201
+ /** Logo customization props */
202
+ logoProps?: {
203
+ gradient?: string;
204
+ color?: string;
205
+ svgUrl?: string;
206
+ };
207
+ /** The style object to apply to the component */
208
+ style?: SxProps<Theme>;
209
+ /** The class name to apply to the component */
210
+ className?: string;
211
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@beydesign/storybook",
3
3
  "private": false,
4
- "version": "0.2.5",
4
+ "version": "0.2.7",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",