bulma/docs/documentation/elements/notification.html

101 lines
3.5 KiB
HTML
Raw Normal View History

---
2017-07-29 12:02:00 +00:00
title: Notification
layout: documentation
doc-tab: elements
doc-subtab: notification
2018-04-09 13:15:31 +00:00
breadcrumb:
- home
- documentation
- elements
- elements-notification
meta:
colors: true
sizes: false
variables: true
---
2017-07-29 12:02:00 +00:00
{% capture notification %}
<div class="notification">
<button class="delete"></button>
Lorem ipsum dolor sit amet, consectetur
adipiscing elit lorem ipsum dolor. <strong>Pellentesque risus mi</strong>, tempus quis placerat ut, porta nec nulla. Vestibulum rhoncus ac ex sit amet fringilla. Nullam gravida purus diam, et dictum <a>felis venenatis</a> efficitur.
</div>
2017-07-29 12:02:00 +00:00
{% endcapture %}
{% capture notification_js_html %}
<div class="notification">
<button class="delete"></button>
Lorem ipsum
</div>
{% endcapture %}
{% capture notification_js_code %}
document.addEventListener('DOMContentLoaded', () => {
(document.querySelectorAll('.notification .delete') || []).forEach(($delete) => {
const $notification = $delete.parentNode;
2020-01-05 12:56:19 +00:00
$delete.addEventListener('click', () => {
$notification.parentNode.removeChild($notification);
});
});
});
{% endcapture %}
<div class="content">
<p>
2019-10-13 18:20:44 +00:00
The notification is a simple colored block meant to draw the attention to the user about something. As such, it can be used as a pinned notification in the corner of the viewport. That's why it supports the use of the <code>delete</code> element.
</p>
</div>
2018-04-09 21:25:26 +00:00
{% include elements/snippet.html content=notification %}
2017-07-29 12:02:00 +00:00
2018-04-09 21:25:26 +00:00
{% include elements/anchor.html name="Colors" %}
2017-07-29 12:02:00 +00:00
<div class="content">
<p>
The notification element is available in all the <strong>different colors</strong> defined by the <a href="{{ site.data.links.by_id.customize-variables.path }}"><code>$colors</code> Sass map</a>.
</p>
</div>
{% for color in site.data.colors.justColors %}
{% capture foobar %}
<div class="notification is-{{ color }}">
<button class="delete"></button>
Primar lorem ipsum dolor sit amet, consectetur
adipiscing elit lorem ipsum dolor. <strong>Pellentesque risus mi</strong>, tempus quis placerat ut, porta nec nulla. Vestibulum rhoncus ac ex sit amet fringilla. Nullam gravida purus diam, et dictum <a>felis venenatis</a> efficitur.
</div>
{% endcapture %}
{% include elements/snippet.html content=foobar %}
{% endfor %}
2017-07-29 12:02:00 +00:00
2020-01-05 12:56:19 +00:00
{% include elements/anchor.html name="Light colors" %}
<div class="content">
Each color also comes in its <strong>light</strong> version. Simply append the <code>is-light</code> modifier to obtain the light version of the notification.
</div>
2020-01-05 12:56:19 +00:00
{% for color in site.data.colors.justColors %}
{% capture foobar %}
<div class="notification is-{{ color }} is-light">
<button class="delete"></button>
Primar lorem ipsum dolor sit amet, consectetur
adipiscing elit lorem ipsum dolor. <strong>Pellentesque risus mi</strong>, tempus quis placerat ut, porta nec nulla. Vestibulum rhoncus ac ex sit amet fringilla. Nullam gravida purus diam, et dictum <a>felis venenatis</a> efficitur.
</div>
{% endcapture %}
{% include elements/snippet.html content=foobar %}
{% endfor %}
2020-01-05 12:56:19 +00:00
{% include elements/anchor.html name="JavaScript example" %}
<div class="content">
<p>
The Bulma package <strong>does not come with any JavaScript</strong>. Here is however an implementation example, which sets the <code>click</code> handler for Bulma <code>delete</code> all on the page, in vanilla JavaScript.
</p>
2020-01-05 12:56:19 +00:00
{% highlight html %}{{ notification_js_html }}{% endhighlight %}
2020-01-05 12:56:19 +00:00
{% highlight javascript %}{{ notification_js_code }}{% endhighlight %}
</div>
{% include components/variables.html type='element' %}