(react) improve loader

Add small size to the loader for the file uploader.
This commit is contained in:
Nathan Vasse
2023-06-22 17:15:47 +02:00
committed by NathanVss
parent 93bfaae502
commit af3caed43f
3 changed files with 63 additions and 24 deletions

View File

@@ -1,23 +1,50 @@
.c__loader { .c__loader {
width: 48px;
height: 48px;
border-radius: 50%; border-radius: 50%;
position: relative; position: relative;
animation: rotate 1s linear infinite animation: rotate 1s linear infinite;
}
.c__loader::before , .c__loader::after { &::before,
content: ""; &::after {
box-sizing: border-box; content: "";
position: absolute; box-sizing: border-box;
inset: 0; position: absolute;
border-radius: 50%; inset: 0;
border: 5px solid var(--c--theme--colors--primary-700); border-radius: 50%;
animation: prixClipFix 2s linear infinite ; border-style: solid;
} border-color: var(--c--theme--colors--primary-700);
.c__loader::after{ animation: prixClipFix 2s linear infinite;
border-color: var(--c--theme--colors--primary-400); }
animation: prixClipFix 2s linear infinite , rotate 0.5s linear infinite reverse;
inset: 6px; &::after {
border-color: var(--c--theme--colors--primary-400);
animation: prixClipFix 2s linear infinite,
rotate 0.5s linear infinite reverse;
inset: 6px;
}
span {
display: none;
}
&--small {
width: 24px;
height: 24px;
&::before,
&::after {
border-width: 2px;
}
}
&--medium {
width: 48px;
height: 48px;
&::before,
&::after {
border-width: 5px;
}
}
} }
@keyframes rotate { @keyframes rotate {

View File

@@ -1,5 +1,4 @@
import { Meta, StoryFn } from "@storybook/react"; import { Meta, StoryObj } from "@storybook/react";
import React from "react";
import { Loader } from ":/components/Loader/index"; import { Loader } from ":/components/Loader/index";
export default { export default {
@@ -7,9 +6,14 @@ export default {
component: Loader, component: Loader,
} as Meta<typeof Loader>; } as Meta<typeof Loader>;
const Template: StoryFn<typeof Loader> = () => <Loader />; type Story = StoryObj<typeof Loader>;
export const Default = { export const Medium: Story = {
render: Template,
args: {}, args: {},
}; };
export const Small: Story = {
args: {
size: "small",
},
};

View File

@@ -1,9 +1,17 @@
import React from "react"; import React from "react";
import classNames from "classnames";
interface Props { interface Props {
"aria-label"?: string; "aria-label"?: string;
size?: "small" | "medium";
} }
export const Loader = (props: Props) => { export const Loader = ({ size = "medium", ...props }: Props) => {
return <div className="c__loader" role="status" {...props} />; return (
<div
className={classNames("c__loader", "c__loader--" + size)}
role="status"
{...props}
/>
);
}; };