style(components): add css var width & margin-top for dialog (#3431)

This commit is contained in:
云游君 2021-09-16 23:01:22 +08:00 committed by GitHub
parent c17161e21c
commit fb22634b61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 8 deletions

View File

@ -62,7 +62,6 @@ export const dialogProps = {
},
top: {
type: String,
default: '15vh',
},
modelValue: {
type: Boolean,
@ -71,7 +70,6 @@ export const dialogProps = {
modalClass: String,
width: buildProp<string | number>({
type: [String, Number],
default: '50%',
validator: isValidWidthUnit,
}),
zIndex: {

View File

@ -29,9 +29,14 @@ export const useDialog = (
const style = computed<CSSProperties>(() => {
const style: CSSProperties = {}
const varPrefix = `--el-dialog`
if (!props.fullscreen) {
style.marginTop = props.top
if (props.width) style.width = normalizeWidth.value
if (props.top) {
style[`${varPrefix}-margin-top`] = props.top
}
if (props.width) {
style[`${varPrefix}-width`] = normalizeWidth.value
}
}
return style
})

View File

@ -643,6 +643,8 @@ $--switch: map.merge(
$--dialog: () !default;
$--dialog: map.merge(
(
'width': 50%,
'margin-top': 15vh,
'background-color': var(--el-color-white),
'box-shadow': 0 1px 3px rgba(0, 0, 0, 0.3),
'title-font-size': var(--el-font-size-large),

View File

@ -10,16 +10,16 @@
@include set-component-css-var('dialog', $--dialog);
position: relative;
margin: 0 auto 50px;
margin: var(--el-dialog-margin-top, 15vh) auto 50px;
background: var(--el-dialog-background-color);
border-radius: var(--el-border-radius-small);
box-shadow: var(--el-dialog-box-shadow);
box-sizing: border-box;
width: 50%;
width: var(--el-dialog-width, 50%);
@include when(fullscreen) {
width: 100%;
margin-top: 0;
--el-dialog-width: 100%;
--el-dialog-margin-top: 0;
margin-bottom: 0;
height: 100%;
overflow: auto;