Skip to content

Commit

Permalink
feat(Modal): modal component with basic functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
YossiSaadi committed Sep 5, 2024
1 parent 8a4cbb6 commit 5dc52ba
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/core/src/components/ModalNew/Modal/Modal.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.overlay {
position: fixed;
inset: 0;
background-color: rgba(41, 47, 76, 0.7);
}

.modal {
position: relative;
display: flex;
flex-direction: column;
background-color: var(--primary-background-color);
}
52 changes: 52 additions & 0 deletions packages/core/src/components/ModalNew/Modal/Modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React, { forwardRef } from "react";
import cx from "classnames";
import { getTestId } from "../../../tests/test-ids-utils";
import { ComponentDefaultTestId } from "../../../tests/constants";
import styles from "./Modal.module.scss";
import { ModalProps } from "./Modal.types";
import ModalTopActions from "../ModalTopActions/ModalTopActions";

const Modal = forwardRef(
(
{
show,
size = "medium",
renderHeaderAction,
closeButtonTheme,
closeButtonAriaLabel,
onClose,
children,
className,
style,
id,
"data-testid": dataTestId
}: ModalProps,
ref: React.ForwardedRef<HTMLDivElement>
) => {
return (
<div id="overlay" className={styles.overlay}>
<div
ref={ref}
className={cx(styles.modal, className)}
style={style}
id={id}
data-testid={dataTestId || getTestId(ComponentDefaultTestId.MODAL, id)}
role="dialog"
aria-modal
aria-labelledby="TODO" // TODO
aria-describedby="TODO" // TODO
>
<ModalTopActions
renderAction={renderHeaderAction}
color={closeButtonTheme}
closeButtonAriaLabel={closeButtonAriaLabel}
onClose={onClose}
/>
{children}
</div>
</div>
);
}
);

export default Modal;
15 changes: 15 additions & 0 deletions packages/core/src/components/ModalNew/Modal/Modal.types.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { VibeComponentProps } from "../../../types";
import React from "react";
import { ModalTopActionsProps } from "../ModalTopActions/ModalTopActions.types";

export type ModalSize = "small" | "medium" | "large";

export interface ModalProps extends VibeComponentProps {
show: boolean;
size?: ModalSize;
closeButtonTheme?: ModalTopActionsProps["color"];
closeButtonAriaLabel?: ModalTopActionsProps["closeButtonAriaLabel"];
onClose?: ModalTopActionsProps["onClose"];
renderHeaderAction?: ModalTopActionsProps["renderAction"];
children: React.ReactNode;
}

0 comments on commit 5dc52ba

Please sign in to comment.