Skip to content
This repository was archived by the owner on Jan 9, 2022. It is now read-only.

Commit 4eb8941

Browse files
committed
feat: add cusomization for GDialogContent
- add customization for background - add customization for border-radius - set default white backgraund by default - make customization for each compnent by css vars
1 parent c9da180 commit 4eb8941

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

src/components/GDialog.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
:scrollable="scrollable"
2525
:depressed="depressed"
2626
:fullscreen="fullscreen"
27+
:background="background"
28+
:border-radius="borderRadius"
2729
>
2830
<slot />
2931
</GDialogContent>
@@ -53,6 +55,16 @@ export default defineComponent({
5355
},
5456
5557
props: {
58+
background: {
59+
type: [Boolean, String],
60+
default: true,
61+
},
62+
63+
borderRadius: {
64+
type: [Boolean, Number, String],
65+
default: true,
66+
},
67+
5668
contentClass: {
5769
type: String,
5870
default: '',

src/components/GDialogContent.vue

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,21 @@
77
<script lang="ts">
88
import { computed, defineComponent } from 'vue'
99
import { useSizeStyle } from '../composable/sizeStyle'
10+
import { convertToUnit } from '../helper'
1011
1112
export default defineComponent({
1213
name: 'GDialogContent',
1314
props: {
15+
background: {
16+
type: [Boolean, String],
17+
required: true,
18+
},
19+
20+
borderRadius: {
21+
type: [Boolean, Number, String],
22+
required: true,
23+
},
24+
1425
class: {
1526
type: String,
1627
default: '',
@@ -59,12 +70,37 @@ export default defineComponent({
5970
'g-dialog-content--scrollable': props.scrollable,
6071
'g-dialog-content--depressed': props.depressed,
6172
'g-dialog-content--fullscreen': props.fullscreen,
73+
'g-dialog-content--no-bg': props.background,
6274
},
6375
])
6476
77+
const computedBackground = computed(() => {
78+
if (typeof props.background === 'string') {
79+
return props.background
80+
} else if(props.background) {
81+
return 'var(--content-bg)'
82+
}
83+
84+
return 'transparent'
85+
})
86+
87+
const computedBorderRadius = computed(() => {
88+
if (typeof props.borderRadius === 'string') {
89+
return convertToUnit(props.borderRadius)
90+
} else if(props.borderRadius) {
91+
return 'var(--content-border-radius)'
92+
}
93+
94+
return '0'
95+
})
96+
97+
// const computedBorderRadius = computed(() => convertToUnit(props.borderRadius))
98+
6599
return {
66100
styles,
67101
classes,
102+
computedBackground,
103+
computedBorderRadius,
68104
}
69105
},
70106
})
@@ -74,11 +110,16 @@ export default defineComponent({
74110
.g-dialog-content {
75111
$dialog: &;
76112
113+
--content-bg: var(--g-dialog-content-bg, #fff);
114+
--content-border-radius: var(--g-dialog-content-border-radius, 4px);
115+
77116
pointer-events: auto;
78117
overflow-y: auto;
79118
transition: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
80119
width: 100%;
81120
z-index: inherit;
121+
background: v-bind('computedBackground');
122+
border-radius: v-bind('computedBorderRadius');
82123
83124
&:not(#{$dialog}--depressed) {
84125
box-shadow:
@@ -88,7 +129,6 @@ export default defineComponent({
88129
}
89130
90131
&:not(#{$dialog}--fullscreen) {
91-
border-radius: 4px;
92132
max-height: 90%;
93133
margin: 24px;
94134
}
@@ -99,6 +139,7 @@ export default defineComponent({
99139
100140
&--fullscreen {
101141
height: 100%;
142+
border-radius: 0;
102143
}
103144
}
104145
</style>

0 commit comments

Comments
 (0)