|
|
il y a 3 mois | |
|---|---|---|
| .. | ||
| components | il y a 3 mois | |
| README.md | il y a 3 mois | |
| global.less | il y a 3 mois | |
| layout-modes.less | il y a 3 mois | |
| mixins.less | il y a 3 mois | |
| theme.less | il y a 3 mois | |
src/style/
├── theme.less # 主题变量定义(CSS变量)
├── mixins.less # 公共样式mixins
├── global.less # 全局样式入口文件
├── layout-modes.less # 布局模式样式
├── components/ # 组件样式目录
│ ├── menu.less # 菜单组件样式
│ ├── button.less # 按钮组件样式
│ ├── table.less # 表格组件样式
│ ├── form.less # 表单组件样式
│ └── function-components.less # 功能组件样式
└── pages/ # 页面样式目录
├── homePage/
└── loginPage/
--bg-color: 页面主背景色(最深层)--component-background: 组件背景色(中间层)--sidebar-background: 侧边栏专用背景色(特殊用途)--drawer-bg: 抽屉背景色--modal-bg: 模态框背景色--dropdown-bg: 下拉菜单背景色--input-bg: 输入框背景色--table-header-bg: 表格头背景色--text-primary: 主要文字颜色--text-secondary: 次要文字颜色--text-disabled: 禁用文字颜色--text-color: 兼容性别名,指向 --text-primary--border-color-base: 基础边框颜色--border-color-split: 分割线颜色--divider-color: 分隔符颜色.hover-lift-effect() // 通用上浮hover效果
.hover-slide-effect() // 侧滑hover效果
.hover-scale-effect() // 缩放hover效果
.base-card() // 基础卡片样式
.base-list-item() // 列表项基础样式
.drawer-gradient-header() // 抽屉渐变头部
.drawer-content-base() // 抽屉内容基础样式
.input-base() // 输入框基础样式
.action-button-base() // 操作按钮基础样式
.action-button-theme() // 操作按钮主题色
.menu-item-base() // 菜单项基础样式
.menu-item-hover() // 菜单项hover效果
.menu-item-active() // 菜单项激活效果
// ✅ 推荐:语义化命名
.message-item {
// 样式定义
}
// ❌ 避免:缩写或无意义命名
.msg-itm {
// 样式定义
}
// ✅ 推荐:适度嵌套(不超过3层)
.dark-theme {
.ant-table {
.table-action-bar {
// 样式定义
}
}
}
// ❌ 避免:过深嵌套
.dark-theme .ant-table .table-action-bar .action-buttons .action-btn {
// 样式定义
}
// ✅ 推荐:使用CSS变量
background-color: var(--component-background);
// ❌ 避免:硬编码颜色
background-color: #1f1f1f;
// === 大段落注释 ===
// 用于标识主要功能模块
// 小段落注释
// 用于解释特定样式的作用
/*
* 多行注释
* 用于详细说明复杂逻辑
*/
// ✅ 推荐:完整的主题适配
.dark-theme {
.component {
background-color: var(--component-background);
color: var(--text-primary);
border-color: var(--border-color-base);
}
}
// ✅ 推荐:使用mixins进行响应式设计
.component {
.responsive(md; {
// 中等屏幕样式
});
}
// ✅ 推荐:使用预定义的动画mixin
.card {
.hover-lift-effect();
}
// ✅ 推荐:使用适度的特异性
.dark-theme .ant-component {
property: value !important;
}
// ❌ 避免:过度使用!important
.component {
property: value !important !important;
}
// ❌ 避免:重复的样式定义
.component-a {
background: var(--component-background);
border-radius: 8px;
transition: all 0.3s ease;
}
.component-b {
background: var(--component-background);
border-radius: 8px;
transition: all 0.3s ease;
}
// ✅ 推荐:使用mixin提取公共样式
.base-component {
background: var(--component-background);
border-radius: 8px;
transition: all 0.3s ease;
}
.component-a {
.base-component();
}
.component-b {
.base-component();
}
// ❌ 避免:过深的嵌套
.page {
.container {
.content {
.section {
.item {
// 样式定义
}
}
}
}
}
// ✅ 推荐:扁平化结构
.page-item {
// 样式定义
}
// ❌ 避免:硬编码的颜色和尺寸
.component {
background-color: #1f1f1f;
padding: 16px;
margin: 8px;
}
// ✅ 推荐:使用变量和标准化尺寸
.component {
background-color: var(--component-background);
padding: @spacing-md;
margin: @spacing-sm;
}
最后更新: 202-08-27 维护者: BearJia Team