Skip to content

Commit

Permalink
Touch up dots1
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank1513 committed Apr 28, 2024
1 parent 01f37c9 commit cad3f83
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/admin/src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function App(): JSX.Element {
Admin <br />
<span>Kitchen Sink</span>
</h1>
<Dots1 />
<Dots1 color="#00f" width={60} />
<Dots2 color="#00f" width={50} dotSize={8} />
</div>
);
Expand Down
4 changes: 3 additions & 1 deletion lib/src/server/dots/dots1/dots1.module.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* HTML: <div class="loader"></div> */
.loader {
--c: #000;
width: 60px;
aspect-ratio: 4;
background: radial-gradient(circle closest-side, #000 90%, #0000) 0 / calc(100% / 3) 100% space;
background: radial-gradient(circle closest-side, var(--c) 90%, #0000) 0 / calc(100% / 3) 100%
space;
clip-path: inset(0 100% 0 0);
animation: anim 1s steps(4) infinite;
}
Expand Down
21 changes: 16 additions & 5 deletions lib/src/server/dots/dots1/dots1.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import * as React from "react";
import styles from "./dots1.module.scss";

interface Dots1Props {
children?: React.ReactNode;
interface Dots1Props extends React.HTMLAttributes<HTMLDivElement> {
/** width of the loader element in pixels or a string with a length unit. */
width?: number | string;
/** Color of the dots - CSS compatible color */
color?: string;
}

/**
* # Dots1
* A simple loader with 3 dots.
*
* @example
* <Dots1 />
*
* @source
*/
export function Dots1({ children }: Dots1Props) {
return <div className={styles.loader} data-testid="dots1" />;
export function Dots1({ width, color = "#000", ...props }: Dots1Props) {
let w = props.style?.width ?? width ?? 32;
w = typeof width === "string" ? width : `${width}px`;
const className = [styles.loader, props.className].filter(Boolean).join(" ");
const style = { ...(props.style ?? {}), width: w, "--c": color };
return <div className={className} style={style} />;
}

0 comments on commit cad3f83

Please sign in to comment.