Refactored button spinner

This commit is contained in:
Daniel Cojocea committed 2024-08-31 18:10:50 -04:00
1 parent 9fc2d5c33a
commit bee367fc8d
7 files changed
+106 -74

No files matched your search

@@ -2,7 +2,7 @@ import TabPanel from "@mui/lab/TabPanel";
import React, { useState } from "react"; import React, { useState } from "react";
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { Box, Stack, Typography } from "@mui/material"; import { Box, Stack, Typography } from "@mui/material";
import ButtonSpinner from "../../ButtonSpinner"; import LoadingButton from "@mui/lab/LoadingButton";
import Field from "../../Inputs/Field"; import Field from "../../Inputs/Field";
import { credentials } from "../../../Validation/validation"; import { credentials } from "../../../Validation/validation";
import Alert from "../../Alert"; import Alert from "../../Alert";
@@ -164,19 +164,20 @@ const PasswordPanel = () => {
</Box> </Box>
</Stack> </Stack>
<Stack direction="row" justifyContent="flex-end"> <Stack direction="row" justifyContent="flex-end">
<ButtonSpinner <LoadingButton
level="primary" variant="contained"
label="Save" color="primary"
onClick={handleSubmit} onClick={handleSubmit}
isLoading={isLoading} loading={isLoading}
loadingText="Saving..." loadingIndicator="Saving..."
disabled={Object.keys(errors).length !== 0 && true} disabled={Object.keys(errors).length !== 0 && true}
sx={{ sx={{
paddingX: theme.spacing(12), px: theme.spacing(12),
width: "fit-content",
mt: theme.spacing(20), mt: theme.spacing(20),
}} }}
/> >
Save
</LoadingButton>
</Stack> </Stack>
</Stack> </Stack>
</TabPanel> </TabPanel>
@@ -2,7 +2,6 @@ import { useTheme } from "@emotion/react";
import { useRef, useState } from "react"; import { useRef, useState } from "react";
import TabPanel from "@mui/lab/TabPanel"; import TabPanel from "@mui/lab/TabPanel";
import { Box, Button, Divider, Modal, Stack, Typography } from "@mui/material"; import { Box, Button, Divider, Modal, Stack, Typography } from "@mui/material";
import ButtonSpinner from "../../ButtonSpinner";
import Avatar from "../../Avatar"; import Avatar from "../../Avatar";
import Field from "../../Inputs/Field"; import Field from "../../Inputs/Field";
import ImageField from "../../Inputs/Image"; import ImageField from "../../Inputs/Image";
@@ -19,6 +18,7 @@ import { formatBytes } from "../../../Utils/fileUtils";
import { clearUptimeMonitorState } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice"; import { clearUptimeMonitorState } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
import { createToast } from "../../../Utils/toastUtils"; import { createToast } from "../../../Utils/toastUtils";
import { logger } from "../../../Utils/Logger"; import { logger } from "../../../Utils/Logger";
import LoadingButton from "@mui/lab/LoadingButton";
/** /**
* ProfilePanel component displays a form for editing user profile information * ProfilePanel component displays a form for editing user profile information
@@ -308,19 +308,19 @@ const ProfilePanel = () => {
/> />
<Stack direction="row" justifyContent="flex-end"> <Stack direction="row" justifyContent="flex-end">
<Box width="fit-content"> <Box width="fit-content">
<ButtonSpinner <LoadingButton
level="primary" variant="contained"
label="Save" color="primary"
onClick={handleSaveProfile} onClick={handleSaveProfile}
isLoading={isLoading} loading={isLoading}
loadingText="Saving..." loadingIndicator="Saving..."
disabled={ disabled={
Object.keys(errors).length !== 0 && !errors?.picture && true Object.keys(errors).length !== 0 && !errors?.picture && true
} }
sx={{ sx={{ px: theme.spacing(12) }}
paddingX: theme.spacing(12), >
}} Save
/> </LoadingButton>
</Box> </Box>
</Stack> </Stack>
</Stack> </Stack>
@@ -391,12 +391,14 @@ const ProfilePanel = () => {
<Button variant="text" color="info" onClick={() => setIsOpen("")}> <Button variant="text" color="info" onClick={() => setIsOpen("")}>
Cancel Cancel
</Button> </Button>
<ButtonSpinner <LoadingButton
level="error" variant="contained"
label="Delete account" color="error"
onClick={handleDeleteAccount} onClick={handleDeleteAccount}
isLoading={isLoading} loading={isLoading}
/> >
Delete account
</LoadingButton>
</Stack> </Stack>
</Stack> </Stack>
</Modal> </Modal>
@@ -11,7 +11,6 @@ import {
TextField, TextField,
Typography, Typography,
} from "@mui/material"; } from "@mui/material";
import ButtonSpinner from "../../ButtonSpinner";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import EditSvg from "../../../assets/icons/edit.svg?react"; import EditSvg from "../../../assets/icons/edit.svg?react";
import Field from "../../Inputs/Field"; import Field from "../../Inputs/Field";
@@ -22,6 +21,7 @@ import { useSelector } from "react-redux";
import BasicTable from "../../BasicTable"; import BasicTable from "../../BasicTable";
import Remove from "../../../assets/icons/trash-bin.svg?react"; import Remove from "../../../assets/icons/trash-bin.svg?react";
import Select from "../../Inputs/Select"; import Select from "../../Inputs/Select";
import LoadingButton from "@mui/lab/LoadingButton";
/** /**
* TeamPanel component manages the organization and team members, * TeamPanel component manages the organization and team members,
@@ -392,13 +392,15 @@ const TeamPanel = () => {
<Button variant="text" color="info" onClick={closeInviteModal}> <Button variant="text" color="info" onClick={closeInviteModal}>
Cancel Cancel
</Button> </Button>
<ButtonSpinner <LoadingButton
level="primary" variant="contained"
label="Send invite" color="primary"
onClick={handleInviteMember} onClick={handleInviteMember}
isLoading={false} loading={false}
disabled={Object.keys(errors).length !== 0} disabled={Object.keys(errors).length !== 0}
/> >
Send invite
</LoadingButton>
</Stack> </Stack>
</Stack> </Stack>
</Modal> </Modal>
+8 -7
View File
@@ -7,10 +7,10 @@ import { useEffect, useState } from "react";
import { credentials } from "../../Validation/validation"; import { credentials } from "../../Validation/validation";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import Field from "../../Components/Inputs/Field"; import Field from "../../Components/Inputs/Field";
import ButtonSpinner from "../../Components/ButtonSpinner";
import Logo from "../../assets/icons/bwu-icon.svg?react"; import Logo from "../../assets/icons/bwu-icon.svg?react";
import Key from "../../assets/icons/key.svg?react"; import Key from "../../assets/icons/key.svg?react";
import background from "../../assets/Images/background_pattern_decorative.png"; import background from "../../assets/Images/background_pattern_decorative.png";
import LoadingButton from "@mui/lab/LoadingButton";
import "./index.css"; import "./index.css";
const ForgotPassword = () => { const ForgotPassword = () => {
@@ -166,18 +166,19 @@ const ForgotPassword = () => {
onChange={handleChange} onChange={handleChange}
error={errors.email} error={errors.email}
/> />
<ButtonSpinner <LoadingButton
variant="contained"
color="primary"
loading={isLoading}
disabled={errors.email !== undefined} disabled={errors.email !== undefined}
onClick={handleSubmit} onClick={handleSubmit}
isLoading={isLoading}
level="primary"
label="Send instructions"
sx={{ sx={{
width: "100%", width: "100%",
fontWeight: 400,
mt: theme.spacing(15), mt: theme.spacing(15),
}} }}
/> >
Send instructions
</LoadingButton>
</Box> </Box>
</Stack> </Stack>
</Stack> </Stack>
+9 -7
View File
@@ -8,11 +8,11 @@ import { useState } from "react";
import { credentials } from "../../Validation/validation"; import { credentials } from "../../Validation/validation";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import Check from "../../Components/Check/Check"; import Check from "../../Components/Check/Check";
import ButtonSpinner from "../../Components/ButtonSpinner";
import Field from "../../Components/Inputs/Field"; import Field from "../../Components/Inputs/Field";
import LockIcon from "../../assets/icons/lock-button-icon.svg?react"; import LockIcon from "../../assets/icons/lock-button-icon.svg?react";
import background from "../../assets/Images/background_pattern_decorative.png"; import background from "../../assets/Images/background_pattern_decorative.png";
import Logo from "../../assets/icons/bwu-icon.svg?react"; import Logo from "../../assets/icons/bwu-icon.svg?react";
import LoadingButton from "@mui/lab/LoadingButton";
import "./index.css"; import "./index.css";
const SetNewPassword = () => { const SetNewPassword = () => {
@@ -266,14 +266,16 @@ const SetNewPassword = () => {
/> />
</Stack> </Stack>
</Box> </Box>
<ButtonSpinner <LoadingButton
disabled={Object.keys(errors).length !== 0} variant="contained"
isLoading={isLoading} color="primary"
loading={isLoading}
onClick={handleSubmit} onClick={handleSubmit}
level="primary" disabled={Object.keys(errors).length !== 0}
label="Reset password"
sx={{ width: "100%", maxWidth: 400 }} sx={{ width: "100%", maxWidth: 400 }}
/> >
Reset password
</LoadingButton>
</Stack> </Stack>
</Stack> </Stack>
<Box textAlign="center" p={theme.spacing(12)}> <Box textAlign="center" p={theme.spacing(12)}>
+46 -24
View File
@@ -16,13 +16,15 @@ import {
} from "../../../Features/UptimeMonitors/uptimeMonitorsSlice"; } from "../../../Features/UptimeMonitors/uptimeMonitorsSlice";
import Field from "../../../Components/Inputs/Field"; import Field from "../../../Components/Inputs/Field";
import PauseCircleOutlineIcon from "@mui/icons-material/PauseCircleOutline"; import PauseCircleOutlineIcon from "@mui/icons-material/PauseCircleOutline";
import PlayCircleOutlineRoundedIcon from "@mui/icons-material/PlayCircleOutlineRounded";
import Select from "../../../Components/Inputs/Select"; import Select from "../../../Components/Inputs/Select";
import Checkbox from "../../../Components/Inputs/Checkbox"; import Checkbox from "../../../Components/Inputs/Checkbox";
import Breadcrumbs from "../../../Components/Breadcrumbs"; import Breadcrumbs from "../../../Components/Breadcrumbs";
import PulseDot from "../../../Components/Animated/PulseDot"; import PulseDot from "../../../Components/Animated/PulseDot";
import "./index.css";
import SkeletonLayout from "./skeleton"; import SkeletonLayout from "./skeleton";
import ButtonSpinner from "../../../Components/ButtonSpinner"; import LoadingButton from "@mui/lab/LoadingButton";
import "./index.css";
/** /**
* Parses a URL string and returns a URL object. * Parses a URL string and returns a URL object.
* *
@@ -247,27 +249,40 @@ const Configure = () => {
ml: "auto", ml: "auto",
}} }}
> >
<ButtonSpinner <LoadingButton
isLoading={isLoading} variant="contained"
level="tertiary" color="secondary"
label={monitor?.isActive ? "Pause" : "Resume"} loading={isLoading}
img={<PauseCircleOutlineIcon />}
sx={{ sx={{
backgroundColor: theme.palette.background.main, backgroundColor: theme.palette.background.main,
px: theme.spacing(6), px: theme.spacing(5),
mr: theme.spacing(6), mr: theme.spacing(6),
"& svg": {
mr: theme.spacing(2),
},
}} }}
onClick={handlePause} onClick={handlePause}
/> >
<ButtonSpinner {monitor?.isActive ? (
isLoading={isLoading} <>
level="error" <PauseCircleOutlineIcon />
label="Remove" Pause
sx={{ </>
px: theme.spacing(8), ) : (
}} <>
<PlayCircleOutlineRoundedIcon />
Resume
</>
)}
</LoadingButton>
<Button
variant="contained"
color="error"
sx={{ px: theme.spacing(8) }}
onClick={() => setIsOpen(true)} onClick={() => setIsOpen(true)}
/> >
Remove
</Button>
</Box> </Box>
</Stack> </Stack>
<ConfigBox> <ConfigBox>
@@ -374,13 +389,15 @@ const Configure = () => {
</Stack> </Stack>
</ConfigBox> </ConfigBox>
<Stack direction="row" justifyContent="flex-end" mt="auto"> <Stack direction="row" justifyContent="flex-end" mt="auto">
<ButtonSpinner <LoadingButton
isLoading={isLoading} variant="contained"
level="primary" color="primary"
label="Save" loading={isLoading}
sx={{ px: theme.spacing(12) }} sx={{ px: theme.spacing(12) }}
onClick={handleSubmit} onClick={handleSubmit}
/> >
Save
</LoadingButton>
</Stack> </Stack>
</Stack> </Stack>
</> </>
@@ -439,9 +456,14 @@ const Configure = () => {
> >
Cancel Cancel
</Button> </Button>
<Button variant="contained" color="error" onClick={handleRemove}> <LoadingButton
variant="contained"
color="error"
loading={isLoading}
onClick={handleRemove}
>
Delete Delete
</Button> </LoadingButton>
</Stack> </Stack>
</Stack> </Stack>
</Modal> </Modal>
+8 -6
View File
@@ -1,6 +1,5 @@
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { Box, Button, Stack, styled, Typography } from "@mui/material"; import { Box, Button, Stack, styled, Typography } from "@mui/material";
import ButtonSpinner from "../../Components/ButtonSpinner";
import Field from "../../Components/Inputs/Field"; import Field from "../../Components/Inputs/Field";
import Link from "../../Components/Link"; import Link from "../../Components/Link";
import Select from "../../Components/Inputs/Select"; import Select from "../../Components/Inputs/Select";
@@ -10,6 +9,7 @@ import { useDispatch, useSelector } from "react-redux";
import { createToast } from "../../Utils/toastUtils"; import { createToast } from "../../Utils/toastUtils";
import { deleteMonitorChecksByTeamId } from "../../Features/UptimeMonitors/uptimeMonitorsSlice"; import { deleteMonitorChecksByTeamId } from "../../Features/UptimeMonitors/uptimeMonitorsSlice";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import LoadingButton from "@mui/lab/LoadingButton";
const Settings = ({ isAdmin }) => { const Settings = ({ isAdmin }) => {
const theme = useTheme(); const theme = useTheme();
const { user, authToken } = useSelector((state) => state.auth); const { user, authToken } = useSelector((state) => state.auth);
@@ -124,13 +124,15 @@ const Settings = ({ isAdmin }) => {
/> />
<Box> <Box>
<Typography>Clear all stats. This is irreversible.</Typography> <Typography>Clear all stats. This is irreversible.</Typography>
<ButtonSpinner <LoadingButton
isLoading={isLoading} variant="contained"
level="error" color="error"
label="Clear all stats" loading={isLoading}
onClick={handleClearStats} onClick={handleClearStats}
sx={{ mt: theme.spacing(4) }} sx={{ mt: theme.spacing(4) }}
/> >
Clear all stats
</LoadingButton>
</Box> </Box>
</Stack> </Stack>
</ConfigBox> </ConfigBox>