Skip to content

Commit e39c6b2

Browse files
committed
animations: Swapped CSS-based spinners for SVG-based ones
This is based on the work of Utkarsh Verma (n3r4zzurr0 on GitHub), under the MIT license.
1 parent 2b8dfac commit e39c6b2

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

docs/content/index.en-us.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,11 @@ You can try it out using [the online demo](https://try.gitea.io/).
283283

284284
- Web server framework: [Chi](http://github.com/go-chi/chi)
285285
- ORM: [XORM](https://xorm.io)
286-
- UI frameworks:
286+
- UI:
287287
- [jQuery](https://jquery.com)
288288
- [Fomantic UI](https://fomantic-ui.com)
289289
- [Vue3](https://vuejs.org)
290+
- [svg-spinners by Utkarsh Verma](https://github.com/n3r4zzurr0/svg-spinners)
290291
- and various components (see package.json)
291292
- Editors:
292293
- [CodeMirror](https://codemirror.net)

web_src/css/base.css

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
--checkbox-mask-checked: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="-1 -1 18 18" width="16" height="16"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg>');
1414
--checkbox-mask-indeterminate: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M2 7.75A.75.75 0 012.75 7h10a.75.75 0 010 1.5h-10A.75.75 0 012 7.75z"></path></svg>');
1515
--octicon-chevron-right: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path d="M6.22 3.22a.75.75 0 0 1 1.06 0l4.25 4.25a.75.75 0 0 1 0 1.06l-4.25 4.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042L9.94 8 6.22 4.28a.75.75 0 0 1 0-1.06Z"></path></svg>');
16+
--spinner-bar: url('data:image/svg+xml;utf-8,<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="4" cy="12" r="3" opacity="1"/><circle cx="12" cy="12" r="3" opacity="1"/><circle cx="20" cy="12" r="3" opacity="1" id="circle3"/></svg>');
17+
--spinner-bar-animated: url('data:image/svg+xml;utf-8,<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><circle cx="4" cy="12" r="3" opacity="1"><animate id="spinner_qYjJ" begin="0;spinner_t4KZ.end-0.25s" attributeName="opacity" dur="0.75s" values="1;.2" fill="freeze"/></circle><circle cx="12" cy="12" r="3" opacity=".4"><animate begin="spinner_qYjJ.begin+0.15s" attributeName="opacity" dur="0.75s" values="1;.2" fill="freeze"/></circle><circle cx="20" cy="12" r="3" opacity=".3"><animate id="spinner_t4KZ" begin="spinner_qYjJ.begin+0.3s" attributeName="opacity" dur="0.75s" values="1;.2" fill="freeze"/></circle></svg>');
18+
--spinner-ring: url('data:image/svg+xml;utf-8,<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z" opacity=".25"/><path d="M 10.14,1.16 C 5.5567308,1.9332423 1.9541327,5.5038173 1.14,10.08 0.93830154,10.982014 1.5455751,11.865321 2.46,12 3.2691211,12.07754 3.9960611,11.504803 4.11,10.7 4.6691025,7.289357 7.3552406,4.6233851 10.77,4.09 11.785222,2.4815355 10.7774,4.0836 11.788589,2.4769418 10.142774,1.1587614 11.790739,2.4756981 10.14,1.16 Z"/></svg>');
19+
--spinner-ring-animated: url('data:image/svg+xml;utf-8,<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z" opacity=".25"/><path d="M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z"><animateTransform attributeName="transform" type="rotate" dur="0.75s" values="0 12 12;360 12 12" repeatCount="indefinite"/></path></svg>')
1620
/* non-color variables */
1721
--border-radius: 0.28571429rem;
1822
--opacity-disabled: 0.55;

web_src/css/modules/animations.css

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
@keyframes isloadingspin {
2-
0% { transform: translate(-50%, -50%) rotate(0deg); }
3-
100% { transform: translate(-50%, -50%) rotate(360deg); }
4-
}
5-
61
.is-loading {
72
pointer-events: none !important;
83
position: relative !important;
@@ -22,20 +17,28 @@
2217
height: min(4em, 66.6%);
2318
aspect-ratio: 1;
2419
transform: translate(-50%, -50%);
25-
border-width: 4px;
26-
border-style: solid;
27-
border-color: var(--color-secondary) var(--color-secondary) var(--color-secondary-dark-8) var(--color-secondary-dark-8);
28-
border-radius: 100%;
20+
mask-size: cover;
21+
-webkit-mask-size: cover;
22+
mask-image: var(--spinner-ring);
23+
-webkit-mask-image: var(--spinner-ring);
24+
background: currentcolor;
25+
}
26+
27+
.is-loading.small-loading-icon::after {
28+
mask-image: var(--spinner-bar);
29+
-webkit-mask-image: var(--spinner-bar);
2930
}
3031

3132
@media (prefers-reduced-motion: no-preference) {
3233
.is-loading::after {
33-
animation: isloadingspin 500ms infinite linear;
34+
mask-image: var(--spinner-ring-animated);
35+
-webkit-mask-image: var(--spinner-ring-animated);
3436
}
35-
}
3637

37-
.is-loading.small-loading-icon::after {
38-
border-width: 2px;
38+
.is-loading.small-loading-icon::after {
39+
mask-image: var(--spinner-bar-animated);
40+
-webkit-mask-image: var(--spinner-bar-animated);
41+
}
3942
}
4043

4144
/* for single form button, the loading state should be on the button, but not go semi-transparent, just replace the text on the button with the loader. */

0 commit comments

Comments
 (0)