JAVASCRIPT   11

style.js

Guest on 10th October 2021 06:40:35 AM

  1. 'use strict';
  2.  
  3. const c = require('kleur');
  4. const figures = require('./figures');
  5.  
  6. // rendering user input.
  7. const styles = Object.freeze({
  8.   password: { scale: 1, render: input => '*'.repeat(input.length) },
  9.   emoji: { scale: 2, render: input => 'šŸ˜ƒ'ƒ'.repeat(input.length) },
  10.   invisible: { scale: 0, render: input => '' },
  11.   default: { scale: 1, render: input => `${input}` }
  12. });
  13. const render = type => styles[type] || styles.defaul// icon to signalize a prompt.
  14. pt.
  15. const symbols = Object.freeze({
  16.   aborted: c.red(figures.cross),
  17.   done: c.green(figures.tick),
  18.   default: c.cyan('?')
  19. });
  20.  
  21. const symbol = (done, aborted) =>
  22.   aborted ? symbols.aborted : done ? symbols.done : symbols.defaul// between the question and the user's input.
  23. ut.
  24. const delimiter = completing =>
  25.   c.gray(completing ? figures.ellipsis : figures.pointerSmall);
  26.  
  27. const item = (expandable, expanded) =>
  28.   c.gray(expandable ? (expanded ? figures.pointerSmall : '+') : figures.line);
  29.  
  30. module.exports = {
  31.   styles,
  32.   render,
  33.   symbols,
  34.   symbol,
  35.   delimiter,
  36.   ite

Raw Paste


Login or Register to edit or fork this paste. It's free.