Skip to content

Commit

Permalink
Version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dharFr committed Oct 16, 2014
1 parent 93ab546 commit 1f141fd
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 24 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ badgee.log('Configuring badgee...');
```
> ![simple-log](http://www.dhar.fr/assets/badgee/step-1.png)
### Configuration

A simple configuration object allows to:
- enable/disable logs globally
- enable/disable styled badges globally
Expand All @@ -49,6 +51,8 @@ badgee.log( 'Config set to:', badgee.config() );
```
> ![config](http://www.dhar.fr/assets/badgee/step-2.png)
### Defining a new badgee instance

The `define()` method creates a new badgee instance identified by the first argument. The second argument points to an already defined style.
The retunred object works the same way as `console` or `badgee` objects, but every console output is prefixed with a "green" styled badge.

Expand All @@ -58,6 +62,8 @@ helloBadge.log('hello badge defined!');
```
> ![define](http://www.dhar.fr/assets/badgee/step-3.png)
### Styling badges

There is already a few styles defined for your badges.
You can list them all using the `style()` method without any argument.

Expand Down Expand Up @@ -97,6 +103,8 @@ importantBadge.log("Don't miss this one!");
```
> ![define](http://www.dhar.fr/assets/badgee/step-6.png)
### Reusing badgee instances

Somewhere else in your application, you may want to reuse an existing badge.
Get it back by calling the `get()` method with the badge identifier as a first argument.

Expand All @@ -106,6 +114,8 @@ helloBadge.log('Using Hello badge from another module' );
```
> ![get](http://www.dhar.fr/assets/badgee/step-7.png)
### Nested badges

You can also use the `define()` method on an existing badgee instance to define a nested badge.
The newly defined object is still a `badgee` instance.
But every console output will be prefixed with two badges instead of one.
Expand Down Expand Up @@ -168,11 +178,19 @@ When called without parameters, returns the list of already defined styles.

- `name`
Type: String
The name of the new style to define.
The name of the new style to define/retrive.
- `style`
Type: Object
A set of key/value pairs to define a CSS style for badges.

### `badgee.defaultStyle([style])`

When called without parameters, returns the current default styles.

- `style`
Type: Object
A set of key/value pairs to apply by defaultwhen defining a new style for badges.

### `badgee.define(label, style)`

Creates and returns a new badgee instance, for which every console output will be prefixed with the provided `label`, formated according to provided `style` definition.
Expand All @@ -185,7 +203,6 @@ Creates and returns a new badgee instance, for which every console output will b
Type: String
The name of an already defined badgee style (see `badgee.style()`)


### `badgee.get(label)`

Returns an existing badgee instance, identified by its `label`
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "badgee",
"author": ["Olivier Audard <[email protected]>"],
"version": "1.0.2",
"version": "1.1.0",
"description": "a browser console improvement",
"main": "build/badgee.min.js",
"repository": {
Expand Down
73 changes: 55 additions & 18 deletions build/badgee.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.badgee=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
(function (global){

/*! badgee v1.0.0 - MIT license */
/*! badgee v1.1.0 - MIT license */
'use strict';
var Badgee, Store, argsForBadgee, b, concatLabelToOutput, config, currentConf, e, fallback, method, methods, noop, properties, store, styles, unformatableMethods, _defineMethods, _i, _len, _ref,
__slice = [].slice;
Expand Down Expand Up @@ -122,6 +122,8 @@ b = new Badgee;

b.style = styles.style;

b.defaultStyle = styles.defaults;

b.get = function(label) {
var _ref1;
return (_ref1 = store.get(label)) != null ? _ref1.badgee : void 0;
Expand All @@ -146,6 +148,7 @@ try {
return console;
};
fallback.style = b.style;
b.styleDefaults = b.styleDefaults;
fallback.get = function() {
return console;
};
Expand Down Expand Up @@ -231,22 +234,38 @@ module.exports = Store;


},{}],4:[function(_dereq_,module,exports){
var Store, black, defaults, extend, store, styles, white;
var Store, black, defaults, extend, store, styles;

Store = _dereq_('./store');

extend = _dereq_('./utils').extend;

store = new Store;

defaults = {
'border-radius': '2px',
'padding': '1px 3px',
'margin': '0 1px',
'color': 'white'
};

styles = {
style: function(name, style) {
if ((name != null) && (style != null)) {
style = extend({}, defaults, style);
store.add(name, style);
} else if (name != null) {
return store.get(name);
} else {
return store.list();
}
},
defaults: function(style) {
if (style != null) {
defaults = style;
}
return defaults;
},
stringForStyle: function(name) {
var k, style, v;
style = store.get(name);
Expand All @@ -262,37 +281,55 @@ styles = {
}
};

defaults = {
'border-radius': '2px',
'padding': '1px 3px',
'margin': '0 1px'
};

white = {
'color': 'white'
};

black = {
'color': 'black'
};

styles.style('green', extend({}, defaults, white, {
styles.style('black', extend({}, {
'background': 'black'
}));

styles.style('blue', extend({}, {
'background': 'blue'
}));

styles.style('brown', extend({}, {
'background': 'brown'
}));

styles.style('gray', extend({}, {
'background': 'gray'
}));

styles.style('green', extend({}, {
'background': 'green'
}));

styles.style('purple', extend({}, defaults, white, {
styles.style('purple', extend({}, {
'background': 'purple'
}));

styles.style('orange', extend({}, defaults, white, {
styles.style('red', extend({}, {
'background': 'red'
}));

styles.style('cyan', extend({}, black, {
'background': 'cyan'
}));

styles.style('magenta', extend({}, black, {
'background': 'magenta'
}));

styles.style('orange', extend({}, black, {
'background': 'orange'
}));

styles.style('red', extend({}, defaults, white, {
'background': 'red'
styles.style('pink', extend({}, black, {
'background': 'pink'
}));

styles.style('yellow', extend({}, defaults, black, {
styles.style('yellow', extend({}, black, {
'background': 'yellow'
}));

Expand Down
2 changes: 1 addition & 1 deletion build/badgee.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "badgee",
"author": "Olivier Audard <[email protected]>",
"version": "1.0.2",
"version": "1.1.0",
"description": "a browser console improvement",
"main": "build/badgee.min.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/badgee.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
###! badgee v1.0.0 - MIT license ###
###! badgee v1.1.0 - MIT license ###
'use strict'

# For the record, every single console methods and properties
Expand Down

0 comments on commit 1f141fd

Please sign in to comment.