Skip to content

Commit

Permalink
Merge pull request #72 from precision-sustainable-ag/loading-spinner
Browse files Browse the repository at this point in the history
Create a shared loading indicator component #24
  • Loading branch information
Adamws33 authored Dec 2, 2024
2 parents 6f764aa + de71cef commit 666098e
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Loadingspinner/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import { PSALoadingspinner } from "./loadingspinner";
export default PSALoadingspinner;
28 changes: 28 additions & 0 deletions src/Loadingspinner/loadingspinner.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from "react";
import PropTypes from "prop-types";
import styles from "./spinner.module.scss";

export function PSALoadingspinner({ loaderStyle }) {

const defaultStyle = {
width: '50px',
height: '50px',
border: `8px solid #90EE90`,
borderTop: `8px solid green`,
borderLeft: `8px solid green`,
borderRight: `8px solid green`,
borderRadius: "50%",
animation: `${styles.spin} 2s linear infinite`,
};

return <div style={loaderStyle ? loaderStyle : defaultStyle}></div>;
}

PSALoadingspinner.propTypes = {

/**
* Styles for the loader
*/
loaderStyle: PropTypes.object,

};
Empty file.
30 changes: 30 additions & 0 deletions src/Loadingspinner/loadingspinner.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { PSALoadingspinner } from "./loadingspinner";
import styles from "./spinner.module.scss";

const meta = {
title: "Feedback/Loadingspinner",
component: PSALoadingspinner,
tags: ["autodocs"],
parameters: {
layout: "centered",
},
};

export default meta;

export const DefaultStyle = {};

export const LoaderStyle = {
args: {
loaderStyle: {
width: "50px",
height: "50px",
border: `8px solid black`,
borderTop: `8px solid red`,
borderLeft: `8px solid red`,
borderRight: `8px solid red`,
borderRadius: "50%",
animation: `${styles.spin} 2s linear infinite`,
},
},
};
8 changes: 8 additions & 0 deletions src/Loadingspinner/spinner.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ export { default as PSAModal } from "./Modal/index";
export { default as PSACheckbox } from "./Checkbox/index";
export { default as PSAProfile } from "./Profile/index";
export { default as PSARadiobutton } from "./Radiobutton/index";
export { default as PSALoadingspinner } from "./Loadingspinner/index";

0 comments on commit 666098e

Please sign in to comment.