2019-02-28 08:00:59 +00:00
< script >
import bus from '../../bus';
import { tintColor } from '../../color.js';
const varMap = {
'primary': '$--color-primary',
'success': '$--color-success',
'warning': '$--color-warning',
'danger': '$--color-danger',
'info': '$--color-info',
'white': '$--color-white',
'black': '$--color-black',
'textPrimary': '$--color-text-primary',
'textRegular': '$--color-text-regular',
'textSecondary': '$--color-text-secondary',
'textPlaceholder': '$--color-text-placeholder',
'borderBase': '$--border-color-base',
'borderLight': '$--border-color-light',
'borderLighter': '$--border-color-lighter',
'borderExtraLight': '$--border-color-extra-light'
};
const original = {
primary: '#409EFF',
success: '#67C23A',
warning: '#E6A23C',
danger: '#F56C6C',
info: '#909399',
white: '#FFFFFF',
black: '#000000',
textPrimary: '#303133',
textRegular: '#606266',
textSecondary: '#909399',
textPlaceholder: '#C0C4CC',
borderBase: '#DCDFE6',
borderLight: '#E4E7ED',
borderLighter: '#EBEEF5',
borderExtraLight: '#F2F6FC'
}
export default {
created() {
bus.$on('user-theme-config-update', this.setGlobal);
},
mounted() {
this.setGlobal();
},
methods: {
tintColor(color, tint) {
return tintColor(color, tint);
},
setGlobal() {
if (window.userThemeConfig) {
this.global = window.userThemeConfig.global;
}
}
},
data() {
return {
global: {},
primary: '',
success: '',
warning: '',
danger: '',
info: '',
white: '',
black: '',
textPrimary: '',
textRegular: '',
textSecondary: '',
textPlaceholder: '',
borderBase: '',
borderLight: '',
borderLighter: '',
borderExtraLight: ''
}
},
watch: {
global: {
immediate: true,
handler(value) {
Object.keys(original).forEach((o) => {
if (value[varMap[o]]) {
this[o] = value[varMap[o]]
} else {
this[o] = original[o]
}
});
}
}
},
}
< / script >
2017-11-06 11:22:02 +00:00
< style >
.demo-color-box {
2019-02-28 08:00:59 +00:00
position: relative;
2017-11-06 11:22:02 +00:00
border-radius: 4px;
padding: 20px;
2018-03-05 03:01:27 +00:00
margin: 5px 0;
2019-02-28 08:00:59 +00:00
height: 114px;
2017-11-06 11:22:02 +00:00
box-sizing: border-box;
color: #fff ;
font-size: 14px;
2019-02-28 08:00:59 +00:00
2017-11-06 11:22:02 +00:00
& .value {
font-size: 12px;
opacity: 0.69;
line-height: 24px;
}
}
2019-02-28 08:00:59 +00:00
.demo-color-box-other {
height: 74px;
margin: 10px 0!important;
border-radius: 4px 4px 4px 4px!important;
padding: 15px 20px;
}
2017-11-06 11:22:02 +00:00
.demo-color-box-group {
.demo-color-box {
border-radius: 0;
2018-03-05 03:01:27 +00:00
margin: 0;
2017-11-06 11:22:02 +00:00
}
.demo-color-box:first-child {
border-radius: 4px 4px 0 0;
}
.demo-color-box:last-child {
border-radius: 0 0 4px 4px;
}
}
2019-02-28 08:00:59 +00:00
.bg-color-sub {
width: 100%;
height: 40px;
left: 0;
bottom: 0;
position: absolute;
border-radius: 0 0 4px 4px;
2017-11-06 11:22:02 +00:00
}
2019-02-28 08:00:59 +00:00
.bg-blue-sub-item {
width: 11.1111111%;
height: 100%;
display: inline-block;
2017-11-06 11:22:02 +00:00
}
2019-02-28 08:00:59 +00:00
.bg-blue-sub-item:first-child {
border-radius: 0 0 0 4px;
2017-11-06 11:22:02 +00:00
}
2019-02-28 08:00:59 +00:00
.bg-success-sub-item {
width: 50%;
height: 100%;
display: inline-block;
2017-11-06 11:22:02 +00:00
}
2019-02-28 08:00:59 +00:00
.bg-success-sub-item:first-child {
border-radius: 0 0 0 4px;
2017-11-06 11:22:02 +00:00
}
2019-02-28 08:00:59 +00:00
.bg-success-sub-item:last-child {
border-radius: 0 0 4px 0;
2017-11-06 11:22:02 +00:00
}
2019-02-28 08:00:59 +00:00
.bg-transparent {
border: 1px solid #FCC3C3 ;
color: #303133 ;
background: url("data:image/svg+xml;utf8,< svg xmlns = 'http://www.w3.org/2000/svg' version = '1.1' preserveAspectRatio = 'none' viewBox = '0 0 100 100' > < path d = 'M0 98 L100 0 L100 1 L1 98' fill = '%23FCC3C3' / > < / svg > ");
background-repeat:no-repeat;
background-position:center center;
background-size: 100% 100%, auto;
2017-11-06 11:22:02 +00:00
}
2019-02-28 08:00:59 +00:00
.demo-color-box-lite {
2017-12-12 04:45:09 +00:00
color: #303133 ;
2017-11-06 11:22:02 +00:00
}
< / style >
## Color
2017-11-08 06:19:52 +00:00
Element utiliza un conjunto de paletas para especificar colores, y así, proporcionar una apariencia y sensación coherente para los productos que construye.
2017-11-06 11:22:02 +00:00
2017-11-08 06:19:52 +00:00
### Color principal
2017-11-06 11:22:02 +00:00
2017-11-08 06:19:52 +00:00
El color principal de Element es el azul brillante y amigable.
2017-11-06 11:22:02 +00:00
< el-row :gutter = "12" >
2019-02-28 08:00:59 +00:00
< el-col :span = "10" :xs = "{span: 12}" >
< div
class="demo-color-box"
:style="{ background: primary }"
>
Brand Color< div class = "value" > #409EFF< / div >
< div
class="bg-color-sub"
:style="{ background: tintColor(primary, 0.9) }"
>
< div
class="bg-blue-sub-item"
v-for="(item, key) in Array(8)"
:key="key"
:style="{ background: tintColor(primary, (key + 1) / 10) }"
>
< / div >
< / div >
2017-11-06 11:22:02 +00:00
< / el-col >
< / el-row >
2017-11-08 06:19:52 +00:00
### Color secundario
2017-11-06 11:22:02 +00:00
2017-12-03 10:03:06 +00:00
Además del color principal, se necesitan utilizar distintos colores para diferentes escenarios (por ejemplo, el color en tono rojo indica una operación peligrosa).
2017-11-06 11:22:02 +00:00
< el-row :gutter = "12" >
2018-03-05 03:01:27 +00:00
< el-col :span = "6" :xs = "{span: 12}" >
2019-02-28 08:00:59 +00:00
< div class = "demo-color-box"
:style="{ background: success }"
>Success< div class = "value" > #67C23A< / div >
< div
class="bg-color-sub"
>
< div
class="bg-success-sub-item"
v-for="(item, key) in Array(2)"
:key="key"
:style="{ background: tintColor(success, (key + 8) / 10) }"
>
< / div >
< / div >
< / div >
2017-11-06 11:22:02 +00:00
< / el-col >
2018-03-05 03:01:27 +00:00
< el-col :span = "6" :xs = "{span: 12}" >
2019-02-28 08:00:59 +00:00
< div class = "demo-color-box"
:style="{ background: warning }"
>Warning< div class = "value" > #E6A23C< / div >
< div
class="bg-color-sub"
>
< div
class="bg-success-sub-item"
v-for="(item, key) in Array(2)"
:key="key"
:style="{ background: tintColor(warning, (key + 8) / 10) }"
>
< / div >
< / div >
< / div >
2017-11-06 11:22:02 +00:00
< / el-col >
2018-03-05 03:01:27 +00:00
< el-col :span = "6" :xs = "{span: 12}" >
2019-02-28 08:00:59 +00:00
< div class = "demo-color-box"
:style="{ background: danger }"
>Danger< div class = "value" > #F56C6C< / div >
< div
class="bg-color-sub"
>
< div
class="bg-success-sub-item"
v-for="(item, key) in Array(2)"
:key="key"
:style="{ background: tintColor(danger, (key + 8) / 10) }"
>
< / div >
< / div >
< / div >
2017-11-06 11:22:02 +00:00
< / el-col >
2018-03-05 03:01:27 +00:00
< el-col :span = "6" :xs = "{span: 12}" >
2019-02-28 08:00:59 +00:00
< div class = "demo-color-box"
:style="{ background: info }"
>Info< div class = "value" > #909399< / div >
< div
class="bg-color-sub"
>
< div
class="bg-success-sub-item"
v-for="(item, key) in Array(2)"
:key="key"
:style="{ background: tintColor(info, (key + 8) / 10) }"
>
< / div >
< / div >
< / div >
2017-11-06 11:22:02 +00:00
< / el-col >
< / el-row >
2017-11-08 06:19:52 +00:00
### Color neutro
2017-11-06 11:22:02 +00:00
2017-12-03 10:03:06 +00:00
Los colores neutrales son para texto, fondos y bordes. Puede usar diferentes colores neutrales para representar una estructura jeráquica.
2017-11-06 11:22:02 +00:00
< el-row :gutter = "12" >
2018-03-05 03:01:27 +00:00
< el-col :span = "6" :xs = "{span: 12}" >
2017-11-06 11:22:02 +00:00
< div class = "demo-color-box-group" >
2019-02-28 08:00:59 +00:00
< div class = "demo-color-box demo-color-box-other"
:style="{ background: textPrimary }"
>Texto primario< div class = "value" > {{textPrimary}}< / div > < / div >
< div class = "demo-color-box demo-color-box-other"
:style="{ background: textRegular }"
>
Texto regular< div class = "value" > {{textRegular}}< / div > < / div >
< div class = "demo-color-box demo-color-box-other"
:style="{ background: textSecondary }"
>Texto secundario< div class = "value" > {{textSecondary}}< / div > < / div >
< div class = "demo-color-box demo-color-box-other"
:style="{ background: textPlaceholder }"
>Texto de placeholder< div class = "value" > {{textPlaceholder}}< / div > < / div >
< / div >
< / el-col >
< el-col :span = "6" :xs = "{span: 12}" >
< div class = "demo-color-box-group" >
< div class = "demo-color-box demo-color-box-other demo-color-box-lite"
:style="{ background: borderBase }"
>Borde base< div class = "value" > {{borderBase}}< / div > < / div >
< div class = "demo-color-box demo-color-box-other demo-color-box-lite"
:style="{ background: borderLight }"
>Borde ligero< div class = "value" > {{borderLight}}< / div > < / div >
< div class = "demo-color-box demo-color-box-other demo-color-box-lite"
:style="{ background: borderLighter }"
>Borde claro< div class = "value" > {{borderLighter}}< / div > < / div >
< div class = "demo-color-box demo-color-box-other demo-color-box-lite"
:style="{ background: borderExtraLight }"
>Borde extra claro< div class = "value" > {{borderExtraLight}}< / div > < / div >
2017-11-06 11:22:02 +00:00
< / div >
< / el-col >
2018-03-05 03:01:27 +00:00
< el-col :span = "6" :xs = "{span: 12}" >
2017-11-06 11:22:02 +00:00
< div class = "demo-color-box-group" >
2019-02-28 08:00:59 +00:00
< div
class="demo-color-box demo-color-box-other"
:style="{ background: black }"
>Basic Black< div class = "value" > {{black}}< / div > < / div >
< div
class="demo-color-box demo-color-box-other"
:style="{ background: white, color: '#303133', border: '1px solid #eee ' }"
>Basic White< div class = "value" > {{white}}< / div > < / div >
< div class = "demo-color-box demo-color-box-other bg-transparent" > Transparent< div class = "value" > Transparent< / div >
2017-11-06 11:22:02 +00:00
< / div >
< / el-col >
2018-03-05 03:01:27 +00:00
< / el-row >