• Stars
    star
    186
  • Rank 207,316 (Top 5 %)
  • Language
    CSS
  • Created almost 10 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A client side, multi-style alerts system for Meteor.

Bert

Bert is a client side, multi-style alerts system for Meteor.

Say what again!

Contents

  1. Installation
  2. Upgrade Warning
  3. Changes & Deprecations in v2.0.*
  4. Basic Usage
  5. API & Defaults
  6. Customization
  7. Tests
  8. Contributing
  9. License

Installation

To get Bert into your app, just run the following command from within your project's directory:

meteor add themeteorchef:bert

Upgrade Warning

Bert wasn't too happy about this one. Because Bert relies on the ecmascript package, v2.0.* is not compatible with versions of Meteor before 1.2. This means that if you attempt to update Bert in a Meteor application using a version < 1.2, you will receive an error in your terminal. For now, applications that need to remain below 1.2 are advised to pin Bert to 1.1.0: meteor add [email protected]. Bert apologizes for this.

Changes & Deprecations in v2.x

Bert hit the gym since v1.0 came out and has dropped some fat and put on a bit of muscle. If you were working with Bert prior to version 2.0 here are a few things to keep in mind:

  1. Bert no longer requires you to add the {{> bertAlert}} template tag manually. This is automatically added to your application's <body></body> tag.
  2. Bert has added support for icons via the fortawesome:fontawesome package. As of v2.2.0, you are responsible for providing the FontAwesome dependency. This allows you to use any version of that library that you'd like. Instructions for installation are found here.
  3. Bert has dropped support for setting the following defaults: animated, animationSpeed, autoHide, and dismmissable.
  4. Like other notification systems, Bert can now be dismissed with a single click, anywhere on the message.
  5. Bert went to some self-actualization classes and realized he prefers to always be animated and always hide on his own. Of course, you can suggest how fast he should hide and he'll listen.
  6. Bert started experimenting with meditation and found that while he enjoyed CSS, he found Sass to be much more...zen. His CSS is written in Sass, but can still be overridden with plain CSS. Namaste.

Despite having totally ripped abs now—and aside from the changes to defaults mentioned above—Bert's API is 100% backwards compatible. Bert doesn't forget where he came from. Represent.

Basic Usage

There are two ways to display messages with Bert. The classic way, passing a message, type, and style:

Bert.alert( 'Yes, I do Mind!', 'danger', 'growl-top-right' );

And now in v2.0 we also get the Advanced method...

Bert.alert({
  title: 'Now Playing',
  message: 'Ernie &mdash; Rubber Duckie',
  type: 'info',
  style: 'growl-top-right',
  icon: 'fas fa-music'
});

It's important to point out that the Classic version has also picked up support for adding an icon, but requires that you specify all arguments before it:

Bert.alert( 'Ernie, pick up your rubber duckies, now!', 'danger', 'fixed-top', 'fas fa-frown-open' );

API & Defaults

Bert wants to make sure that your users know how angry (or happy) he is about what they're doing. Bert comes with a handful of ways to get the point across:

  • Bert.types

    • default (default)
    • success
    • info
    • warning
    • danger
  • Bert.styles

    • fixed-top (default)
    • fixed-bottom
    • growl-top-left
    • growl-top-right
    • growl-bottom-left
    • growl-bottom-right
  • Bert.icons (based on the type passed to Bert)

    • default: 'fas fa-bell',
    • success: 'fas fa-check',
    • info: 'fas fa-info',
    • warning: 'fas fa-exclamation-triangle',
    • danger: 'fas fa-times'

If you'd like (recommended), you can set any of the values above as defaults, along with a few other settings:

Bert.defaults = {
  hideDelay: 3500,
  // Accepts: a number in milliseconds.
  style: 'fixed-top',
  // Accepts: fixed-top, fixed-bottom, growl-top-left,   growl-top-right,
  // growl-bottom-left, growl-bottom-right.
  type: 'default'
  // Accepts: default, success, info, warning, danger.
};

To add new types and styles, you can call Bert.types.push( '<type>' ) or Bert.styles.push( '<style>' ) from anywhere on the client. To change the icon used for one of the pre-defined types, you can call Bert.icons.<type> = 'fas fa-icon-name', or add a new one by calling Bert.icons[ 'new-type' ] = 'fas fa-icon-name'. Heads up: The fas part is defining which sub-library of FontAwesome you're using (solid, regular, and light). Again, Bert DOES NOT load FontAwesome for you, so which classes you use will be dependent on which version of the library you load on your own.

To set a new default, just call Bert.defaults.<setting> in your client code. For example, to change Bert's hide delay (how long Bert stays on screen), you can set Bert.defaults.hideDelay = 2000. Here, this would make Bert's alerts go away after two seconds instead of three and a half.

Customization

Bert was designed to be easily customized to fit your application's styles. The basic template for a Bert alert is:

<template name="bertAlert">
  <div class="bert-alert {{alert.style}} {{alert.type}} clearfix">
    <div class="bert-container">
      <div class="bert-gem">
        <i class="fa {{alert.icon}}"></i>
      </div>
      <div class="bert-content">
        {{#if alert.title}}<h5>{{alert.title}}</h5>{{/if}}
        <p>{{{alert.message}}}</p>
      </div>
    </div>
  </div>
</template>

Nice and simple! All of the CSS is easily overridden, too. Dress Bert up!

Note: the Spacebars helper for outputting Bert {{{alert.message}}} makes use of Spacebar's triple mustache convention to prevent escaping of HTML characters. This means you can pass any HTML to Bert and he'll render it inside the alert. For example:

Bert.alert( '<h1>Hiya</h1>', 'danger', 'growl-top-right' );

Fair warning: this means you're responsible for styling anything you add. Bert is totally flexible thanks to his yoga practice but he's not that flexible.

Custom Types/Styles

Bert comes with everything you need out of the box, but is extremely flexible when it comes to adding new types and styles of alerts. For example, we can add some CSS for a new type called game-added and use Bert's advanced method for setting alerts:

Bert.alert({
  type: 'game-added',
  style: 'growl-bottom-right',
  title: 'Game Added',
  message: 'Final Fantasy VII',
  icon: 'fas fa-gamepad'
});

The value of type simply gets added to Bert as a CSS class, so we can tweak the colors just by adding a little CSS on the client:

.bert-alert.game-added {
  background: purple;
  color: #fff;
}

Customizing Bert's styles

Tests

Bert comes with a suite of TinyTest-based tests to ensure that all of your alerts make it to the client as intended. To run the tests, open up your terminal and type:

meteor test-packages themeteorchef:bert

Pop open your browser http://localhost:3000. Verify tests are passing. Note: if your app is already running on http://localhost:3000, you can run tests separately by running meteor test-packages themeteorchef:bert --port 3001.

Contributing

Contributing, forking, and dorking is fully encouraged with Bert! If you'd like to help out with the package, take a look at the contribution guide and start hacking :)

License

The code for this package is licensed under the MIT License.

More Repositories

1

base

A starting point for Meteor apps.
JavaScript
695
star
2

security-essentials

Essential security techniques for Meteor applications.
JavaScript
81
star
3

saas-stripe

Learn how to integrate Stripe with Meteor.
JavaScript
61
star
4

roll-your-own-authentication

Learn how to add custom authentication to your Meteor application.
JavaScript
31
star
5

building-a-markdown-editor

JavaScript
31
star
6

building-a-blog-with-react

JavaScript
28
star
7

adding-a-beta-invitation-system-to-your-meteor-application

Learn how to send and approve beta invites in your Meteor application.
JavaScript
26
star
8

writing-an-api

JavaScript
23
star
9

building-complex-forms

JavaScript
19
star
10

react-pdfs

https://themeteorchef.com/snippets/rendering-pdfs-with-react-components
JavaScript
18
star
11

controller

An API for organizing your template logic.
JavaScript
18
star
12

building-a-chat-application

JavaScript
17
star
13

jquery-validation

jQuery Validation repackaged for Meteor.
JavaScript
16
star
14

server-only-methods

Creating Server-Only Methods
JavaScript
16
star
15

how-to-build-a-react-native-app-with-meteor

JavaScript
15
star
16

getting-started-with-react-router-v4

JavaScript
15
star
17

building-a-user-admin

JavaScript
13
star
18

writing-a-package

Learn how to write a package for Meteor.
JavaScript
12
star
19

subscriptions-with-stripe

JavaScript
11
star
20

getting-started-with-react-old

JavaScript
11
star
21

exporting-data-from-your-meteor-application

A recipe for exporting data from your Meteor application.
CSS
10
star
22

building-an-error-logger

JavaScript
9
star
23

reusable-seo-with-react-helmet

JavaScript
9
star
24

slugged-routes

Using slugs instead of document IDs with Meteor
JavaScript
8
star
25

uploading-files-to-amazon-s3

JavaScript
7
star
26

credit-card-forms-with-react

JavaScript
6
star
27

building-a-simple-twitter-clone

JavaScript
6
star
28

scheduling-cron-jobs

https://themeteorchef.com/tutorials/scheduling-cron-jobs
JavaScript
6
star
29

getting-started-with-react

https://themeteorchef.com/tutorials/getting-started-with-react
JavaScript
6
star
30

holiday-wish-list

JavaScript
6
star
31

building-an-invoicing-app

JavaScript
6
star
32

simple-search-react

https://themeteorchef.com/tutorials/simple-search-with-react
JavaScript
5
star
33

react-router-spa

https://themeteorchef.com/snippets/single-page-applications-with-react-router
JavaScript
5
star
34

commonmark

CommonMark.js parser and helper function for converting Markdown to HTML on the client and server.
JavaScript
4
star
35

working-with-the-mantra-architecture

JavaScript
4
star
36

uploading-files-to-amazon-s3-with-react

JavaScript
4
star
37

building-an-in-app-notifications-system

JavaScript
4
star
38

apollo-react-chicago

Code from React Chicago Meetup on February 22nd, 2017
HTML
4
star
39

html5-sortable

HTML5 Sortable by voidberg, repackaged for Meteor.
JavaScript
3
star
40

i18n-and-meteor

This is a demo of i18n with Meteor for The Meteor Chef
JavaScript
3
star
41

fullcalendar

Scratch repo for https://themeteorchef.com/tutorials/reactive-calendars-with-fullcalendar
JavaScript
3
star
42

from-zero-to-mvp

Demo app for From Zero to MVP
JavaScript
3
star
43

react-sticky-scroll

JavaScript
3
star
44

using-the-email-package

https://themeteorchef.com/tutorials/using-the-email-package
JavaScript
3
star
45

deploying-to-modulus

JavaScript
3
star
46

payments-with-stripe-checkout

JavaScript
3
star
47

using-the-module-pattern

https://themeteorchef.com/tutorials/using-the-module-pattern
JavaScript
3
star
48

react-css-transition-groups

https://themeteorchef.com/snippets/react-css-transition-groups
JavaScript
3
star
49

api-wrapper

https://themeteorchef.com/snippets/writing-an-api-wrapper
JavaScript
2
star
50

santa-spotter

Track Santa Claus!
JavaScript
2
star
51

getting-started-with-apollo

JavaScript
2
star
52

seeder

Database seeding utility for Meteor.
JavaScript
2
star
53

pinboard-bookmarks

Fetch your bookmarks from the Pinboard.in service.
JavaScript
2
star
54

dynamic-templates-snippet

Scratch repo for the dynamic templates snippet.
JavaScript
2
star
55

managing-users-with-react

JavaScript
2
star
56

split-testing-with-meteor

JavaScript
2
star
57

building-an-rsvp-system

JavaScript
2
star
58

server-side-rendering

JavaScript
2
star
59

import-csv-snippet

Scratch repo for the import csv snippet.
JavaScript
1
star
60

handling-webhooks

https://themeteorchef.com/snippets/handling-webhooks
JavaScript
1
star
61

managing-dates-with-moment

JavaScript
1
star
62

getting-started-with-meteor

https://themeteorchef.com/tutorials/getting-started-with-meteor
JavaScript
1
star
63

mailing-lists-with-mailchimp

JavaScript
1
star
64

writing-an-npm-package

JavaScript
1
star
65

sortable-lists-with-react-sortable

https://themeteorchef.com/snippets/sortable-lists-with-react-sortable
JavaScript
1
star
66

global-modals-in-react

https://themeteorchef.com/tutorials/global-modals-in-react
JavaScript
1
star
67

document-ownership

https://themeteorchef.com/snippets/document-ownership-basics
JavaScript
1
star
68

using-react-komposer-v2-with-meteor

JavaScript
1
star
69

rate-limiting-methods

https://themeteorchef.com/snippets/rate-limiting-methods
JavaScript
1
star
70

secure-methods-publications

https://themeteorchef.com/tutorials/securing-methods-and-publications-for-production
JavaScript
1
star
71

how-to-deploy-a-meteor-application-to-aws-elastic-beanstalk-for-free

1
star
72

managing-data-migrations

JavaScript
1
star
73

building-a-nested-comments-feature

JavaScript
1
star
74

writing-a-database-seeder

JavaScript
1
star
75

enhanced-deployments-with-galaxy-pro

JavaScript
1
star
76

using-mysql-with-meteor-via-methods

JavaScript
1
star
77

reusable-email-notifications

JavaScript
1
star