Skip to content

Commit

Permalink
Modal - add backdrop class customization (#2181)
Browse files Browse the repository at this point in the history
  • Loading branch information
juujisai authored Nov 30, 2023
1 parent 206a0f2 commit f0f3552
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
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

0 comments on commit f0f3552

Please sign in to comment.