Skip to content

Commit

Permalink
feat(ModalContent): content component to be used in modal by consumers (
Browse files Browse the repository at this point in the history
  • Loading branch information
YossiSaadi committed Sep 12, 2024
1 parent 933f07d commit 3f8faa6
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import "~monday-ui-style/dist/mixins";

.content {
padding-block-end: var(--spacing-xl);
overflow: auto;
@include scroller;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React, { forwardRef } from "react";
import cx from "classnames";
import { getTestId } from "../../../tests/test-ids-utils";
import { ComponentDefaultTestId } from "../../../tests/constants";
import styles from "./ModalContent.module.scss";
import { ModalContentProps } from "./ModalContent.types";

const ModalContent = forwardRef(
(
{ children, className, id, "data-testid": dataTestId }: ModalContentProps,
ref: React.ForwardedRef<HTMLDivElement>
) => {
return (
<div
ref={ref}
className={cx(styles.content, className)}
id={id}
data-testid={dataTestId || getTestId(ComponentDefaultTestId.MODAL_NEXT_CONTENT, id)}
>
{children}
</div>
);
}
);

export default ModalContent;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from "react";
import { VibeComponentProps } from "../../../types";

export interface ModalContentProps extends VibeComponentProps {
children?: React.ReactNode;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react";
import { render } from "@testing-library/react";
import ModalContent from "../ModalContent";

describe("ModalContent", () => {
const childrenContent = <span>My content</span>;

it("renders the children correctly", () => {
const { getByText } = render(<ModalContent>{childrenContent}</ModalContent>);
expect(getByText("My content")).toBeInTheDocument();
});

it("renders when no children are provided", () => {
const { container } = render(<ModalContent />);
expect(container.firstChild).toBeInTheDocument();
});
});
1 change: 1 addition & 0 deletions packages/core/src/tests/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export enum ComponentDefaultTestId {
MODAL_HEADER = "modal-header",
MODAL_FOOTER_BUTTONS = "modal-footer-buttons",
MODAL_NEXT_HEADER = "modal-header",
MODAL_NEXT_CONTENT = "modal-content",
FORMATTED_NUMBER = "formatted-number",
HIDDEN_TEXT = "hidden-text",
DIALOG_CONTENT_CONTAINER = "dialog-content-container",
Expand Down

0 comments on commit 3f8faa6

Please sign in to comment.