krishnamohan-yagneswaran-ui
Version:
A lightweight custom UI framework built by Krishnamohan Yagneswaran
42 lines (35 loc) • 1.18 kB
JavaScript
import { krishna } from '../krishnamohan.js';
export function KrishnamohanLoadingDots() {
const style = `
display: flex;
gap: 6px;
align-items: center;
justify-content: center;
height: 2rem;
`;
const dotStyle = (i) => `
width: 8px;
height: 8px;
background-color: #0077B6;
border-radius: 50%;
animation: krishna-bounce 1.4s infinite;
animation-delay: ${i * 0.2}s;
`;
const dot1 = krishna.createElement("div", { style: dotStyle(0) });
const dot2 = krishna.createElement("div", { style: dotStyle(1) });
const dot3 = krishna.createElement("div", { style: dotStyle(2) });
const container = krishna.createElement("div", { style }, dot1, dot2, dot3);
// Add keyframes style tag only once
if (!document.getElementById("krishna-loading-style")) {
const styleTag = document.createElement("style");
styleTag.id = "krishna-loading-style";
styleTag.textContent = `
@keyframes krishna-bounce {
0%, 80%, 100% { transform: scale(0); }
40% { transform: scale(1); }
}
`;
document.head.appendChild(styleTag);
}
return container;
}