Skip to content

Commit

Permalink
Fix: Add button styles to notice actions without url. Allow custom cl…
Browse files Browse the repository at this point in the history
…asses on notice actions.
  • Loading branch information
jorgefilipecosta committed Jan 2, 2019
1 parent b4ff7cf commit 5522384
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
39 changes: 28 additions & 11 deletions packages/components/src/notice/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,34 @@ function Notice( {
<div className={ classes }>
<div className="components-notice__content">
{ children }
{ actions.map( ( { label, url, onClick }, index ) => (
<Button
key={ index }
href={ url }
isLink={ !! url }
onClick={ onClick }
className="components-notice__action"
>
{ label }
</Button>
) ) }
{ actions.map(
(
{
className: buttonAdditionalClass,
label,
onClick,
url,
},
index
) => {
return (
<Button
key={ index }
href={ url }
isDefault={ ! url }
isLink={ !! url }
onClick={ url ? undefined : onClick }
className={ classnames(
'components-notice__action',
buttonAdditionalClass
) }
>
{ label }
</Button>
);
}

) }
</div>
{ isDismissible && (
<IconButton
Expand Down
3 changes: 3 additions & 0 deletions packages/components/src/notice/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
&.is-link {
margin-left: 4px;
}
&.is-default {
vertical-align: initial;
}
}

.components-notice__dismiss {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ exports[`Notice should match snapshot 1`] = `
<ForwardRef(Button)
className="components-notice__action"
href="https://example.com"
isDefault={false}
isLink={true}
>
View
Expand Down

0 comments on commit 5522384

Please sign in to comment.