Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modal - add backdrop class customization #2181

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion site/content/docs/standard/components/modal/a.html
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,21 @@ <h4 class="mt-4 font-bold">Via JavaScript</h4>
<tbody>
<tr
class="border-b bg-neutral-100 dark:border-neutral-500 dark:bg-neutral-700">
<td
class="border-r px-6 py-4 font-medium dark:border-neutral-500 max-lg:whitespace-nowrap">
<code>backdrop</code>
</td>
<td
class="border-r px-6 py-4 dark:border-neutral-500 max-lg:whitespace-nowrap">
opacity-50 transition-all duration-300 ease-in-out
fixed top-0 left-0 z-[1040] bg-black w-screen h-screen
</td>
<td class="px-6 py-4 max-lg:whitespace-nowrap">
Sets styles for the backdrop.
</td>
</tr>
<tr
class="border-b bg-white dark:border-neutral-500 dark:bg-neutral-600">
<td
class="border-r px-6 py-4 font-medium dark:border-neutral-500 max-lg:whitespace-nowrap">
<code>static</code>
Expand All @@ -372,7 +387,7 @@ <h4 class="mt-4 font-bold">Via JavaScript</h4>
</td>
</tr>
<tr
class="border-b bg-white dark:border-neutral-500 dark:bg-neutral-600">
class="border-b bg-neutral-100 dark:border-neutral-500 dark:bg-neutral-700">
<td
class="border-r px-6 py-4 font-medium dark:border-neutral-500 max-lg:whitespace-nowrap">
<code>staticProperties</code>
Expand Down
4 changes: 4 additions & 0 deletions src/js/components/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ const DefaultClasses = {
show: "transform-none",
static: "scale-[1.02]",
staticProperties: "transition-scale duration-300 ease-in-out",
backdrop:
"opacity-50 transition-all duration-300 ease-in-out fixed top-0 left-0 z-[1040] bg-black w-screen h-screen",
};

const DefaultClassesType = {
show: "string",
static: "string",
staticProperties: "string",
backdrop: "string",
};

const EVENT_HIDE = `hide${EVENT_KEY}`;
Expand Down Expand Up @@ -216,6 +219,7 @@ class Modal extends BaseComponent {
return new Backdrop({
isVisible: Boolean(this._config.backdrop), // 'static' option will be translated to true, and booleans will keep their value
isAnimated: this._isAnimated(),
backdropClasses: this._classes.backdrop,
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/js/util/backdrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const DefaultType = {
isAnimated: "boolean",
rootElement: "(element|string)",
clickCallback: "(function|null)",
backdropClasses: "(array|null)",
backdropClasses: "(array|string|null)",
};
const NAME = "backdrop";
const EVENT_MOUSEDOWN = `mousedown.te.${NAME}`;
Expand Down