Skip to content

Commit 8a4a2f5

Browse files
committed
[Scorecards][General] Added percentage ring component
1 parent 7feb51a commit 8a4a2f5

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

scoring/static/scoring/scss/main.scss

+1
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,4 @@
6666
@import "open-graph-preview";
6767
@import "years";
6868
@import "gallery-component";
69+
@import "percentage-ring";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* USAGE:
2+
Always check how the ring will look at 100% and if there is an overlap between elements.
3+
4+
<div class="progress-ring" style="--ring-size: 40px;--ring-percentage: {% widthratio answer.council_count council_count 100%};">
5+
<div class="percentage fs-8">
6+
{% widthratio answer.council_count council_count 100%}%
7+
</div>
8+
</div>
9+
*/
10+
11+
.progress-ring {
12+
min-width: var(--ring-size, 150px);
13+
height: var(--ring-size, 150px);
14+
border-radius: 50%;
15+
position: relative;
16+
display: flex;
17+
justify-content: center;
18+
align-items: center;
19+
background: conic-gradient(
20+
var(--ring-primary-color, $primary) 0% calc(var(--ring-percentage) * 1%),
21+
var(--ring-secondary-color, $primary-200) calc(var(--ring-percentage) * 1%) 100%
22+
);
23+
24+
.percentage {
25+
font-weight: bold;
26+
color: var(--ring-primary-color, $primary);
27+
position: absolute;
28+
display: flex;
29+
justify-content: center;
30+
align-items: center;
31+
width: calc(var(--ring-size, 150px) * 0.7);
32+
height: calc(var(--ring-size, 150px) * 0.7);
33+
background: white;
34+
border-radius: 50%;
35+
}
36+
}

0 commit comments

Comments
 (0)