[ng-alain系列]工具类规则

工具类规则

ng-alain 在 Ant Design 的基础上生产一套尺寸、间距、颜色等工具类。

尺寸

我认为这些工具类只会运用在内容区域,因此,按 Ant Design 的规范,尺寸的宽度是以一个 8px Gutter 基础间距为基础;并衍生出三个尺寸,分别为:

名称公式尺寸说明
sm$gutter8px小号
md$gutter * 216px中号
lg$gutter * 324px大号

依这些尺寸规则,衍生出尺寸微调整的类,这些类包括 marginpadding,其命名规则如下。

类型包括:paddingmargin

方向包括:toprightbottomleftxleftright)、ytopbottom);方向为可选。

消除

[<类型>p|m][<方向>t|r|b|l|x|y]?0

基础

[<类型>p|m][<方向>t|r|b|l|x|y]?-[<尺寸>sm|md|lg]

示例:

.p-sm { padding: 8px !important; }
.pt-sm { padding-top: 8px !important; }
.m-sm { margin: 16px !important; }
.mt-md { margin-top: 16px !important; }

.p0 { padding: 0 !important; }

色彩

Ant Design 并没有按钮色这一说,而是以视觉效果为基准。nz-button 包括四种类型:primarydashed 等。但 primary 是固定的蓝色系列,这是默认色系。

ng-alain 依然不会破坏这种规则,但依 色彩 章节,我产生了一种运用于文本、背景的色系类。

色彩一共有十种,前九种依色彩为准,以及新增一种 teal【#20c997】 (别问我为什么,我就喜欢偶数而已),分别如下:

名称基本色说明
red#f04134热情、警示
green#00a854成功、通过、安全
blue#108ee9专业、科技
pink#f5317f典雅、明快、女性
orange#f56a00醒目、温暖
purple#7265e6高雅、浪漫
yellow#ffbf00活力、提示
cyan#00a2ae清新、冷静、结构化
grey#bfbfbf平稳、中性
teal#20c997

这些色彩会衍生出 10 种渐变色,然而每一种渐变色要想产生一个有效的命名(10 * 10)非常困难。因此,我只衍生三种颜色规则,分别为:

名称色号
light5号
normal6号
dark7号

然后依以下规则产生:

类型包括:textbackground-colorbackground-color:hover

[<类型>text|bg]-[<色彩名>red|green|blue|pink|orange|purple|yellow|cyan|teal|grey](-[light|dark])?(-h)?

normal 本身即是基本色,所以实际无须加上 normal

grey 可能会更常用,因此,除了 grey-lightgrey-dark 额外增加了 grey-lightergrey-darker 表示更浅深度。

示例:

// Text color
.text-red-light { color: #fabeb9 !important; }
.text-red { color: #f04134 !important; }
.text-red-dark { color: #a31837 !important; }

// background-color color
.bg-red-light { background-color: #fabeb9 !important; }
.bg-red { background-color: #f04134 !important; }
.bg-red-dark { background-color: #a31837 !important; }

// hover color
.bg-red-light-h { &:hover { background-color: #fabeb9 !important; } }
.bg-red-h { &:hover { background-color: #f04134 !important; } }
.bg-red-dark-h { &:hover { background-color: #a31837 !important; } }

别名

实际上 Ant Design 提供一套类似 bootstrap 的命名方式的别名规则。只是,我们无法使用到这里内置的而已,这些别名包括:

别名色系
primaryblue
successgreen
errorred
warningyellow

进而,我将取转化成文本与背景,其命名规则同上面一样,只是将色彩名变成为别名而已。

示例:

// Text color
.text-error-light { color: #fabeb9 !important; }
.text-error { color: #f04134 !important; }
.text-error-dark { color: #a31837 !important; }

// background-color color
.bg-error-light { background-color: #fabeb9 !important; }
.bg-error { background-color: #f04134 !important; }
.bg-error-dark { background-color: #a31837 !important; }

// hover color
.bg-error-light-h { &:hover { background-color: #fabeb9 !important; } }
.bg-error-h { &:hover { background-color: #f04134 !important; } }
.bg-error-dark-h { &:hover { background-color: #a31837 !important; } }

Clearfix

ng-zoroo-antd 自带清除浮动 .clearfix

Display

别名CSS
d-nonedisplay: none
d-blockdisplay: block
d-inline-blockdisplay: inline-block
d-flexdisplay: flex
d-inline-flexdisplay: inline-flex

Float

名称说明
fixed-top顶部
fixed-bottom底部

Text

Sizing

Ant Design 是以 12px 为基准字号。

名称说明
text-sm12px
text-md24px
text-lg36px

Alignment

名称说明
text-left文本居左
text-center文本居中
text-right文本居右

Wrapping

**容器必须是 display: inline-blockdisplay: block

名称说明
text-nowrap文本超出不换行
text-truncate文本超出截取并加 ...

Transformation

名称说明
text-lowercase小写文本
text-uppercase大写文本
text-capitalize首词大写
text-deleted删除线

Weight and italics

名称说明
font-weight-normalfont-weight: normal
font-weight-boldfont-weight: 700
font-italicfont-style: italic

Borders

边框

名称说明
borderborder: 1px solid #f5f5f5 !important;
border-0border: 0 !important;
border-top-0border-top: 0 !important;
border-right-0border-right: 0 !important;
border-bottom-0border-bottom: 0 !important;
border-left-0border-left: 0 !important;

颜色

支持色彩章节所有的色系&别名写法,例如:border-redborder-success

圆角

名称说明
rounded-0border-radius: 0;
rounded-circleborder-radius: 50%;
rounded-smborder-radius: 2px;
rounded-mdborder-radius: 4px;
rounded-lgborder-radius: 6px;

Width

名称说明
width-sm160px
width-md240px
width-lg320px

Responsive

类似 Bootstrap 响应式规则,当屏幕小于 480px 时会隐藏所有 hidden-xs 类。

名称屏幕
hidden-xs<480px
hidden-sm<768px
hidden-md<992px
hidden-lg<1200px

Other

名称说明
block-centermargin: 0 auto
pointcursor: pointer
no-resize设置不允许调整元素
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值