UNPKG

@buun_group/brutalist-ui

Version:
246 lines (212 loc) 4.27 kB
.spinner { display: inline-flex; align-items: center; justify-content: center; gap: var(--brutal-space-2); } /* Screen reader only text */ .srOnly { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border-width: 0; } /* Sizes */ .sm { --spinner-size: 16px; --dot-size: 4px; --bar-width: 2px; --bar-height: 8px; } .md { --spinner-size: 24px; --dot-size: 6px; --bar-width: 3px; --bar-height: 12px; } .lg { --spinner-size: 32px; --dot-size: 8px; --bar-width: 4px; --bar-height: 16px; } .xl { --spinner-size: 48px; --dot-size: 12px; --bar-width: 6px; --bar-height: 24px; } /* Colors */ .default { --spinner-color: var(--brutal-black); } .accent { --spinner-color: var(--brutal-accent); } .success { --spinner-color: var(--brutal-success); } .warning { --spinner-color: var(--brutal-warning); } .error { --spinner-color: var(--brutal-error); } .info { --spinner-color: var(--brutal-info); } /* Speed */ .speed-slow { --animation-duration: 2s; } .speed-normal { --animation-duration: 1.2s; } .speed-fast { --animation-duration: 0.8s; } /* Dots variant */ .dots .dot { width: var(--dot-size); height: var(--dot-size); background-color: var(--spinner-color); border: 2px solid var(--brutal-black); animation: dotPulse var(--animation-duration) ease-in-out infinite; } .dots .dot:nth-child(2) { animation-delay: calc(var(--animation-duration) * 0.2); } .dots .dot:nth-child(3) { animation-delay: calc(var(--animation-duration) * 0.4); } @keyframes dotPulse { 0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; } 40% { transform: scale(1.2); opacity: 1; } } /* Bars variant */ .bars { height: var(--spinner-size); } .bars .bar { width: var(--bar-width); height: var(--bar-height); background-color: var(--spinner-color); border: 2px solid var(--brutal-black); animation: barStretch var(--animation-duration) ease-in-out infinite; } .bars .bar:nth-child(2) { animation-delay: calc(var(--animation-duration) * 0.1); } .bars .bar:nth-child(3) { animation-delay: calc(var(--animation-duration) * 0.2); } .bars .bar:nth-child(4) { animation-delay: calc(var(--animation-duration) * 0.3); } @keyframes barStretch { 0%, 40%, 100% { transform: scaleY(0.4); } 20% { transform: scaleY(1); } } /* Square variant */ .square .square { width: var(--spinner-size); height: var(--spinner-size); border: 4px solid var(--brutal-black); background-color: var(--spinner-color); animation: squareRotate var(--animation-duration) linear infinite; } @keyframes squareRotate { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } /* Glitch variant */ .glitch { position: relative; width: var(--spinner-size); height: var(--spinner-size); } .glitch .glitchSquare { position: absolute; width: 100%; height: 100%; border: 3px solid var(--brutal-black); background-color: var(--spinner-color); } .glitch .glitchSquare:nth-child(1) { animation: glitch1 var(--animation-duration) steps(2, end) infinite; } .glitch .glitchSquare:nth-child(2) { animation: glitch2 var(--animation-duration) steps(3, end) infinite; background-color: transparent; border-color: var(--spinner-color); } .glitch .glitchSquare:nth-child(3) { animation: glitch3 var(--animation-duration) steps(4, end) infinite; background-color: var(--brutal-black); border: none; transform: scale(0.8); } @keyframes glitch1 { 0%, 100% { transform: translate(0); } 20% { transform: translate(-2px, 2px); } 40% { transform: translate(-2px, -2px); } 60% { transform: translate(2px, 2px); } 80% { transform: translate(2px, -2px); } } @keyframes glitch2 { 0%, 100% { transform: translate(0) scale(1); } 20% { transform: translate(2px, -2px) scale(1.1); } 40% { transform: translate(-2px, 2px) scale(0.9); } 60% { transform: translate(2px, 2px) scale(1.05); } 80% { transform: translate(-2px, -2px) scale(0.95); } } @keyframes glitch3 { 0%, 100% { opacity: 0; } 20%, 80% { opacity: 1; } 50% { opacity: 0.5; } }