|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 2 weeks ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | const c = require('kleur');
|
|---|
| 4 |
|
|---|
| 5 | const figures = require('./figures'); // rendering user input.
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 | const styles = Object.freeze({
|
|---|
| 9 | password: {
|
|---|
| 10 | scale: 1,
|
|---|
| 11 | render: input => '*'.repeat(input.length)
|
|---|
| 12 | },
|
|---|
| 13 | emoji: {
|
|---|
| 14 | scale: 2,
|
|---|
| 15 | render: input => '😃'.repeat(input.length)
|
|---|
| 16 | },
|
|---|
| 17 | invisible: {
|
|---|
| 18 | scale: 0,
|
|---|
| 19 | render: input => ''
|
|---|
| 20 | },
|
|---|
| 21 | default: {
|
|---|
| 22 | scale: 1,
|
|---|
| 23 | render: input => `${input}`
|
|---|
| 24 | }
|
|---|
| 25 | });
|
|---|
| 26 |
|
|---|
| 27 | const render = type => styles[type] || styles.default; // icon to signalize a prompt.
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | const symbols = Object.freeze({
|
|---|
| 31 | aborted: c.red(figures.cross),
|
|---|
| 32 | done: c.green(figures.tick),
|
|---|
| 33 | exited: c.yellow(figures.cross),
|
|---|
| 34 | default: c.cyan('?')
|
|---|
| 35 | });
|
|---|
| 36 |
|
|---|
| 37 | const symbol = (done, aborted, exited) => aborted ? symbols.aborted : exited ? symbols.exited : done ? symbols.done : symbols.default; // between the question and the user's input.
|
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 | const delimiter = completing => c.gray(completing ? figures.ellipsis : figures.pointerSmall);
|
|---|
| 41 |
|
|---|
| 42 | const item = (expandable, expanded) => c.gray(expandable ? expanded ? figures.pointerSmall : '+' : figures.line);
|
|---|
| 43 |
|
|---|
| 44 | module.exports = {
|
|---|
| 45 | styles,
|
|---|
| 46 | render,
|
|---|
| 47 | symbols,
|
|---|
| 48 | symbol,
|
|---|
| 49 | delimiter,
|
|---|
| 50 | item
|
|---|
| 51 | }; |
|---|
Note:
See
TracBrowser
for help on using the repository browser.