Make modal width configurable
This commit is contained in:
1 parent
feba813b38
commit
ccf99fa310
4 files changed
+21
-5
No files matched your search
@@ -7,6 +7,22 @@ export default class ModalDialogComponent extends Component {
|
||||
@tracked currentComponent = this.args.initialComponent;
|
||||
@tracked componentProps = this.args.initialProps || {};
|
||||
|
||||
get maxWidthClass() {
|
||||
const widths = {
|
||||
'sm': 'sm:max-w-sm',
|
||||
'md': 'sm:max-w-md',
|
||||
'lg': 'sm:max-w-lg',
|
||||
'xl': 'sm:max-w-xl',
|
||||
'2xl': 'sm:max-w-2xl',
|
||||
'3xl': 'sm:max-w-3xl',
|
||||
'4xl': 'sm:max-w-4xl',
|
||||
'5xl': 'sm:max-w-5xl',
|
||||
'6xl': 'sm:max-w-6xl',
|
||||
'7xl': 'sm:max-w-7xl',
|
||||
};
|
||||
return widths[this.args.maxWidth || 'md'] || widths.md;
|
||||
}
|
||||
|
||||
@action
|
||||
switchComponent(component, props = {}) {
|
||||
this.currentComponent = component;
|
||||
@@ -26,9 +42,9 @@ export default class ModalDialogComponent extends Component {
|
||||
<dialog id={{@id}} aria-labelledby="dialog-title" class="fixed inset-0 size-auto max-h-none max-w-none overflow-y-auto bg-transparent backdrop:bg-transparent">
|
||||
<el-dialog-backdrop class="fixed inset-0 bg-neutral-950/75 transition-opacity data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in"></el-dialog-backdrop>
|
||||
<div tabindex="0" class="flex min-h-full items-end justify-center p-4 text-center focus:outline-none sm:items-center sm:p-0">
|
||||
<el-dialog-panel class="relative transform overflow-hidden rounded-lg bg-white px-4 pt-5 pb-4 text-left shadow-xl transition-all data-closed:translate-y-4 data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in sm:my-8 sm:w-full sm:max-w-sm sm:p-6 data-closed:sm:translate-y-0 data-closed:sm:scale-95">
|
||||
<el-dialog-panel class="relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all data-closed:translate-y-4 data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in sm:my-8 sm:w-full {{this.maxWidthClass}} data-closed:sm:translate-y-0 data-closed:sm:scale-95">
|
||||
{{#if this.currentComponent}}
|
||||
<this.currentComponent
|
||||
<this.currentComponent
|
||||
@switchComponent={{this.switchComponent}}
|
||||
@closeDialog={{this.closeDialog}}
|
||||
...attributes
|
||||
|
||||
@@ -5,7 +5,7 @@ import ModalStepTwo from './modal-step-two.gjs';
|
||||
|
||||
export default class ModalStepOneComponent extends Component {
|
||||
<template>
|
||||
<div>
|
||||
<div class="p-6">
|
||||
<h3 id="dialog-title" class="text-base font-semibold leading-6 text-gray-900">Step 1: Welcome</h3>
|
||||
<div class="mt-2">
|
||||
<p class="text-sm text-gray-500">
|
||||
|
||||
@@ -5,7 +5,7 @@ import ModalStepOne from './modal-step-one.gjs';
|
||||
|
||||
export default class ModalStepTwoComponent extends Component {
|
||||
<template>
|
||||
<div>
|
||||
<div class="p-6">
|
||||
<h3 id="dialog-title" class="text-base font-semibold leading-6 text-gray-900">Step 2: Configuration</h3>
|
||||
<div class="mt-2">
|
||||
<p class="text-sm text-gray-500">
|
||||
|
||||
@@ -30,7 +30,7 @@ export default class IndexRoute extends Component {
|
||||
|
||||
{{! Yielded content dialog }}
|
||||
<ModalDialog @id="modal-dialog-yield" as |modal|>
|
||||
<div>
|
||||
<div class="p-6">
|
||||
<h3 id="dialog-title" class="text-base font-semibold leading-6 text-gray-900">Simple Dialog</h3>
|
||||
<div class="mt-2">
|
||||
<p class="text-sm text-gray-500">
|
||||
|
||||
Reference in new issue
Block a user