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

[Modal] - Label heading fix for "full space content" Modal type + Avatar in the modal header #793

Merged
merged 4 commits into from
Sep 27, 2023
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
1 change: 1 addition & 0 deletions packages/react-components/src/components/Avatar/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { Avatar } from './Avatar';
export type { AvatarProps } from './Avatar';
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

&--full-space {
padding: 0;
overflow: hidden;
}

&__overlay {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
width: 100%;
}

.full-space-wrapper img {
border-top-left-radius: var(--radius-3);
border-top-right-radius: var(--radius-3);
}

.full-space-content {
display: flex;
flex-direction: column;
Expand Down
14 changes: 14 additions & 0 deletions packages/react-components/src/components/Modal/Modal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
export default {
title: 'Components/Modal',
component: ModalComponent,
subcomponents: { ModalHeader },
parameters: {
viewMode: 'story',
previewTabs: {
Expand Down Expand Up @@ -96,6 +97,19 @@ ModalWithLabeledHeader.args = {
export const ModalWithFullSpaceContent = StoryTemplate.bind({});
ModalWithFullSpaceContent.args = {
...defaultModalProps,
labelHeading: (
<ModalHeader
title="Modal Header"
avatarProps={{
type: 'image',
size: 'small',
src: 'https://cdn-labs.livechat-files.com/api/file/lc/img/100019504/df59da4b5b0cdb6030efb08787fd255d.jpg',
}}
>
{' '}
Modal description{' '}
</ModalHeader>
),
children: <ModalFullSpaceContent />,
fullSpaceContent: true,
footer: null,
Expand Down
6 changes: 1 addition & 5 deletions packages/react-components/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ export const Modal: React.FC<ModalProps> = ({
)}
<div
data-testid="modal-body"
className={cx(
styles[`${baseClass}__body`],
fullSpaceContent && styles[`${baseClass}__body--full-space`],
contentClassName
)}
className={cx(styles[`${baseClass}__body`], contentClassName)}
>
{isTextContent ? <Text as="div">{children}</Text> : children}
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.modal-header {
display: flex;
align-items: center;
justify-content: flex-start;

&__heading-icon {
&__heading-left-node {
margin-right: 12px;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';

import { cx } from '@emotion/css';

import { Avatar, AvatarProps } from '../../Avatar';
import { Icon, IconProps } from '../../Icon';
import { Heading, Text } from '../../Typography';

Expand All @@ -10,15 +11,32 @@ import styles from './ModalHeader.module.scss';
const baseClass = 'modal-header';

export interface ModalHeaderProps {
/**
* Set the header title
*/
title?: React.ReactNode;
/**
* Set to display the icon
*/
iconProps?: IconProps;
/**
* Set to display avatar
*/
avatarProps?: AvatarProps;
/**
* Children element
*/
children?: React.ReactNode;
/**
* Define class name for container
*/
className?: 'string';
}

export const ModalHeader: React.FC<ModalHeaderProps> = ({
title,
iconProps,
avatarProps,
children,
className = '',
}) => {
Expand All @@ -27,7 +45,16 @@ export const ModalHeader: React.FC<ModalHeaderProps> = ({
return (
<div className={mergedClassNames}>
{iconProps && (
<Icon className={styles[`${baseClass}__heading-icon`]} {...iconProps} />
<Icon
className={styles[`${baseClass}__heading-left-node`]}
{...iconProps}
/>
)}
{avatarProps && (
<Avatar
className={styles[`${baseClass}__heading-left-node`]}
{...avatarProps}
/>
)}
<div className={styles[`${baseClass}__heading-body`]}>
<Heading
Expand Down