-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
81 lines (69 loc) · 2.38 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const inquirer = require('inquirer');
const fs = require('fs');
const chalk = require('chalk');
const Circle = require('../SVG_logo_maker/lib/circle');
const Triangle = require('../SVG_logo_maker/lib/triangle');
const Square = require('../SVG_logo_maker/lib/square');
inquirer
.prompt([
{
type: 'input',
name: 'logoText',
message: chalk.magenta('Please enter (up to) three characters for your logo.'),
validate: (answer) => {
if (answer.length > 3) {
throw Error(chalk.bgRed("You have selected too many characters."))
} else if (answer.length < 1) {
throw Error(chalk.bgRed("You have not selected any characters."))
}
return true;
}
},
{
type: 'input',
name: 'textColor',
message: chalk.yellow('Select the color of the text for your logo. (You can enter a color keyword or a hexadecimal number.)'),
},
{
type: 'list',
message: chalk.keyword('orange')('We offer three shapes for the logo, which would you like?'),
name: 'selectedShape',
choices: ['circle', 'triangle', 'square'],
},
{
type: 'input',
name: 'shapeColor',
message: chalk.green('What color would you like your logo to be? (You can enter a color keyword or a hexadecimal number.)'),
}
])
.then((response) => {
const fontColor = response.textColor;
const shapeColor = response.shapeColor;
const logoText = response.logoText;
switch (response.selectedShape) {
case 'circle':
const chosenCircle = new Circle(shapeColor, fontColor, logoText);
convertToHTML(chosenCircle);
break;
case 'triangle':
const chosenTriangle = new Triangle (shapeColor, fontColor, logoText);
convertToHTML(chosenTriangle);
break;
case 'square':
const chosenSquare = new Square (shapeColor, fontColor, logoText);
convertToHTML(chosenSquare);
break;
}
});
function convertToHTML(chosenShape) {
var logoRender = chosenShape.getHTML();
writeToSVG (logoRender);
};
function writeToSVG (logoRender) {
fs.writeFile('Example.svg', (logoRender), (err) =>
err ? console.log(err) : console.log(chalk.blue.bgWhite.bold('Generated logo.svg!'))
);
}
function init() {
}
init();