@allxsmith/bestax-bulma 5.49.1 → 5.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,160 @@
1
+ // Bestax Extras - RingProgress Styles
2
+ // A value drawn as a ring, with anything the app passes in the middle. Bulma
3
+ // has a linear progress bar and no ring.
4
+ //
5
+ // The ring is an SVG: a track circle, and an arc per value whose length and
6
+ // start the component sets as custom properties, in percent of the way
7
+ // round. Each arc has `pathLength="100"`, so a percentage is a dash length
8
+ // as it is, and nothing is measured. Forced colors leaves SVG strokes in the
9
+ // author's colours, so a rule here gives them the system's.
10
+
11
+ @use "bulma/sass/utilities/initial-variables" as iv;
12
+ @use "bulma/sass/utilities/css-variables" as cv;
13
+
14
+ $ring-progress-size: 5rem !default;
15
+ $ring-progress-size-small: 3.5rem !default;
16
+ $ring-progress-size-medium: 7rem !default;
17
+ $ring-progress-size-large: 9rem !default;
18
+ // In the ring's own units: the ring is 100 across and its circle has a
19
+ // radius of 42, so a thickness up to 16 fits.
20
+ $ring-progress-thickness: 10 !default;
21
+ // The unfilled ring, the color Bulma gives a progress bar's track.
22
+ $ring-progress-track-color: cv.getVar("border-weak") !default;
23
+ $ring-progress-arc-color: cv.getVar("primary") !default;
24
+ $ring-progress-duration: cv.getVar("duration") !default;
25
+ $ring-progress-label-color: cv.getVar("text-strong") !default;
26
+ $ring-progress-label-weight: cv.getVar("weight-semibold") !default;
27
+ // A fifth of the ring, so the middle grows and shrinks with it: 1rem at the
28
+ // default size.
29
+ $ring-progress-label-size: calc(#{cv.getVar("ring-progress-size")} / 5) !default;
30
+
31
+ .#{iv.$class-prefix}ring-progress {
32
+ @include cv.register-vars(
33
+ (
34
+ "ring-progress-size": #{$ring-progress-size},
35
+ "ring-progress-thickness": #{$ring-progress-thickness},
36
+ "ring-progress-track-color": #{$ring-progress-track-color},
37
+ "ring-progress-arc-color": #{$ring-progress-arc-color},
38
+ "ring-progress-duration": #{$ring-progress-duration},
39
+ "ring-progress-label-color": #{$ring-progress-label-color},
40
+ "ring-progress-label-weight": #{$ring-progress-label-weight},
41
+ "ring-progress-label-size": #{$ring-progress-label-size},
42
+ )
43
+ );
44
+ }
45
+
46
+ @each $size, $value in ("small": $ring-progress-size-small, "medium": $ring-progress-size-medium, "large": $ring-progress-size-large) {
47
+ .#{iv.$class-prefix}ring-progress.#{iv.$class-prefix}is-#{$size} {
48
+ @include cv.register-vars(
49
+ (
50
+ "ring-progress-size": #{$value},
51
+ )
52
+ );
53
+ }
54
+ }
55
+
56
+ // ---- The ring and its middle ---------------------------------------------------
57
+
58
+ // One grid cell holds both the ring and the label, so the label sits in the
59
+ // middle at any size.
60
+ .#{iv.$class-prefix}ring-progress {
61
+ display: inline-grid;
62
+ place-items: center;
63
+ inline-size: cv.getVar("ring-progress-size");
64
+ block-size: cv.getVar("ring-progress-size");
65
+ vertical-align: middle;
66
+ // On the root, so a `textColor` helper's class outranks it and the middle
67
+ // inherits either.
68
+ color: cv.getVar("ring-progress-label-color");
69
+ // The gap between sections, in percent of the way round: none until
70
+ // forced colors needs one, below.
71
+ --ring-progress-gap: 0;
72
+ }
73
+
74
+ .#{iv.$class-prefix}ring-progress-ring,
75
+ .#{iv.$class-prefix}ring-progress-label {
76
+ grid-area: 1 / 1;
77
+ }
78
+
79
+ .#{iv.$class-prefix}ring-progress-ring {
80
+ inline-size: 100%;
81
+ block-size: 100%;
82
+ // A circle's path starts at three o'clock and runs clockwise; this puts
83
+ // the start at the top.
84
+ transform: rotate(-90deg);
85
+ }
86
+
87
+ .#{iv.$class-prefix}ring-progress-track,
88
+ .#{iv.$class-prefix}ring-progress-arc {
89
+ fill: none;
90
+ stroke-width: cv.getVar("ring-progress-thickness");
91
+ }
92
+
93
+ .#{iv.$class-prefix}ring-progress-track {
94
+ stroke: cv.getVar("ring-progress-track-color");
95
+ }
96
+
97
+ .#{iv.$class-prefix}ring-progress-arc {
98
+ stroke: cv.getVar("ring-progress-arc-color");
99
+ // In px, which here are the circle's path units: Firefox drops a
100
+ // dasharray whose calc() works in bare numbers.
101
+ stroke-dasharray: max(0px, calc((var(--ring-progress-length) - var(--ring-progress-gap)) * 1px)) 100px;
102
+ stroke-dashoffset: calc(var(--ring-progress-start) * -1px);
103
+ transition-property: stroke-dasharray, stroke-dashoffset;
104
+ transition-duration: cv.getVar("ring-progress-duration");
105
+ }
106
+
107
+ .#{iv.$class-prefix}ring-progress.#{iv.$class-prefix}is-rounded .#{iv.$class-prefix}ring-progress-arc {
108
+ stroke-linecap: round;
109
+ }
110
+
111
+ .#{iv.$class-prefix}ring-progress-label {
112
+ font-size: cv.getVar("ring-progress-label-size");
113
+ font-weight: cv.getVar("ring-progress-label-weight");
114
+ line-height: 1.2;
115
+ text-align: center;
116
+ // Inside the ring, clear of the arc.
117
+ max-inline-size: 70%;
118
+ }
119
+
120
+ // ---- Colors ----------------------------------------------------------------------
121
+
122
+ // On the root, the color of every arc; on an arc, that section's own.
123
+ @each $name in "primary", "link", "info", "success", "warning", "danger", "black", "dark", "light", "white" {
124
+ .#{iv.$class-prefix}ring-progress.#{iv.$class-prefix}is-#{$name} {
125
+ @include cv.register-vars(
126
+ (
127
+ "ring-progress-arc-color": #{cv.getVar($name)},
128
+ )
129
+ );
130
+ }
131
+
132
+ .#{iv.$class-prefix}ring-progress-arc.#{iv.$class-prefix}is-#{$name} {
133
+ stroke: cv.getVar($name);
134
+ }
135
+ }
136
+
137
+ // ---- Media ---------------------------------------------------------------------
138
+
139
+ @media (prefers-reduced-motion: reduce) {
140
+ .#{iv.$class-prefix}ring-progress-arc {
141
+ transition: none;
142
+ }
143
+ }
144
+
145
+ // SVG strokes keep the author's colours in forced colors, so the ring takes
146
+ // the system's, and sections, now one colour, get gaps between them.
147
+ @media (forced-colors: active) {
148
+ .#{iv.$class-prefix}ring-progress.#{iv.$class-prefix}has-sections {
149
+ --ring-progress-gap: 1.5;
150
+ }
151
+
152
+ .#{iv.$class-prefix}ring-progress-track {
153
+ stroke: GrayText;
154
+ }
155
+
156
+ // Through the root, so it outranks a section's own color class.
157
+ .#{iv.$class-prefix}ring-progress .#{iv.$class-prefix}ring-progress-arc {
158
+ stroke: CanvasText;
159
+ }
160
+ }