Skip to content

Commit

Permalink
feat(notifications): notification board components
Browse files Browse the repository at this point in the history
  • Loading branch information
wri7tno committed Aug 22, 2023
1 parent 3d557a3 commit f87d311
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/assets/icons/calendar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/icons/info-rounded.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/layers.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/icons/warning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions src/components/notifications/notification-item/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react';
import PropTypes from 'prop-types';
import CalendarIcon from 'assets/icons/calendar.svg';
import InfoIcon from 'assets/icons/info-rounded.svg';
import LayersIcon from 'assets/icons/layers.svg';
import WarningIcon from 'assets/icons/warning.svg';
import { NotificationItemWrapper } from './styles';

const NotificationItem = ({ title, description, date, icon }) => {
const renderIcon = (option) => {
switch (option) {
case 'layers':
return <LayersIcon />;
case 'warning':
return <WarningIcon />;
case 'calendar':
return <CalendarIcon />;
default:
return <InfoIcon />;
}
};

return (
<NotificationItemWrapper data-component-type="notification-item">
<div>{renderIcon(icon)}</div>
<div>
<div className="text">
<div className="header">
<div className="title">{title}</div>
<div className="date">{date}</div>
</div>
<div
className="description"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: description }}
/>
</div>
</div>
</NotificationItemWrapper>
);
};

NotificationItem.propTypes = {
/** Title of notification. */
title: PropTypes.string,
/** Description, it supports basic HTML. */
description: PropTypes.string,
/** YYY-MM-DD */
date: PropTypes.string,
/** It can be one of the following options: info | warning | calendar | layers */
icon: PropTypes.string,
};

export default NotificationItem;
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Notification item.

```js
<NotificationItem
icon="layers"
title="Upcoming Event: Notification Title"
description={`
Lorem Ipsum is simply <b>dummy text of the printing</b> and typesetting industry. <a href="/#">Lorem Ipsum</a> has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
`}
date="2023-08-23"
/>
```
50 changes: 50 additions & 0 deletions src/components/notifications/notification-item/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import styled from '@emotion/styled';

export const NotificationItemWrapper = styled.div`
background-color: #ffffff;
display: flex;
flex-direction: row;
gap: 6px;
padding: 20px;
.text {
padding-left: 20px;
padding-right: 20px;
.header {
display: flex;
flex-direction: row;
font-size: 16px;
.title {
font-weight: 500;
width: 75%;
}
.date {
color: #555555;
font-weight: 400;
text-align: right;
width: 25%;
}
}
.description {
font-size: 14px;
line-height: 22.4px;
padding-bottom: 10px;
padding-top: 10px;
text-align: justify;
> b,
strong {
font-weight: 500;
}
> a {
color: #7d953b;
font-weight: 500;
}
}
}
`;
4 changes: 4 additions & 0 deletions src/docs/notifications.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<br />
Notification components for Notifications Board.
<br />
<br />
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export { default as NoContent } from './components/no-content';
export { default as Switch } from './components/switch';
export { default as Tooltip } from './components/tooltip';
export { default as CookiesBanner } from './components/cookies-banner';
export { default as NotificationItem } from './components/notifications/notification-item';

// Forms
export { default as ContactUsForm } from './components/forms/contact-us';
Expand Down
5 changes: 5 additions & 0 deletions styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ module.exports = {
content: 'src/docs/modals.md',
components: 'src/components/modals/*/index.js',
},
{
name: 'Notification Board',
content: 'src/docs/notifications.md',
components: 'src/components/notifications/*/index.jsx',
},
{
name: 'Form components',
content: 'src/docs/form-components.md',
Expand Down

0 comments on commit f87d311

Please sign in to comment.