Skip to content

Create skeleton card component#70

Open
rotemergty5 wants to merge 3 commits into
mainfrom
add-skeletons-component
Open

Create skeleton card component#70
rotemergty5 wants to merge 3 commits into
mainfrom
add-skeletons-component

Conversation

@rotemergty5
Copy link
Copy Markdown
Collaborator

@rotemergty5 rotemergty5 commented May 16, 2026

I built Skeleton components in React and MUI in a clean and reusable way.

I created a base SGLSkeleton component that supports customizable colors, sizes, and styling, and on top of it I built a card component that includes a profile image, title, description, image, and button.

I also added support for passing different texts, colors, and images to each card, including a default placeholder image when no image is provided.

Summary by CodeRabbit

  • Refactor

    • Updated the Skeleton loading component to use a theme-based styling preset, standardizing background and animation timing.
  • New Features

    • Component still defaults to wave animation and now accepts a simple inline style prop for minor visual tweaks.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

📝 Walkthrough

Walkthrough

SGLSkeleton was refactored to use a new theme-based skeletonStyles(theme) factory; the component now accepts only style?: CSSProperties (omitting sx/skeletonColor) and computes MUI Skeleton’s sx by merging the theme styles with the provided style, defaulting animation to 'wave'.

Changes

Skeleton Components Library

Layer / File(s) Summary
Props and public type change
src/components/UI/Skeleton/SGLSkeleton.tsx
SGLSkeletonProps now omits MUI's style and sx and exposes only style?: CSSProperties; skeletonColor and a public sx prop were removed.
Implementation and theme styles
src/components/UI/Skeleton/styles.ts, src/components/UI/Skeleton/SGLSkeleton.tsx
Adds skeletonStyles(theme) that sets backgroundColor, opacity, and wave animationDuration; SGLSkeleton computes sx by merging skeletonStyles(theme) with the provided style, defaults animation='wave', and forwards remaining props to MUI Skeleton.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

A rabbit hums as styles align,
Theme-fed waves in gentle line,
I tuck the props to keep them neat,
A tidy ske-le-ton, calm and sweet,
🐇✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title describes creating a skeleton card component, but the actual changes only refactor the base SGLSkeleton component and add styling utilities—no card component is present in the changeset. Update the title to reflect the actual changes: e.g., 'Refactor SGLSkeleton component with theme-based styling' or 'Add SGLSkeleton styling utilities'.
Description check ⚠️ Warning The description claims to have created a base SGLSkeleton and card component with multiple features, but the changeset only shows SGLSkeleton refactoring and styles.ts addition—no card component is present. Update the description to match the actual changes: document the SGLSkeleton refactoring to use theme-based styling and the new styles.ts utilities, removing claims about card components not yet implemented.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-skeletons-component

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/components/UI/Skeleton/SGLContentCardSkeleton.css (1)

142-143: ⚡ Quick win

Replace deprecated word-break: break-word.

Use modern wrapping behavior (overflow-wrap) and avoid deprecated word-break keyword.

Proposed fix
 .image-description {
   position: relative;
@@
-  word-break: break-word;
   overflow-wrap: anywhere;
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/UI/Skeleton/SGLContentCardSkeleton.css` around lines 142 -
143, The CSS rule in SGLContentCardSkeleton.css currently uses the deprecated
declaration "word-break: break-word"; remove that line and rely on
"overflow-wrap: anywhere" (or add "word-break: break-all" only if intentional
hard breaks are needed) so update the selector containing "word-break:
break-word" to delete that property and keep "overflow-wrap: anywhere" as the
modern wrapping behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/UI/Skeleton/SGLContentCardSkeleton.css`:
- Around line 92-101: The CSS for .sgl-image-wrapper hardcodes height: 180px
which prevents the component from honoring the imageHeight prop; remove the
fixed height declaration from .sgl-image-wrapper and either rely on inline
styles set by the component using the imageHeight prop or add a CSS variable
(e.g., height: var(--sgl-image-height, auto)) that the component can set from
imageHeight, ensuring the wrapper's height becomes configurable at runtime.
- Around line 51-54: The CSS declaration in the .sgl-text-wrapper rule uses
invalid quoted value width: 'fit-content'; which gets ignored; update the
.sgl-text-wrapper rule to use a valid value (remove the quotes so it reads
fit-content) or use an appropriate alternative (e.g., display: inline-block or
width: max-content) to achieve the intended sizing behavior for the element.

In `@src/components/UI/Skeleton/SGLSkeleton.tsx`:
- Around line 35-41: In SGLSkeleton update the component to avoid spreading the
incoming sx (which may be an array or function) into an object; instead build a
baseSx object containing the conditional fontSize (from variant/textSize),
bgcolor (skeletonColor), borderRadius (radius), and opacity, and pass the prop
as an array composition like sx={[baseSx, sx]} so MUI can handle
object/array/function SxProps correctly; modify the code around the sx
assignment in SGLSkeleton to create baseSx and supply sx as an array rather than
using ...sx.

---

Nitpick comments:
In `@src/components/UI/Skeleton/SGLContentCardSkeleton.css`:
- Around line 142-143: The CSS rule in SGLContentCardSkeleton.css currently uses
the deprecated declaration "word-break: break-word"; remove that line and rely
on "overflow-wrap: anywhere" (or add "word-break: break-all" only if intentional
hard breaks are needed) so update the selector containing "word-break:
break-word" to delete that property and keep "overflow-wrap: anywhere" as the
modern wrapping behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5cad883a-36b0-44b4-a597-a96d5a09a486

📥 Commits

Reviewing files that changed from the base of the PR and between ea2e2de and 9904d54.

📒 Files selected for processing (3)
  • src/components/UI/Skeleton/SGLContentCardSkeleton.css
  • src/components/UI/Skeleton/SGLContentCardSkeleton.tsx
  • src/components/UI/Skeleton/SGLSkeleton.tsx

Comment thread src/components/UI/Skeleton/SGLContentCardSkeleton.css Outdated
Comment thread src/components/UI/Skeleton/SGLContentCardSkeleton.css Outdated
Comment thread src/components/UI/Skeleton/SGLSkeleton.tsx Outdated
@Tamir198 Tamir198 closed this May 18, 2026
@Tamir198 Tamir198 reopened this May 18, 2026
Copy link
Copy Markdown
Member

@Tamir198 Tamir198 left a comment

Choose a reason for hiding this comment

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

We are implementing our UI components in the project based on material ui (MUI) library and they already got ready to work skeleton that we can just wrap, check the docs :

https://mui.com/material-ui/react-skeleton/

The component should be similar in props to any other component under the ui folder, SGLCard for example is a simple one that you can take reference from

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/UI/Skeleton/SGLSkeleton.tsx`:
- Around line 1-3: Normalize the file's line endings from CRLF to LF for
src/components/UI/Skeleton/SGLSkeleton.tsx (including the import block
referencing Skeleton and MuiSkeletonProps) and any other affected lines (e.g.,
the occurrence at line 7), then re-run the project's formatter/prettier so the
file is saved with repository-preferred LF endings and formatting checks pass.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 874b4398-eeb0-4054-9a90-13f0d5f15756

📥 Commits

Reviewing files that changed from the base of the PR and between 9904d54 and fd424d6.

📒 Files selected for processing (1)
  • src/components/UI/Skeleton/SGLSkeleton.tsx

Comment on lines +1 to +3
import Skeleton, {
type SkeletonProps as MuiSkeletonProps,
} from '@mui/material/Skeleton'
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Normalize line endings to satisfy CI formatting checks.

Prettier/lint failures indicate CRLF/newline formatting issues on this file. Please normalize to repository-preferred LF and re-run formatting so checks pass.

Also applies to: 7-7

🧰 Tools
🪛 GitHub Check: Build, lint, prettier and tests

[failure] 1-1:
Replace ␍⏎··type·SkeletonProps·as·MuiSkeletonProps,␍⏎ with ·type·SkeletonProps·as·MuiSkeletonProps·

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/UI/Skeleton/SGLSkeleton.tsx` around lines 1 - 3, Normalize the
file's line endings from CRLF to LF for
src/components/UI/Skeleton/SGLSkeleton.tsx (including the import block
referencing Skeleton and MuiSkeletonProps) and any other affected lines (e.g.,
the occurrence at line 7), then re-run the project's formatter/prettier so the
file is saved with repository-preferred LF endings and formatting checks pass.

Copy link
Copy Markdown
Member

@Tamir198 Tamir198 left a comment

Choose a reason for hiding this comment

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

left some comments, also do you see linter errors when you run your code locally?

return (
<Skeleton
sx={{
bgcolor: skeletonColor,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

bgcolor is MUI prop, we dont want do to it, we want to create css object like we we in the rest of the components

}

export const SGLSkeleton = ({
skeletonColor = '#8F3DFF',
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No hardcoded colors, bring theme from the theme object in theme.ts

interface SGLSkeletonProps
extends Omit<MuiSkeletonProps, 'sx'> {
skeletonColor?: string
sx?: SxProps<Theme>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

not sx, the component should accept styles object, check how we are doing it in other ui components

@rotemergty5 rotemergty5 requested review from GilHeller and Tamir198 May 19, 2026 15:59
@rotemergty5
Copy link
Copy Markdown
Collaborator Author

left some comments, also do you see linter errors when you run your code locally?

It worked for me, hope the new version works for you too.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/UI/Skeleton/SGLSkeleton.tsx`:
- Around line 19-22: The component SGLSkeleton currently spreads the incoming
style prop into the MUI sx object (sx={(theme)=>({...skeletonStyles(theme),
...style})}), which causes numeric values to be interpreted by the MUI system;
remove spreading style into sx and instead pass the style prop through as a
plain React inline style on the root element (e.g., use style={style}), keeping
skeletonStyles/theme-derived values in sx and merging only the incoming sx prop
(not style). Ensure the prop type remains style?: CSSProperties and update any
usage in SGLSkeleton where sx is composed (refer to skeletonStyles and the
existing sx merge) so style is applied as an ordinary DOM style, not part of sx.

In `@src/components/UI/Skeleton/styles.ts`:
- Line 12: The file src/components/UI/Skeleton/styles.ts is missing a trailing
newline which breaks Prettier; open styles.ts and ensure the file ends with a
single newline character (add a '\n' at EOF), save the file so the final closing
brace is followed by a newline, then re-run Prettier/commit the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d987ac94-96d2-4c65-83ff-70deef110f93

📥 Commits

Reviewing files that changed from the base of the PR and between fd424d6 and fdd253b.

📒 Files selected for processing (2)
  • src/components/UI/Skeleton/SGLSkeleton.tsx
  • src/components/UI/Skeleton/styles.ts

Comment on lines +19 to +22
sx={(theme) => ({
...skeletonStyles(theme),
...style,
})}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

In MUI v7, how does the sxprop interpret numeric values for properties like margin, padding, borderRadius, width, and height, and how does that differ from passing the same values through the Reactstyle prop?

💡 Result:

In MUI v7, the sx prop acts as a theme-aware interface that interprets numeric values differently depending on the specific CSS property [1]. Unlike the standard React style prop, which passes values directly to the browser as inline CSS styles (often requiring explicit units like 'px' or 'rem'), the sx prop maps numbers to theme-defined values or specific transformation functions [1]. Key behaviors for numeric values in the sx prop include: 1. Spacing (margin, padding): Numeric values are multiplied by the theme.spacing value (default is 8px) [1]. For example, sx={{ m: 2 }} results in a margin of 16px. 2. Sizing (width, height, minWidth, minHeight, maxWidth, maxHeight): These properties use a custom transform function [1]. If the numeric value is between (0, 1], it is converted to a percentage (e.g., sx={{ width: 0.5 }} becomes width: 50%). If the value is greater than 1, it is treated as a pixel value (e.g., sx={{ width: 20 }} becomes width: 20px) [1]. 3. borderRadius: Numeric values are multiplied by the theme.shape.borderRadius value (default is 4px) [1]. 4. Border: Numeric values are interpreted as pixel widths for a solid black border (e.g., sx={{ border: 1 }} equates to border: 1px solid black) [1]. In contrast, the React style prop performs no such transformations [2]. Passing a number to style (e.g., style={{ margin: 2 }}) is generally invalid for CSS properties that require units, as React will not automatically append 'px' to most numeric values, resulting in the style being ignored by the browser [2]. The sx prop provides a more concise, theme-integrated approach, whereas the style prop remains a standard, direct way to apply inline styles without MUI-specific logic or theme awareness [2].

Citations:


Fix style prop contract: don’t merge style into MUI sx

style?: CSSProperties implies React inline-style semantics, but spreading style into sx makes numeric values follow MUI system transforms (e.g., spacing via theme.spacing, borderRadius scaling via theme.shape.borderRadius, special transforms for width/height). That changes how callers’ values are interpreted versus a real React style prop.

Proposed fix
     <Skeleton
-      sx={(theme) => ({
-        ...skeletonStyles(theme),
-        ...style,
-      })}
+      sx={(theme) => skeletonStyles(theme)}
+      style={style}
       animation={animation}
       {...props}
     />
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/UI/Skeleton/SGLSkeleton.tsx` around lines 19 - 22, The
component SGLSkeleton currently spreads the incoming style prop into the MUI sx
object (sx={(theme)=>({...skeletonStyles(theme), ...style})}), which causes
numeric values to be interpreted by the MUI system; remove spreading style into
sx and instead pass the style prop through as a plain React inline style on the
root element (e.g., use style={style}), keeping skeletonStyles/theme-derived
values in sx and merging only the incoming sx prop (not style). Ensure the prop
type remains style?: CSSProperties and update any usage in SGLSkeleton where sx
is composed (refer to skeletonStyles and the existing sx merge) so style is
applied as an ordinary DOM style, not part of sx.

animationDuration: '1.6s',
},
}
} No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add the missing trailing newline.

This file currently fails Prettier because it ends without a newline.

🧰 Tools
🪛 GitHub Check: Build, lint, prettier and tests

[failure] 12-12:
Insert

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/components/UI/Skeleton/styles.ts` at line 12, The file
src/components/UI/Skeleton/styles.ts is missing a trailing newline which breaks
Prettier; open styles.ts and ensure the file ends with a single newline
character (add a '\n' at EOF), save the file so the final closing brace is
followed by a newline, then re-run Prettier/commit the change.

@GilHeller
Copy link
Copy Markdown
Collaborator

@rotemergty5 Notice that the ESLint auto check failed. Please Fix it

Copy link
Copy Markdown
Member

@Tamir198 Tamir198 left a comment

Choose a reason for hiding this comment

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

@rotemergty5 The code works locally but you have prettier error, run prettier locally and push them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants