1
Fork 0

Show values in output

This commit is contained in:
Jake Howard 2019-06-29 21:41:41 +01:00
parent 1402b04b51
commit 3e7f6168ca
Signed by: jake
GPG key ID: 57AFB45680EDD477
4 changed files with 14 additions and 5 deletions

View file

@ -59,6 +59,13 @@ function writeTemplate(
writeFileSync(outputFile, template(context));
}
function humanize(value: number) {
if (isPrecision(value, 0)) {
return value.toString();
}
return value.toFixed(2);
}
(async function() {
rimraf.sync(BUILD_DIR);
@ -94,7 +101,8 @@ function writeTemplate(
const value = parseFloat(i.toFixed(2));
const context = {
...baseContext,
value: value.toFixed(2),
displayValue: "£" + humanize(value),
value: humanize(value)
};
writeTemplate(template, value.toString(), context);
if (isPrecision(value, 1)) {
@ -106,7 +114,7 @@ function writeTemplate(
}
bar.tick();
});
writeTemplate(template, '', { ...baseContext, value: '' });
writeTemplate(template, '', { ...baseContext, displayValue: 'money' });
const filesOutput = glob.sync(join(BUILD_DIR, '**/index.html')).length;
console.log(`Generated ${filesOutput} files.`);
})();

View file

@ -6,7 +6,7 @@
"build": "ts-node index.ts",
"lint": "tsc --noEmit --project tsconfig.json && tslint --project tsconfig.json index.ts",
"prettier": "prettier --write index.ts",
"start": "http-server build/"
"start": "http-server build/ -c-1"
},
"repository": {
"type": "git",

View file

@ -3,7 +3,7 @@
<div class="card-deck">
{{#each accounts }}
<div class="card text-center mx-5">
<a href="{{ link }}" class="colour-invert">
<a href="{{ link }}/{{ ../value }}" class="colour-invert">
<img src="{{ image }}" class="card-img-top my-3 mx-3" alt="{{ name }} logo" style="max-width:40%" />
</a>
</div>

View file

@ -3,12 +3,13 @@
<link rel="stylesheet" href="../node_modules/@fortawesome/fontawesome-free/css/all.min.css" />
<link rel="stylesheet" href="../node_modules/animate.css/animate.min.css" />
<link rel="stylesheet" href="./index.scss" />
<title>Give {{ displayValue }} to me</title>
</head>
<body>
<div class="jumbotron mb-0 jumbotron-fluid text-center vertical-center">
<div class="container">
<h1 class="display-1"></h1>
<p class="lead">You should give me money. Here's how:</p>
<p class="lead">You should give me {{ displayValue }}. Here's how:</p>
<h1>
<i class="fas fa-chevron-down mt-5 animated infinite slideInDown"></i>
</h1>