File tree Expand file tree Collapse file tree 5 files changed +48
-23
lines changed
packages/components/src/Modal Expand file tree Collapse file tree 5 files changed +48
-23
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 >
Original file line number Diff line number Diff line change 2626
2727import 'jest-styled-components'
2828import 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'
3031import { ModalHeader } from './ModalHeader'
3132
3233test ( '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+ } )
Original file line number Diff line number Diff 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
5661export 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}
Original file line number Diff line number Diff 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>
You can’t perform that action at this time.
0 commit comments