0.5.0 • Published 5 years ago

wya-sass v0.5.0

Weekly downloads
29
License
MIT
Repository
github
Last release
5 years ago

wya-sass

npm changelog

npm install --save wya-sass

1. 准则

2. 文件目录

3. 命名规范

4. 使用方式

5. 样式输出

准则

  1. 以flex布局为主,栅格布局、固定布局、流体布局,绝对定位布局,浮动布局等为辅的一套css样式表。
  2. 常见的flex布局和flex单个属性类。
  3. 辅助布局类。

文件目录

  • themes 定义公共的变量
    • color.scss 颜色变量
    • default.scss 全局变量
  • mixins 定义公共的方法
    • animate.scss 动画
    • common.scss 公共方法
  • core 输出全局的样式
    • globals.scss 定义全局变量的方法
    • reset.scss 输出reset样式
    • animate.scss 输出动画
    • flex.scss 输出flex布局
    • layout.scss 输出全局变量
    • pc pc模块样式
    • mobile 手机模块样式

命名规范

  • 全局命名以 g- 开头
  • 模块命名以 v- 开头 1. 外层:以 v- 开头, v-(路由简写)-(组件模块), 例如: v-home-header; 2. 内层:以_ 开头, _(模块), 例如: _tab;
  • 公共组件命名以 c- 开头 1. 外层:以 c- 开头, c-(弹层功能)-(结构), 例如: c-addr-header; 2. 内层:以__ 开头, __(模块), 例如: __tab;

使用方法

在需要引用公共变量的时候,一般里面可以去改变全局的颜色,边距,单位等变量。

  @import "../themes/default"; // 公共变量

在需要引用公共方法的时候,可以去调用全局定义的方法,例如:@include commonScale(100px)

  @import "../mixins/common"; // 公共方法

在需要引用动画方法的时候,定义了例如: @keyframes animate-fadeIn 淡入等动画。

  @import "../mixins/animate"; // 公共动画

样式输出

百分比布局

class备注关键代码
.g-flexflex布局display: flex
.g-col占一位flex: 1
.g-col-2占两位flex: 2
.g-full铺满flex: 0 0 100%
.g-1of2占50%flex: 0 0 50%
.g-1of3占1/3flex: 0 0 33.33333333%
.g-2of3占2/3flex: 0 0 66.66666666%
.g-1of4占1/4flex: 0 0 25%
.g-3of4占3/4flex: 0 0 75%
.g-1of5占1/5flex: 0 0 20%
.g-2of5占2/5flex: 0 0 40%
.g-3of5占3/5flex: 0 0 60%
.g-4of5占4/5flex: 0 0 80%

基本网格布局

class备注
.g-flex-grid-3三列
.g-flex-grid-4四列
.g-flex-grid-5五列
.g-flex-grid-6六列

圣杯布局

class备注
.g-flex-holy

输入框的布局

<div class="g-flex">
	<label></label>
	<input class="g-col" />
	<button></button>
</div>

悬挂式布局

<div class="g-flex g-ai-fs">
  <img class="g-m-r" src="" alt="">
  <p class="g-col"></p>
</div>

对齐

class备注关键代码
.g-flex-cc水平垂直居中justify-content: center; align-items: center
.g-flex-ac垂直居中align-items: center

flex单个属性类 以g-(属性名首字母)-(属性值首字母) 命名

class备注关键代码
.g-fd-c主轴为垂直方向,起点在上flex-direction: column
.g-fd-cr主轴为垂直方向,倒序flex-direction: column-reverse
.g-fd-r主轴为水平方向,起点在左flex-direction: row
.g-fd-rr主轴为水平方向,起点在右flex-direction: row-reverse
.g-fw-w换行,第一行在上方。flex-wrap: wrap
.g-fw-wr换行,第一行在下方。flex-wrap: wrap-reverse
.g-fw-n不换行flex-wrap: nowrap
.g-jc-fs位于容器的开头justify-content: flex-start
.g-jc-fe位于容器的结尾justify-content: flex-end
.g-jc-c位于容器的中心justify-content: center
.g-jc-sb两端对齐, 间隔相等justify-content: space-between
.g-jc-sa间隔相等justify-content: space-around
.g-ai-fs侧轴方向, 位于容器的开头, 主轴方向排列align-items: flex-start
.g-ai-fe侧轴方向, 位于容器的结尾, 主轴方向排列align-items: flex-end
.g-ai-c侧轴方向, 位于容器的中心, 主轴方向排列align-items: center
.g-ai-b侧轴方向, 位于容器的基线上, 主轴方向排列align-items: baseline
.g-ai-s侧轴方向, 元素被拉伸以适应容器, 主轴方向排列align-items: stretch
.g-ac-fs侧轴方向, 元素位于容器的开头, 侧轴方向排列align-content: flex-start
.g-ac-fe侧轴方向,元素位于容器的结尾, 侧轴方向排列align-content: flex-end
.g-ac-sb两端对齐, 间隔相等, 侧轴方向排列align-content: space-between
.g-ac-sa间隔相等, 侧轴方向排列align-content: space-around
.g-ac-s元素被拉伸以适应容器, 剩余空间被所有行平分, 以扩大它们的侧轴尺寸align-content: stretch
.g-as-fsflex子项在侧轴方向上的对齐方式: 位于容器的开头align-self: flex-start
.g-as-feflex子项在侧轴方向上的对齐方式: 位于容器的结尾align-self: flex-end
.g-as-a默认值,继承了它的父容器的 align-items 属性。如果没有父容器则为 "stretch"align-self: auto
.g-as-b元素位于容器的基线上align-self: baseline
.g-as-cflex子项在侧轴方向上的对齐方式: 元素位于容器的中心align-self: center
.g-as-s元素被拉伸以适应容器align-self: stretch

color g-c-(颜色/变量) 颜色效果可在MarkDown编辑器中查看

class备注颜色效果
.g-c-blue-dark#0b76feblue-dark
.g-c-blue-mid#16a3ffblue-mid
.g-c-blue-light#6ab4ffblue-light
.g-c-yellow-dark#f2c300yellow-dark
.g-c-yellow-mid#ffd00dyellow-mid
.g-c-yellow-light#ffd31cyellow-light
.g-c-orange-dark#ef3528orange-dark
.g-c-orange-mid#fa6f60orange-mid
.g-c-orange-light#fc9780orange-light
.g-c-gray-dark#edeef0gray-dark
.g-c-gray-mid#f5f6f7gray-mid
.g-c-gray-light#f7f8fagray-light
.g-c-black-dark#2e3136black-dark
.g-c-black-mid#636770black-mid
.g-c-black-light#9c9fa6black-light
.g-c-purple-dark#8b61f3purple-dark
.g-c-purple-mid#a48efcpurple-mid
.g-c-purple-light#cca3ffpurple-light
.g-c-black#000black
.g-c-white#fffwhite

bgColor g-bg-(颜色/变量) 颜色效果可在MarkDown编辑器中查看

class备注颜色效果
.g-bg-blue-dark#0b76fe
.g-bg-blue-mid#16a3ff
.g-bg-blue-light#6ab4ff
.g-bg-yellow-dark#f2c300
.g-bg-yellow-mid#ffd00d
.g-bg-yellow-light#ffd31c
.g-bg-orange-dark#ef3528
.g-bg-orange-mid#fa6f60
.g-bg-orange-light#fc9780
.g-bg-gray-dark#edeef0
.g-bg-gray-mid#f5f6f7
.g-bg-gray-light#f7f8fa
.g-bg-black-dark#2e3136
.g-bg-black-mid#636770
.g-bg-black-light#9c9fa6
.g-bg-purple-dark#8b61f3
.g-bg-purple-mid#a48efc
.g-bg-purple-light#cca3ff
.g-bg-black#000
.g-bg-white#fff

font-size g-fs-(字号)

class备注
.g-fs-10font-size: 10px
.g-fs-12font-size: 12px
.g-fs-14font-size: 14px
.g-fs-16font-size: 16px
.g-fs-18font-size: 18px
.g-fs-20font-size: 20px
.g-fs-22font-size: 22px
.g-fs-24font-size: 24px
.g-fs-26font-size: 26px
.g-fs-28font-size: 28px
.g-fs-30font-size: 30px
.g-fs-32font-size: 32px
.g-fs-34font-size: 34px
.g-fs-36font-size: 36px
.g-fs-38font-size: 38px
.g-fs-40font-size: 40px
.g-fs-48font-size: 48px
.g-fs-50font-size: 50px
.g-fs-60font-size: 60px
.g-fs-70font-size: 70px
.g-fs-80font-size: 80px
.g-fs-90font-size: 90px
.g-fs-100font-size: 100px

line-height g-lh-(值)

class备注
.g-lh-16line-height: 16px
.g-lh-18line-height: 18px
.g-lh-20line-height: 20px
.g-lh-22line-height: 22px
.g-lh-24line-height: 24px
.g-lh-26line-height: 26px
.g-lh-28line-height: 28px
.g-lh-30line-height: 30px
.g-lh-32line-height: 32px
.g-lh-34line-height: 34px
.g-lh-36line-height: 36px
.g-lh-38line-height: 38px
.g-lh-40line-height: 40px
.g-lh-42line-height: 42px
.g-lh-44line-height: 44px
.g-lh-60line-height: 60px
.g-lh-72line-height: 72px
.g-lh-80line-height: 80px
.g-lh-88line-height: 88px
.g-lh-120line-height: 120px

padding g-pd-(方向)?-(值/变量)

class备注
.g-pd-5padding: 5px
.g-pd-10padding: 10px
.g-pd-15padding: 15px
.g-pd-20padding: 20px
.g-pd-25padding: 25px
.g-pd-30padding: 30px
.g-pd-tb-5padding-top: 5px; padding-bottom: 5px
.g-pd-tb-10padding-top: 10px; padding-bottom: 10px
.g-pd-tb-15padding-top: 15px; padding-bottom: 15px
.g-pd-tb-20padding-top: 20px; padding-bottom: 20px
.g-pd-tb-25padding-top: 25px; padding-bottom: 25px
.g-pd-tb-30padding-top: 30px; padding-bottom: 30px
.g-pd-lr-5padding-left: 5px; padding-right: 5px
.g-pd-lr-10padding-left: 10px; padding-right: 10px
.g-pd-lr-15padding-left: 15px; padding-right: 15px
.g-pd-lr-20padding-left: 20px; padding-right: 20px
.g-pd-lr-25padding-left: 25px; padding-right: 25px
.g-pd-lr-30padding-left: 30px; padding-right: 30px
.g-pd-t-5padding-top: 5px
.g-pd-t-10padding-top: 10px
.g-pd-t-15padding-top: 15px
.g-pd-t-20padding-top: 20px
.g-pd-t-25padding-top: 25px
.g-pd-t-30padding-top: 30px
.g-pd-l-5padding-left: 5px
.g-pd-l-10padding-left: 10px
.g-pd-l-15padding-left: 15px
.g-pd-l-20padding-left: 20px
.g-pd-l-25padding-left: 25px
.g-pd-l-30padding-left: 30px
.g-pd-b-5padding-bottom: 5px
.g-pd-b-10padding-bottom: 10px
.g-pd-b-15padding-bottom: 15px
.g-pd-b-20padding-bottom: 20px
.g-pd-b-25padding-bottom: 25px
.g-pd-b-30padding-bottom: 30px
.g-pd-r-5padding-right: 5px
.g-pd-r-10padding-right: 10px
.g-pd-r-15padding-right: 15px
.g-pd-r-20padding-right: 20px
.g-pd-r-25padding-right: 25px
.g-pd-r-30padding-right: 30px

margin g-m-(方向)?-(值/变量)

class备注
.g-m-5margin: 5px
.g-m-10margin: 10px
.g-m-15margin: 15px
.g-m-20margin: 20px
.g-m-25margin: 25px
.g-m-30margin: 30px
.g-m-tb-5margin-top: 5px; margin-bottom: 5px
.g-m-tb-10margin-top: 10px; margin-bottom: 10px
.g-m-tb-15margin-top: 15px; margin-bottom: 15px
.g-m-tb-20margin-top: 20px; margin-bottom: 20px
.g-m-tb-25margin-top: 25px; margin-bottom: 25px
.g-m-tb-30margin-top: 30px; margin-bottom: 30px
.g-m-lr-5margin-left: 5px; margin-right: 5px
.g-m-lr-10margin-left: 10px; margin-right: 10px
.g-m-lr-15margin-left: 15px; margin-right: 15px
.g-m-lr-20margin-left: 20px; margin-right: 20px
.g-m-lr-25margin-left: 25px; margin-right: 25px
.g-m-lr-30margin-left: 30px; margin-right: 30px
.g-m-t-5margin-top: 5px
.g-m-t-10margin-top: 10px
.g-m-t-15margin-top: 15px
.g-m-t-20margin-top: 20px
.g-m-t-25margin-top: 25px
.g-m-t-30margin-top: 30px
.g-m-l-5margin-left: 5px
.g-m-l-10margin-left: 10px
.g-m-l-15margin-left: 15px
.g-m-l-20margin-left: 20px
.g-m-l-25margin-left: 25px
.g-m-l-30margin-left: 30px
.g-m-b-5margin-bottom: 5px
.g-m-b-10margin-bottom: 10px
.g-m-b-15margin-bottom: 15px
.g-m-b-20margin-bottom: 20px
.g-m-b-25margin-bottom: 25px
.g-m-b-30margin-bottom: 30px
.g-m-r-5margin-right: 5px
.g-m-r-10margin-right: 10px
.g-m-r-15margin-right: 15px
.g-m-r-20margin-right: 20px
.g-m-r-25margin-right: 25px
.g-m-r-30margin-right: 30px

img大小 g-img-(值)

class备注
.g-img-40长宽40px
.g-img-46长宽46px
.g-img-50长宽50px
.g-img-60长宽60px
.g-img-70长宽70px
.g-img-76长宽76px
.g-img-80长宽80px
.g-img-100长宽100px
.g-img-120长宽120px
.g-img-140长宽140px
.g-img-160长宽160px
class备注
.g-row
.g-w-(number)12>= number >=1
.g-fw-(number)12>= number >=1 float:left;
class备注
.g-fixed固定定位
.g-relative绝对定位
.g-absolute相对定位
class备注
.g-clearfix清除浮动
.g-fr右浮
.g-fl左浮

1像素边框

class备注
.g-b1像素边框
.g-bb1像素下(border-bottom)边框
.g-br1像素右(border-right)边框
.g-bl1像素左(border-left)边框
.g-bt1像素上(border-top)边框

文本

class备注
.g-tc居中
.g-tl居左
.g-tr居右
.g-td-lh删除线
.g-td-ul下划线
.g-nowrap不换行
.g-nobreak字母数字不换行

其他

class备注
.g-h-fullheight: 100vh;
.g-br-circleborder-radius: 100%;
.g-br-sem默认圆角 (8px)
.g-bs边框阴影
.g-disabled禁用事件
.g-noanimate禁用动画
.g-show, .g-block, .g-dp-bdisplay: block
.g-dp-n, .g-hide, .g-nonedisplacy: none
.g-dp-i, .g-inlinedisplay: inline
.g-dp-ib, .g-inline-blockdisplay: inline-block
.g-pointercursor: pointer
.g-divide分割线
.g-dot5像素的点
.g-of-hoverflow: hidden
.g-oneline单行省略
.g-twoline两行省略
.g-one-lh行高32px, 高度64px
.g-two-lh行高32px, 高度32px
.g-operation点击文字按钮样式
.g-disabled无点击事件
class备注
.g-popup-down向下弹出 height:50%
.g-popup-up向上弹出 height:50%
.g-popup-left向左弹出 height:50%
.g-popup-right向右弹出 height:50%
.g-bg-mask遮罩层
.g-modal居中弹窗
0.5.0

5 years ago

0.4.3

5 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.9

6 years ago

0.2.8

6 years ago

0.2.7

6 years ago

0.2.6

6 years ago

0.2.5

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago