-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ModalContent): content component to be used in modal by consumers (
- Loading branch information
1 parent
933f07d
commit 3f8faa6
Showing
5 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
packages/core/src/components/ModalNew/ModalContent/ModalContent.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/core/src/components/ModalNew/ModalContent/ModalContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
6 changes: 6 additions & 0 deletions
6
packages/core/src/components/ModalNew/ModalContent/ModalContent.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/core/src/components/ModalNew/ModalContent/__tests__/ModalContent.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters