@fragments-sdk/ui 0.8.1 → 0.8.3

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.
Files changed (108) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +14 -2
  3. package/fragments.json +1 -1
  4. package/package.json +23 -2
  5. package/src/assets/fragments-logo.tsx +37 -0
  6. package/src/assets/fragments_logo.svg +1 -0
  7. package/src/assets/fragments_logo_text.svg +1 -0
  8. package/src/blocks/AccountSettings.block.ts +1 -1
  9. package/src/blocks/ActivityFeed.block.ts +7 -7
  10. package/src/blocks/ChatInterface.block.ts +36 -80
  11. package/src/blocks/DashboardLayout.block.ts +85 -66
  12. package/src/blocks/DashboardPage.block.ts +298 -0
  13. package/src/blocks/EmptyState.block.ts +6 -4
  14. package/src/blocks/FeatureGrid.block.ts +1 -1
  15. package/src/blocks/LoginForm.block.ts +21 -26
  16. package/src/blocks/PricingComparison.block.ts +1 -1
  17. package/src/blocks/SettingsPanel.block.ts +4 -4
  18. package/src/blocks/ShoppingCart.block.ts +2 -2
  19. package/src/components/Accordion/Accordion.fragment.tsx +67 -1
  20. package/src/components/Alert/Alert.fragment.tsx +69 -1
  21. package/src/components/Alert/Alert.module.scss +7 -3
  22. package/src/components/AppShell/AppShell.fragment.tsx +326 -87
  23. package/src/components/Avatar/Avatar.fragment.tsx +35 -2
  24. package/src/components/Badge/Badge.fragment.tsx +47 -9
  25. package/src/components/Badge/Badge.module.scss +1 -0
  26. package/src/components/Breadcrumbs/Breadcrumbs.fragment.tsx +1 -1
  27. package/src/components/Breadcrumbs/Breadcrumbs.module.scss +3 -0
  28. package/src/components/Button/Button.fragment.tsx +1 -1
  29. package/src/components/Checkbox/Checkbox.fragment.tsx +4 -4
  30. package/src/components/Checkbox/Checkbox.module.scss +7 -7
  31. package/src/components/Checkbox/index.tsx +6 -1
  32. package/src/components/Chip/Chip.fragment.tsx +1 -1
  33. package/src/components/CodeBlock/CodeBlock.fragment.tsx +10 -2
  34. package/src/components/CodeBlock/CodeBlock.module.scss +48 -11
  35. package/src/components/CodeBlock/CodeBlock.test.tsx +51 -1
  36. package/src/components/CodeBlock/index.tsx +221 -3
  37. package/src/components/ColorPicker/ColorPicker.fragment.tsx +1 -1
  38. package/src/components/ColorPicker/ColorPicker.module.scss +8 -7
  39. package/src/components/Combobox/Combobox.fragment.tsx +1 -1
  40. package/src/components/Combobox/Combobox.module.scss +1 -3
  41. package/src/components/Field/index.tsx +1 -1
  42. package/src/components/Form/Form.fragment.tsx +4 -4
  43. package/src/components/Input/Input.fragment.tsx +1 -1
  44. package/src/components/Input/Input.test.tsx +35 -0
  45. package/src/components/Input/index.tsx +47 -2
  46. package/src/components/Menu/Menu.module.scss +2 -0
  47. package/src/components/Message/Message.module.scss +3 -3
  48. package/src/components/Popover/Popover.fragment.tsx +1 -1
  49. package/src/components/Popover/Popover.module.scss +1 -3
  50. package/src/components/Prompt/Prompt.module.scss +6 -19
  51. package/src/components/Prompt/Prompt.test.tsx +8 -0
  52. package/src/components/Prompt/index.tsx +12 -1
  53. package/src/components/RadioGroup/RadioGroup.fragment.tsx +4 -3
  54. package/src/components/RadioGroup/RadioGroup.module.scss +9 -9
  55. package/src/components/RadioGroup/index.tsx +5 -1
  56. package/src/components/Sidebar/Sidebar.module.scss +9 -2
  57. package/src/components/Sidebar/Sidebar.test.tsx +6 -0
  58. package/src/components/Sidebar/index.tsx +4 -1
  59. package/src/components/Slider/Slider.fragment.tsx +2 -2
  60. package/src/components/Slider/Slider.module.scss +2 -0
  61. package/src/components/Switch/index.ts +1 -0
  62. package/src/components/Table/Table.fragment.tsx +1 -1
  63. package/src/components/Theme/Theme.fragment.tsx +16 -0
  64. package/src/components/Theme/ThemeToggle.module.scss +4 -3
  65. package/src/components/Toast/Toast.fragment.tsx +1 -0
  66. package/src/components/Toast/Toast.module.scss +9 -4
  67. package/src/components/Toggle/Toggle.fragment.tsx +32 -32
  68. package/src/components/Toggle/Toggle.module.scss +33 -26
  69. package/src/components/Toggle/Toggle.test.tsx +10 -10
  70. package/src/components/Toggle/index.tsx +23 -15
  71. package/src/components/ToggleGroup/ToggleGroup.fragment.tsx +34 -2
  72. package/src/index.ts +9 -1
  73. package/src/tokens/_derive.scss +32 -8
  74. package/src/tokens/_mixins.scss +14 -0
  75. package/src/tokens/_variables.scss +12 -6
  76. package/src/blocks/AIChat.block.ts +0 -266
  77. package/src/blocks/AppShell.block.ts +0 -175
  78. package/src/blocks/CTABanner.block.ts +0 -24
  79. package/src/blocks/CardGrid.block.ts +0 -22
  80. package/src/blocks/CodeExamples.block.ts +0 -66
  81. package/src/blocks/ConfirmDialog.block.ts +0 -19
  82. package/src/blocks/ConversationWithHistory.block.ts +0 -45
  83. package/src/blocks/DashboardNav.block.ts +0 -183
  84. package/src/blocks/ForgotPassword.block.ts +0 -26
  85. package/src/blocks/FormLayout.block.ts +0 -31
  86. package/src/blocks/InsetDashboardLayout.block.ts +0 -79
  87. package/src/blocks/MetricDashboard.block.ts +0 -38
  88. package/src/blocks/NewsletterSignup.block.ts +0 -26
  89. package/src/blocks/NotificationList.block.ts +0 -39
  90. package/src/blocks/NotificationPreferences.block.ts +0 -40
  91. package/src/blocks/OrderSummary.block.ts +0 -52
  92. package/src/blocks/ProfileEditForm.block.ts +0 -51
  93. package/src/blocks/SearchResults.block.ts +0 -39
  94. package/src/blocks/SettingsPage.block.ts +0 -58
  95. package/src/blocks/StreamingMessage.block.ts +0 -24
  96. package/src/blocks/TestimonialCard.block.ts +0 -27
  97. package/src/blocks/UserProfileCard.block.ts +0 -29
  98. package/src/recipes/AIChat.recipe.ts +0 -266
  99. package/src/recipes/AppShell.recipe.ts +0 -175
  100. package/src/recipes/CardGrid.recipe.ts +0 -22
  101. package/src/recipes/ChatInterface.recipe.ts +0 -87
  102. package/src/recipes/CodeExamples.recipe.ts +0 -66
  103. package/src/recipes/ConfirmDialog.recipe.ts +0 -19
  104. package/src/recipes/DashboardLayout.recipe.ts +0 -73
  105. package/src/recipes/DashboardNav.recipe.ts +0 -183
  106. package/src/recipes/FormLayout.recipe.ts +0 -31
  107. package/src/recipes/LoginForm.recipe.ts +0 -33
  108. package/src/recipes/SettingsPage.recipe.ts +0 -58
@@ -1,73 +0,0 @@
1
- import { defineRecipe } from '@fragments/core';
2
-
3
- export default defineRecipe({
4
- name: 'Dashboard Layout',
5
- description: 'Dashboard grid with a featured full-width card and smaller metric cards below',
6
- category: 'layout',
7
- components: ['Grid', 'Card', 'Badge', 'Separator'],
8
- tags: ['dashboard', 'layout', 'metrics', 'widgets', 'overview'],
9
- code: `
10
- <Grid columns={4} gap="lg">
11
- <Grid.Item colSpan="full">
12
- <Card>
13
- <Card.Header>
14
- <Card.Title>Overview</Card.Title>
15
- <Card.Description>Key metrics for this period</Card.Description>
16
- </Card.Header>
17
- <Card.Body>{summaryContent}</Card.Body>
18
- </Card>
19
- </Grid.Item>
20
- <Card variant="outlined">
21
- <Card.Header>
22
- <Card.Title>Users</Card.Title>
23
- </Card.Header>
24
- <Card.Body>
25
- <Badge variant="success">{stats.users}</Badge>
26
- </Card.Body>
27
- </Card>
28
- <Card variant="outlined">
29
- <Card.Header>
30
- <Card.Title>Revenue</Card.Title>
31
- </Card.Header>
32
- <Card.Body>
33
- <Badge variant="info">{stats.revenue}</Badge>
34
- </Card.Body>
35
- </Card>
36
- <Card variant="outlined">
37
- <Card.Header>
38
- <Card.Title>Orders</Card.Title>
39
- </Card.Header>
40
- <Card.Body>
41
- <Badge variant="warning">{stats.orders}</Badge>
42
- </Card.Body>
43
- </Card>
44
- <Card variant="outlined">
45
- <Card.Header>
46
- <Card.Title>Errors</Card.Title>
47
- </Card.Header>
48
- <Card.Body>
49
- <Badge variant="danger">{stats.errors}</Badge>
50
- </Card.Body>
51
- </Card>
52
- <Grid.Item colSpan="full">
53
- <Separator spacing="md" />
54
- </Grid.Item>
55
- <Grid.Item colSpan={2}>
56
- <Card>
57
- <Card.Header>
58
- <Card.Title>Recent Activity</Card.Title>
59
- </Card.Header>
60
- <Card.Body>{activityList}</Card.Body>
61
- </Card>
62
- </Grid.Item>
63
- <Grid.Item colSpan={2}>
64
- <Card>
65
- <Card.Header>
66
- <Card.Title>Notifications</Card.Title>
67
- </Card.Header>
68
- <Card.Body>{notificationList}</Card.Body>
69
- </Card>
70
- </Grid.Item>
71
- </Grid>
72
- `.trim(),
73
- });
@@ -1,183 +0,0 @@
1
- import { defineRecipe } from '@fragments/core';
2
-
3
- export default defineRecipe({
4
- name: 'Dashboard Navigation',
5
- description: 'Sidebar navigation pattern for dashboard applications with user profile, sections, and nested menus',
6
- category: 'navigation',
7
- components: ['Sidebar', 'Avatar'],
8
- tags: ['navigation', 'sidebar', 'dashboard', 'admin', 'menu'],
9
- code: `
10
- // Dashboard Navigation with User Profile
11
- // A complete sidebar navigation for admin/dashboard interfaces
12
-
13
- function DashboardNav({ user, currentPath }) {
14
- const [collapsed, setCollapsed] = React.useState(false);
15
- const [projectsExpanded, setProjectsExpanded] = React.useState(false);
16
-
17
- return (
18
- <Sidebar
19
- collapsed={collapsed}
20
- onCollapsedChange={setCollapsed}
21
- >
22
- {/* Brand header */}
23
- <Sidebar.Header>
24
- <svg width="32" height="32" viewBox="0 0 256 256" fill="var(--fui-color-accent)">
25
- <path d="M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm0,176H48V48H208V208Z" />
26
- </svg>
27
- {!collapsed && (
28
- <span style={{ fontWeight: 600, fontSize: '16px' }}>Dashboard</span>
29
- )}
30
- <Sidebar.CollapseToggle />
31
- </Sidebar.Header>
32
-
33
- {/* Main navigation */}
34
- <Sidebar.Nav aria-label="Dashboard navigation">
35
- {/* Primary section */}
36
- <Sidebar.Section>
37
- <Sidebar.Item
38
- icon={<HomeIcon />}
39
- href="/dashboard"
40
- active={currentPath === '/dashboard'}
41
- >
42
- Overview
43
- </Sidebar.Item>
44
- <Sidebar.Item
45
- icon={<ChartIcon />}
46
- href="/analytics"
47
- active={currentPath === '/analytics'}
48
- badge="New"
49
- >
50
- Analytics
51
- </Sidebar.Item>
52
- <Sidebar.Item
53
- icon={<InboxIcon />}
54
- href="/inbox"
55
- active={currentPath === '/inbox'}
56
- badge="5"
57
- >
58
- Inbox
59
- </Sidebar.Item>
60
- </Sidebar.Section>
61
-
62
- {/* Projects section with nested items */}
63
- <Sidebar.Section label="Workspace">
64
- <Sidebar.Item
65
- icon={<FolderIcon />}
66
- hasSubmenu
67
- expanded={projectsExpanded}
68
- onExpandedChange={setProjectsExpanded}
69
- >
70
- Projects
71
- </Sidebar.Item>
72
- <Sidebar.Submenu>
73
- <Sidebar.SubItem
74
- href="/projects/website"
75
- active={currentPath === '/projects/website'}
76
- >
77
- Website Redesign
78
- </Sidebar.SubItem>
79
- <Sidebar.SubItem
80
- href="/projects/mobile"
81
- active={currentPath === '/projects/mobile'}
82
- >
83
- Mobile App
84
- </Sidebar.SubItem>
85
- <Sidebar.SubItem
86
- href="/projects/api"
87
- active={currentPath === '/projects/api'}
88
- >
89
- API Integration
90
- </Sidebar.SubItem>
91
- </Sidebar.Submenu>
92
- <Sidebar.Item
93
- icon={<UsersIcon />}
94
- href="/team"
95
- active={currentPath === '/team'}
96
- >
97
- Team Members
98
- </Sidebar.Item>
99
- <Sidebar.Item
100
- icon={<CalendarIcon />}
101
- href="/calendar"
102
- active={currentPath === '/calendar'}
103
- >
104
- Calendar
105
- </Sidebar.Item>
106
- </Sidebar.Section>
107
-
108
- {/* Settings section */}
109
- <Sidebar.Section label="Account">
110
- <Sidebar.Item
111
- icon={<GearIcon />}
112
- href="/settings"
113
- active={currentPath === '/settings'}
114
- >
115
- Settings
116
- </Sidebar.Item>
117
- <Sidebar.Item
118
- icon={<HelpIcon />}
119
- href="/help"
120
- active={currentPath === '/help'}
121
- >
122
- Help & Support
123
- </Sidebar.Item>
124
- </Sidebar.Section>
125
- </Sidebar.Nav>
126
-
127
- {/* Footer with user profile */}
128
- <Sidebar.Footer>
129
- <div style={{
130
- display: 'flex',
131
- alignItems: 'center',
132
- gap: '12px',
133
- padding: collapsed ? '0' : '8px',
134
- borderRadius: '8px',
135
- cursor: 'pointer',
136
- }}>
137
- <Avatar
138
- src={user.avatar}
139
- name={user.name}
140
- size="sm"
141
- />
142
- {!collapsed && (
143
- <div style={{ flex: 1, minWidth: 0 }}>
144
- <div style={{
145
- fontWeight: 500,
146
- fontSize: '14px',
147
- whiteSpace: 'nowrap',
148
- overflow: 'hidden',
149
- textOverflow: 'ellipsis',
150
- }}>
151
- {user.name}
152
- </div>
153
- <div style={{
154
- fontSize: '12px',
155
- color: 'var(--fui-text-secondary)',
156
- whiteSpace: 'nowrap',
157
- overflow: 'hidden',
158
- textOverflow: 'ellipsis',
159
- }}>
160
- {user.email}
161
- </div>
162
- </div>
163
- )}
164
- </div>
165
- </Sidebar.Footer>
166
- </Sidebar>
167
- );
168
- }
169
-
170
- // Usage example:
171
- // <DashboardNav
172
- // user={{ name: 'Jane Doe', email: 'jane@example.com', avatar: '/avatar.jpg' }}
173
- // currentPath="/dashboard"
174
- // />
175
-
176
- // Icon components (use your preferred icon library)
177
- const HomeIcon = () => (
178
- <svg width="20" height="20" viewBox="0 0 256 256" fill="currentColor">
179
- <path d="M219.31,108.68l-80-80a16,16,0,0,0-22.62,0l-80,80A15.87,15.87,0,0,0,32,120v96a8,8,0,0,0,8,8H96a8,8,0,0,0,8-8V160h48v56a8,8,0,0,0,8,8h56a8,8,0,0,0,8-8V120A15.87,15.87,0,0,0,219.31,108.68Z" />
180
- </svg>
181
- );
182
- `.trim(),
183
- });
@@ -1,31 +0,0 @@
1
- import { defineRecipe } from '@fragments/core';
2
-
3
- export default defineRecipe({
4
- name: 'Form Layout',
5
- description: 'Two-column form with full-width fields where needed, using Grid for alignment',
6
- category: 'forms',
7
- components: ['Grid', 'Input', 'Textarea', 'Select', 'Button'],
8
- tags: ['form', 'layout', 'grid', 'inputs', 'settings'],
9
- code: `
10
- <Grid columns={2} gap="md">
11
- <Input label="First Name" placeholder="Jane" />
12
- <Input label="Last Name" placeholder="Doe" />
13
- <Grid.Item colSpan="full">
14
- <Input label="Email" type="email" placeholder="jane@example.com" />
15
- </Grid.Item>
16
- <Grid.Item colSpan="full">
17
- <Select label="Role">
18
- <Select.Item value="admin">Admin</Select.Item>
19
- <Select.Item value="editor">Editor</Select.Item>
20
- <Select.Item value="viewer">Viewer</Select.Item>
21
- </Select>
22
- </Grid.Item>
23
- <Grid.Item colSpan="full">
24
- <Textarea label="Bio" placeholder="Tell us about yourself" />
25
- </Grid.Item>
26
- <Grid.Item colSpan="full">
27
- <Button type="submit" variant="primary">Save</Button>
28
- </Grid.Item>
29
- </Grid>
30
- `.trim(),
31
- });
@@ -1,33 +0,0 @@
1
- import { defineRecipe } from '@fragments/core';
2
-
3
- export default defineRecipe({
4
- name: 'Login Form',
5
- description: 'Email/password authentication form with validation states',
6
- category: 'forms',
7
- components: ['Input', 'Button', 'Alert'],
8
- tags: ['auth', 'login', 'form'],
9
- code: `
10
- <Input
11
- label="Email"
12
- type="email"
13
- placeholder="you@example.com"
14
- error={Boolean(errors.email)}
15
- helperText={errors.email}
16
- />
17
- <Input
18
- label="Password"
19
- type="password"
20
- error={Boolean(errors.password)}
21
- helperText={errors.password}
22
- />
23
- <Button type="submit" variant="primary">Sign in</Button>
24
- {error && (
25
- <Alert severity="error">
26
- <Alert.Icon />
27
- <Alert.Body>
28
- <Alert.Content>{error}</Alert.Content>
29
- </Alert.Body>
30
- </Alert>
31
- )}
32
- `.trim(),
33
- });
@@ -1,58 +0,0 @@
1
- import { defineRecipe } from '@fragments/core';
2
-
3
- export default defineRecipe({
4
- name: 'Settings Page',
5
- description: 'Settings page with labeled sections using cards, toggles, and a save action',
6
- category: 'forms',
7
- components: ['Grid', 'Card', 'Toggle', 'Input', 'Select', 'Separator', 'Button'],
8
- tags: ['settings', 'preferences', 'form', 'toggle', 'layout'],
9
- code: `
10
- <Grid columns={1} gap="lg">
11
- <Card>
12
- <Card.Header>
13
- <Card.Title>Profile</Card.Title>
14
- <Card.Description>Your public profile information</Card.Description>
15
- </Card.Header>
16
- <Card.Body>
17
- <Grid columns={2} gap="md">
18
- <Input label="Display Name" defaultValue={user.name} />
19
- <Input label="Email" type="email" defaultValue={user.email} />
20
- <Grid.Item colSpan="full">
21
- <Input label="Website" type="url" defaultValue={user.website} />
22
- </Grid.Item>
23
- </Grid>
24
- </Card.Body>
25
- </Card>
26
-
27
- <Card>
28
- <Card.Header>
29
- <Card.Title>Notifications</Card.Title>
30
- <Card.Description>Choose what you get notified about</Card.Description>
31
- </Card.Header>
32
- <Card.Body>
33
- <Grid columns={1} gap="sm">
34
- <Toggle label="Email notifications" checked={prefs.emailNotifs} onChange={onToggle('emailNotifs')} />
35
- <Toggle label="Push notifications" checked={prefs.pushNotifs} onChange={onToggle('pushNotifs')} />
36
- <Toggle label="Weekly digest" checked={prefs.digest} onChange={onToggle('digest')} />
37
- </Grid>
38
- </Card.Body>
39
- </Card>
40
-
41
- <Card>
42
- <Card.Header>
43
- <Card.Title>Appearance</Card.Title>
44
- </Card.Header>
45
- <Card.Body>
46
- <Select label="Theme" value={prefs.theme} onChange={onThemeChange}>
47
- <Select.Item value="light">Light</Select.Item>
48
- <Select.Item value="dark">Dark</Select.Item>
49
- <Select.Item value="system">System</Select.Item>
50
- </Select>
51
- </Card.Body>
52
- </Card>
53
-
54
- <Separator />
55
- <Button variant="primary" type="submit">Save Changes</Button>
56
- </Grid>
57
- `.trim(),
58
- });