mirror of
https://github.com/nextui-org/nextui.git
synced 2025-12-08 19:26:11 +00:00
fix(spinner): cater global spinner variant (#5948)
* fix(spinner): cater global spinner variant * feat(spinner): add spinner test cases * chore(changeset): add changeset
This commit is contained in:
parent
ce0c298785
commit
0825f88cd2
5
.changeset/perfect-toes-cry.md
Normal file
5
.changeset/perfect-toes-cry.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@heroui/spinner": patch
|
||||
---
|
||||
|
||||
cater global spinner variant (#5939)
|
||||
@ -1,5 +1,6 @@
|
||||
import * as React from "react";
|
||||
import {render} from "@testing-library/react";
|
||||
import {HeroUIProvider} from "@heroui/system";
|
||||
|
||||
import {Spinner} from "../src";
|
||||
|
||||
@ -40,4 +41,24 @@ describe("Spinner", () => {
|
||||
|
||||
expect(getByLabelText("Custom label")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should use global spinner variant if variant is not defined", () => {
|
||||
const {container} = render(
|
||||
<HeroUIProvider spinnerVariant="gradient">
|
||||
<Spinner aria-label="Custom label" />
|
||||
</HeroUIProvider>,
|
||||
);
|
||||
|
||||
expect(container.querySelector("[class*='gradient']")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should not use global spinner variant if variant is defined", () => {
|
||||
const {container} = render(
|
||||
<HeroUIProvider spinnerVariant="gradient">
|
||||
<Spinner aria-label="Custom label" variant="default" />
|
||||
</HeroUIProvider>,
|
||||
);
|
||||
|
||||
expect(container.querySelector("[class*='gradient']")).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@ -45,7 +45,10 @@ export function useSpinner(originalProps: UseSpinnerProps) {
|
||||
|
||||
const {children, className, classNames, label: labelProp, ...otherProps} = props;
|
||||
|
||||
const slots = useMemo(() => spinner({...variantProps}), [objectToDeps(variantProps)]);
|
||||
const slots = useMemo(
|
||||
() => spinner({...variantProps, variant}),
|
||||
[objectToDeps(variantProps), variant],
|
||||
);
|
||||
|
||||
const baseStyles = clsx(classNames?.base, className);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user