@xyhp915/slack-base-ui 0.0.1 → 0.0.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 (54) hide show
  1. package/README.md +220 -4
  2. package/agents/slack-base-ui/SKILL.md +137 -0
  3. package/agents/slack-base-ui/checklists/style-review.md +56 -0
  4. package/agents/slack-base-ui/templates/consumer-setup.md +109 -0
  5. package/agents/slack-base-ui/templates/slack-theme.css +152 -0
  6. package/libs/Dialog.d.ts +73 -0
  7. package/libs/Dialog.d.ts.map +1 -1
  8. package/libs/Popover.d.ts +69 -0
  9. package/libs/Popover.d.ts.map +1 -1
  10. package/libs/index.d.ts +4 -4
  11. package/libs/index.d.ts.map +1 -1
  12. package/libs/index.js +2885 -2718
  13. package/package.json +1 -1
  14. package/src/App.css +7 -0
  15. package/src/App.tsx +18 -0
  16. package/src/assets/react.svg +1 -0
  17. package/src/components/AlertDialog.tsx +185 -0
  18. package/src/components/AutoComplete.tsx +311 -0
  19. package/src/components/Avatar.tsx +70 -0
  20. package/src/components/Badge.tsx +48 -0
  21. package/src/components/Button.tsx +53 -0
  22. package/src/components/Checkbox.tsx +109 -0
  23. package/src/components/ContextMenu.tsx +393 -0
  24. package/src/components/Dialog.tsx +371 -0
  25. package/src/components/Form.tsx +409 -0
  26. package/src/components/IconButton.tsx +49 -0
  27. package/src/components/Input.tsx +56 -0
  28. package/src/components/Loading.tsx +123 -0
  29. package/src/components/Menu.tsx +368 -0
  30. package/src/components/Popover.tsx +367 -0
  31. package/src/components/Progress.tsx +89 -0
  32. package/src/components/Radio.tsx +137 -0
  33. package/src/components/Select.tsx +177 -0
  34. package/src/components/Switch.tsx +116 -0
  35. package/src/components/Tabs.tsx +128 -0
  36. package/src/components/Toast.tsx +149 -0
  37. package/src/components/Tooltip.tsx +46 -0
  38. package/src/components/index.ts +186 -0
  39. package/src/context/ThemeContext.tsx +53 -0
  40. package/src/context/useTheme.ts +11 -0
  41. package/src/examples/slack-clone/SlackApp.tsx +94 -0
  42. package/src/examples/slack-clone/components/ChannelHeader.tsx +34 -0
  43. package/src/examples/slack-clone/components/Composer.tsx +42 -0
  44. package/src/examples/slack-clone/components/Message.tsx +97 -0
  45. package/src/examples/slack-clone/components/UserProfile.tsx +78 -0
  46. package/src/examples/slack-clone/layout/Layout.tsx +27 -0
  47. package/src/examples/slack-clone/layout/Sidebar.tsx +67 -0
  48. package/src/examples/slack-clone/layout/SidebarItem.tsx +57 -0
  49. package/src/examples/slack-clone/layout/TopBar.tsx +30 -0
  50. package/src/index.css +240 -0
  51. package/src/main.tsx +22 -0
  52. package/src/pages/ComponentShowcase.tsx +1964 -0
  53. package/src/pages/Dashboard.tsx +87 -0
  54. package/src/pages/QuickStartDemo.tsx +262 -0
@@ -0,0 +1,87 @@
1
+ import { Link } from 'react-router-dom';
2
+ import { useTheme } from '../context/useTheme';
3
+ import { Sun, Moon } from 'lucide-react';
4
+
5
+ export const Dashboard = () => {
6
+ const { theme, toggleTheme } = useTheme();
7
+
8
+ return (
9
+ <div className="min-h-screen bg-(--bg-secondary) p-8 font-sans transition-colors duration-300">
10
+ <header className="mb-12 max-w-4xl mx-auto flex items-start justify-between">
11
+ <div>
12
+ <h1 className="text-4xl font-black text-(--text-primary) mb-4 tracking-tight">
13
+ Slack Base UI
14
+ </h1>
15
+ <p className="text-xl text-(--text-secondary) leading-relaxed">
16
+ A recreation of the Slack interface using <code className="bg-(--bg-hover) px-1.5 py-0.5 rounded text-(--text-primary) text-sm">@base-ui/react</code>.
17
+ This project demonstrates how to build complex, polished applications with modern component primitives.
18
+ </p>
19
+ </div>
20
+ <button
21
+ onClick={toggleTheme}
22
+ className="p-2 rounded-full bg-(--bg-hover) text-(--text-primary) hover:bg-(--border-light) transition-colors"
23
+ title={`Switch to ${theme === 'light' ? 'dark' : 'light'} mode`}
24
+ >
25
+ {theme === 'light' ? <Moon size={24} /> : <Sun size={24} />}
26
+ </button>
27
+ </header>
28
+
29
+ <main className="max-w-4xl mx-auto grid grid-cols-1 md:grid-cols-2 gap-8">
30
+
31
+ {/* Featured Example Card */}
32
+ <Link to="/examples/slack" className="group block">
33
+ <div className="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden hover:shadow-lg transition-all duration-300 transform group-hover:-translate-y-1">
34
+ <div className="h-48 bg-[#4A154B] flex items-center justify-center relative pattern-grid-lg">
35
+ {/* Abstract representation of Slack UI */}
36
+ <div className="bg-white/10 w-3/4 h-3/4 rounded-lg backdrop-blur-sm border border-white/20 shadow-2xl flex">
37
+ <div className="w-1/4 border-r border-white/10 h-full p-2 space-y-2">
38
+ <div className="w-8 h-8 bg-white/20 rounded-md"></div>
39
+ <div className="h-2 w-full bg-white/20 rounded"></div>
40
+ <div className="h-2 w-2/3 bg-white/20 rounded"></div>
41
+ </div>
42
+ <div className="flex-1 p-2 space-y-2">
43
+ <div className="h-8 w-full bg-white/20 rounded-md"></div>
44
+ <div className="space-y-2 mt-4">
45
+ <div className="h-12 bg-white/10 rounded-md"></div>
46
+ <div className="h-12 bg-white/10 rounded-md"></div>
47
+ </div>
48
+ </div>
49
+ </div>
50
+ </div>
51
+ <div className="p-6">
52
+ <div className="flex items-center justify-between mb-2">
53
+ <span className="text-xs font-bold tracking-wider text-[#4A154B] uppercase bg-[#4A154B]/5 px-2 py-1 rounded">Application Demo</span>
54
+ </div>
55
+ <h2 className="text-2xl font-bold text-gray-900 mb-2 group-hover:text-[#4A154B] transition-colors">Slack Clone</h2>
56
+ <p className="text-gray-500">
57
+ A full-page application layout featuring Sidebar, Channel Header, Message List, and Rich Text Composer.
58
+ </p>
59
+ </div>
60
+ </div>
61
+ </Link>
62
+
63
+ {/* Component Library Card */}
64
+ <Link to="/components" className="group block h-full">
65
+ <div className="bg-(--bg-primary) rounded-2xl shadow-sm border border-(--border-light) overflow-hidden p-6 hover:shadow-lg transition-all duration-300 transform group-hover:-translate-y-1 h-full flex flex-col">
66
+ <h2 className="text-2xl font-bold text-(--text-primary) mb-4 group-hover:text-[#1164A3] transition-colors">Component Library</h2>
67
+ <p className="text-(--text-secondary) mb-6">
68
+ Individual component demonstrations and documentation. Use these primitives to build your own interfaces.
69
+ </p>
70
+ <div className="grid grid-cols-2 gap-3 mb-6">
71
+ {['Button', 'Avatar', 'Badge', 'Input', 'Tooltip', 'IconButton', 'Dialog'].map((component) => (
72
+ <div key={component} className="p-3 border border-(--border-light) rounded-lg bg-(--bg-secondary) text-sm font-medium text-(--text-secondary) flex items-center gap-2">
73
+ <div className="w-2 h-2 rounded-full bg-green-500"></div>
74
+ {component}
75
+ </div>
76
+ ))}
77
+ </div>
78
+ <div className="mt-auto pt-6 border-t border-(--border-light)">
79
+ <p className="text-sm text-(--text-muted) italic group-hover:text-[#1164A3] transition-colors">Click to explore components &rarr;</p>
80
+ </div>
81
+ </div>
82
+ </Link>
83
+
84
+ </main>
85
+ </div>
86
+ );
87
+ };
@@ -0,0 +1,262 @@
1
+ import { useState } from 'react'
2
+ import { AlertDialog } from '../components/AlertDialog'
3
+ import { Form, FormInput, FormTextarea, FormSelect, FormCheckbox, FormActions } from '../components/Form'
4
+ import { Button } from '../components/Button'
5
+
6
+ /**
7
+ * 快速上手演示页面
8
+ * 展示 AlertDialog 和 Form 组件的基本使用
9
+ */
10
+ export const QuickStartDemo = () => {
11
+ const [alertOpen, setAlertOpen] = useState(false)
12
+
13
+ return (
14
+ <div className="min-h-screen bg-(--bg-muted) p-8">
15
+ <div className="max-w-4xl mx-auto space-y-12">
16
+ <header>
17
+ <h1 className="text-3xl font-black text-(--text-primary) mb-2">
18
+ 快速上手演示
19
+ </h1>
20
+ <p className="text-(--text-secondary)">
21
+ AlertDialog 和 Form 组件的基本使用示例
22
+ </p>
23
+ </header>
24
+
25
+ {/* AlertDialog 示例 */}
26
+ <section className="bg-(--bg-primary) rounded-lg border border-(--border-light) p-6">
27
+ <h2 className="text-xl font-bold text-(--text-primary) mb-4">
28
+ AlertDialog 示例
29
+ </h2>
30
+ <p className="text-(--text-secondary) mb-4">
31
+ 点击按钮打开警告对话框
32
+ </p>
33
+
34
+ <Button variant="danger" onClick={() => setAlertOpen(true)}>
35
+ 删除账户
36
+ </Button>
37
+
38
+ <AlertDialog
39
+ open={alertOpen}
40
+ onOpenChange={setAlertOpen}
41
+ title="确认删除账户?"
42
+ description="此操作无法撤销,将永久删除您的账户。"
43
+ variant="danger"
44
+ confirmText="确认删除"
45
+ cancelText="取消"
46
+ onConfirm={async () => {
47
+ // 模拟异步操作
48
+ await new Promise(resolve => setTimeout(resolve, 1000))
49
+ console.log('账户已删除')
50
+ alert('账户已删除!')
51
+ }}
52
+ >
53
+ <div className="space-y-2">
54
+ <p className="text-(--text-secondary)">
55
+ 删除后将丢失:
56
+ </p>
57
+ <ul className="list-disc list-inside text-(--text-secondary) space-y-1 ml-2">
58
+ <li>所有个人数据</li>
59
+ <li>聊天记录</li>
60
+ <li>上传的文件</li>
61
+ </ul>
62
+ </div>
63
+ </AlertDialog>
64
+ </section>
65
+
66
+ {/* Form 示例 */}
67
+ <section className="bg-(--bg-primary) rounded-lg border border-(--border-light) p-6">
68
+ <h2 className="text-xl font-bold text-(--text-primary) mb-4">
69
+ Form 示例
70
+ </h2>
71
+ <p className="text-(--text-secondary) mb-6">
72
+ 一个带验证的完整表单
73
+ </p>
74
+
75
+ <Form
76
+ initialValues={{
77
+ name: '',
78
+ email: '',
79
+ role: '',
80
+ message: '',
81
+ terms: false,
82
+ }}
83
+ validate={(values) => {
84
+ const errors: Record<string, string> = {}
85
+
86
+ if (!values.name) {
87
+ errors.name = '姓名为必填项'
88
+ } else if (values.name.length < 2) {
89
+ errors.name = '姓名至少需要 2 个字符'
90
+ }
91
+
92
+ if (!values.email) {
93
+ errors.email = '邮箱为必填项'
94
+ } else if (!/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i.test(values.email)) {
95
+ errors.email = '邮箱格式不正确'
96
+ }
97
+
98
+ if (!values.role) {
99
+ errors.role = '请选择角色'
100
+ }
101
+
102
+ if (!values.message) {
103
+ errors.message = '消息为必填项'
104
+ } else if (values.message.length < 10) {
105
+ errors.message = '消息至少需要 10 个字符'
106
+ }
107
+
108
+ if (!values.terms) {
109
+ errors.terms = '必须同意条款才能继续'
110
+ }
111
+
112
+ return errors
113
+ }}
114
+ onSubmit={(values) => {
115
+ console.log('表单提交:', values)
116
+ alert(`表单提交成功!\n\n姓名:${values.name}\n邮箱:${values.email}\n角色:${values.role}`)
117
+ }}
118
+ >
119
+ <div className="space-y-4">
120
+ <FormInput
121
+ name="name"
122
+ label="姓名"
123
+ placeholder="请输入您的姓名"
124
+ required
125
+ fullWidth
126
+ />
127
+
128
+ <FormInput
129
+ name="email"
130
+ label="邮箱"
131
+ type="email"
132
+ placeholder="your@email.com"
133
+ required
134
+ fullWidth
135
+ />
136
+
137
+ <FormSelect
138
+ name="role"
139
+ label="角色"
140
+ required
141
+ fullWidth
142
+ options={[
143
+ { value: 'developer', label: '开发者' },
144
+ { value: 'designer', label: '设计师' },
145
+ { value: 'manager', label: '项目经理' },
146
+ { value: 'other', label: '其他' },
147
+ ]}
148
+ />
149
+
150
+ <FormTextarea
151
+ name="message"
152
+ label="留言"
153
+ placeholder="告诉我们您的想法..."
154
+ required
155
+ fullWidth
156
+ rows={4}
157
+ />
158
+
159
+ <FormCheckbox
160
+ name="terms"
161
+ label="我同意服务条款和隐私政策"
162
+ />
163
+
164
+ <FormActions>
165
+ <Button
166
+ type="button"
167
+ variant="secondary"
168
+ onClick={() => {
169
+ console.log('表单取消')
170
+ }}
171
+ >
172
+ 取消
173
+ </Button>
174
+ <Button type="submit" variant="primary">
175
+ 提交表单
176
+ </Button>
177
+ </FormActions>
178
+ </div>
179
+ </Form>
180
+ </section>
181
+
182
+ {/* 代码示例 */}
183
+ <section className="bg-(--bg-primary) rounded-lg border border-(--border-light) p-6">
184
+ <h2 className="text-xl font-bold text-(--text-primary) mb-4">
185
+ 代码示例
186
+ </h2>
187
+
188
+ <div className="space-y-4">
189
+ <div>
190
+ <h3 className="font-semibold text-(--text-primary) mb-2">AlertDialog 用法</h3>
191
+ <pre className="bg-(--bg-secondary) p-4 rounded text-sm overflow-x-auto">
192
+ <code>{`<AlertDialog
193
+ open={open}
194
+ onOpenChange={setOpen}
195
+ title="确认删除?"
196
+ description="此操作无法撤销"
197
+ variant="danger"
198
+ onConfirm={async () => {
199
+ await deleteItem()
200
+ }}
201
+ />`}</code>
202
+ </pre>
203
+ </div>
204
+
205
+ <div>
206
+ <h3 className="font-semibold text-(--text-primary) mb-2">Form 用法</h3>
207
+ <pre className="bg-(--bg-secondary) p-4 rounded text-sm overflow-x-auto">
208
+ <code>{`<Form
209
+ initialValues={{ name: '', email: '' }}
210
+ validate={(values) => {
211
+ const errors = {}
212
+ if (!values.name) errors.name = '必填'
213
+ return errors
214
+ }}
215
+ onSubmit={(values) => {
216
+ console.log(values)
217
+ }}
218
+ >
219
+ <FormInput name="name" label="姓名" required />
220
+ <FormInput name="email" label="邮箱" required />
221
+ <FormActions>
222
+ <Button type="submit">提交</Button>
223
+ </FormActions>
224
+ </Form>`}</code>
225
+ </pre>
226
+ </div>
227
+ </div>
228
+ </section>
229
+
230
+ {/* 更多资源 */}
231
+ <section className="bg-(--bg-primary) rounded-lg border border-(--border-light) p-6">
232
+ <h2 className="text-xl font-bold text-(--text-primary) mb-4">
233
+ 📚 更多资源
234
+ </h2>
235
+ <ul className="space-y-2 text-(--text-secondary)">
236
+ <li>
237
+ 📖 <a href="/components" className="text-(--slack-blue) hover:underline">
238
+ 查看完整组件展示
239
+ </a>
240
+ </li>
241
+ <li>
242
+ 📝 <a href="https://github.com" className="text-(--slack-blue) hover:underline">
243
+ 阅读详细文档
244
+ </a> (docs/ALERTDIALOG_AND_FORM_GUIDE.md)
245
+ </li>
246
+ <li>
247
+ ⚡️ <a href="https://github.com" className="text-(--slack-blue) hover:underline">
248
+ 快速参考
249
+ </a> (docs/QUICK_REFERENCE.md)
250
+ </li>
251
+ <li>
252
+ 🎯 <a href="https://github.com" className="text-(--slack-blue) hover:underline">
253
+ 最佳实践
254
+ </a> (CHANGELOG.md)
255
+ </li>
256
+ </ul>
257
+ </section>
258
+ </div>
259
+ </div>
260
+ )
261
+ }
262
+