Skip to content

Commit

Permalink
add with property to stateSkeletonBar for easy customization
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabricevladimir committed Apr 16, 2024
1 parent dd8b9ee commit 4e2ab32
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/core/components/states/stateSkeletonBar/stateSkeletonBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ export interface IStateSkeletonBarProps extends ComponentPropsWithoutRef<'span'>
* @default 'md'
*/
size?: StateSkeletonBarSize;
/**
* Specifies the width of the skeleton element.
* Can be provided as a number (interpreted as pixels)
* or a string with explicit units (e.g., px, %, em).
* @default 160
*
* @example
* width={200} // Sets width to 200 pixels.
* width="100px" // Sets width to 100 pixels.
* width="10%" // Sets width to 10% of its parent container.
*/
width?: string | number;
}

const responsiveSizeClasses: ResponsiveAttributeClassMap<StateSkeletonBarSize> = {
Expand All @@ -26,7 +38,7 @@ const responsiveSizeClasses: ResponsiveAttributeClassMap<StateSkeletonBarSize> =
};

export const StateSkeletonBar = forwardRef<HTMLDivElement, IStateSkeletonBarProps>((props, ref) => {
const { className, responsiveSize = {}, size = 'md', ...otherProps } = props;
const { className, responsiveSize = {}, size = 'md', width, ...otherProps } = props;

const classes = classNames(
'w-40 animate-pulse rounded-full bg-neutral-50',
Expand All @@ -41,6 +53,7 @@ export const StateSkeletonBar = forwardRef<HTMLDivElement, IStateSkeletonBarProp
className={classes}
tabIndex={-1}
aria-hidden={true}
style={{ width }}
{...otherProps}
/>
);
Expand Down

0 comments on commit 4e2ab32

Please sign in to comment.