diff --git a/specifyweb/frontend/js_src/lib/components/Forms/SpecifyForm.tsx b/specifyweb/frontend/js_src/lib/components/Forms/SpecifyForm.tsx index 900a921c5ad..d7840e410e6 100644 --- a/specifyweb/frontend/js_src/lib/components/Forms/SpecifyForm.tsx +++ b/specifyweb/frontend/js_src/lib/components/Forms/SpecifyForm.tsx @@ -72,7 +72,6 @@ export function SpecifyForm({ const resolvedResource = loadedResource ?? oldResourceRef.current; const formIsLoaded = typeof viewDefinition === 'object' && typeof resolvedResource === 'object'; - // Const formIsLoaded = false; // If parent resource is loading, don't duplicate the loading bar in children const isAlreadyLoading = React.useContext(FormLoadingContext); diff --git a/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/AppResource.tsx b/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/AppResource.tsx index a5527e1c935..3bb03ff2bab 100644 --- a/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/AppResource.tsx +++ b/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/AppResource.tsx @@ -1,37 +1,24 @@ import React from 'react'; -import ContentLoader from 'react-content-loader'; +import { Skeleton } from './Skeleton'; -import { userPreferences } from '../Preferences/userPreferences'; - -export function AppResourceSkeleton(): JSX.Element { - const [motionPref] = userPreferences.use('general', 'ui', 'reduceMotion'); - return ( -
- - - - - - - - - - - - - - - - - - - -
- ); -} +export const AppResourceSkeleton = () => ( + + + + + + + + + + + + + + + + + + + +); diff --git a/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/AttachmentGallery.tsx b/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/AttachmentGallery.tsx index 34033c7a75d..df5d07bef36 100644 --- a/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/AttachmentGallery.tsx +++ b/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/AttachmentGallery.tsx @@ -1,55 +1,25 @@ import React from 'react'; -import ContentLoader from 'react-content-loader'; - -import { userPreferences } from '../Preferences/userPreferences'; - -const DEFAULT_FETCH_LIMIT = 20; - -export function AttachmentGallerySkeleton(): JSX.Element { - const [motionPref] = userPreferences.use('general', 'ui', 'reduceMotion'); - - function createRectangles() { - const rectWidth = 22; - const rectHeight = 22; - const rectRadius = 2; - let rectX = 5; // Starting x position - let rectY = 0; // Starting y position - const rectangles = []; // Array to hold the generated rectangles - - for (let i = 0; i < DEFAULT_FETCH_LIMIT; i++) { - rectangles.push( - - ); - - rectX += rectWidth + 5; - - if ((i + 1) % 4 === 0) { - rectX = 5; - rectY += rectHeight + 10; - } - } - - return rectangles; - } - - return ( -
- - {createRectangles()} - -
- ); +import { Skeleton } from './Skeleton'; +import { DEFAULT_FETCH_LIMIT } from '../DataModel/collection'; + +export const AttachmentGallerySkeleton = () => ( + {createRectangles()} +); + +function createRectangles() { + const rectWidth = 22; + const rectHeight = 22; + const rectRadius = 2; + const rectangles = Array.from({ length: DEFAULT_FETCH_LIMIT }, (_, index) => ( + + )); + + return rectangles; } diff --git a/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/AttachmentPlugin.tsx b/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/AttachmentPlugin.tsx index ba7e2ffd6f1..4decdff82ef 100644 --- a/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/AttachmentPlugin.tsx +++ b/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/AttachmentPlugin.tsx @@ -1,34 +1,21 @@ import React from 'react'; -import ContentLoader from 'react-content-loader'; +import { Skeleton } from './Skeleton'; -import { userPreferences } from '../Preferences/userPreferences'; - -export function AttachmentPluginSkeleton(): JSX.Element { - const [motionPref] = userPreferences.use('general', 'ui', 'reduceMotion'); - return ( -
- - - - - - - - - - - - - - - - -
- ); -} +export const AttachmentPluginSkeleton = () => ( + + + + + + + + + + + + + + + + +); diff --git a/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/Form.tsx b/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/Form.tsx index bf7a379ec3a..2f388f54825 100644 --- a/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/Form.tsx +++ b/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/Form.tsx @@ -1,52 +1,39 @@ import React from 'react'; -import ContentLoader from 'react-content-loader'; - -import { userPreferences } from '../Preferences/userPreferences'; - -export function FormSkeleton(): JSX.Element { - const [motionPref] = userPreferences.use('general', 'ui', 'reduceMotion'); - return ( -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ); -} +import { Skeleton } from './Skeleton'; + +export const FormSkeleton = () => ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +); diff --git a/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/QueryBuilder.tsx b/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/QueryBuilder.tsx index f58c4a8dca8..248a29cb000 100644 --- a/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/QueryBuilder.tsx +++ b/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/QueryBuilder.tsx @@ -1,42 +1,29 @@ import React from 'react'; -import ContentLoader from 'react-content-loader'; +import { Skeleton } from './Skeleton'; -import { userPreferences } from '../Preferences/userPreferences'; +export const QueryBuilderSkeleton = () => ( + + + + + -export function QueryBuilderSkeleton(): JSX.Element { - const [motionPref] = userPreferences.use('general', 'ui', 'reduceMotion'); - return ( -
- - - - - + + + + - - - - + + + + + - - - - - + + - - - - - - - -
- ); -} + + + +
+); diff --git a/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/Skeleton.tsx b/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/Skeleton.tsx new file mode 100644 index 00000000000..6e61bb0a263 --- /dev/null +++ b/specifyweb/frontend/js_src/lib/components/SkeletonLoaders/Skeleton.tsx @@ -0,0 +1,32 @@ +import React, { ReactNode } from 'react'; +import ContentLoader from 'react-content-loader'; +import { userPreferences } from '../Preferences/userPreferences'; + +type SkeletonProps = { + speed?: number; + viewBox?: string; + className?: string; + children: ReactNode; +}; + +export function Skeleton({ + speed = 3, + viewBox = '0 0 200 400', + className = 'h-full w-full', + children, +}: SkeletonProps): JSX.Element { + const [motionPref] = userPreferences.use('general', 'ui', 'reduceMotion'); + return ( +
+ + {children} + +
+ ); +}