2017-08-24 23:54:02 +02:00
|
|
|
const html = require('choo/html');
|
2018-02-13 20:32:59 +01:00
|
|
|
const percent = require('../../utils').percent;
|
2017-08-24 23:54:02 +02:00
|
|
|
|
|
|
|
const radius = 73;
|
|
|
|
const oRadius = radius + 10;
|
|
|
|
const oDiameter = oRadius * 2;
|
|
|
|
const circumference = 2 * Math.PI * radius;
|
|
|
|
|
|
|
|
module.exports = function(progressRatio) {
|
|
|
|
const dashOffset = (1 - progressRatio) * circumference;
|
2018-02-07 21:09:23 +01:00
|
|
|
const percentComplete = percent(progressRatio);
|
2018-02-16 21:56:53 +01:00
|
|
|
return html`
|
2018-02-13 20:32:59 +01:00
|
|
|
<div class="progress">
|
2018-01-24 19:23:13 +01:00
|
|
|
<svg
|
|
|
|
width="${oDiameter}"
|
|
|
|
height="${oDiameter}"
|
|
|
|
viewPort="0 0 ${oDiameter} ${oDiameter}"
|
|
|
|
version="1.1">
|
|
|
|
<circle
|
2018-02-13 20:32:59 +01:00
|
|
|
class="progress__bg"
|
2018-01-24 19:23:13 +01:00
|
|
|
r="${radius}"
|
|
|
|
cx="${oRadius}"
|
|
|
|
cy="${oRadius}"
|
|
|
|
fill="transparent"/>
|
|
|
|
<circle
|
2018-02-13 20:32:59 +01:00
|
|
|
class="progress__bar"
|
2018-01-24 19:23:13 +01:00
|
|
|
r="${radius}"
|
|
|
|
cx="${oRadius}"
|
|
|
|
cy="${oRadius}"
|
|
|
|
fill="transparent"
|
|
|
|
transform="rotate(-90 ${oRadius} ${oRadius})"
|
|
|
|
stroke-dasharray="${circumference}"
|
|
|
|
stroke-dashoffset="${dashOffset}"/>
|
2018-02-13 20:32:59 +01:00
|
|
|
<text class="progress__percent" text-anchor="middle" x="50%" y="98">
|
|
|
|
${percentComplete}
|
2018-01-24 19:23:13 +01:00
|
|
|
</text>
|
2017-08-24 23:54:02 +02:00
|
|
|
</svg>
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
};
|