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: Modal dark mode #894

Merged
merged 3 commits into from
Jun 13, 2024
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
6 changes: 3 additions & 3 deletions src/components/Modal/Modal.Overview.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ In order to hide or show the Modal, set the Modal's `isOpen` prop to `true` or `
/>
<Modal.Body>Modal content</Modal.Body>
<Modal.Footer>
<Button variant="primary" tone="neutral" onClick={closeModal}>
<Button variant="secondary" tone="neutral" onClick={closeModal}>
Cancel
</Button>
<Button variant="primary">Primary Action</Button>
Expand Down Expand Up @@ -192,7 +192,7 @@ Omit `<Modal.Header/>` to render a minimal modal without a header.
>
<Modal.Body>Modal content</Modal.Body>
<Modal.Footer>
<Button variant="primary" tone="neutral" onClick={closeModal}>
<Button variant="secondary" tone="neutral" onClick={closeModal}>
Cancel
</Button>
<Button variant="primary">Primary Action</Button>
Expand Down Expand Up @@ -239,7 +239,7 @@ Use `fullScreenMobile` to enable fullscreen at mobile viewport widths.
/>
<Modal.Body>Modal content</Modal.Body>
<Modal.Footer>
<Button variant="primary" tone="neutral" onClick={closeModal}>
<Button variant="secondary" tone="neutral" onClick={closeModal}>
Cancel
</Button>
<Button variant="primary">Primary Action</Button>
Expand Down
10 changes: 5 additions & 5 deletions src/components/Modal/Modal.VisualTests.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const BasicExample = () => (
<Modal.Header id="title" title="The Modal Title" onDismiss={() => null} />
<Modal.Body>Modal content</Modal.Body>
<Modal.Footer>
<Button variant="primary" tone="neutral" onClick={() => null}>
<Button variant="secondary" tone="neutral" onClick={() => null}>
Cancel
</Button>
<Button variant="primary">Primary Action</Button>
Expand All @@ -58,7 +58,7 @@ export const WithoutHeader = () => (
<Modal ariaLabel="modal without header" isOpen onDismiss={() => null}>
<Modal.Body>Modal content</Modal.Body>
<Modal.Footer>
<Button variant="primary" tone="neutral" onClick={() => null}>
<Button variant="secondary" tone="neutral" onClick={() => null}>
Cancel
</Button>
<Button variant="primary">Primary Action</Button>
Expand All @@ -75,7 +75,7 @@ export const FullScreenOnMobile = () => (
/>
<Modal.Body>Modal content</Modal.Body>
<Modal.Footer>
<Button variant="primary" tone="neutral" onClick={() => null}>
<Button variant="secondary" tone="neutral" onClick={() => null}>
Cancel
</Button>
<Button variant="primary">Primary Action</Button>
Expand All @@ -92,7 +92,7 @@ export const WithMaxWidth = () => (
/>
<Modal.Body>Modal content</Modal.Body>
<Modal.Footer>
<Button variant="primary" tone="neutral" onClick={() => null}>
<Button variant="secondary" tone="neutral" onClick={() => null}>
Cancel
</Button>
<Button variant="primary">Primary Action</Button>
Expand All @@ -114,7 +114,7 @@ export const WithResponsiveMaxWidth = () => (
/>
<Modal.Body>Modal content</Modal.Body>
<Modal.Footer>
<Button variant="primary" tone="neutral" onClick={() => null}>
<Button variant="secondary" tone="neutral" onClick={() => null}>
Cancel
</Button>
<Button variant="primary">Primary Action</Button>
Expand Down
20 changes: 8 additions & 12 deletions src/components/Modal/Modal.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,18 @@
background: transparent;
cursor: pointer;
padding: var(--size-spacing-xs);
color: var(--modal-close-button-color, var(--color-brand-grey-500));
color: var(--color-text-body-primary);
line-height: var(--size-line-height-base);
border-radius: var(--size-border-radius-sm);

&:hover {
color: var(--modal-close-button-color-hover, var(--color-brand-grey-600));
color: var(--color-text-contrast);
}

// Show focus styles on keyboard focus.
&:focus-visible {
outline: 0;
box-shadow: var(
--modal-close-button-box-shadow-focus,
0 0 0 4px var(--color-brand-grey-200)
);
box-shadow: 0 0 0 4px var(--color-brand-grey-200);
}

// Hide focus styles if they are not needed, for example,
Expand All @@ -35,6 +32,7 @@
}
}


[data-reach-dialog-overlay].modal {
display: flex;
position: fixed;
Expand All @@ -44,8 +42,7 @@
left: 0;
align-items: flex-end;
z-index: var(--size-z-index-overlay);
background: hsl(0deg 0% 0% / 33%);
background-color: rgb(77 82 79 / 50%);
background-color: rgba(0 0 0 / 60%);
overflow: hidden;

:global {
Expand Down Expand Up @@ -78,6 +75,8 @@
}

[data-reach-dialog-content] {
color: var(--color-text-body-primary);
font-family: var(--asset-fonts-body);
display: flex;
position: absolute;
bottom: 0;
Expand All @@ -86,10 +85,7 @@
grid-column: 1;
z-index: var(--size-z-index-modal);
margin: 0;
background-color: var(
--modal-background-color,
var(--color-brand-white-500)
);
background-color: var(--color-background-primary);
padding: 0;
width: 100%;
border-radius: var(--modal-border-radius, var(--size-border-radius-md))
Expand Down
4 changes: 2 additions & 2 deletions src/components/Modal/Modal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ describe('Modal', () => {

test('onDismiss', async () => {
const mockOnDismiss = jest.fn();
const { getByTestId } = render(
const { getByLabelText } = render(
<Modal isOpen onDismiss={mockOnDismiss} ariaLabel="testSubcomponents">
<Modal.Header id="titleFooterBody" title="The Modal Title" onDismiss={mockOnDismiss} />
<Modal.Body>Modal body content</Modal.Body>
<Modal.Footer>This is content in the modal footer</Modal.Footer>
</Modal>,
);

const closeButton = getByTestId('icon-testid--remove').closest('button');
const closeButton = getByLabelText('close');
expect(closeButton).toBeInTheDocument();

if (closeButton) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export const ModalFooter: FC<ModalFooterProps> = ({
direction={direction}
alignItems={alignItems}
justifyContent={justifyContent}
borderColor="separator"
borderWidth="xs 0 0 0"
gap={gap}
style={{
flexShrink: 0,
borderColor: 'var(--modal-border-separator-color, var(--color-brand-grey-100))',
...style,
}}
{...restProps}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Modal/components/ModalHeader/ModalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export const ModalHeader: FC<ModalHeaderProps> = ({ id, onDismiss, title = undef
direction="row"
alignItems="center"
justifyContent={justifyContentValue}
borderColor="separator"
borderWidth="0 0 xs 0"
style={{
flexShrink: 0,
borderColor: 'var(--modal-border-separator-color, var(--color-brand-grey-100))',
}}
height="lg"
>
Expand All @@ -46,7 +46,7 @@ export const ModalHeader: FC<ModalHeaderProps> = ({ id, onDismiss, title = undef
className={styles['modal-close']}
onClick={onDismiss}
>
<Icon name="remove" />
<Icon name="remove-light" />
</button>
)}
</Box>
Expand Down
Loading