-
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| 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, | ||
| })} | ||
|
Comment on lines
+19
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 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
Proposed fix <Skeleton
- sx={(theme) => ({
- ...skeletonStyles(theme),
- ...style,
- })}
+ sx={(theme) => skeletonStyles(theme)}
+ style={style}
animation={animation}
{...props}
/>🤖 Prompt for AI Agents |
||
| animation={animation} | ||
| {...props} | ||
| /> | ||
| ) | ||
| } | ||
| 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', | ||
| }, | ||
| } | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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: 🤖 Prompt for AI Agents |
||
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.
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