This repository has been archived by the owner on Aug 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(notification): version one - WIP
- Loading branch information
Andrew Leyva
committed
Sep 29, 2018
1 parent
e0e9dff
commit 2e62d46
Showing
12 changed files
with
432 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#### Notification Menu | ||
|
||
```js | ||
const Flexbox = require('flexbox-react').default; | ||
|
||
const notificationCount = 8; | ||
|
||
const notifications1 = []; | ||
|
||
const notifications = [ | ||
{id:1, type:'error', title:'First Notification', description:'Tets etetsd hgfasdgf asjfgs dfjgfh ets etetsd hgfasdgf asjfgs dfjgfh ets etetsd hgfasdgf asjfgs dfjgfh ets etetsd hgfasdgf asjfgs dfjgfh ets etetsd hgfasdgf asjfgs dfjgfh ets etetsd hgfasdgf asjfgs dfjgfh ', timeStamp:'Just now', isMsgRead:false}, | ||
{id:2, type:'success', title:'Second Notification', description:'Tetsetetsd hgfasdgfasjfgsdfjgfh', timeStamp:'Just now', isMsgRead:false}, | ||
{id:3, type:'info', title:'Third Notification', description:'Tetsetetsdhgfasdgfasjfgs dfjgfh', timeStamp:'Just now', isMsgRead:false}, | ||
{id:4, type:'warning', title:'Fourth Notification', description:'Tetsetetsdhgfa sdgfasjfgsdfjgfh', timeStamp:'Just now', isMsgRead:true}, | ||
{id:5, type:'error', title:'Fifth Notification', description:'Tets etetsd hgfasdgf asjfgs dfjgfh ets etetsd hgfasdgf asjfgs dfjgfh ets etetsd hgfasdgf asjfgs dfjgfh ets etetsd hgfasdgf asjfgs dfjgfh ets etetsd hgfasdgf asjfgs dfjgfh ets etetsd hgfasdgf asjfgs dfjgfh ', timeStamp:'Just now', isMsgRead:false}, | ||
{id:6, type:'error', title:'Six Notification', description:'Tetsetetsd hgfasdgfasjfgsdfjgfh', timeStamp:'Just now', isMsgRead:false}, | ||
{id:7, type:'info', title:'Seven Notification', description:'Tetsetetsdhgfasdgfasjfgs dfjgfh', timeStamp:'Just now', isMsgRead:false}, | ||
{id:8, type:'warning', title:'First Notification', description:'Tetsetetsdhgfa sdgfasjfgsdfjgfh', timeStamp:'Just now', isMsgRead:true} | ||
]; | ||
|
||
<div > | ||
<Notification> | ||
<Notification.Badge key={'badge'} size='large' notificationCount={notificationCount} /> | ||
<Notification.Tray key={'tray'}> | ||
<Notification.Header title={'Notification'} notificationCount={notificationCount} /> | ||
<Notification.Body notifications={notifications} removeItem={null}> | ||
</Notification.Body> | ||
<Notification.Footer> | ||
<div>Clear All</div> | ||
</Notification.Footer> | ||
</Notification.Tray> | ||
</Notification> | ||
</div> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import '../../styles/components/notification.css' | ||
import React from 'react' | ||
import { Popup } from 'semantic-ui-react' | ||
import NotificationBadge from './NotificationBadge' | ||
import NotificationTray from './NotificationTray' | ||
import NotificationHeader from './NotificationHeader' | ||
import NotificationBody from './NotificationBody' | ||
import NotificationFooter from './NotificationFooter' | ||
import NotificationEmpty from './NotificationEmpty' | ||
|
||
const Notification = props => { | ||
const { children, ...rest } = props | ||
let visible = true | ||
let childrenNodes = {} | ||
children.forEach(ele => { | ||
childrenNodes[ele.key] = ele | ||
}) | ||
|
||
return ( | ||
<Popup | ||
visible={visible} | ||
trigger={childrenNodes.badge} | ||
content={childrenNodes.tray} | ||
on='click' | ||
position='bottom center' | ||
className={'notificationPopup'} | ||
{...rest} | ||
/> | ||
) | ||
} | ||
|
||
Notification.Badge = NotificationBadge | ||
Notification.Tray = NotificationTray | ||
Notification.Header = NotificationHeader | ||
Notification.Body = NotificationBody | ||
Notification.Footer = NotificationFooter | ||
Notification.Empty = NotificationEmpty | ||
|
||
export default Notification |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react' | ||
import { Icon } from 'semantic-ui-react' | ||
import PropTypes from 'prop-types' | ||
|
||
const NotificationBadge = props => { | ||
const { size, notificationCount, ...rest } = props | ||
|
||
return ( | ||
<span className={`notificationIcon ${size}`} {...rest}> | ||
<Icon name='bell outline' size={size} /> | ||
<span className={`notificationCount ${size}`}>{notificationCount}</span> | ||
</span> | ||
) | ||
} | ||
|
||
NotificationBadge.defaultProps = { | ||
notificationCount: 0 | ||
} | ||
|
||
NotificationBadge.propTypes = { | ||
notificationCount: PropTypes.number | ||
} | ||
|
||
export default NotificationBadge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React from 'react' | ||
import NotificationMessage from './NotificationMessage' | ||
import NotificationEmpty from './NotificationEmpty' | ||
|
||
const NotificationBody = props => { | ||
const { children, notifications, removeItem, ...rest } = props | ||
let componentToRender = ( | ||
<div> | ||
<NotificationEmpty /> | ||
</div> | ||
) | ||
|
||
if (notifications.length > 0) { | ||
componentToRender = ( | ||
<div className='notificationBody' {...rest}> | ||
{notifications.map( | ||
({ id, type, title, description, timeStamp, isMsgRead }) => { | ||
let icon = '' | ||
switch (type) { | ||
case 'success': | ||
icon = 'icon_error-triangle_alt' | ||
break | ||
case 'info': | ||
icon = 'icon_error-triangle_alt' | ||
break | ||
case 'warning': | ||
icon = 'icon_error-triangle_alt' | ||
break | ||
case 'error': | ||
icon = 'icon_error-circle_alt' | ||
break | ||
default: | ||
icon = 'icon_check_alt2' | ||
} | ||
const options = { | ||
id, | ||
type, | ||
title, | ||
description, | ||
timeStamp, | ||
isMsgRead, | ||
icon: icon, | ||
removeItem: removeItem | ||
} | ||
return <NotificationMessage key={id} options={options} /> | ||
} | ||
)} | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
return componentToRender | ||
} | ||
|
||
NotificationBody.defaultProps = {} | ||
|
||
NotificationBody.propTypes = {} | ||
|
||
export default NotificationBody |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react' | ||
import { Icon } from 'semantic-ui-react' | ||
|
||
const NotificationEmpty = props => { | ||
const { children, ...rest } = props | ||
return ( | ||
<div className='empty__notification_panel' {...rest}> | ||
<div className='empty__circle'> | ||
<div className='bell_icon'> | ||
<Icon name='bell outline' size='big' /> | ||
</div> | ||
<div className='info_text'> | ||
<span>No New Notifications!</span> | ||
</div> | ||
</div> | ||
<div className='title'> | ||
<span> | ||
Check back again for updates, alerts and any other general | ||
notifications. | ||
</span> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
NotificationEmpty.defaultProps = {} | ||
|
||
NotificationEmpty.propTypes = {} | ||
|
||
export default NotificationEmpty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react' | ||
|
||
const NotificationFooter = props => { | ||
const { children, ...rest } = props | ||
return ( | ||
<div className={'notificationFooter clearfix'} {...rest}> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
NotificationFooter.defaultProps = {} | ||
|
||
NotificationFooter.propTypes = {} | ||
|
||
export default NotificationFooter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react' | ||
|
||
const NotificationHeader = props => { | ||
const { title, notificationCount, children, ...rest } = props | ||
return ( | ||
<div className={'notificationHeader clearfix'} {...rest}> | ||
<span className='notificationTitle'>{title} </span> | ||
<span className='notificationCount'>{notificationCount}</span> | ||
{children} | ||
</div> | ||
) | ||
} | ||
|
||
NotificationHeader.defaultProps = {} | ||
|
||
NotificationHeader.propTypes = {} | ||
|
||
export default NotificationHeader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import Flexbox from 'flexbox-react' | ||
import { Icon } from 'semantic-ui-react' | ||
|
||
const NotificationMessage = props => { | ||
const { options, ...rest } = props | ||
const { id, type, title, description, timeStamp, isMsgRead, icon } = options | ||
return ( | ||
<Flexbox | ||
id={id} | ||
isMsgRead={isMsgRead} | ||
flexDirection='column' | ||
flexGrow={1} | ||
className={'column singleNotification'} | ||
{...rest} | ||
> | ||
<Flexbox title={title}> | ||
<Icon className={`ei text-large notificationIcon ${type} ${icon}`} /> | ||
<Flexbox flexDirection='column' className={`notificationContent`}> | ||
<div className='notificationTitle'>{title}</div> | ||
<div className='notificationDesc '>{description}</div> | ||
<div className='notificationActions'> | ||
<span className='notificationClear'>Clear</span> | ||
</div> | ||
</Flexbox> | ||
<div className='notificationTime'>{timeStamp}</div> | ||
</Flexbox> | ||
</Flexbox> | ||
) | ||
} | ||
|
||
NotificationMessage.defaultProps = { | ||
title: '', | ||
description: '', | ||
timeStamp: '', | ||
icon: '' | ||
} | ||
|
||
NotificationMessage.propTypes = { | ||
title: PropTypes.string, | ||
description: PropTypes.string | ||
} | ||
|
||
export default NotificationMessage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react' | ||
|
||
const NotificationTray = props => { | ||
const { children, ...rest } = props | ||
return <div {...rest}>{children}</div> | ||
} | ||
|
||
export default NotificationTray |
Oops, something went wrong.