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

feat(ModalSideBySideLayout): side by side layout component for new Modal #2460

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.media {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if it's an image? Will users need to adjust the size?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if they need a specific change they can pass className, but it should behave well with either image/lottie/video

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like the way it's being provided now promises more than that 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got ya, will check with different scenarios

align-items: normal;
align-self: normal;
width: 100%;
height: auto;
max-height: 100%;
overflow: hidden;
}
28 changes: 28 additions & 0 deletions packages/core/src/components/ModalNew/layouts/ModalMedia.tsx
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;
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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.layout {
width: 100%;
flex-grow: 1;
overflow: hidden;

.leftPane {
height: 100%;
width: 60%;
padding-inline: var(--modal-inline-padding);

.header {
width: 100%;
margin-block: var(--spacing-xl) var(--spacing-large);
}

.content {
width: 100%;
}
}

.media {
flex-shrink: 0;
width: 40%;
YossiSaadi marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React, { forwardRef } from "react";
import cx from "classnames";
import { getTestId } from "../../../../tests/test-ids-utils";
import { ComponentDefaultTestId } from "../../../../tests/constants";
import styles from "./ModalSideBySideLayout.module.scss";
import { ModalSideBySideLayoutProps } from "./ModalSideBySideLayout.types";
import Flex from "../../../Flex/Flex";

const ModalSideBySideLayout = forwardRef(
(
{ children, className, id, "data-testid": dataTestId }: ModalSideBySideLayoutProps,
ref: React.ForwardedRef<HTMLDivElement>
) => {
const [header, content, media] = React.Children.toArray(children);
return (
<Flex
ref={ref}
className={cx(styles.layout, className)}
id={id}
data-testid={dataTestId || getTestId(ComponentDefaultTestId.MODAL_NEXT_SIDE_BY_SIDE_LAYOUT, id)}
>
<Flex direction={Flex.directions.COLUMN} align={Flex.align.START} className={styles.leftPane}>
<div className={styles.header}>{header}</div>
<div className={styles.content}>{content}</div>
</Flex>
<div className={styles.media}>{media}</div>
</Flex>
);
}
);

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

export interface ModalSideBySideLayoutProps extends VibeComponentProps {
children: React.ReactNode;
}
2 changes: 2 additions & 0 deletions packages/core/src/tests/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ export enum ComponentDefaultTestId {
MODAL_NEXT_OVERLAY = "modal-overlay",
MODAL_NEXT_HEADER = "modal-header",
MODAL_NEXT_CONTENT = "modal-content",
MODAL_NEXT_MEDIA = "modal-media",
MODAL_NEXT_BASIC_LAYOUT = "modal-basic-layout",
MODAL_NEXT_SIDE_BY_SIDE_LAYOUT = "modal-side-by-side-layout",
FORMATTED_NUMBER = "formatted-number",
HIDDEN_TEXT = "hidden-text",
DIALOG_CONTENT_CONTAINER = "dialog-content-container",
Expand Down