Skip to content

Commit

Permalink
feat: Improve banner (#405)
Browse files Browse the repository at this point in the history
  • Loading branch information
dherault authored Feb 6, 2023
1 parent 042f0e4 commit 66496a8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/components/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const BannerOuter = styled.div<{
const BannerInner = styled.div(({ theme }) => ({
display: 'flex',
paddingTop: theme.spacing.xxsmall,
paddingBottom: theme.spacing.xxsmall,
alignItems: 'flex-start',
}))

Expand Down Expand Up @@ -146,12 +147,6 @@ ref: Ref<any>) {
const iconColorKey = severityToIconColorKey[severity]
const borderColorKey = severityToBorderColorKey[severity]

function handleClose() {
if (typeof onClose === 'function') {
onClose()
}
}

const content = (
<BannerOuter
ref={ref}
Expand Down Expand Up @@ -181,7 +176,9 @@ ref: Ref<any>) {
</div>
</BannerInner>
<Div flexGrow={1} />
<CloseButton onClick={handleClose} />
{typeof onClose === 'function' && (
<CloseButton onClick={onClose} />
)}
</BannerOuter>
)

Expand Down
13 changes: 13 additions & 0 deletions src/stories/Banner.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@ function Template(args: any) {
>
Having a full width Banner can sometimes be useful.
</Banner>
<H1
marginTop="medium"
subtitle2
>
onClose=fn
</H1>
<Banner
{...args}
fullWidth
onClose={() => {}}
>
Having a full width Banner can sometimes be useful.
</Banner>
</Flex>
)
}
Expand Down

0 comments on commit 66496a8

Please sign in to comment.