Skip to content

Commit

Permalink
fix(Spinner)!: removing spacing prop in favor of Tailwind classes (#830)
Browse files Browse the repository at this point in the history
  • Loading branch information
aversini authored Dec 29, 2024
1 parent df3ad6a commit ffe1486
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
9 changes: 2 additions & 7 deletions packages/ui-spinner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"files": ["dist"],
"scripts": {
"build:check": "tsc",
"build:js": "vite build",
Expand All @@ -39,11 +37,8 @@
},
"dependencies": {
"@tailwindcss/typography": "0.5.15",
"@versini/ui-spacing": "workspace:../ui-spacing",
"@versini/ui-types": "workspace:../ui-types",
"tailwindcss": "3.4.17"
},
"sideEffects": [
"**/*.css"
]
"sideEffects": ["**/*.css"]
}
8 changes: 4 additions & 4 deletions packages/ui-spinner/src/components/Spinner/Spinner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { getSpacing } from "@versini/ui-spacing";
import clsx from "clsx";

import { SPINNER_CLASSNAME } from "../../common/constants";
Expand All @@ -8,13 +7,13 @@ export const Spinner = ({
spinnerRef,
mode = "system",
type = "circle",
spacing,
className,
}: SpinnerProps) => {
const spinnerClassName =
type === "circle"
? clsx(
SPINNER_CLASSNAME,
getSpacing(spacing),

"h-8 w-8",
"align-[-0.125em]",
"border-4",
Expand All @@ -25,8 +24,9 @@ export const Spinner = ({
"text-copy-dark dark:text-copy-accent": mode === "system",
"text-copy-accent dark:text-copy-dark": mode === "alt-system",
},
className,
)
: clsx(SPINNER_CLASSNAME, getSpacing(spacing));
: clsx(SPINNER_CLASSNAME, className);

const dotClassName = clsx("av-spinner__dot", {
"fill-copy-dark": mode === "dark",
Expand Down
8 changes: 5 additions & 3 deletions packages/ui-spinner/src/components/Spinner/SpinnerTypes.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { SpacingTypes } from "@versini/ui-types";

export type SpinnerProps = {
/**
* The class name to apply to the spinner.
*/
className?: string;
/**
* The mode of spinner to render. This will change the color of the spinner.
*/
Expand All @@ -13,4 +15,4 @@ export type SpinnerProps = {
* The type of spinner to render. This will change the layout of the spinner.
*/
type?: "circle" | "dots";
} & SpacingTypes.Props;
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ describe("Spinner (exceptions)", () => {
});
});

describe("Spinner spacing", () => {
it("should render a spinner with a right margin spacing", async () => {
render(<Spinner className="mr-2" />);
const node = await screen.findByRole("status");
// not only it should be there, but it should be the last entry
expect(node.className).toContain("mr-2");
expect(node.className.slice(-4)).toBe("mr-2");
});
});

describe("Spinner modifiers", () => {
it("should render a default Spinner (dark)", async () => {
render(<Spinner />);
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-spinner/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import { commonTailwindConfigForComponent } from "../../configuration/tailwind.common";
export default commonTailwindConfigForComponent();
export default commonTailwindConfigForComponent("ui-spinner");
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const componentsWithNoSpacingProp = [
"ui-modal",
"ui-panel",
"ui-pill",
"ui-spinner",
"ui-svgicon",
"ui-truncate",
];
Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ffe1486

Please sign in to comment.