Style templates for console.log

Overview

sttyl

Tags Doc

Style templates for console.log.

Usage

This module is primarily intended for Deno and browsers.

import { sttyl } from "https://deno.land/x/[email protected]/mod.ts";
//
// Basic
//
console.log(
  ...sttyl`Hello, here is some ${"RED"}.b.i.red.u//&${"YELLOW"}.yellow/ text.`,
  {
    and: "some args",
    more: "and some more args",
  },
);
console.log("");
//
// Dynamic Styles
//
const style1 = ".b.i.cyan.u/";
const style2 = ".b.green/";
console.log(
  ...sttyl`...and some ${"dynamically"}${style1} ${"styled"}${style2} text.`,
);
console.log("");
//
// Custom Styles
//
const styles = {
  s1: `color: magenta; font-weight: bold`,
  s2: `color: orange; font-style: italic`,
};
const myStyle = sttyl.with(styles);
console.log(
  ...myStyle`...and ${"text"}.s1/ ${"with custom style names"}.s2.u/.`,
);

Preview

The code above should output something like this:

Image of console text output styled with sttyl

Browser Usage

The usage above works in modern browsers.

Install with npm install sttyl or yarn add sttyl and modify import to:

import sttyl from "sttyl";

Default Styles

When you pass your custom styles into sttyl.with(), they are combined with and can override all of the defaultStyles shown below.

const defaultStyles: Record<string, string> = {
  // #region Colors
  black: "color: black",
  blue: "color: blue",
  cyan: "color: cyan",
  gray: "color: gray",
  green: "color: green",
  grey: "color: grey",
  magenta: "color: magenta",
  red: "color: red",
  white: "color: white",
  yellow: "color: yellow",
  // #endregion
  // #region Formatting
  b: "font-weight: bold",
  bold: "font-weight: bold",
  i: "font-style: italic",
  italic: "font-style: italic",
  s: "text-decoration: line-through",
  strike: "text-decoration: line-through",
  u: "text-decoration: underline",
  underline: "text-decoration: underline",
  // #endregion
};
You might also like...

A library to log for Scriptable.

scriptable-logger Logger is a library to log for Scriptable. Usage const Logger = importModule('logger'); Logger.log('log'); // 'log' in white color.

Apr 29, 2022

Benefit cards API, create and store card data and log transactions

Benefit cards API, create and store card data and log transactions

Valex 💳 Benefit cards for companies and employees! 💻 Tech used Overview An API to store benefit cards from companies to employees and log transactio

Apr 25, 2022

A full stack application that uses an authentication system to allow FAA Inspectors, Airliners, and Aircraft Technicians to update progress on their work all while keeping a log of records on projects completed.

A full stack application that uses an authentication system to allow FAA Inspectors, Airliners, and Aircraft Technicians to update progress on their work all while keeping a log of records on projects completed.

Jun 13, 2022

This code can be used to log activity on yours Polytoria Games.

This code can be used to log activity on yours Polytoria Games.

polyGameLogger This code can be used to log activity on yours Polytoria Games. current version: 0.1.1 Basic Setup First of all, you need to create a .

Jun 13, 2022

A progressive web app to help volunteers track their volunteering activities, register vet concerns and log incident reports.

POOPS - Pets of Older Persons 2022 Introduction This is a Next.js project bootstrapped with create-next-app. Getting Started First, install yarn: npm

Jan 3, 2023

Register your username, log into the app and create your list of a to-do with local storage.

Register your username, log into the app and create your list of a to-do with local storage.

Todofy Todofy is a web app to create your to-do list with local storage. Explore the docs » View Demo · Report Bug · Request Feature Table of Contents

Jun 30, 2022

Browser extension that enables you to Log-in as ANY address on ALL dapps

Browser extension that enables you to Log-in as ANY address on ALL dapps

Impersonator Extension Log-in as ANY address on ALL dapps. Impersonator injects into the dapps just like Metamask, but gives you the freedom to set cu

Dec 14, 2022

Collection of customizable Anki flashcard templates with modern and clean themes.

Collection of customizable Anki flashcard templates with modern and clean themes.

Anki Templates Collection of customizable Anki flashcard templates with modern and clean themes. About Features Themes Instructions Add-on support Com

Dec 29, 2022
Releases(1.0.3)
Owner
Wayne Bloss
Wayne Bloss
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Console log to terminal

Termlog Console log to terminal What it does termlog send the browser console log to your terminal It also comes with a nodejs REPL so you can do some

Quang Ngoc 16 Jan 21, 2022
Another logger in JS. This one offers a console.log-like API and formatting, colored lines and timestamps (or not if desired), all that with 0 dependencies.

hellog Your new logger ! hellog is a general-purpose logging library. It offers a console.log-like API and formatting, extensible type-safety colored

Maxence Lecanu 4 Jan 5, 2022
This is a toy, it is an enhanced version of console.log

uu-console Hi, this is a toy. When you use console.log to print some logs, this can help you do some useless things. What is uu-console Support built-

KK Liu 2 Sep 25, 2022
Base62-token.js - Generate & Verify GitHub-style & npm-style Base62 Tokens

base62-token.js Generate & Verify GitHub-style & npm-style Secure Base62 Tokens Works in Vanilla JS (Browsers), Node.js, and Webpack. Online Demo See

Root 4 Jun 11, 2022
This is a full stack application where you can log all you places where you visited....-

Full Stack Travelling Log ?? ?? ✈️ This is a full stack application where you can log ✈️ your all places ?? ?? ?? you have visited .... ??️ ??️ ??️ Se

null 19 Sep 29, 2022
Chrome extension that uses vulnerabilities CVE-2021-33044 and CVE-2021-33045 to log in to Dahua cameras without authentication.

DahuaLoginBypass Chrome extension that uses vulnerability CVE-2021-33044 to log in to Dahua IP cameras and VTH/VTO (video intercom) devices without au

null 71 Nov 26, 2022
Get the last logs of your /var/log folder

var-log-crawler Get the last logs of your /var/log folder Requirements: Node installed. Hot to use: Rename .env.sample to .env and fill with your valu

David William Rigamonte 2 Jan 5, 2022
A simple to do list webpage where you can log the daily tasks you have to do, mark them as checked, modify them, reorder them and remove them. Made using HTML, CSS and JavaScript.

To-Do-List This Webpage is for an app called To-Do-List which helps you add, remove or check tasks you have to do. It is a simple web page which conta

Zeeshan Haider 9 Mar 12, 2022