update modals
This commit is contained in:
@ -35,12 +35,18 @@ export class DeesModal extends DeesElement {
|
||||
heading: string;
|
||||
content: TemplateResult;
|
||||
menuOptions: plugins.tsclass.website.IMenuItem<DeesModal>[];
|
||||
width?: 'small' | 'medium' | 'large' | 'fullscreen' | number;
|
||||
maxWidth?: number;
|
||||
minWidth?: number;
|
||||
}) {
|
||||
const body = document.body;
|
||||
const modal = new DeesModal();
|
||||
modal.heading = optionsArg.heading;
|
||||
modal.content = optionsArg.content;
|
||||
modal.menuOptions = optionsArg.menuOptions;
|
||||
if (optionsArg.width) modal.width = optionsArg.width;
|
||||
if (optionsArg.maxWidth) modal.maxWidth = optionsArg.maxWidth;
|
||||
if (optionsArg.minWidth) modal.minWidth = optionsArg.minWidth;
|
||||
modal.windowLayer = await DeesWindowLayer.createAndShow({
|
||||
blur: true,
|
||||
});
|
||||
@ -49,6 +55,7 @@ export class DeesModal extends DeesElement {
|
||||
});
|
||||
body.append(modal.windowLayer);
|
||||
body.append(modal);
|
||||
return modal;
|
||||
}
|
||||
|
||||
// INSTANCE
|
||||
@ -64,6 +71,15 @@ export class DeesModal extends DeesElement {
|
||||
@state({})
|
||||
public menuOptions: plugins.tsclass.website.IMenuItem<DeesModal>[] = [];
|
||||
|
||||
@property({ type: String })
|
||||
public width: 'small' | 'medium' | 'large' | 'fullscreen' | number = 'medium';
|
||||
|
||||
@property({ type: Number })
|
||||
public maxWidth: number;
|
||||
|
||||
@property({ type: Number })
|
||||
public minWidth: number;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
@ -92,7 +108,6 @@ export class DeesModal extends DeesElement {
|
||||
will-change: transform;
|
||||
transform: translateY(0px) scale(0.95);
|
||||
opacity: 0;
|
||||
width: 480px;
|
||||
min-height: 120px;
|
||||
background: ${cssManager.bdTheme('#ffffff', '#111')};
|
||||
border-radius: 8px;
|
||||
@ -100,6 +115,33 @@ export class DeesModal extends DeesElement {
|
||||
transition: all 0.2s;
|
||||
overflow: hidden;
|
||||
box-shadow: ${cssManager.bdTheme('0px 2px 10px rgba(0, 0, 0, 0.1)', '0px 2px 5px rgba(0, 0, 0, 0.5)')};
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
/* Width variations */
|
||||
.modal.width-small {
|
||||
width: 380px;
|
||||
}
|
||||
|
||||
.modal.width-medium {
|
||||
width: 560px;
|
||||
}
|
||||
|
||||
.modal.width-large {
|
||||
width: 800px;
|
||||
}
|
||||
|
||||
.modal.width-fullscreen {
|
||||
width: calc(100vw - 40px);
|
||||
height: calc(100vh - 40px);
|
||||
max-height: calc(100vh - 40px);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.modal {
|
||||
width: calc(100vw - 40px) !important;
|
||||
max-width: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.modal.show {
|
||||
@ -130,26 +172,22 @@ export class DeesModal extends DeesElement {
|
||||
flex-direction: row;
|
||||
border-top: 1px solid ${cssManager.bdTheme('#e0e0e0', '#333')};
|
||||
justify-content: flex-end;
|
||||
gap: 8px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.modal .bottomButtons .bottomButton {
|
||||
margin: 8px 0px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 4px;
|
||||
padding: 8px 16px;
|
||||
border-radius: 6px;
|
||||
line-height: 16px;
|
||||
text-align: center;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
transition: all 0.2s;
|
||||
background: ${cssManager.bdTheme('rgba(0, 0, 0, 0.05)', 'rgba(255, 255, 255, 0.05)')};
|
||||
}
|
||||
|
||||
.modal .bottomButtons .bottomButton:first-child {
|
||||
margin-left: 8px;
|
||||
}
|
||||
.modal .bottomButtons .bottomButton:last-child {
|
||||
margin-right: 8px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.modal .bottomButtons .bottomButton:hover {
|
||||
@ -178,25 +216,32 @@ export class DeesModal extends DeesElement {
|
||||
];
|
||||
|
||||
public render(): TemplateResult {
|
||||
const widthClass = typeof this.width === 'string' ? `width-${this.width}` : '';
|
||||
const customWidth = typeof this.width === 'number' ? `${this.width}px` : '';
|
||||
const maxWidthStyle = this.maxWidth ? `${this.maxWidth}px` : '';
|
||||
const minWidthStyle = this.minWidth ? `${this.minWidth}px` : '';
|
||||
|
||||
return html`
|
||||
<style>
|
||||
.modal .bottomButtons {
|
||||
grid-template-columns: ${cssManager.cssGridColumns(this.menuOptions.length, 0)};
|
||||
}
|
||||
${customWidth ? `.modal { width: ${customWidth}; }` : ''}
|
||||
${maxWidthStyle ? `.modal { max-width: ${maxWidthStyle}; }` : ''}
|
||||
${minWidthStyle ? `.modal { min-width: ${minWidthStyle}; }` : ''}
|
||||
</style>
|
||||
<div class="modalContainer" @click=${this.handleOutsideClick}>
|
||||
<div class="modal">
|
||||
<div class="modal ${widthClass}">
|
||||
<div class="heading">${this.heading}</div>
|
||||
<div class="content">${this.content}</div>
|
||||
<div class="bottomButtons">
|
||||
${this.menuOptions.map(
|
||||
(actionArg, index) => html`
|
||||
<div class="bottomButton ${index === this.menuOptions.length - 1 ? 'primary' : ''} ${actionArg.name === 'OK' ? 'ok' : ''}" @click=${() => {
|
||||
actionArg.action(this);
|
||||
}}>${actionArg.name}</div>
|
||||
`
|
||||
)}
|
||||
</div>
|
||||
${this.menuOptions.length > 0 ? html`
|
||||
<div class="bottomButtons">
|
||||
${this.menuOptions.map(
|
||||
(actionArg, index) => html`
|
||||
<div class="bottomButton ${index === this.menuOptions.length - 1 ? 'primary' : ''} ${actionArg.name === 'OK' ? 'ok' : ''}" @click=${() => {
|
||||
actionArg.action(this);
|
||||
}}>${actionArg.name}</div>
|
||||
`
|
||||
)}
|
||||
</div>
|
||||
` : ''}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
Reference in New Issue
Block a user