var http = require('http');
var tailwind = require('./tailwind.config.js');
http
.createServer(function (req, res) {
var html = buildHtml(req);
res.writeHead(200, {
'Content-Type': 'text/html',
'Content-Length': html.length,
Expires: new Date().toUTCString(),
});
res.end(html);
})
.listen(8080);
function buildHtml(req) {
var colors = tailwind.theme.colors;
return `
${buildColorHtml(colors)}
`;
}
function buildColorHtml(colors) {
return Object.keys(colors)
.map((color) => {
return `
${color}
${buildColorDivs(colors[color])}
`;
})
.join('');
}
function buildColorDivs(colors) {
if (typeof colors !== 'object') {
return buildSingleColorDiv(colors, colors);
}
return Object.keys(colors)
.map((variant) => {
return buildSingleColorDiv(colors[variant], variant);
})
.join('');
}
function buildSingleColorDiv(color, title) {
return `
`;
}