mirror of
https://github.com/ElemeFE/element.git
synced 2025-12-16 11:44:01 +08:00
3.2 KiB
3.2 KiB
<script>
import bus from '../../bus';
import { ACTION_USER_CONFIG_UPDATE } from '../../components/theme/constant.js';
const varMap = {
'$--box-shadow-light': 'boxShadowLight',
'$--box-shadow-base': 'boxShadowBase',
'$--border-radius-base': 'borderRadiusBase',
'$--border-radius-small': 'borderRadiusSmall'
};
const original = {
boxShadowLight: '0 2px 12px 0 rgba(0, 0, 0, 0.1)',
boxShadowBase: '0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)',
borderRadiusBase: '4px',
borderRadiusSmall: '2px'
}
export default {
created() {
bus.$on(ACTION_USER_CONFIG_UPDATE, this.setGlobal);
},
mounted() {
this.setGlobal();
},
methods: {
setGlobal() {
if (window.userThemeConfig) {
this.global = window.userThemeConfig.global;
}
}
},
data() {
return {
global: {},
boxShadowLight: '',
boxShadowBase: '',
borderRadiusBase: '',
borderRadiusSmall: ''
}
},
watch: {
global: {
immediate: true,
handler(value) {
Object.keys(varMap).forEach((c) => {
if (value[c]) {
this[varMap[c]] = value[c]
} else {
this[varMap[c]] = original[varMap[c]]
}
});
}
}
}
}
</script>
Border
We standardize the borders that can be used in buttons, cards, pop-ups and other components.
Border
There are few border styles to choose.
| Name | Thickness | Demo |
| Solid | 1px | |
| Dashed | 2px |
Radius
There are few radius styles to choose.
No Radius
border-radius: 0px
Small Radius
border-radius: {{borderRadiusSmall}}
Large Radius
border-radius: {{borderRadiusBase}}
Round Radius
border-radius: 30px
Shadow
There are few shadow styles to choose.
Basic Shadow box-shadow: {{boxShadowBase}} Light Shadow box-shadow: {{boxShadowLight}}