Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add loading animation #232

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions taxonomy-editor-frontend/src/components/Loader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is ok to replace the 'loading...' message with a spinner. But for the moment I'd say we could just use the CircularProgress directly, without the need for a wrapper, this gives us more control on the spacing, size, etc. Please instead of importing this component, use the CircularProgress.

import { Box } from "@mui/material";
import CircularProgress from "@mui/material/CircularProgress";

const Loader = () => {
return (
<Box
sx={{
width: "100%",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this width:100% needed? from what I could see it is a div by default

textAlign: "center",
py: 10,
Copy link
Collaborator

@nobeeakon nobeeakon Feb 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please when replacing the Loader component adapt the margins to the places where used, for example, having py:10 feels like a lot of space in the children or parent list. Also, may be better to use my.

m: 0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it needed to override the margins to 0?

}}
>
<CircularProgress />
</Box>
);
};

export default Loader;
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ListTranslations from "./ListTranslations";
import ListAllEntryProperties from "./ListAllEntryProperties";
import ListAllNonEntryInfo from "./ListAllNonEntryInfo";
import { createURL, getNodeType } from "../../utils";
import Loader from "../../components/Loader";

/**
* Component used for rendering node information
Expand Down Expand Up @@ -63,11 +64,7 @@ const AccumulateAllComponents = ({ id, taxonomyName, branchName }) => {

// Loading...
if (isPending) {
return (
<Typography sx={{ ml: 4 }} variant="h5">
Loading..
</Typography>
);
return <Loader />;
}

// Helper functions for Dialog component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
import ISO6391 from "iso-639-1";
import { ENTER_KEYCODE } from "../../constants";
import { greyHexCode } from "../../constants";
import Loader from "../../components/Loader";

const ListEntryChildren = ({ url, urlPrefix, setUpdateNodeChildren }) => {
const [relations, setRelations] = useState(null);
Expand Down Expand Up @@ -86,11 +87,7 @@ const ListEntryChildren = ({ url, urlPrefix, setUpdateNodeChildren }) => {
);
}
if (isPending) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nobeeakon I am taking this PR
I can see the 2 loading spins when we want to edit a node.
Do we want a circular progress when we are waiting for children and parents ? Or do we only need a circular progress for the whole page ?
I ask these questions to know if I delete these circular progress components in ListEntryChildren and ListEntryParents. If we want to keep them, we will display both of them or do we only want one for both lists ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Piv94165 let's keep it simple ! Spinners are not the main UX blocker right now ;-)

return (
<Typography sx={{ ml: 4 }} variant="h5">
Loading..
</Typography>
);
return <Loader />;
}
return (
<Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Box, Typography } from "@mui/material";

import useFetch from "../../components/useFetch";
import type { ParentsAPIResponse } from "../../backend-types/types";
import Loader from "../../components/Loader";

type Props = {
fetchUrl: string;
Expand All @@ -25,11 +26,7 @@ const ListEntryParents = ({ fetchUrl, linkHrefPrefix }: Props) => {
}

if (isPending) {
return (
<Typography sx={{ ml: 4 }} variant="h5">
Loading...
</Typography>
);
return <Loader />;
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import useFetch from "../../components/useFetch";
import { API_URL } from "../../constants";
import { toSnakeCase, toTitleCase } from "../../utils";
import type { ProjectsAPIResponse } from "../../backend-types/types";
import Loader from "../../components/Loader";

type ProjectType = {
id: string;
Expand Down Expand Up @@ -70,7 +71,7 @@ const GoToProject = ({ clearNavBarLinks }: Props) => {
}

if (isPending) {
return <Typography variant="h5">Loading..</Typography>;
return <Loader />;
}

return (
Expand Down
7 changes: 2 additions & 5 deletions taxonomy-editor-frontend/src/pages/root-nodes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import useFetch from "../../components/useFetch";
import { toTitleCase, createBaseURL } from "../../utils";
import { greyHexCode } from "../../constants";
import type { RootEntriesAPIResponse } from "../../backend-types/types";
import Loader from "../../components/Loader";

type RootNodesProps = {
addNavLinks: ({
Expand Down Expand Up @@ -79,11 +80,7 @@ const RootNodes = ({
}

if (isPending || !nodes) {
return (
<Box>
<Typography variant="h5">Loading...</Typography>
</Box>
);
return <Loader />;
}

return (
Expand Down