Skip to content
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 src/components/Modal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import { BBBModal } from 'bbb-ui-components-react';
| `shouldCloseOnEsc` | `boolean` | `false` | Allows closing with ESC key. |
| `allowScroll` | `boolean` | `true` | Enables scroll in the modal body. |
| `noFooter` | `boolean` | `false` | Hides the modal footer. |
| `hideCloseButton` | `boolean` | `false` | Hides the header close button. |
| `footerContent` | `React.ReactNode` | `null` | Custom content for the footer. |
| `stickyFooter` | `boolean` | `true` | Makes the footer sticky. |
| `testId` | `string` | — | Test identifier applied to the modal element (native `ReactModal` prop). |
Expand Down
13 changes: 13 additions & 0 deletions src/components/Modal/component.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ const meta = {
control: 'boolean',
description: 'Hide the footer section.',
},
hideCloseButton: {
control: 'boolean',
description: 'Hide the header close button.',
},
footerContent: {
control: false,
description: 'Custom React node to render inside the footer.',
Expand Down Expand Up @@ -190,3 +194,12 @@ export const Default: Story = {
},
render: (args) => <ModalStory {...args}><ModalBody /></ModalStory>,
};

/** Modal without a header close button, for mandatory-action or externally-controlled flows. */
export const HideCloseButton: Story = {
args: {
...Default.args,
hideCloseButton: true,
},
render: (args) => <ModalStory {...args}><ModalBody /></ModalStory>,
};
19 changes: 11 additions & 8 deletions src/components/Modal/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const Modal: React.FC<ModalProps> = ({
shouldCloseOnEsc = false,
allowScroll = true,
noFooter = false,
hideCloseButton = false,
footerContent = null,
stickyFooter = true,
testId,
Expand Down Expand Up @@ -65,14 +66,16 @@ const Modal: React.FC<ModalProps> = ({
>
{title}
</BBBTypography>
<BBButton
layout="circle"
icon={<MdClose size="1.5rem" />}
onClick={onRequestClose}
variant="subtle"
ariaLabel="close"
{...(_closeButtonDataTest ? { dataTest: _closeButtonDataTest } : {})}
/>
{!hideCloseButton && (
<BBButton
layout="circle"
icon={<MdClose size="1.5rem" />}
onClick={onRequestClose}
variant="subtle"
ariaLabel="close"
{...(_closeButtonDataTest ? { dataTest: _closeButtonDataTest } : {})}
/>
)}
</Styled.ModalHeader>

{showDividers && <BBBDivider />}
Expand Down
9 changes: 0 additions & 9 deletions src/components/Modal/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@ export const ModalHeader = styled.div`
align-items: center;
`;

export const CloseButton = styled.button`
background: none;
border: none;
font-size: 1.5rem;
cursor: pointer;
padding: 0;
line-height: 1;
`;

export const ModalScrollArea = styled.div<StyledModalBodyProps>`
flex-grow: 1;
overflow-y: ${({ $allowScroll }) => $allowScroll ? 'auto' : 'hidden'};
Expand Down
3 changes: 3 additions & 0 deletions src/components/Modal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export interface ModalProps extends Omit<ReactModal.Props, 'style'> {
/** Hide the footer section. @default false */
noFooter?: boolean;

/** Hide the header close button. @default false */
hideCloseButton?: boolean;

/** When true, the footer is sticky to the bottom instead of scrolling with the body. @default true */
stickyFooter?: boolean;

Expand Down
Loading