[breaking change] rebuild style struct (#2021)

This commit is contained in:
neverland
2018-11-03 21:08:06 +08:00
committed by GitHub
parent a5576762d8
commit 11ce2a602f
165 changed files with 1371 additions and 4729 deletions
+61
View File
@@ -0,0 +1,61 @@
@keyframes van-slide-bottom-enter {
from {
transform: translate3d(0, 100%, 0);
}
}
@keyframes van-slide-bottom-leave {
to {
transform: translate3d(0, 100%, 0);
}
}
@keyframes van-fade-in {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes van-fade-out {
from {
opacity: 1;
}
to {
opacity: 0;
}
}
@keyframes van-rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.van-fade {
&-enter-active {
animation: .3s van-fade-in;
}
&-leave-active {
animation: .3s van-fade-out;
}
}
.van-slide-bottom {
&-enter-active {
animation: van-slide-bottom-enter .3s both ease;
}
&-leave-active {
animation: van-slide-bottom-leave .3s both ease;
}
}
+16
View File
@@ -0,0 +1,16 @@
/**
* Entry of basic styles
*/
@import './var';
@import './normalize';
@import './ellipsis';
@import './clearfix';
@import './hairline';
@import './animation';
@import '../info/index';
@import '../icon/index';
@import '../loading/index';
@import '../button/index';
@import '../cell/index';
@import '../cell-group/index';
+5
View File
@@ -0,0 +1,5 @@
@import './mixins/clearfix';
.van-clearfix {
.clearfix();
}
+85
View File
@@ -0,0 +1,85 @@
<template>
<demo-section>
<demo-block :title="$t('ellipsis')">
<div class="van-ellipsis">{{ $t('text') }}</div>
</demo-block>
<demo-block :title="$t('hairline')">
<div class="van-hairline--top" />
</demo-block>
<demo-block :title="$t('animation')">
<van-switch-cell v-model="show" :title="$t('toggle')" :border="false" />
<van-row>
<transition name="van-fade">
<van-col span="8" v-show="show">Fade</van-col>
</transition>
<transition name="van-slide-bottom">
<van-col span="8" v-show="show">Slide Bottom</van-col>
</transition>
</van-row>
</demo-block>
</demo-section>
</template>
<script>
export default {
i18n: {
'zh-CN': {
hairline: '1px 边框',
ellipsis: '文字省略',
animation: '动画',
toggle: '切换动画',
text: '这是一段宽度限制 250px 的文字,后面的内容会省略'
},
'en-US': {
hairline: 'Hairline',
ellipsis: 'Text Ellipsis',
animation: 'Animation',
toggle: 'Switch animation',
text: 'This is a paragraph of 250px width limit, the back will be omitted.'
}
},
data() {
return {
show: true
};
}
};
</script>
<style lang="less">
.demo-style {
.van-ellipsis {
font-size: 13px;
margin-left: 15px;
max-width: 250px;
}
.van-hairline--top {
height: 30px;
background-color: #fff;
&::after {
top: 5px;
}
}
.van-col {
height: 50px;
color: #fff;
font-size: 14px;
border-radius: 3px;
text-align: center;
line-height: 50px;
margin-left: 15px;
background-color: #39a9ed;
}
.van-switch-cell {
margin-bottom: 15px;
}
}
</style>
+5
View File
@@ -0,0 +1,5 @@
@import './mixins/ellipsis';
.van-ellipsis {
.ellipsis();
}
+48
View File
@@ -0,0 +1,48 @@
## Built-in Style
Vant contains some common styles that can be used directly by the className.
### Text ellipsis
When the text content length exceeds the maximum container width, the excess text is automatically omitted.
```html
<div class="van-ellipsis">
This is a paragraph of 250px width limit, the back will be omitted.
</div>
```
### Hairline
Add 1px border under the Retina screen for the element, based on a pseudo element.
```html
<!-- border top -->
<div class="van-hairline--top"></div>
<!-- border bottom -->
<div class="van-hairline--bottom"></div>
<!-- border left -->
<div class="van-hairline--left"></div>
<!-- border right -->
<div class="van-hairline--right"></div>
<!-- border top & bottom -->
<div class="van-hairline--top-bottom"></div>
<!-- full border -->
<div class="van-hairline--surround"></div>
```
### Animation
```html
<!-- fade in -->
<transition name="van-fade">
<div v-show="visible">Fade</div>
</transition>
<!-- slide bottom -->
<transition name="van-slide-bottom">
<div v-show="visible">Fade</div>
</transition>
```
+35
View File
@@ -0,0 +1,35 @@
@import './mixins/hairline';
[class*='van-hairline'] {
position: relative;
&::after {
.hairline();
}
}
.van-hairline {
&--top::after {
border-top-width: 1px;
}
&--left::after {
border-left-width: 1px;
}
&--right::after {
border-right-width: 1px;
}
&--bottom::after {
border-bottom-width: 1px;
}
&--top-bottom::after {
border-width: 1px 0;
}
&--surround::after {
border-width: 1px;
}
}
+7
View File
@@ -0,0 +1,7 @@
.clearfix() {
&::after {
content: '';
display: table;
clear: both;
}
}
+14
View File
@@ -0,0 +1,14 @@
.multi-ellipsis(@lines) {
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: @lines;
/* autoprefixer: ignore next */
-webkit-box-orient: vertical;
}
.ellipsis() {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
+27
View File
@@ -0,0 +1,27 @@
.hairline-common() {
content: ' ';
position: absolute;
pointer-events: none;
box-sizing: border-box;
}
.hairline(@border-color: #eee) {
.hairline-common();
top: -50%;
left: -50%;
right: -50%;
bottom: -50%;
transform: scale(0.5);
border: 0 solid @border-color;
}
.hairline-bottom(@border-color: #eee, @left: 0) {
.hairline-common();
left: @left;
right: 0;
bottom: 0;
transform: scaleY(0.5);
border-bottom: 1px solid @border-color;
}
+38
View File
@@ -0,0 +1,38 @@
/**
* 基本样式入口
*/
html {
-webkit-tap-highlight-color: transparent;
}
body {
margin: 0;
}
a {
text-decoration: none;
}
a,
input,
button,
textarea {
&:focus {
outline: none;
}
}
ol,
ul {
margin: 0;
padding: 0;
list-style: none;
}
input,
button,
textarea {
font: inherit;
color: inherit;
}
+172
View File
@@ -0,0 +1,172 @@
@import './var';
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
vertical-align: baseline;
}
html {
line-height: 1;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
ol,
ul {
list-style: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
caption,
th,
td {
font-weight: normal;
vertical-align: middle;
}
q,
blockquote {
quotes: none;
}
q::before,
q::after,
blockquote::before,
blockquote::after {
content: '';
content: none;
}
a img {
border: none;
}
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section,
summary {
display: block;
}
* {
box-sizing: content-box;
}
body {
font-family: Arial, Helvetica, 'STHeiti STXihei', 'Microsoft YaHei', Tohoma, sans-serif;
color: @text-color;
background-color: @background-color;
}
a {
background: transparent;
text-decoration: none;
}
button,
input[type='number'],
input[type='text'],
input[type='password'],
input[type='email'],
input[type='search'],
select,
textarea {
font-family: inherit;
margin: 0;
-webkit-appearance: none;
}
+54
View File
@@ -0,0 +1,54 @@
// color variables
@black: #000;
@white: #fff;
@red: #f44;
@blue: #1989fa;
@orange: #ff976a;
@orange-dark: #ed6a0c;
@orange-light: #fffbe8;
@green: #4b0;
@gray: #c9c9c9;
@gray-light: #e5e5e5;
@gray-darker: #666;
@gray-dark: #999;
// default colors
@text-color: #333;
@border-color: #eee;
@active-color: #e8e8e8;
@background-color: #f8f8f8;
@background-color-light: #fafafa;
// button
@button-default-color: @text-color;
@button-default-background-color: @white;
@button-default-border-color: @border-color;
@button-primary-color: @white;
@button-primary-background-color: @green;
@button-primary-border-color: @green;
@button-danger-color: @white;
@button-danger-background-color: @red;
@button-danger-border-color: @red;
@button-warning-color: @white;
@button-warning-background-color: @orange;
@button-warning-border-color: @orange;
@button-bottom-action-default-color: @white;
@button-bottom-action-default-background-color: @orange;
@button-bottom-action-primary-color: @white;
@button-bottom-action-primary-background-color: @red;
// checkbox
@van-checkbox-size: 20px;
// radio
@van-radio-size: 20px;
// swipe
@van-swipe-indicator: 6px;
// tab
@van-tabs-line-height: 44px;
@van-tabs-card-height: 30px;
// number keyboard
@van-number-keyboard-key-height: 54px;
+47
View File
@@ -0,0 +1,47 @@
## 内置样式
Vant 中默认包含了一些常用样式,可以直接通过 className 的方式使用。
### 文字省略
当文本内容长度超过容器最大宽度时,自动省略多余的文本。
```html
<div class="van-ellipsis">这是一段宽度限制 250px 的文字,后面的内容会省略</div>
```
### 1px 边框
为元素添加 Retina 屏幕下的 1px 边框(即 hairline),基于伪类 transform 实现。
```html
<!-- 上边框 -->
<div class="van-hairline--top"></div>
<!-- 下边框 -->
<div class="van-hairline--bottom"></div>
<!-- 左边框 -->
<div class="van-hairline--left"></div>
<!-- 右边框 -->
<div class="van-hairline--right"></div>
<!-- 上下边框 -->
<div class="van-hairline--top-bottom"></div>
<!-- 全边框 -->
<div class="van-hairline--surround"></div>
```
### 动画
可以通过 `transition` 组件使用内置的动画
```html
<!-- 淡入 -->
<transition name="van-fade">
<div v-show="visible">Fade</div>
</transition>
<!-- 下滑 -->
<transition name="van-slide-bottom">
<div v-show="visible">Fade</div>
</transition>
```