Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

test(site): make loading snapshots more predictable#14564

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
BrunoQuaresma merged 3 commits intomainfrombq/determinate-loading-on-storybook
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes fromall 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
9 changes: 7 additions & 2 deletionssite/src/components/Loader/Loader.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
import type { Interpolation, Theme } from "@emotion/react";
importCircularProgressfrom "@mui/material/CircularProgress";
import{ Spinner }from "components/Spinner/Spinner";
import type { FC, HTMLAttributes } from "react";

interface LoaderProps extends HTMLAttributes<HTMLDivElement> {
fullscreen?: boolean;
size?: number;
/**
* A label for the loader. This is used for accessibility purposes.
*/
label?: string;
}

export const Loader: FC<LoaderProps> = ({
fullscreen,
size = 26,
label = "Loading...",
...attrs
}) => {
return (
Expand All@@ -18,7 +23,7 @@ export const Loader: FC<LoaderProps> = ({
data-testid="loader"
{...attrs}
>
<CircularProgress size={size} />
<Spinner aria-label={label} size={size} />
</div>
);
};
Expand Down
22 changes: 22 additions & 0 deletionssite/src/components/Spinner/Spinner.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
import CircularProgress, {
type CircularProgressProps,
} from "@mui/material/CircularProgress";
import isChromatic from "chromatic/isChromatic";
import type { FC } from "react";

/**
* Spinner component used to indicate loading states. This component abstracts
* the MUI CircularProgress to provide better control over its rendering,
* especially in snapshot tests with Chromatic.
*/
export const Spinner: FC<CircularProgressProps> = (props) => {
/**
* During Chromatic snapshots, we render the spinner as determinate to make it
* static without animations, using a deterministic value (75%).
*/
if (isChromatic()) {
props.variant = "determinate";
props.value = 75;
Copy link
Member

Choose a reason for hiding this comment

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

nice

}
return <CircularProgress {...props} />;
};
Loading

[8]ページ先頭

©2009-2025 Movatter.jp