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

fix: MDS-966 Modal add className and fix big content examples #2550

Merged
merged 4 commits into from
Feb 16, 2024
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
2 changes: 1 addition & 1 deletion next-docs/public/examples/modal/BigContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Example = () => {
<Button onClick={openModal}>Open dialog</Button>
<Modal open={isOpen} onClose={closeModal}>
<Modal.Backdrop />
<Modal.Panel>
<Modal.Panel className="max-h-[calc(100vh-150px)] overflow-scroll">
<div className="p-4 border-b-2 border-beerus">
<h3 className="text-moon-18 text-bulma font-medium">
Payment successful
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Object {
class="flex min-h-full items-center justify-center p-4"
>
<div
class="w-full max-w-sm inline-block rounded-xl bg-goku align-middle shadow-moon-lg transition-all transition duration-300 ease-out transform scale-95 opacity-0"
class="w-full max-w-sm inline-block rounded-xl bg-goku align-middle shadow-moon-lg transition-all max-h-[calc(100vh-150px)] overflow-scroll transition duration-300 ease-out transform scale-95 opacity-0"
data-headlessui-state="open"
id="headlessui-dialog-panel-:rk:"
>
Expand Down Expand Up @@ -1037,7 +1037,7 @@ Object {
class="flex min-h-full items-center justify-center p-4"
>
<div
class="w-full max-w-sm inline-block rounded-xl bg-goku align-middle shadow-moon-lg transition-all transition duration-300 ease-out transform scale-95 opacity-0"
class="w-full max-w-sm inline-block rounded-xl bg-goku align-middle shadow-moon-lg transition-all max-h-[calc(100vh-150px)] overflow-scroll transition duration-300 ease-out transform scale-95 opacity-0"
data-headlessui-state="open"
id="headlessui-dialog-panel-:r3:"
>
Expand Down
13 changes: 10 additions & 3 deletions workspaces/core/src/modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type ModalRootProps = {
open: boolean;
onClose: () => void;
initialFocus?: React.MutableRefObject<HTMLElement | null>;
className?: string;
};

type ModalComponentProps = (
Expand All @@ -26,6 +27,7 @@ const ModalRoot: ModalComponentProps = ({
onClose,
children,
initialFocus,
className
}) => {
const defFocus = useRef(null);
const [focusElRef, setFocusElRef] =
Expand All @@ -37,7 +39,7 @@ const ModalRoot: ModalComponentProps = ({
<Transition appear show={open} as={React.Fragment}>
<Dialog
as="div"
className="relative z-10"
className={mergeClassnames("relative z-10", className)}
onClose={onClose}
initialFocus={focusElRef}
>
Expand Down Expand Up @@ -75,8 +77,13 @@ const Panel = ({ children, className }: WithChildren<PanelProps>) => (
</div>
);

const Title = ({ children }: { children?: ReactNode }) => (
<Dialog.Title as="h3" className="text-moon-18 font-medium text-gray-900">
type TitleProps = {
children?: ReactNode;
className?: string;
}

const Title = ({ children, className }: TitleProps) => (
<Dialog.Title as="h3" className={mergeClassnames("text-moon-18 font-medium text-gray-900", className)}>
{children}
</Dialog.Title>
);
Expand Down
Loading