Skip to content

Commit 81d03eb

Browse files
author
Luke Bowerman
authored
Confirm no longer includes "Close" icon in header (#696)
ModalHeader - allow hiding of Dialog closing IconButton (hideClose)
1 parent 576353e commit 81d03eb

File tree

5 files changed

+48
-23
lines changed

5 files changed

+48
-23
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- `TextArea` component was created with documentation and tests
1313
- `FieldTextArea` component was created with documentation and tests
1414
- `ArrowLeft`, `EditOutline`, `ExploreOutline` Icons added
15+
- `ModalHeader` add support for `iconClose` option
1516

1617
### Change
1718

1819
- move path for InlineInputText now under Form/Inputs
1920
- `ArrowDropDown` and `ArrowDropUp` Icons renamed to `ArrowUp` and `ArrowDown`
2021
- `CacheRefesh` Icon update
22+
- `Confirm` no longer displays a `Close` `IconButton` in the header
2123

2224
## [0.7.24] - 2020-03-12
2325

packages/components/src/Modal/Dialog/ConfirmLayout.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ export const ConfirmLayout: FC<ConfirmLayoutProps> = ({
3737
}) => {
3838
return (
3939
<>
40-
<ModalHeader headerIcon={titleIcon}>{title}</ModalHeader>
40+
<ModalHeader hideClose headerIcon={titleIcon}>
41+
{title}
42+
</ModalHeader>
4143
<ModalContent innerProps={{ py: 'none' }}>
4244
{typeof message === 'string' ? (
4345
<Paragraph>{message}</Paragraph>

packages/components/src/Modal/Layout/ModalHeader.test.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,22 @@
2626

2727
import 'jest-styled-components'
2828
import React from 'react'
29-
import { assertSnapshot } from '@looker/components-test-utils'
29+
import { assertSnapshot, mountWithTheme } from '@looker/components-test-utils'
30+
import { IconButton } from '../../Button'
3031
import { ModalHeader } from './ModalHeader'
3132

3233
test('ModalHeader', () => {
3334
assertSnapshot(<ModalHeader>The Heading for a Dialog</ModalHeader>)
3435
})
36+
37+
test('ModalHeader with hideClose', () => {
38+
const withClose = mountWithTheme(
39+
<ModalHeader>The Heading for a Dialog</ModalHeader>
40+
)
41+
expect(withClose.find(IconButton).exists()).toBeTruthy()
42+
43+
const withoutClose = mountWithTheme(
44+
<ModalHeader hideClose>The Heading for a Dialog</ModalHeader>
45+
)
46+
expect(withoutClose.find(IconButton).exists()).toBeFalsy()
47+
})

packages/components/src/Modal/Layout/ModalHeader.tsx

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ export interface ModalHeaderProps
4343
extends SpaceProps,
4444
CompatibleHTMLProps<HTMLElement> {
4545
children: string | string[]
46+
/**
47+
* Don't include the "Close" option
48+
* @default false
49+
*/
50+
hideClose?: boolean
4651
/**
4752
* Specify an icon to be used for close. Defaults to `Close`
4853
*/
@@ -56,6 +61,7 @@ export interface ModalHeaderProps
5661
export const ModalHeader: FC<ModalHeaderProps> = ({
5762
children,
5863
closeIcon = 'Close',
64+
hideClose,
5965
headerIcon,
6066
...props
6167
}) => {
@@ -72,15 +78,17 @@ export const ModalHeader: FC<ModalHeaderProps> = ({
7278
>
7379
{children}
7480
</Heading>
75-
<IconButton
76-
tabIndex={-1}
77-
color="neutral"
78-
size="small"
79-
onClick={closeModal}
80-
label="Close"
81-
icon={closeIcon}
82-
style={{ gridArea: 'close' }}
83-
/>
81+
{!hideClose && (
82+
<IconButton
83+
tabIndex={-1}
84+
color="neutral"
85+
size="small"
86+
onClick={closeModal}
87+
label="Close"
88+
icon={closeIcon}
89+
style={{ gridArea: 'close' }}
90+
/>
91+
)}
8492
</Header>
8593
)
8694
}

packages/components/src/Modal/Layout/__snapshots__/ModalHeader.test.tsx.snap

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ exports[`ModalHeader 1`] = `
8686
color: #262D33;
8787
}
8888
89+
.c0 {
90+
padding: 1.25rem;
91+
padding-right: 2rem;
92+
padding-left: 2rem;
93+
display: grid;
94+
grid-template-columns: [icon] auto [text] 1fr [close] auto;
95+
-webkit-align-items: center;
96+
-webkit-box-align: center;
97+
-ms-flex-align: center;
98+
align-items: center;
99+
}
100+
89101
.c5 {
90102
position: absolute;
91103
height: 1px;
@@ -99,18 +111,6 @@ exports[`ModalHeader 1`] = `
99111
pointer-events: none;
100112
}
101113
102-
.c0 {
103-
padding: 1.25rem;
104-
padding-right: 2rem;
105-
padding-left: 2rem;
106-
display: grid;
107-
grid-template-columns: [icon] auto [text] 1fr [close] auto;
108-
-webkit-align-items: center;
109-
-webkit-box-align: center;
110-
-ms-flex-align: center;
111-
align-items: center;
112-
}
113-
114114
<header
115115
className="c0"
116116
>

0 commit comments

Comments
 (0)