A very simple, tiny & useful Google+ style notification bar which comes from the bottom, notifies you & transitions back to the bottom. Screenshots below.
If you're reading this on npmjs website, please visit GitHub page for better documentation!!
These screenshots are from Instagram-clone I created & you can use the code with 5 simple & straight-forward steps!!
- jQuery
- First install the package with
npm
orYarn
.
npm install handy-notification
or
yarn add handy-notification
- Create a div with class
handy-notify
.
<div class='handy-notify'>
<span></span>
</div>
- Add below styles to the
.handy-notify
div in your stylesheet.
.handy-notify{
position: fixed;
background: #333;
left: 2%;
color: white;
border-radius: 3px;
padding: 12px 80px 12px 25px;
font-size: 15px;
cursor: pointer;
text-align: left;
z-index: 3;
top: 105%;
}
- And here comes the fun part.
import Handy from 'handy-notification'
Handy({
value: "Hello, how are you?", // Message to be displayed
action: "https://github.com/yTakkar/Handy-Notification", // URL when clicked on the notification bar
done: () => console.log('I notified you & went back to the bottom!') // function to be executed when you're notified
})
- Copy
Handy-notify-plugin.js
into your project & include it.
<script src="/Handy-notify-plugin.js" ></script>
- Create a div with class
handy-notify
.
<div class='handy-notify'>
<span></span>
</div>
- Add below styles to the
.handy-notify
div in your stylesheet.
.handy-notify{
position: fixed;
background: #333;
left: 2%;
color: white;
border-radius: 3px;
padding: 12px 80px 12px 25px;
font-size: 15px;
cursor: pointer;
text-align: left;
z-index: 3;
top: 105%;
}
- And here comes the fun part.
$('.handy-notify').HandyNotify({
value: "Hello, how are you?", // Message to be displayed
action: "https://github.com/yTakkar/Handy-Notification", // URL when clicked on the notification bar
done: () => console.log('I notified you & went back to the bottom!') // function to be executed when we're notified
})
Handy(options:Object)
options = {
beforeTop,
afterTop,
value,
selector,
action,
done
}
- beforeTop:
- Initial top style which keeps the notification bar at the bottom to hide it. Default top style is 105%.
- afterTop
- Top style where it comes from the bottom & stops to notify you. Default top style is 90%.
- value
- This will be the message.
- selector
- Selector we just created (NOTE: Not availabe to jQuery plugins).
- action
- It's a URL. Responsible to redirect when clicked.
- done
- It's a function which will be executed when you're notified
Thanks for reading!!