Skip to content

Commit

Permalink
Fix Banner pointer behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljaltamirano committed Sep 28, 2020
1 parent a572517 commit e148436
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
8 changes: 8 additions & 0 deletions docs/banner.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ import { Banner } from 'radiance-ui';
</React.Fragment>
}
/>
<Banner
onClick={() => alert('clicked!')}
content={
<React.Fragment>
<strong>Clickable banner</strong> This is a banner with an onClick prop
</React.Fragment>
}
/>
<Banner
content={
<React.Fragment>
Expand Down
6 changes: 3 additions & 3 deletions src/shared-components/banner/__snapshots__/test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports[`Banner UI snapshots renders error type and text 1`] = `
background: transparent;
border: none;
width: 100%;
cursor: pointer;
cursor: inherit;
position: relative;
margin: 0 auto 0.5rem;
padding: 1rem;
Expand Down Expand Up @@ -115,7 +115,7 @@ exports[`Banner UI snapshots renders info type and text 1`] = `
background: transparent;
border: none;
width: 100%;
cursor: pointer;
cursor: inherit;
position: relative;
margin: 0 auto 0.5rem;
padding: 1rem;
Expand Down Expand Up @@ -163,7 +163,7 @@ exports[`Banner UI snapshots renders success type and text 1`] = `
background: transparent;
border: none;
width: 100%;
cursor: pointer;
cursor: inherit;
position: relative;
margin: 0 auto 0.5rem;
padding: 1rem;
Expand Down
7 changes: 5 additions & 2 deletions src/shared-components/banner/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@ const errorAlertStyles = css`
/**
* width: 100% to match previous <div> behavior
*/
export const BannerContainer = styled.button<{ bannerType: BannerType }>`
export const BannerContainer = styled.button<{
bannerType: BannerType;
onClick?: () => void;
}>`
${buttonReset}
width: 100%;
&:focus {
outline: none;
box-shadow: ${BOX_SHADOWS.focus};
}
cursor: pointer;
cursor: ${({ onClick }) => (onClick ? `pointer` : `inherit`)};
position: relative;
margin: 0 auto ${SPACER.small};
padding: ${SPACER.medium};
Expand Down
9 changes: 9 additions & 0 deletions stories/banner/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ stories.add(
}
type="success"
/>
<Banner
onClick={() => alert('clicked!')}
content={
<React.Fragment>
<strong>Clickable banner</strong> This is a banner with an onClick
prop
</React.Fragment>
}
/>
<Banner
content={
<React.Fragment>
Expand Down

0 comments on commit e148436

Please sign in to comment.