Skip to content

Commit

Permalink
feat(ui/dialog): add width props (#718)
Browse files Browse the repository at this point in the history
  • Loading branch information
2b0x authored Oct 9, 2022
1 parent a3ff191 commit 916ee21
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/varlet-ui/src/dialog/Dialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
@route-change="onRouteChange"
@click-overlay="handleClickOverlay"
>
<div :class="classes('var--box', n(), dialogClass)" :style="dialogStyle" v-bind="$attrs">
<div
:class="classes('var--box', n(), dialogClass)"
:style="{ ...dialogStyle, width: toSizeUnit(dialogWidth) }"
v-bind="$attrs"
>
<div :class="n('title')">
<slot name="title">{{ dt(title, pack.dialogTitle) }}</slot>
</div>
Expand Down Expand Up @@ -62,6 +66,7 @@ import { dt } from '../utils/shared'
import { pack } from '../locale'
import type { Ref } from 'vue'
import { call, createNamespace } from '../utils/components'
import { toSizeUnit } from '../utils/elements'
const { n, classes } = createNamespace('dialog')
Expand Down Expand Up @@ -153,6 +158,7 @@ export default defineComponent({
handleClickOverlay,
confirm,
cancel,
toSizeUnit,
}
},
})
Expand Down
2 changes: 2 additions & 0 deletions packages/varlet-ui/src/dialog/example/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const actions = {
const createBasic = () =>
Dialog({
message: pack.value.message,
dialogWidth: 220,
})
const createAction = async () => actions[await Dialog(pack.value.message)]()
Expand Down Expand Up @@ -82,6 +83,7 @@ watchDarkMode(dark)
v-model:show="show"
:title="pack.title"
:message="pack.message"
dialog-width="220"
@confirm="() => Snackbar.success('confirm')"
@cancel="() => Snackbar.error('cancel')"
@closed="() => Snackbar.info('closed')"
Expand Down
3 changes: 3 additions & 0 deletions packages/varlet-ui/src/dialog/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export const props = {
dialogStyle: {
type: Object,
},
dialogWidth: {
type: [Number, String],
},
...pickProps(popupProps, [
'overlay',
'overlayClass',
Expand Down

0 comments on commit 916ee21

Please sign in to comment.