Skip to content

Commit 348d7d2

Browse files
author
Luke Bowerman
authored
Rename Banner's dismissable prop to canDismiss (#786)
* Rename Banner's dismissable prop to `canDismiss`
1 parent f6f89ab commit 348d7d2

File tree

5 files changed

+74
-77
lines changed

5 files changed

+74
-77
lines changed

CHANGELOG.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,30 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [UNRELEASED]
8+
## [0.7.26] - 2020-04-14
99

1010
### Added
1111

12-
- Layout components
13-
- `Grid` component
14-
- `Space` & `SpaceVertical` components
15-
- `SelectMulti` component
12+
- `ActionListManager` component
1613
- `CodeBlock` component
14+
- `ComponentsProvider` component to provide a pre-packaged `ThemeProvider` + `theme`
15+
- `Grid` component
1716
- `InputTimeSelect` component
18-
- `Board`, `ShareAlt` Icon
19-
- `ActionListItemAction` accepts color prop when value is "danger"
20-
- `Prompt` component
21-
- `ActionListManager` component
2217
- `Pagination` component
23-
- `ComponentsProvider` component to provide a pre-packaged `ThemeProvider` + `theme`
24-
- New Icons `VisibilityOutline`, `SendEmail`, `SendSftp`, `SendWebhook`
18+
- `Prompt` component
19+
- `SelectMulti` component
20+
- `Space` & `SpaceVertical` components
21+
- Icons - `Board`, `ShareAlt`,`SendEmail`, `SendSftp`, `SendWebhook`, `VisibilityOutline`,
2522

2623
### Changed
2724

28-
- `Share` Icon updated
25+
- `ActionListItemAction` accepts `color` prop (only takes `danger`)
26+
- Icons - `Share` updated
2927

3028
### Fixed
3129

3230
- `usePopper` (used in `Popover` and `Tooltip`) positioning issue with `placement="top"` and offset parent is the window
33-
- `Select` runtime error with no options, defaultValue or placeholder
31+
- `Select` no longer throws a runtime error when no options, defaultValue or placeholder are specified
3432

3533
## [0.7.25] - 2020-03-23
3634

packages/components/src/Banner/Banner.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ test('Confirmation banner', () => {
4545
assertSnapshot(<Banner intent="confirmation">Confirmation</Banner>)
4646
})
4747

48-
test('Dismissable banner', () => {
48+
test('Banner can be dismissed', () => {
4949
assertSnapshot(
50-
<Banner intent="info" dismissable>
50+
<Banner intent="info" canDismiss>
5151
Info!
5252
</Banner>
5353
)

packages/components/src/Banner/Banner.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ import {
3131
} from '@looker/design-tokens'
3232
import React, { forwardRef, Ref } from 'react'
3333
import { IconButton } from '../Button'
34-
import { Box } from '../Layout/Box'
34+
import { Box, Flex } from '../Layout'
3535
import { Icon } from '../Icon'
36-
import { Flex } from '../Layout/Flex'
3736
import { VisuallyHidden } from '../VisuallyHidden'
3837

3938
export type BannerIntent = 'warning' | 'info' | 'error' | 'confirmation'
@@ -46,7 +45,7 @@ export interface BannerProps
4645
* @default: 'info'
4746
*/
4847
intent?: BannerIntent
49-
dismissable?: boolean
48+
canDismiss?: boolean
5049
onDismiss?: () => void
5150
}
5251

@@ -99,7 +98,7 @@ export const Banner = forwardRef(
9998
(props: BannerProps, ref: Ref<HTMLDivElement>) => {
10099
const {
101100
children,
102-
dismissable,
101+
canDismiss,
103102
intent = 'warning',
104103
onDismiss,
105104
...typeAndSpaceProps
@@ -127,7 +126,7 @@ export const Banner = forwardRef(
127126
{icon}
128127
<VisuallyHidden>{accessibilityLabel}</VisuallyHidden>
129128
<Box flex="auto">{children}</Box>
130-
{dismissable && (
129+
{canDismiss && (
131130
<IconButton
132131
ml="auto"
133132
style={{ padding: '1px' }}

packages/components/src/Banner/__snapshots__/Banner.test.tsx.snap

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Confirmation banner 1`] = `
4-
.c2 {
5-
-webkit-flex: auto;
6-
-ms-flex: auto;
7-
flex: auto;
8-
}
9-
10-
.c0 {
11-
border-radius: 0.25rem;
12-
background-color: #e0ffe7;
13-
margin: 0.75rem;
14-
padding-top: 0.5rem;
15-
padding-bottom: 0.5rem;
16-
padding-left: 0.75rem;
17-
padding-right: 0.75rem;
18-
-webkit-flex: auto;
19-
-ms-flex: auto;
20-
flex: auto;
21-
-webkit-align-items: center;
22-
-webkit-box-align: center;
23-
-ms-flex-align: center;
24-
align-items: center;
25-
display: -webkit-box;
26-
display: -webkit-flex;
27-
display: -ms-flexbox;
28-
display: flex;
29-
}
30-
31-
.c1 {
32-
position: absolute;
33-
height: 1px;
34-
width: 1px;
35-
overflow: hidden;
36-
-webkit-clip: rect(1px,1px,1px,1px);
37-
clip: rect(1px,1px,1px,1px);
38-
}
39-
40-
<div
41-
aria-live="polite"
42-
className="c0"
43-
role="status"
44-
>
45-
<div
46-
className="c1"
47-
/>
48-
<div
49-
className="c2"
50-
>
51-
Confirmation
52-
</div>
53-
</div>
54-
`;
55-
56-
exports[`Dismissable banner 1`] = `
3+
exports[`Banner can be dismissed 1`] = `
574
.c1 {
585
color: #49a9f2;
596
margin-right: 0.75rem;
@@ -288,6 +235,59 @@ exports[`Dismissable banner 1`] = `
288235
</div>
289236
`;
290237

238+
exports[`Confirmation banner 1`] = `
239+
.c2 {
240+
-webkit-flex: auto;
241+
-ms-flex: auto;
242+
flex: auto;
243+
}
244+
245+
.c0 {
246+
border-radius: 0.25rem;
247+
background-color: #e0ffe7;
248+
margin: 0.75rem;
249+
padding-top: 0.5rem;
250+
padding-bottom: 0.5rem;
251+
padding-left: 0.75rem;
252+
padding-right: 0.75rem;
253+
-webkit-flex: auto;
254+
-ms-flex: auto;
255+
flex: auto;
256+
-webkit-align-items: center;
257+
-webkit-box-align: center;
258+
-ms-flex-align: center;
259+
align-items: center;
260+
display: -webkit-box;
261+
display: -webkit-flex;
262+
display: -ms-flexbox;
263+
display: flex;
264+
}
265+
266+
.c1 {
267+
position: absolute;
268+
height: 1px;
269+
width: 1px;
270+
overflow: hidden;
271+
-webkit-clip: rect(1px,1px,1px,1px);
272+
clip: rect(1px,1px,1px,1px);
273+
}
274+
275+
<div
276+
aria-live="polite"
277+
className="c0"
278+
role="status"
279+
>
280+
<div
281+
className="c1"
282+
/>
283+
<div
284+
className="c2"
285+
>
286+
Confirmation
287+
</div>
288+
</div>
289+
`;
290+
291291
exports[`Error banner 1`] = `
292292
.c1 {
293293
color: #B2121F;

packages/www/src/documentation/components/content/banner.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ The `<Banner />` component is used to alert the user with `warning`, `error`, `i
1313
<Banner intent="confirmation">Confirmation</Banner>
1414
```
1515

16-
## Dismissable
16+
## canDismiss
1717

18-
Banners can also be set to be `dismissable`, giving them a close button, and allows for a dismiss handler to be passed to `onDismiss`.
18+
Banners can also be set to be `canDismiss`, giving them a close button, and allows for a dismiss handler to be passed to `onDismiss`.
1919

2020
```jsx
2121
;() => {
2222
const { value, setOff, setOn } = useToggle(true)
2323
return value ? (
24-
<Banner intent="warning" onDismiss={setOff} dismissable>
24+
<Banner intent="warning" onDismiss={setOff} canDismiss>
2525
I can be closed
2626
</Banner>
2727
) : (

0 commit comments

Comments
 (0)