-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcircle-showing-progress-in-border.scss
105 lines (95 loc) · 2.69 KB
/
circle-showing-progress-in-border.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* SCSS source code for drawing progress circles
* see also https://github.com/radiance/scss-progress-circle-border/
*/
@import url('https://fonts.googleapis.com/css2?family=Source+Sans+Pro&display=swap');
// minimal css reset for showing standalone example
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
// compute border for showing progress in credits-circle
@mixin helper-classes-for-progress-circle-border {
@for $p from 1 through 100 {
&.p-#{$p} {
@include rotate-for-progress-circle-border($p);
}
}
}
@mixin rotate-for-progress-circle-border($percent) {
@if $percent <= 50 {
.left-half-circle { // fills 0 to
border-color: $default-border-color !important; // overwrite info color to hide other half circle part
z-index: 2;
transform: rotate(0deg);
}
.right-half-circle { // fills 0 to 180
transform: rotate(#{3.6 * $percent}deg);
}
}
@if $percent > 50 { // if p>50, don't clip left half
.left-half-circle { // fills -180 to 0
transform: rotate(#{-180 + ($percent - 50) * 3.6}deg);
}
.right-half-circle { // fills 0 to 180
transform: rotate(180deg);
}
}
}
$default-content-background-color: #fff;
$default-border-color: #ccc;
$info-color: #33f;
.progress-circle {
display: block;
height: 120px;
min-height: 120px;
min-width: 120px;
width: 120px;
margin: 2em;
.progress-circle-border {
border: 5px solid $default-border-color;
border-radius: 100%;
font-size: 120px;
height: 120px;
position: absolute;
text-align: center;
width: 120px;
.left-half-circle,
.right-half-circle {
border: 5px solid $info-color;
border-radius: 50%;
clip: rect(0, .5em, 1em, 0); // clips the whole left half
height: 120px;
margin-top: -5px; // negative margin because of parents border
margin-left: -5px; // negative margin because of parents border
position: absolute;
width: 120px;
}
.left-half-circle {
clip: rect(0, .5em, 1em, 0); // clips the whole right half
}
}
.progress-circle-content {
align-items: center;
background-color: $default-content-background-color;
border: 0;
border-radius: 100%;
display: flex;
flex-direction: column;
font-family: 'Source Sans Pro', sans-serif;
height: 110px;
justify-content: center;
margin: 5px;
min-height: 110px;
min-width: 110px;
padding: 1em;
position: absolute;
text-align: center;
width: 110px;
z-index: 2;
}
@include helper-classes-for-progress-circle-border; // call mixin at last
}