Skip to content

Commit

Permalink
Merge pull request #45 from babylonlabs-io/feat-loader
Browse files Browse the repository at this point in the history
feat: loader
  • Loading branch information
totraev authored Nov 25, 2024
2 parents 3d49b6b + ebb7166 commit 766e632
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-icons-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@babylonlabs-io/bbn-core-ui": minor
---

add loader
35 changes: 35 additions & 0 deletions src/components/Loader/Loader.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@keyframes bbn-loader-stroke-animation {
0% {
stroke-dasharray: 1px, 200px;
stroke-dashoffset: 0;
}
50% {
stroke-dasharray: 100px, 200px;
stroke-dashoffset: -15px;
}
to {
stroke-dasharray: 100px, 200px;
stroke-dashoffset: -125px;
}
}

@keyframes bbn-loader-rotate-animation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}

.bbn-loader {
display: inline-block;
animation: 1.4s linear 0s infinite normal none running bbn-loader-rotate-animation;

& circle {
animation: bbn-loader-stroke-animation 1.4s ease-in-out infinite;
stroke: currentColor;
stroke-dasharray: 80px, 200px;
stroke-dashoffset: 0;
}
}
18 changes: 18 additions & 0 deletions src/components/Loader/Loader.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Meta, StoryObj } from "@storybook/react";

import { Loader } from "./Loader";

const meta: Meta<typeof Loader> = {
component: Loader,
tags: ["autodocs"],
};

export default meta;

type Story = StoryObj<typeof meta>;

export const Default: Story = {
args: {
className: "text-secondary-main",
},
};
17 changes: 17 additions & 0 deletions src/components/Loader/Loader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { twMerge } from "tailwind-merge";
import "./Loader.css";

interface LoaderProps {
className?: string;
size?: number;
}

export function Loader({ size = 40, className }: LoaderProps) {
return (
<span className={twMerge("bbn-loader text-current", className)} style={{ width: size, height: size }}>
<svg viewBox="22 22 44 44">
<circle cx="44" cy="44" r="20.2" fill="none" stroke="currentColor" stroke-width="3.6" />
</svg>
</span>
);
}
1 change: 1 addition & 0 deletions src/components/Loader/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Loader";
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ export * from "./components/Input";
export * from "./components/Dialog";
export * from "./components/Chip";
export * from "./components/Portal";
export * from "./components/Loader";

export { ScrollLocker } from "@/context/Dialog.context";

0 comments on commit 766e632

Please sign in to comment.