diff --git a/.changeset/bright-icons-wait.md b/.changeset/bright-icons-wait.md new file mode 100644 index 0000000..2d80ec9 --- /dev/null +++ b/.changeset/bright-icons-wait.md @@ -0,0 +1,5 @@ +--- +"@babylonlabs-io/bbn-core-ui": minor +--- + +add loader diff --git a/src/components/Loader/Loader.css b/src/components/Loader/Loader.css new file mode 100644 index 0000000..f95338a --- /dev/null +++ b/src/components/Loader/Loader.css @@ -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; + } +} diff --git a/src/components/Loader/Loader.stories.tsx b/src/components/Loader/Loader.stories.tsx new file mode 100644 index 0000000..e590147 --- /dev/null +++ b/src/components/Loader/Loader.stories.tsx @@ -0,0 +1,18 @@ +import type { Meta, StoryObj } from "@storybook/react"; + +import { Loader } from "./Loader"; + +const meta: Meta = { + component: Loader, + tags: ["autodocs"], +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = { + args: { + className: "text-secondary-main", + }, +}; diff --git a/src/components/Loader/Loader.tsx b/src/components/Loader/Loader.tsx new file mode 100644 index 0000000..7a6d207 --- /dev/null +++ b/src/components/Loader/Loader.tsx @@ -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 ( + + + + + + ); +} diff --git a/src/components/Loader/index.ts b/src/components/Loader/index.ts new file mode 100644 index 0000000..f9f5a2b --- /dev/null +++ b/src/components/Loader/index.ts @@ -0,0 +1 @@ +export * from "./Loader"; diff --git a/src/index.tsx b/src/index.tsx index 7d84175..df437bf 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -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";