Skip to content

Commit 79cbbd3

Browse files
committed
fix(docs): clarify docs
1 parent 3d2c92e commit 79cbbd3

2 files changed

Lines changed: 64 additions & 50 deletions

File tree

README.md

Lines changed: 64 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,91 +10,103 @@
1010
1111
![example](/media/example.png)
1212

13-
## Install
13+
## Get Started
1414

1515
```bash
1616
$ npm install --save pretty-web-console
1717
```
1818

1919
## Usage
2020

21-
You can either pass a config or use chaining for your desired logs. See the **Available Styles** section for options.
21+
You can use the rich **chaining** api and/or pass a **config** for your desired logs. It's easy!
2222

23-
### 1. Config
23+
### Chaining
2424

2525
```javascript
2626
import pwc from 'pretty-web-console'
2727

28-
const myLogger = pwc({
29-
color: 'blue',
30-
weight: 'bold',
31-
size: 'large',
32-
decorate: 'linethrough'
33-
})
28+
// configure your stylized loggers
29+
const loggerA = pwc().size('large').weight('bold')
30+
const loggerB = pwc().large().bold()
31+
32+
// log anything!
33+
loggerA.log('hi')
34+
loggerB.log('hi')
3435

35-
// now you can re-use your stylized logger
36-
myLogger.log('hello')
36+
// you can even extend your loggers
37+
loggerA.fantasy().underline().info('i am back')
3738
```
3839

39-
### 2. Chaining
40+
### Config
4041

4142
```javascript
42-
const coolLogger = pwc().size('large').weight('bold').bg('lightgreen')
43-
const twinCoolLogger = pwc().large().bold().bglightgreen()
43+
// pass in a config object
44+
const logger = pwc({
45+
color: 'blue',
46+
weight: 'bold',
47+
size: 'large',
48+
decorate: 'linethrough'
49+
})
4450

45-
// both output the same styled logs
46-
coolLogger.log('hi')
47-
twinCoolLogger.log('hi')
51+
// log it!
52+
logger.log('hi')
4853

49-
// you can also mix-and-match
50-
pwc({ size: 'large' }).bold().bg('lightgreen').log('hi again')
54+
// feel free to mix-and-match between different methods
55+
pwc({ color: 'green' }).size('large').bold().log('hi again')
5156
```
5257

53-
## Available Styles
58+
## Properties
59+
60+
All properies below are available for chaining. But, only those marked with an asterisk `*` are supported by the config. These also accept css values, while the properties without an `*` don't take any arguments i.e. `blue()` and `bold()`.
61+
62+
* `blue`, `red`, `turquoise`, `aquamarine`, etc for [all web colors](https://en.wikipedia.org/wiki/Web_colors#X11_color_names) lowercased
63+
* color*
64+
* `bold`, `lighter`, `bolder`
65+
* weight*
66+
* `small`, `medium`, `large`
67+
* size*
68+
* `underline`, `overline`, `linethrough`
69+
* decorate*
70+
* `arial`, `couriernew`, `georgia`, `timesnewroman`, `trebuchetms`, `verdana`, `serif`, `sansserif`, `monospace`, `cursive`, `fantasy`
71+
* family*
72+
* `italic`, `oblique`
73+
* style*
74+
* `capitalize`, `uppercase`, `lowercase`
75+
* transform*
76+
* `bgblue`, `bgred`, `bgturquoise`, `bgaquamarine` etc for [all web colors](https://en.wikipedia.org/wiki/Web_colors#X11_color_names) lowercased and prefixed with `bg`
77+
* bg*
78+
* shadow*
79+
* padding*
80+
* margin*
81+
* css*
5482

55-
Everything to the right of the colon are used for shorthand chaining i.e. `.bold()` and `.cursive()`. Everything to the left are used as keys in chaining and configs i.e. `.weight('bold')` or `{weight: 'bold'}`. All keys support css values.
83+
### Examples
5684

57-
1. color: [all web colors](https://en.wikipedia.org/wiki/Web_colors#X11_color_names) lowercased
58-
1. weight: `bold`, `lighter`, `bolder`
59-
1. size: `small`, `medium`, `large`
60-
1. decorate: `underline`, `overline`, `linethrough`
61-
1. family: `arial`, `couriernew`, `georgia`, `timesnewroman`, `trebuchetms`, `verdana`, `serif`, `sansserif`, `monospace`, `cursive`, `fantasy`
62-
1. style: `italic`, `oblique`
63-
1. transform: `capitalize`, `uppercase`, `lowercase`
64-
1. bg: `bgblue`, `bgred`, etc for [all web colors](https://en.wikipedia.org/wiki/Web_colors#X11_color_names) lowercased and prefixed with `bg`
65-
1. shadow
66-
1. padding
67-
1. margin
68-
1. css
85+
```javascript
86+
pwc().turquoise().bgred().info('turquoise info msg with red background')
6987

70-
### Examples
88+
pwc().decorate('uppercase').cursive().log('uppercased cursive msg')
7189

72-
All of these accomplish the same thing:
90+
pwc({ shadow: '4px 4px 5px green' }).large().error('large error msg with green shadow')
7391

74-
```javascript
75-
/* 1. config */
76-
pwc({ bg: 'red' })
77-
pwc({ bg: '#f00' })
78-
pwc({ bg: 'rgb(255,0,0)' })
79-
80-
/* 2. chaining */
81-
pwc().bg('red')
82-
pwc().bg('#f00')
83-
pwc().bg('rgb(255,0,0)')
84-
pwc().bgred()
92+
pwc({ weight: 'bold', color: '#00f' }).size(20).log('bold, blue, and 20px msg')
8593
```
8694

87-
As shown above, any css value can be used, unless you are using the shorthand chaining api i.e. `.bgred()` which doesn't take any arguments.
95+
Have fun with making your logs pretty!
8896

8997
## Log Levels
9098

91-
`.log()`, `.warn()`, `.error()`, `.info()`, and `.debug()` are supported.
99+
* `.log()`
100+
* `.warn()`
101+
* `.error()`
102+
* `.info()`
103+
* `.debug()`
92104

93105
## Custom Logger
94106

95-
By default, the logger used is the standard browser console. But, you may pass in your own logger if you want!
107+
By default, the logger used is the standard browser console. But, you may pass in your own logger if you want.
96108

97-
For example, `pwc().blue().bold().underline().warn('hi', customWarnFn)` would pass the message and a css styles object as arguments to `customWarnFn`. The styles object for the example would look like this:
109+
For example, let's say you have a logger function named `customWarnFn`. You just need to pass it to the log function as the second argument i.e. `pwc().blue().bold().underline().warn('hi', customWarnFn)`. This passes the message and a css styles object as arguments to your custom logger. The styles object for the example would look like this:
98110

99111
```javascript
100112
{
@@ -104,6 +116,8 @@ For example, `pwc().blue().bold().underline().warn('hi', customWarnFn)` would pa
104116
}
105117
```
106118

119+
Enjoy!
120+
107121
[![NPM](https://nodei.co/npm/pretty-web-console.png?compact=true)](https://www.npmjs.com/package/pretty-web-console)
108122

109123
[![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](https://github.com/bbmoz/pretty-web-console)

media/example.png

11.3 KB
Loading

0 commit comments

Comments
 (0)