Skip to content

Commit

Permalink
Merge pull request #43 from bitjson/symbol-types
Browse files Browse the repository at this point in the history
fix: add missing symbol types, include symbols
  • Loading branch information
doowb authored Sep 9, 2020
2 parents 337c504 + 8169f47 commit f5b5e12
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 10 deletions.
3 changes: 1 addition & 2 deletions symbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const common = {
pilcrow2: '❡',
pilcrow: '¶',
plusMinus: '±',
question: '?',
section: '§',
starsOff: '☆',
starsOn: '★',
Expand All @@ -38,7 +39,6 @@ const windows = Object.assign({}, common, {
ellipsisLarge: '...',
ellipsis: '...',
info: 'i',
question: '?',
questionSmall: '?',
pointer: '>',
pointerSmall: '»',
Expand All @@ -54,7 +54,6 @@ const other = Object.assign({}, common, {
ellipsisLarge: '⋯',
ellipsis: '…',
info: 'ℹ',
question: '?',
questionFull: '?',
questionSmall: '﹖',
pointer: isLinux ? '▸' : '❯',
Expand Down
83 changes: 75 additions & 8 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,81 @@
// Integrated by: Jordan Mele <https://github.com/Silic0nS0ldier>

interface SymbolsType {
check: string;
cross: string;
info: string;
line: string;
pointer: string;
pointerSmall: string;
question: string;
warning: string;
/**
* `undefined` on windows, `✘` on other platforms.
*/
ballotCross?: "✘";
ballotDisabled: "☒";
ballotOff: "☐";
ballotOn: "☑";
bullet: "•";
bulletWhite: "◦";
/**
* `√` on windows, `✔` on other platforms.
*/
check: "√" | "✔";
/**
* `×` on windows, `✖` on other platforms.
*/
cross: "×" | "✖";
/**
* `...` on windows, `⋯` on other platforms.
*/
ellipsisLarge: "..." | "⋯";
/**
* `...` on windows, `…` on other platforms.
*/
ellipsis: "..." | "…";
fullBlock: "█";
heart: "❤";
identicalTo: "≡";
info: "i" | "ℹ";
line: "─";
mark: "※";
middot: "·";
minus: "-";
multiplication: "×";
obelus: "÷";
pencilDownRight: "✎";
pencilRight: "✏";
pencilUpRight: "✐";
percent: "%";
pilcrow2: "❡";
pilcrow: "¶";
plusMinus: "±";
/**
* `>` on windows, `▸` on linux, and `❯` on other platforms.
*/
pointer: ">" | "▸" | "❯";
/**
* `»` on windows, `‣` on linux, and `›` on other platforms.
*/
pointerSmall: "»" | "‣" | "›";
question: "?";
/**
* `undefined` on windows, `?` on other platforms.
*/
questionFull?: "?";
/**
* `?` on windows, `﹖` on other platforms.
*/
questionSmall: "?" | "﹖";
/**
* `( )` on windows, `◯` on other platforms.
*/
radioOff: "( )" | "◯";
/**
* `(*)` on windows, `◉` on other platforms.
*/
radioOn: "(*)" | "◉";
section: "§";
starsOff: "☆";
starsOn: "★";
upDownArrow: "↕";
/**
* `‼` on windows, `⚠` on other platforms.
*/
warning: "‼" | "⚠";
}

type StyleArrayStructure = [number, number];
Expand Down
46 changes: 46 additions & 0 deletions types/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,49 @@ s = colors.unstyle(colors.red("hello"));
s = colors.strip(colors.red("hello"));

s = colors.ok("deployment succeeded!");

// common symbols
s = colors.symbols.ballotDisabled;
s = colors.symbols.ballotOff;
s = colors.symbols.ballotOn;
s = colors.symbols.bullet;
s = colors.symbols.bulletWhite;
s = colors.symbols.fullBlock;
s = colors.symbols.heart;
s = colors.symbols.identicalTo;
s = colors.symbols.line;
s = colors.symbols.mark;
s = colors.symbols.middot;
s = colors.symbols.minus;
s = colors.symbols.multiplication;
s = colors.symbols.obelus;
s = colors.symbols.pencilDownRight;
s = colors.symbols.pencilRight;
s = colors.symbols.pencilUpRight;
s = colors.symbols.percent;
s = colors.symbols.pilcrow2;
s = colors.symbols.pilcrow;
s = colors.symbols.plusMinus;
s = colors.symbols.section;
s = colors.symbols.starsOff;
s = colors.symbols.starsOn;
s = colors.symbols.upDownArrow;

// conditional symbols (differ across platforms)
s = colors.symbols.check;
s = colors.symbols.cross;
s = colors.symbols.ellipsisLarge;
s = colors.symbols.ellipsis;
s = colors.symbols.info;
s = colors.symbols.question;
s = colors.symbols.questionSmall;
s = colors.symbols.pointer;
s = colors.symbols.pointerSmall;
s = colors.symbols.radioOff;
s = colors.symbols.radioOn;
s = colors.symbols.warning;

let maybeString: string | undefined;
// unmatched other symbols (may be undefined)
maybeString = colors.symbols.ballotCross;
maybeString = colors.symbols.questionFull;

0 comments on commit f5b5e12

Please sign in to comment.