-
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(Modal): layouts for new Modal component (#2552)
- Loading branch information
1 parent
43b6b42
commit 97d81fa
Showing
27 changed files
with
373 additions
and
44 deletions.
There are no files selected for viewing
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
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
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
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
17 changes: 0 additions & 17 deletions
17
packages/core/src/components/ModalNew/ModalContent/__tests__/ModalContent.test.tsx
This file was deleted.
Oops, something went wrong.
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
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
4 changes: 2 additions & 2 deletions
4
packages/core/src/components/ModalNew/context/ModalContext.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
20 changes: 20 additions & 0 deletions
20
packages/core/src/components/ModalNew/layouts/ModalBasicLayout/ModalBasicLayout.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,20 @@ | ||
.layout { | ||
width: 100%; | ||
height: 100%; | ||
overflow: hidden; | ||
|
||
.header { | ||
width: 100%; | ||
margin-block: var(--spacing-xl) var(--spacing-large); | ||
padding-inline-end: calc(var(--top-actions-spacing) + var(--top-actions-width) + var(--spacing-medium)); | ||
padding-inline-start: var(--modal-inline-padding); | ||
} | ||
|
||
.divider { | ||
flex-shrink: 0; | ||
} | ||
|
||
.content { | ||
padding-block-end: var(--spacing-xl); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
packages/core/src/components/ModalNew/layouts/ModalBasicLayout/ModalBasicLayout.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,43 @@ | ||
import React, { forwardRef } from "react"; | ||
import cx from "classnames"; | ||
import { getTestId } from "../../../../tests/test-ids-utils"; | ||
import { ComponentDefaultTestId } from "../../../../tests/constants"; | ||
import styles from "./ModalBasicLayout.module.scss"; | ||
import { ModalBasicLayoutProps } from "./ModalBasicLayout.types"; | ||
import Flex from "../../../Flex/Flex"; | ||
import Divider from "../../../Divider/Divider"; | ||
import ModalFooterShadow from "../ModalFooterShadow"; | ||
import ModalLayoutScrollableContent from "../ModalLayoutScrollableContent"; | ||
import useLayoutScrolledContent from "../useLayoutScrolledContent"; | ||
|
||
const ModalBasicLayout = forwardRef( | ||
( | ||
{ children, className, id, "data-testid": dataTestId }: ModalBasicLayoutProps, | ||
ref: React.ForwardedRef<HTMLDivElement> | ||
) => { | ||
const { isContentScrolled, onScroll } = useLayoutScrolledContent(); | ||
const [header, content] = React.Children.toArray(children); | ||
|
||
return ( | ||
<> | ||
<Flex | ||
direction={Flex.directions.COLUMN} | ||
align={Flex.align.START} | ||
ref={ref} | ||
className={cx(styles.layout, className)} | ||
id={id} | ||
data-testid={dataTestId || getTestId(ComponentDefaultTestId.MODAL_NEXT_BASIC_LAYOUT, id)} | ||
> | ||
<div className={styles.header}>{header}</div> | ||
{isContentScrolled && <Divider className={styles.divider} withoutMargin />} | ||
<ModalLayoutScrollableContent onScroll={onScroll} className={styles.content}> | ||
{content} | ||
</ModalLayoutScrollableContent> | ||
</Flex> | ||
{isContentScrolled && <ModalFooterShadow />} | ||
</> | ||
); | ||
} | ||
); | ||
|
||
export default ModalBasicLayout; |
6 changes: 6 additions & 0 deletions
6
packages/core/src/components/ModalNew/layouts/ModalBasicLayout/ModalBasicLayout.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 ModalBasicLayoutProps extends VibeComponentProps { | ||
children: React.ReactNode; | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/core/src/components/ModalNew/layouts/ModalFooterShadow.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 @@ | ||
.shadowWrapper::after { | ||
content: ""; | ||
position: absolute; | ||
width: 100%; | ||
height: 10px; | ||
box-shadow: var(--box-shadow-medium); | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/core/src/components/ModalNew/layouts/ModalFooterShadow.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,8 @@ | ||
import React from "react"; | ||
import styles from "./ModalFooterShadow.module.scss"; | ||
|
||
const ModalFooterShadow = () => { | ||
return <div className={styles.shadowWrapper} />; | ||
}; | ||
|
||
export default ModalFooterShadow; |
4 changes: 3 additions & 1 deletion
4
...New/ModalContent/ModalContent.module.scss → .../ModalLayoutScrollableContent.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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
@import "~monday-ui-style/dist/mixins"; | ||
|
||
.content { | ||
padding-block-end: var(--spacing-xl); | ||
width: 100%; | ||
height: 100%; | ||
padding-inline: var(--modal-inline-padding); | ||
overflow: auto; | ||
@include scroller; | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/core/src/components/ModalNew/layouts/ModalLayoutScrollableContent.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,14 @@ | ||
import React from "react"; | ||
import cx from "classnames"; | ||
import styles from "./ModalLayoutScrollableContent.module.scss"; | ||
import { ModalLayoutScrollableContentProps } from "./ModalLayoutScrollableContent.types"; | ||
|
||
const ModalLayoutScrollableContent = ({ onScroll, className, children }: ModalLayoutScrollableContentProps) => { | ||
return ( | ||
<div className={cx(styles.content, className)} onScroll={onScroll}> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ModalLayoutScrollableContent; |
7 changes: 7 additions & 0 deletions
7
packages/core/src/components/ModalNew/layouts/ModalLayoutScrollableContent.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,7 @@ | ||
import { ReactNode, UIEventHandler } from "react"; | ||
|
||
export interface ModalLayoutScrollableContentProps { | ||
onScroll?: UIEventHandler<HTMLDivElement>; | ||
className?: string; | ||
children: ReactNode; | ||
} |
10 changes: 10 additions & 0 deletions
10
packages/core/src/components/ModalNew/layouts/ModalMedia.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,10 @@ | ||
.media { | ||
max-width: 100%; | ||
max-height: 100%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
flex-shrink: 0; | ||
overflow: hidden; | ||
position: relative; | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/core/src/components/ModalNew/layouts/ModalMedia.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,28 @@ | ||
import React, { forwardRef } from "react"; | ||
import Flex from "../../Flex/Flex"; | ||
import { ModalMediaProps } from "./ModalMedia.types"; | ||
import styles from "./ModalMedia.module.scss"; | ||
import cx from "classnames"; | ||
import { ComponentDefaultTestId, getTestId } from "../../../tests/test-ids-utils"; | ||
|
||
const ModalMedia = forwardRef( | ||
( | ||
{ children, className, id, "data-testid": dataTestId }: ModalMediaProps, | ||
ref: React.ForwardedRef<HTMLDivElement> | ||
) => { | ||
return ( | ||
<Flex | ||
id={id} | ||
data-testid={dataTestId || getTestId(ComponentDefaultTestId.MODAL_NEXT_MEDIA, id)} | ||
justify={Flex.justify.CENTER} | ||
align={Flex.align.STRETCH} | ||
ref={ref} | ||
className={cx(styles.media, className)} | ||
> | ||
{children} | ||
</Flex> | ||
); | ||
} | ||
); | ||
|
||
export default ModalMedia; |
6 changes: 6 additions & 0 deletions
6
packages/core/src/components/ModalNew/layouts/ModalMedia.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 ModalMediaProps extends VibeComponentProps { | ||
children: React.ReactNode; | ||
} |
Oops, something went wrong.