results.css 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /* Variables */
  2. :root {
  3. --gauge-width: 32rem;
  4. --gauge-height: 22rem;
  5. --progress-width: 0.6rem;
  6. --speed-width: 3rem;
  7. }
  8. /* Layout for the gauges */
  9. .gauge-layout {
  10. display: flex;
  11. flex-direction: row;
  12. align-items: start;
  13. justify-content: center;
  14. gap: 5rem;
  15. margin: 5rem auto 3rem auto;
  16. @media screen and (max-width: 1100px) {
  17. display: grid;
  18. grid-template-areas:
  19. "download upload"
  20. "ping jitter";
  21. justify-items: center;
  22. justify-content: center;
  23. --gauge-width: min(40vw, 32rem);
  24. --gauge-height: min(28vw, 22rem);
  25. --progress-width: min(1.2vw, 0.6rem);
  26. --speed-width: min(4vw, 3rem);
  27. }
  28. @media screen and (max-width: 500px) {
  29. gap: 5rem 2rem;
  30. }
  31. }
  32. /* The download/upload speed gauges */
  33. /**
  34. * One thing I should really document here is the weird `transform: scale(1);`
  35. * and `position: fixed` in this code. This is a nasty little trick to allow the
  36. * gauge pointer to break out of the `overflow: hidden` of the .speed element.
  37. * We need the `overflow: hidden` to hide the arc that's rotating into view when
  38. * the value goes up. But we do want to see the full pointer, even when it's at
  39. * zero. This degrades fairly gracefully into showing half of the pointer when
  40. * browsers don't understand this.
  41. *
  42. * Trick taken from this article:
  43. * https://medium.com/@thomas.ryu/css-overriding-the-parents-overflow-hidden-90c75a0e7296
  44. */
  45. div.gauge {
  46. position: relative;
  47. transform: scale(1);
  48. width: var(--gauge-width);
  49. height: var(--gauge-height);
  50. &.download {
  51. grid-area: download;
  52. }
  53. &.upload {
  54. grid-area: upload;
  55. }
  56. & > .progress,
  57. & > .speed {
  58. position: absolute;
  59. top: 0;
  60. left: 0;
  61. width: var(--gauge-width);
  62. height: calc(var(--gauge-width) / 2);
  63. overflow: hidden;
  64. &:after,
  65. &:before {
  66. content: "";
  67. position: absolute;
  68. box-sizing: border-box;
  69. }
  70. }
  71. & > .progress {
  72. &:before,
  73. &:after {
  74. top: 0;
  75. left: 0;
  76. width: var(--gauge-width);
  77. height: calc(var(--gauge-width) / 2);
  78. border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  79. border: var(--progress-width) solid var(--gauge-background-color);
  80. border-bottom: 0;
  81. transform-origin: bottom center;
  82. transform: rotate(var(--progress-rotation));
  83. transition: transform 0.2s linear;
  84. }
  85. &:after {
  86. top: calc(var(--gauge-width) / 2);
  87. border-radius: 0 0 50% 50% / 0 0 100% 100%;
  88. border: var(--progress-width) solid var(--gauge-background-color);
  89. border-top: 0;
  90. transform-origin: top center;
  91. }
  92. }
  93. & > .speed {
  94. &:before,
  95. &:after {
  96. transform: rotate(var(--speed-rotation));
  97. transition: transform 0.2s ease;
  98. transition-timing-function: cubic-bezier(0.56, 0.04, 0.59, 0.91);
  99. }
  100. &:before {
  101. position: fixed;
  102. top: calc(var(--gauge-width) / 2 - var(--speed-width) / 3);
  103. left: var(--progress-width);
  104. width: 0;
  105. height: 0;
  106. border-top: calc(var(--speed-width) / 3) solid transparent;
  107. border-bottom: calc(var(--speed-width) / 3) solid transparent;
  108. border-right: calc(var(--speed-width) * 0.97) solid
  109. var(--gauge-background-color);
  110. z-index: 1;
  111. transform-origin: calc(var(--gauge-width) / 2 - var(--progress-width))
  112. calc(var(--speed-width) / 3);
  113. }
  114. &:after {
  115. top: calc(var(--gauge-width) / 2);
  116. left: calc(var(--progress-width) - 0.1rem);
  117. width: calc(var(--gauge-width) - var(--progress-width) * 2 + 0.2rem);
  118. height: calc(var(--gauge-width) / 2 - var(--progress-width) + 0.1rem);
  119. border-radius: 0 0 50% 50% / 0 0 100% 100%;
  120. border: var(--speed-width) solid var(--gauge-background-color);
  121. border-top: 0;
  122. transform-origin: top center;
  123. }
  124. }
  125. &.enabled {
  126. &.download {
  127. & > .progress:after {
  128. border-color: var(--theme-pink);
  129. }
  130. & > .speed {
  131. &:before {
  132. border-right-color: var(--gauge-pointer-pink);
  133. }
  134. &:after {
  135. border-color: var(--theme-pink);
  136. }
  137. }
  138. }
  139. &.upload {
  140. & > .progress:after {
  141. border-color: var(--theme-green);
  142. }
  143. & > .speed {
  144. &:before {
  145. border-right-color: var(--gauge-pointer-green);
  146. }
  147. &:after {
  148. border-color: var(--theme-green);
  149. }
  150. }
  151. }
  152. & > h1 > span {
  153. color: var(--primary-text-color);
  154. }
  155. }
  156. & > h1,
  157. & > h2 {
  158. display: block;
  159. position: absolute;
  160. width: 100%;
  161. font-family: "Inter", sans-serif;
  162. font-size: 2.1rem;
  163. letter-spacing: -0.1rem;
  164. color: var(--secondary-text-color);
  165. }
  166. & > h1 {
  167. bottom: calc(var(--gauge-height) - var(--gauge-width) / 2);
  168. font-weight: 300;
  169. & > span {
  170. font-size: 5.5rem;
  171. font-weight: 200;
  172. display: block;
  173. color: var(--secondary-text-color);
  174. letter-spacing: -0.3rem;
  175. }
  176. }
  177. & > h2 {
  178. bottom: 0;
  179. font-weight: 700;
  180. text-transform: uppercase;
  181. }
  182. @media screen and (max-width: 500px) {
  183. & > h1 {
  184. font-size: 3vw;
  185. & > span {
  186. font-size: 8vw;
  187. }
  188. }
  189. & > h2 {
  190. font-size: 3vw;
  191. }
  192. }
  193. }
  194. /* Styling for Ping and Jitter */
  195. .ping,
  196. .jitter {
  197. grid-area: jitter;
  198. display: flex;
  199. align-items: end;
  200. height: calc(var(--gauge-width) / 2);
  201. width: 13rem;
  202. font-size: 2.1rem;
  203. letter-spacing: -0.1rem;
  204. font-weight: 300;
  205. color: var(--ping-and-jitter-secondary-text-color);
  206. & > .label {
  207. font-weight: 700;
  208. }
  209. & > .value {
  210. color: var(--ping-and-jitter-primary-text-color);
  211. }
  212. &.hidden {
  213. display: none;
  214. }
  215. @media screen and (max-width: 1100px) {
  216. width: 100%;
  217. height: auto;
  218. justify-content: center !important;
  219. }
  220. @media screen and (max-width: 500px) {
  221. font-size: 1.8rem;
  222. }
  223. }
  224. .ping {
  225. grid-area: ping;
  226. justify-content: end;
  227. }