Skip to content
This repository has been archived by the owner on May 22, 2021. It is now read-only.

Commit

Permalink
use svg for progress
Browse files Browse the repository at this point in the history
  • Loading branch information
dannycoates committed Aug 14, 2017
1 parent 43fa551 commit eada94b
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion frontend/src/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Storage from './storage';
import * as links from './links';
import * as metrics from './metrics';
import * as progress from './progress';
import $ from 'jquery';
import $ from 'jquery/dist/jquery.slim';

const storage = new Storage();
function onUnload(size) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/fileList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import FileSender from './fileSender';
import Storage from './storage';
import * as metrics from './metrics';
import { allowedCopy, copyToClipboard, ONE_DAY_IN_MS } from './utils';
import $ from 'jquery';
import $ from 'jquery/dist/jquery.slim';

const storage = new Storage();
let fileList = null;
Expand Down
12 changes: 11 additions & 1 deletion frontend/src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ body {
position: relative;
}

#progress circle {
stroke: #eee;
stroke-width: 0.75em;
}

#progress #bar {
transition: stroke-dashoffset 300ms linear;
stroke: #3b9dff;
}

.header {
align-items: flex-start;
box-sizing: border-box;
Expand Down Expand Up @@ -420,7 +430,7 @@ tbody {
position: absolute;
letter-spacing: -0.78px;
font-family: 'Segoe UI', 'SF Pro Text', sans-serif;
top: 53px;
top: 58px;
left: 50%;
transform: translateX(-50%);
-moz-user-select: none;
Expand Down
30 changes: 12 additions & 18 deletions frontend/src/progress.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
import { bytes, percent } from './utils';
import $ from 'jquery';
import 'jquery-circle-progress';

let $progress = null;
let $percent = null;
let $text = null;
let percentText = null;
let text = null;
let title = null;
let bar = null;
let updateTitle = false;

const radius = 73;
const circumference = 2 * Math.PI * radius;

document.addEventListener('DOMContentLoaded', function() {
$percent = $('.percent-number');
$text = $('.progress-text');
$progress = $('.progress-bar');
$progress.circleProgress({
value: 0.0,
startAngle: -Math.PI / 2,
fill: '#3B9DFF',
size: 158,
animation: { duration: 300 }
});
percentText = document.querySelector('.percent-number');
text = document.querySelector('.progress-text');
bar = document.getElementById('bar');
title = document.querySelector('title');
});

Expand All @@ -33,8 +27,8 @@ document.addEventListener('focus', function() {

function setProgress(params) {
const ratio = params.complete / params.total;
$progress.circleProgress('value', ratio);
$percent.text(Math.floor(ratio * 100));
bar.setAttribute('stroke-dashoffset', (1 - ratio) * circumference);
percentText.textContent = Math.floor(ratio * 100);
if (updateTitle) {
title.textContent = percent(ratio);
}
Expand All @@ -47,7 +41,7 @@ function setProgress(params) {
}

function setText(str) {
$text.text(str);
text.textContent = str;
}

export { setProgress, setText };
2 changes: 1 addition & 1 deletion frontend/src/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Storage from './storage';
import * as metrics from './metrics';
import * as progress from './progress';
import * as fileList from './fileList';
import $ from 'jquery';
import $ from 'jquery/dist/jquery.slim';

const storage = new Storage();

Expand Down
9 changes: 0 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"git-rev-sync": "^1.9.1",
"husky": "^0.14.3",
"jquery": "^3.2.1",
"jquery-circle-progress": "^1.2.2",
"l20n": "^5.0.0",
"lint-staged": "^4.0.3",
"mocha": "^3.4.2",
Expand Down
7 changes: 5 additions & 2 deletions views/download.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
<div id="download-progress" hidden="true">
<div id="dl-title" class="title"></div>
<div class="description" data-l10n-id="downloadingPageMessage"></div>
<!-- progress bar here -->
<div class="progress-bar" id="dl-progress">
<div class="progress-bar">
<svg id="progress" width="166" height="166" viewPort="0 0 166 166" version="1.1">
<circle r="73" cx="83" cy="83" fill="transparent"/>
<circle id="bar" r="73" cx="83" cy="83" fill="transparent" transform="rotate(-90 83 83)" stroke-dasharray="458.67" stroke-dashoffset="458.67"/>
</svg>
<div class="percentage">
<span class="percent-number"></span>
<span class="percent-sign">%</span>
Expand Down
7 changes: 5 additions & 2 deletions views/index.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@
<div id="upload-progress" hidden="true">
<div class="title" id="upload-filename"></div>
<div class="description"></div>
<!-- progress bar here -->
<div class="progress-bar" id="ul-progress">
<div class="progress-bar">
<svg id="progress" width="166" height="166" viewPort="0 0 166 166" version="1.1">
<circle r="73" cx="83" cy="83" fill="transparent"/>
<circle id="bar" r="73" cx="83" cy="83" fill="transparent" transform="rotate(-90 83 83)" stroke-dasharray="458.67" stroke-dashoffset="458.67"/>
</svg>
<div class="percentage">
<span class="percent-number">0</span>
<span class="percent-sign">%</span>
Expand Down

0 comments on commit eada94b

Please sign in to comment.