diff --git a/.changeset/fix-modal-close-button.md b/.changeset/fix-modal-close-button.md new file mode 100644 index 00000000..71347bf5 --- /dev/null +++ b/.changeset/fix-modal-close-button.md @@ -0,0 +1,5 @@ +--- +"@ainsleydev/sveltekit-helper": patch +--- + +Ensuring the modal close button always renders independently of the title prop, controlled by a new `showClose` prop (defaults to `true`). diff --git a/packages/sveltekit-helper/src/components/Modal.svelte b/packages/sveltekit-helper/src/components/Modal.svelte index 6862e3e3..e011cd34 100644 --- a/packages/sveltekit-helper/src/components/Modal.svelte +++ b/packages/sveltekit-helper/src/components/Modal.svelte @@ -6,6 +6,7 @@ export type TransitionFn = (node: Element, params: Record) => T export type ModalProps = { title?: string; isOpen?: boolean; + showClose?: boolean; children?: Snippet; class?: string; onClose?: () => void; @@ -21,6 +22,7 @@ export type ModalProps = { let { title = '', isOpen = $bindable(false), + showClose = true, children, class: className = '', onClose, @@ -112,6 +114,16 @@ export type ModalProps = { - `--modal-content-padding`: Content padding (default: 1.5rem / 2rem on tablet) - `--modal-header-border`: Header bottom border (default: 1px solid var(--token-border-grey)) - `--modal-close-colour`: Close icon colour (default: var(--token-icon-grey)) + + Props: + - `title` (optional): Modal heading text. + - `isOpen` (bindable): Controls modal visibility. + - `showClose` (default: true): Whether to render the close button. + - `children`: Slot content (Snippet). + - `class`: Custom CSS class. + - `onClose`: Callback when the modal should close. + - `transition`: Custom transition function (default: fade). + - `transitionParams`: Transition parameters. --> {#if isOpen}