|
|
@@ -91,7 +91,7 @@
|
|
|
// mini/src/pages/home/index.tsx
|
|
|
<View className="p-5 bg-white">
|
|
|
<Text className="text-[32rpx] font-bold text-gray-900">标题</Text>
|
|
|
- <Button className="bg-blue-500 text-white rounded-[8rpx] px-10 py-5">
|
|
|
+ <Button className="bg-primary text-white rounded-[8rpx] px-10 py-5">
|
|
|
按钮
|
|
|
</Button>
|
|
|
</View>
|
|
|
@@ -263,7 +263,7 @@ export default function HomePage() {
|
|
|
|
|
|
{/* 查询按钮 */}
|
|
|
<Button
|
|
|
- className="w-full bg-blue-500 text-white py-3 rounded-lg mt-6"
|
|
|
+ className="w-full bg-primary text-white py-3 rounded-lg mt-6"
|
|
|
onClick={handleSearch}
|
|
|
disabled={!startLocation || !endLocation}
|
|
|
>
|
|
|
@@ -930,6 +930,297 @@ module.exports = {
|
|
|
- [ ] 按钮交互效果相同
|
|
|
- [ ] 包车主题效果一致
|
|
|
|
|
|
+## Navbar 导航栏样式规范
|
|
|
+
|
|
|
+### 基础样式定义
|
|
|
+
|
|
|
+#### 高度和布局
|
|
|
+```css
|
|
|
+/* 导航栏总高度计算 */
|
|
|
+--navbar-height: 44px
|
|
|
+--status-bar-height: 系统状态栏高度
|
|
|
+--total-height: status-bar-height + navbar-height
|
|
|
+```
|
|
|
+
|
|
|
+#### 颜色系统
|
|
|
+```css
|
|
|
+/* 背景色 */
|
|
|
+--navbar-bg-default: #ffffff
|
|
|
+--navbar-bg-dark: #1a1a1a
|
|
|
+--navbar-bg-primary: #4A90C2
|
|
|
+--navbar-bg-transparent: transparent
|
|
|
+
|
|
|
+/* 文字色 */
|
|
|
+--navbar-text-default: #333333
|
|
|
+--navbar-text-light: #ffffff
|
|
|
+--navbar-text-primary: #ffffff
|
|
|
+```
|
|
|
+
|
|
|
+### 预设样式变体
|
|
|
+
|
|
|
+#### 默认导航栏
|
|
|
+```tsx
|
|
|
+// 样式配置
|
|
|
+{
|
|
|
+ backgroundColor: 'bg-white',
|
|
|
+ textColor: 'text-gray-900',
|
|
|
+ border: true,
|
|
|
+}
|
|
|
+
|
|
|
+// Tailwind 类名
|
|
|
+className="bg-white text-gray-900 border-b border-gray-200"
|
|
|
+```
|
|
|
+
|
|
|
+#### 深色导航栏
|
|
|
+```tsx
|
|
|
+// 样式配置
|
|
|
+{
|
|
|
+ backgroundColor: 'bg-gray-900',
|
|
|
+ textColor: 'text-white',
|
|
|
+ border: true,
|
|
|
+}
|
|
|
+
|
|
|
+// Tailwind 类名
|
|
|
+className="bg-gray-900 text-white border-b border-gray-700"
|
|
|
+```
|
|
|
+
|
|
|
+#### 透明导航栏
|
|
|
+```tsx
|
|
|
+// 样式配置
|
|
|
+{
|
|
|
+ backgroundColor: 'bg-transparent',
|
|
|
+ textColor: 'text-white',
|
|
|
+ border: false,
|
|
|
+}
|
|
|
+
|
|
|
+// Tailwind 类名
|
|
|
+className="bg-transparent text-white"
|
|
|
+```
|
|
|
+
|
|
|
+#### 主色调导航栏
|
|
|
+```tsx
|
|
|
+// 样式配置
|
|
|
+{
|
|
|
+ backgroundColor: 'bg-primary',
|
|
|
+ textColor: 'text-white',
|
|
|
+ border: false,
|
|
|
+}
|
|
|
+
|
|
|
+// Tailwind 类名
|
|
|
+className="bg-primary text-white"
|
|
|
+```
|
|
|
+
|
|
|
+### 平台适配规范
|
|
|
+
|
|
|
+#### 微信小程序
|
|
|
+```tsx
|
|
|
+// 高度计算
|
|
|
+const NAVBAR_HEIGHT = 44
|
|
|
+const STATUS_BAR_HEIGHT = systemInfo.statusBarHeight || 0
|
|
|
+const TOTAL_HEIGHT = STATUS_BAR_HEIGHT + NAVBAR_HEIGHT
|
|
|
+
|
|
|
+// 胶囊按钮避让
|
|
|
+const menuButtonInfo = Taro.getMenuButtonBoundingClientRect()
|
|
|
+const rightPosition = systemInfo.screenWidth - menuButtonInfo.left + 10
|
|
|
+
|
|
|
+// 标题宽度限制
|
|
|
+const titleMaxWidth = `calc(100% - ${rightPosition}px - 60px - 60px)`
|
|
|
+```
|
|
|
+
|
|
|
+#### H5 环境
|
|
|
+```tsx
|
|
|
+// 标准布局
|
|
|
+left: '12px' // left-3
|
|
|
+right: '12px' // right-3
|
|
|
+```
|
|
|
+
|
|
|
+### 使用示例
|
|
|
+
|
|
|
+#### 基础导航栏
|
|
|
+```tsx
|
|
|
+<Navbar
|
|
|
+ title="页面标题"
|
|
|
+ leftIcon="i-heroicons-chevron-left-20-solid"
|
|
|
+ rightText="完成"
|
|
|
+ onClickLeft={() => Taro.navigateBack()}
|
|
|
+ onClickRight={handleComplete}
|
|
|
+/>
|
|
|
+```
|
|
|
+
|
|
|
+#### 自定义样式导航栏
|
|
|
+```tsx
|
|
|
+<Navbar
|
|
|
+ title="个人中心"
|
|
|
+ backgroundColor="bg-gradient-to-r from-blue-500 to-purple-600"
|
|
|
+ textColor="text-white"
|
|
|
+ border={false}
|
|
|
+ rightIcon="i-heroicons-cog-6-tooth-20-solid"
|
|
|
+ onClickRight={handleSettings}
|
|
|
+/>
|
|
|
+```
|
|
|
+
|
|
|
+## Dialog 对话框样式规范
|
|
|
+
|
|
|
+### 基础样式定义
|
|
|
+
|
|
|
+#### 遮罩层
|
|
|
+```tsx
|
|
|
+// 遮罩样式
|
|
|
+className="fixed inset-0 z-50 flex items-center justify-center bg-black/50"
|
|
|
+```
|
|
|
+
|
|
|
+#### 对话框容器
|
|
|
+```tsx
|
|
|
+// 对话框基础样式
|
|
|
+className="relative bg-white rounded-lg shadow-lg max-w-md w-full mx-4"
|
|
|
+
|
|
|
+// 阴影系统
|
|
|
+--dialog-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)
|
|
|
+```
|
|
|
+
|
|
|
+### 组件结构样式
|
|
|
+
|
|
|
+#### DialogContent 内容区域
|
|
|
+```tsx
|
|
|
+// 基础内边距
|
|
|
+className="p-6"
|
|
|
+
|
|
|
+// 自定义样式
|
|
|
+className={cn("p-6", className)}
|
|
|
+```
|
|
|
+
|
|
|
+#### DialogHeader 头部区域
|
|
|
+```tsx
|
|
|
+// 底部外边距
|
|
|
+className="mb-4"
|
|
|
+
|
|
|
+// 自定义样式
|
|
|
+className={cn("mb-4", className)}
|
|
|
+```
|
|
|
+
|
|
|
+#### DialogTitle 标题
|
|
|
+```tsx
|
|
|
+// 标题样式
|
|
|
+className="text-lg font-semibold text-gray-900"
|
|
|
+
|
|
|
+// 自定义样式
|
|
|
+className={cn("text-lg font-semibold text-gray-900", className)}
|
|
|
+```
|
|
|
+
|
|
|
+#### DialogFooter 底部区域
|
|
|
+```tsx
|
|
|
+// 按钮布局
|
|
|
+className="flex justify-end space-x-2"
|
|
|
+
|
|
|
+// 自定义样式
|
|
|
+className={cn("flex justify-end space-x-2", className)}
|
|
|
+```
|
|
|
+
|
|
|
+### 预设变体样式
|
|
|
+
|
|
|
+#### 确认对话框
|
|
|
+```tsx
|
|
|
+<Dialog open={open} onOpenChange={setOpen}>
|
|
|
+ <DialogContent>
|
|
|
+ <DialogHeader>
|
|
|
+ <DialogTitle>确认操作</DialogTitle>
|
|
|
+ </DialogHeader>
|
|
|
+ <Text className="text-gray-600 mb-6">
|
|
|
+ 确定要执行此操作吗?
|
|
|
+ </Text>
|
|
|
+ <DialogFooter>
|
|
|
+ <Button variant="outline" onClick={() => setOpen(false)}>
|
|
|
+ 取消
|
|
|
+ </Button>
|
|
|
+ <Button onClick={handleConfirm}>
|
|
|
+ 确认
|
|
|
+ </Button>
|
|
|
+ </DialogFooter>
|
|
|
+ </DialogContent>
|
|
|
+</Dialog>
|
|
|
+```
|
|
|
+
|
|
|
+#### 表单对话框
|
|
|
+```tsx
|
|
|
+<Dialog open={open} onOpenChange={setOpen}>
|
|
|
+ <DialogContent className="max-w-lg">
|
|
|
+ <DialogHeader>
|
|
|
+ <DialogTitle>添加乘客</DialogTitle>
|
|
|
+ </DialogHeader>
|
|
|
+ <View className="space-y-4">
|
|
|
+ <Input placeholder="乘客姓名" />
|
|
|
+ <Input placeholder="手机号码" />
|
|
|
+ <Select>
|
|
|
+ <SelectTrigger>
|
|
|
+ <SelectValue placeholder="证件类型" />
|
|
|
+ </SelectTrigger>
|
|
|
+ <SelectContent>
|
|
|
+ <SelectItem value="idCard">身份证</SelectItem>
|
|
|
+ <SelectItem value="passport">护照</SelectItem>
|
|
|
+ </SelectContent>
|
|
|
+ </Select>
|
|
|
+ </View>
|
|
|
+ <DialogFooter>
|
|
|
+ <Button variant="outline" onClick={() => setOpen(false)}>
|
|
|
+ 取消
|
|
|
+ </Button>
|
|
|
+ <Button onClick={handleSubmit}>
|
|
|
+ 保存
|
|
|
+ </Button>
|
|
|
+ </DialogFooter>
|
|
|
+ </DialogContent>
|
|
|
+</Dialog>
|
|
|
+```
|
|
|
+
|
|
|
+#### 警告对话框
|
|
|
+```tsx
|
|
|
+<Dialog open={open} onOpenChange={setOpen}>
|
|
|
+ <DialogContent>
|
|
|
+ <DialogHeader>
|
|
|
+ <View className="flex items-center justify-center w-12 h-12 bg-red-100 rounded-full mb-4">
|
|
|
+ <Text className="i-heroicons-exclamation-triangle-20-solid w-6 h-6 text-red-600" />
|
|
|
+ </View>
|
|
|
+ <DialogTitle className="text-center">警告</DialogTitle>
|
|
|
+ </DialogHeader>
|
|
|
+ <Text className="text-gray-600 text-center mb-6">
|
|
|
+ 此操作不可撤销,请谨慎操作。
|
|
|
+ </Text>
|
|
|
+ <DialogFooter>
|
|
|
+ <Button variant="outline" onClick={() => setOpen(false)}>
|
|
|
+ 取消
|
|
|
+ </Button>
|
|
|
+ <Button variant="destructive" onClick={handleDelete}>
|
|
|
+ 删除
|
|
|
+ </Button>
|
|
|
+ </DialogFooter>
|
|
|
+ </DialogContent>
|
|
|
+</Dialog>
|
|
|
+```
|
|
|
+
|
|
|
+### 迁移指南
|
|
|
+
|
|
|
+#### Navbar 迁移
|
|
|
+```tsx
|
|
|
+// 原小程序
|
|
|
+<navigation-bar title="页面标题" background="#ffffff" />
|
|
|
+
|
|
|
+// 迁移后
|
|
|
+<Navbar title="页面标题" backgroundColor="bg-white" />
|
|
|
+```
|
|
|
+
|
|
|
+#### Dialog 迁移
|
|
|
+```tsx
|
|
|
+// 原小程序
|
|
|
+<modal visible={visible}>
|
|
|
+ <view class="modal-content">内容</view>
|
|
|
+</modal>
|
|
|
+
|
|
|
+// 迁移后
|
|
|
+<Dialog open={visible} onOpenChange={setVisible}>
|
|
|
+ <DialogContent>内容</DialogContent>
|
|
|
+</Dialog>
|
|
|
+```
|
|
|
+
|
|
|
---
|
|
|
|
|
|
**文档状态**: 正式版
|