Skip to content

Commit

Permalink
Merge pull request #540 from appearhere/add-icon-to-dismissible-panel
Browse files Browse the repository at this point in the history
Add icon prop to dismissible panel and add price-tag icon
  • Loading branch information
jamero102 committed Jul 31, 2020
2 parents a112fee + ac4b445 commit a994e3b
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ div.root {

.inner {
width: 90%;
flex-grow: 2;
}

.dismissContainer {
align-self: flex-start;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ const DismissablePanel = (props: Props) => {
context={context}
className={cx(css.root, onClose ? css.dismissable : null, className)}
>
<div className={cx(css.inner)}>{children}</div>
<div className={cx(css.inner)}>
{children}
</div>
{onClose && (
<BtnContainer className={css.dismissContainer} onClick={onClose}>
<Icon className={css.icon} name="cross" />
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/components/Icon/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import travelIdea from './icons/icon-travel-idea.svg';
import twitter from './icons/icon-twitter.svg';
import vipEntrance from './icons/icon-vip-entrance.svg';
import instagram from './icons/icon-instagram.svg';
import priceTag from './icons/icon-price-tag.svg';

export default {
'appearhere-brackets': appearhereBrackets,
Expand Down Expand Up @@ -106,4 +107,5 @@ export default {
ticket: ticket,
twitter: twitter,
instagram: instagram,
'price-tag': priceTag,
};
3 changes: 3 additions & 0 deletions packages/core/src/components/Icon/icons/icon-price-tag.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions packages/core/src/components/Panel/Panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@
.error {
background-color: var(--color-danger);
color: var(--color-white);
}

.icon {
padding-right: var(--size-regular);
align-self: flex-start;
}
7 changes: 6 additions & 1 deletion packages/core/src/components/Panel/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import * as React from 'react';
import cx from 'classnames';
import Icon from '../Icon/Icon';

import css from './Panel.css';

Expand All @@ -20,13 +21,17 @@ type Props = {
typeof PANEL_CONTEXT.ERROR |
typeof PANEL_CONTEXT.SUCCESS,
children: React.Node,
icon?: string,
}

const Panel = (props: Props) => {
const { children, className, context, ...rest } = props;
const { children, className, context, icon, ...rest } = props;

return (
<div {...rest} className={cx(css.root, css[context], className)}>
{icon && (
<Icon className={css.icon} name={icon} dimensions={{ width: '20px', height: '20px' }} />
)}
{children}
</div>
);
Expand Down
5 changes: 5 additions & 0 deletions packages/playground/stories/DismissablePanel.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ storiesOf('DismissablePanel', module)
<DismissablePanel context="error" onClose={action('Closing banner')}>
Something went wrong πŸ˜•
</DismissablePanel>
))
.add('With Icon', () => (
<DismissablePanel icon="price-tag" onClose={action('Closing banner')}>
What a fabulous icon! πŸ”₯
</DismissablePanel>
));
5 changes: 4 additions & 1 deletion packages/playground/stories/Panel.story.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ storiesOf('Panel', module)
<Panel context="blackout">Important information that you should look at right now</Panel>
))
.add('Success context', () => <Panel context="success">You did something right! πŸ‘</Panel>)
.add('Error context', () => <Panel context="error">Something went wrong πŸ˜•</Panel>);
.add('Error context', () => <Panel context="error">Something went wrong πŸ˜•</Panel>)
.add('With icon', () => (
<Panel icon="price-tag">Important information that you should look at right now</Panel>
));

1 comment on commit a994e3b

@vercel
Copy link

@vercel vercel bot commented on a994e3b Jul 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.