Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
},
"dependencies": {},
"peerDependencies": {
"react": "^16 || ^17 || ^18",
"react-dom": "^16 || ^17 || ^18"
"react": "^16 || ^17 || ^18 || ^19",
"react-dom": "^16 || ^17 || ^18 || ^19"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-node-resolve": "^14.0.1",
"@types/react": "^18.0.18",
"@types/react-dom": "^18.0.6",
"@types/react": "^19.1.1",
"@types/react-dom": "^19.1.1",
"postcss": "^8.4.16",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "^19.1.1",
"react-dom": "^19.1.1",
"rollup": "^2.79.0",
"rollup-plugin-peer-deps-external": "^2.2.4",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-typescript2": "^0.33.0",
"rollup-plugin-url": "^3.0.1",
"typescript": "^4.8.2"
"typescript": "^5.9.2"
},
"files": [
"dist"
Expand Down
31 changes: 16 additions & 15 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
import React from "react";

import { ElementType, ComponentPropsWithoutRef, CSSProperties } from "react";
import css from "./styles.css";

interface SkeletonLoaderProps {
width?;
height?;
background?;
radius?;
type SkeletonLoaderProps<T extends ElementType> = {
width?: string;
height?: string;
background?: string;
radius?: string;
circle?: boolean;
block?: boolean;
style?: React.CSSProperties;
as?: keyof JSX.IntrinsicElements
}
style?: CSSProperties;
as?: T;
} & Omit<ComponentPropsWithoutRef<T>, keyof any>; // allow other props for Tag

function SkeletonLoader({
export function SkeletonLoader<T extends ElementType = "div">({
width = "100%",
height = "1em",
background = "#E9ECEF",
radius = "4px",
circle = false,
block = true,
style = {},
as: Tag = "div",
}: SkeletonLoaderProps) {
as,
...restProps
}: SkeletonLoaderProps<T>) {
const Tag = as || "div";

return (
<Tag
className={css.skeleton}
Expand All @@ -34,10 +36,9 @@ function SkeletonLoader({
display: block ? "block" : "inline-block",
...style,
}}
{...restProps}
>
&zwnj;
</Tag>
);
}

export default SkeletonLoader;
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
"lib": ["es6", "dom", "es2016", "es2017"],
"sourceMap": true,
"allowJs": false,
"jsx": "react",
"jsx": "react-jsx",
"declaration": true,
"moduleResolution": "node",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": false,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"allowSyntheticDefaultImports": true
Expand Down
Loading