Last active
March 6, 2024 21:13
-
-
Save nicbet/49a681d036ab8c2886e3419a6e8c6efb to your computer and use it in GitHub Desktop.
Bulma Circular Progress Bars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Progress Bars */ | |
$step: 1; | |
$loops: round(100 / $step); | |
$increment: 360 / $loops; | |
$half: round($loops / 2); | |
$backColor: #fafafa; | |
.progress-circle { | |
position: relative; | |
float: left; | |
width: 50px; | |
height: 50px; | |
border: 2px solid $backColor; | |
border-radius: 50%; | |
@each $name, $pair in $colors { | |
$color: nth($pair, 1); | |
&.is-#{$name} { | |
background-color: $color; | |
@for $i from 0 through $loops { | |
&.is-#{$i * $step} { | |
@if $i < $half { | |
$nextDeg: 90deg + ($increment * $i); | |
background-image: linear-gradient( | |
90deg, | |
#ccc 50%, | |
transparent 50%, | |
transparent | |
), | |
linear-gradient($nextDeg, $color 50%, #ccc 50%, #ccc); | |
} @else { | |
$nextDeg: -90deg + ($increment * ($i - $half)); | |
background-image: linear-gradient( | |
$nextDeg, | |
$color 50%, | |
transparent 50%, | |
transparent | |
), | |
linear-gradient(270deg, $color 50%, #ccc 50%, #ccc); | |
} | |
} | |
&[value="#{$i}"] { | |
@extend .is-#{$i}; | |
} | |
} | |
} | |
} | |
} | |
.progress-inner { | |
position: absolute; | |
margin-left: 15%; | |
margin-top: 15%; | |
font-size: 10px; | |
font-weight: bold; | |
width: 70%; | |
height: 70%; | |
background-color: white; | |
border-radius: 50%; | |
display: inline-flex; | |
align-items: center; | |
justify-content: center; | |
text-align: center; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section class="section"> | |
<div class="container"> | |
<h1 class="title is-1">Circular Progress Bar</h1> | |
<div class="progress-circle is-success" value="40" max="100"> | |
<span class="progress-inner">40%</span> | |
</div> | |
</div> | |
</section> | |
<section class="section"> | |
<div class="container"> | |
<pre> | |
<section class="section"> | |
<div class="container"> | |
<h1 class="title is-1">Circular Progress Bar</h1> | |
<div class="progress-circle is-success" value="40" max="100"> | |
<span class="progress-inner">40%</span> | |
</div> | |
</div> | |
</section> | |
</pre> | |
</div> | |
</section> |
Hi, where can I find the $colors var? Thanks!
Hi, where can I find the $colors var? Thanks!
They are part of the Bulma framework
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thats brilliant thank you for supporting the community!