* Upgrade Stimulus to 3.0 * Remove unused variable * Bump postcss from 8.3.8 to 8.3.9 (#14956) Bumps [postcss](https://github.com/postcss/postcss) from 8.3.8 to 8.3.9. - [Release notes](https://github.com/postcss/postcss/releases) - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) - [Commits](https://github.com/postcss/postcss/compare/8.3.8...8.3.9) --- updated-dependencies: - dependency-name: postcss dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
42 lines
1,012 B
JavaScript
42 lines
1,012 B
JavaScript
import { Controller } from '@hotwired/stimulus';
|
|
|
|
export default class ModalController extends Controller {
|
|
static values = {
|
|
rootSelector: String,
|
|
contentSelector: String,
|
|
title: String,
|
|
size: String,
|
|
};
|
|
|
|
async closeModal() {
|
|
const { render } = await import('preact');
|
|
const modalRoot = document.querySelector(this.rootSelectorValue);
|
|
|
|
render(null, modalRoot);
|
|
}
|
|
|
|
async toggleModal() {
|
|
const [{ Modal }, { render, h }] = await Promise.all([
|
|
import('@crayons/Modal'),
|
|
import('preact'),
|
|
]);
|
|
|
|
const modalRoot = document.querySelector(this.rootSelectorValue);
|
|
|
|
render(
|
|
<Modal
|
|
title={this.titleValue}
|
|
onClose={() => this.closeModal()}
|
|
size={this.sizeValue}
|
|
>
|
|
<div
|
|
// eslint-disable-next-line react/no-danger
|
|
dangerouslySetInnerHTML={{
|
|
__html: document.querySelector(this.contentSelectorValue).innerHTML,
|
|
}}
|
|
/>
|
|
</Modal>,
|
|
modalRoot,
|
|
);
|
|
}
|
|
}
|