? console-badge - Create simple badges in the browser console
source link: https://www.tuicool.com/articles/nEBNVfB
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
:art: console-badge
Create simple badges in the browser console.
Tiny, easy-to-use package. No dependencies.
Features
- Tiny: Less than 1kB (minified and gzipped). No dependencies. ES5-compliant code.
- Customizable: Change the font colors, background colors and texts. Tip: You can use the popular shields.io badge style. :sunglasses:
Installation
$ npm install console-badge # OR $ yarn add console-badge
Usage
import * as consoleBadge from 'console-badge'; consoleBadge.log({ mode: 'shields.io', leftText: 'console-badge', rightText: 'hello world :rocket:', rightBgColor: '#ffc107', rightTextColor: '#1a1a1a' }); consoleBadge.log({ leftText: ':sunglasses: Check out our code here:', leftTextColor: '#000', leftBgColor: '#ddd', rightText: 'https://example.com/oss', rightBgColor: '#000' });
Output:
CDN
For prototyping or learning purposes, you can use the latest version with:
<script src="https://cdn.jsdelivr.net/npm/console-badge"></script>
For production, we recommend linking to a specific version number and build to avoid unexpected breakage from newer versions:
<script src="https://cdn.jsdelivr.net/npm/console-badge@1/dist/console-badge.umd.min.js"></script>
// Global variable consoleBadge.log(); // Property in the window object window.consoleBadge.log();
⚠ NPM is therecommended installation method. It pairs nicely with module bundlers such as webpack .
API
.log(options?)
options
Type: Object
mode
Type: String
Default: 'default'
Values:
'default' 'shields.io'
General style of the badge.
leftText
Type: String
Default: 'Lorem'
The text inside the left section.
rightText
Type: String
Default: 'Ipsum'
The text inside the right section.
leftTextColor
Type: String
Default: '#ffffff'
The font color of the text inside the left section.
rightTextColor
Type: String
Default: '#ffffff'
The font color of the text inside the right section.
leftBgColor
Type: String
Default: '#555555'
The background color of the left section.
rightBgColor
Type: String
Default: '#1966D2'
The background color of the right section.
Show your support
Please :star:️ this repository if this project helped you!
License
Copyright (c) 2019-present, Dennis Herzberg
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK