-
Notifications
You must be signed in to change notification settings - Fork 0
Create skeleton card component #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9904d54
Create skeleton card component
rotemergty5 fd424d6
Update skeleton component
rotemergty5 fdd253b
update skeleton
rotemergty5 fb96d6f
fix prettier issues in skeleton component
rotemergty5 c5b6a60
Add unit tests for SGLSelect
rotemergty5 6a12734
Revert "Fix SGLSelect tests"
rotemergty5 5386389
Revert "Add unit tests for SGLSelect"
rotemergty5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import Skeleton, { type SkeletonProps as MuiSkeletonProps } from '@mui/material/Skeleton' | ||
|
|
||
| import type { CSSProperties } from '@mui/material/styles' | ||
| import { skeletonStyles } from './styles' | ||
|
|
||
| interface SGLSkeletonProps extends Omit<MuiSkeletonProps, 'style' | 'sx'> { | ||
| style?: CSSProperties | ||
| } | ||
|
|
||
| export const SGLSkeleton = ({ animation = 'wave', style, ...props }: SGLSkeletonProps) => { | ||
| return ( | ||
| <Skeleton | ||
| sx={(theme) => ({ | ||
| ...skeletonStyles(theme), | ||
| ...style, | ||
| })} | ||
| animation={animation} | ||
| {...props} | ||
| /> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import type { Theme } from '@mui/material/styles' | ||
|
|
||
| export const skeletonStyles = (theme: Theme) => { | ||
| return { | ||
| backgroundColor: theme.palette.lightGrey.main, | ||
| opacity: 1, | ||
|
|
||
| '&.MuiSkeleton-wave::after': { | ||
| animationDuration: '1.6s', | ||
| }, | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
In MUI v7, how does thesxprop interpret numeric values for properties like margin, padding, borderRadius, width, and height, and how does that differ from passing the same values through the Reactstyleprop?💡 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
styleprop contract: don’t mergestyleinto MUIsxstyle?: CSSPropertiesimplies React inline-style semantics, but spreadingstyleintosxmakes numeric values follow MUI system transforms (e.g., spacing viatheme.spacing,borderRadiusscaling viatheme.shape.borderRadius, special transforms forwidth/height). That changes how callers’ values are interpreted versus a real Reactstyleprop.Proposed fix
🤖 Prompt for AI Agents