-
Notifications
You must be signed in to change notification settings - Fork 34
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
308: Add skeleton loading component #378
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,39 @@ | ||
import React from 'react' | ||
import { EbaySkeleton, EbaySkeletonAvatar, EbaySkeletonButton, EbaySkeletonImage } from '../' | ||
|
||
export default { | ||
component: EbaySkeleton, | ||
title: 'skeleton &ebay-skeleton-avatar' | ||
} | ||
|
||
export const Avatar = () => ( | ||
<> | ||
<EbaySkeleton> | ||
<EbaySkeletonAvatar /> | ||
</EbaySkeleton> | ||
</> | ||
) | ||
|
||
export const ButtonSmall = () => ( | ||
<> | ||
<EbaySkeleton> | ||
<EbaySkeletonButton size="small" style={{ width: '200px'}} /> | ||
</EbaySkeleton> | ||
</> | ||
) | ||
|
||
export const ButtonLarge = () => ( | ||
<> | ||
<EbaySkeleton> | ||
<EbaySkeletonButton size="large" style={{ width: '200px'}}/> | ||
</EbaySkeleton> | ||
</> | ||
) | ||
|
||
export const Image = () => ( | ||
<> | ||
<EbaySkeleton> | ||
<EbaySkeletonImage style={{ width: '100px', height: '100px' }} /> | ||
</EbaySkeleton> | ||
</> | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React, { ComponentProps, FC } from 'react' | ||
import classNames from 'classnames' | ||
import { NativeTags } from './nativeTags' | ||
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. We should use the react type instead:
But I think skin supports |
||
|
||
export type Props = { | ||
as?: NativeTags, | ||
className?: string | ||
} | ||
|
||
const EbaySkeletonAvatar: FC<Props> = ({ | ||
as = 'div', | ||
className, | ||
...rest | ||
}) => { | ||
const NativeTag = as | ||
return ( | ||
<NativeTag className={classNames('skeleton__avatar', className)} {...rest} /> | ||
) | ||
} | ||
|
||
export default EbaySkeletonAvatar |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React, { ComponentProps, FC } from 'react' | ||
import classNames from 'classnames' | ||
|
||
export type Props = ComponentProps<'div'> & { | ||
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. [trivial] other components are exporting types in a separate file |
||
size?: 'small' | 'large'; | ||
} | ||
|
||
const EbaySkeletonButton: FC<Props> = ({ | ||
size, | ||
className, | ||
...rest | ||
}) => ( | ||
<div | ||
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. It needs to support the |
||
className={classNames( | ||
'skeleton__button', | ||
size ? `skeleton__button--${size}` : '', | ||
className)} | ||
{...rest} | ||
/> | ||
) | ||
|
||
export default EbaySkeletonButton |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { ComponentProps, FC } from 'react' | ||
import classNames from 'classnames' | ||
|
||
export type Props = ComponentProps<'div'> & { | ||
a11yText?: string; | ||
} | ||
|
||
const EbaySkeletonImage: FC<Props> = ({ | ||
className, | ||
...rest | ||
}) => ( | ||
<div | ||
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. It needs to support |
||
className={classNames('skeleton__image', className)} | ||
{...rest} | ||
/> | ||
) | ||
|
||
export default EbaySkeletonImage |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { ComponentProps, FC } from 'react' | ||
import classNames from 'classnames' | ||
|
||
export type Props = ComponentProps<'div'> & { | ||
size?: 'small' | 'large'; | ||
multiline?: boolean; | ||
} | ||
|
||
const EbaySkeletonText: FC<Props> = ({ | ||
className, | ||
size, | ||
multiline, | ||
...rest | ||
}) => ( | ||
<div | ||
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. It needs to support |
||
className={classNames( | ||
'skeleton__text', | ||
multiline && 'skeleton__text--multiline', | ||
size === 'large' && `skeleton__text--large`, | ||
className | ||
)} | ||
{...rest} | ||
/> | ||
) | ||
|
||
export default EbaySkeletonText |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React, { ComponentProps, FC } from 'react' | ||
import classNames from 'classnames' | ||
|
||
export type Props = ComponentProps<'div'> | ||
|
||
const EbaySkeletonText: FC<Props> = ({ | ||
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. should be EbaySkeletonTextbox? |
||
className, | ||
...rest | ||
}) => ( | ||
<div | ||
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. It needs to support |
||
className={classNames('skeleton__textbox', className)} | ||
{...rest} | ||
/> | ||
) | ||
|
||
export default EbaySkeletonText |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React, { ComponentProps, FC } from 'react' | ||
import classNames from 'classnames' | ||
|
||
export type Props = ComponentProps<'div'> & { | ||
a11yText?: string; | ||
} | ||
|
||
const EbaySkeleton: FC<Props> = ({ | ||
children, | ||
a11yText = 'Loading...', | ||
className, | ||
...rest | ||
}) => ( | ||
<div | ||
role="img" | ||
aria-label={a11yText} | ||
className={classNames('skeleton', className)} | ||
{...rest} | ||
> | ||
{children} | ||
</div> | ||
) | ||
|
||
export default EbaySkeleton |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export { default as EbaySkeleton } from './ebay-skeleton' | ||
export { default as EbaySkeletonAvatar } from './ebay-skeleton-avatar' | ||
export { default as EbaySkeletonButton } from './ebay-skeleton-button' | ||
export { default as EbaySkeletonImage } from './ebay-skeleton-image' | ||
export { default as EbaySkeletonText } from './ebay-skeleton-text' | ||
export { default as EbaySkeletonTextbox } from './ebay-skeleton-textbox' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
export type NativeTags = | ||
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. This is based on Marko.NativeTags 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. React has |
||
'a' | | ||
'abbr' | | ||
'address' | | ||
'area' | | ||
'article' | | ||
'aside' | | ||
'audio' | | ||
'b' | | ||
'base' | | ||
'bdi' | | ||
'bdo' | | ||
'blockquote' | | ||
'body' | | ||
'br' | | ||
'button' | | ||
'canvas' | | ||
'caption' | | ||
'cite' | | ||
'code' | | ||
'col' | | ||
'colgroup' | | ||
'data' | | ||
'datalist' | | ||
'dd' | | ||
'del' | | ||
'details' | | ||
'dfn' | | ||
'dialog' | | ||
'div' | | ||
'dl' | | ||
'dt' | | ||
'em' | | ||
'embed' | | ||
'fieldset' | | ||
'figcaption' | | ||
'figure' | | ||
'footer' | | ||
'form' | | ||
'h1' | | ||
'h2' | | ||
'h3' | | ||
'h4' | | ||
'h5' | | ||
'h6' | | ||
'head' | | ||
'header' | | ||
'hgroup' | | ||
'hr' | | ||
'html' | | ||
'i' | | ||
'iframe' | | ||
'img' | | ||
'input' | | ||
'ins' | | ||
'kbd' | | ||
'label' | | ||
'legend' | | ||
'li' | | ||
'link' | | ||
'main' | | ||
'map' | | ||
'mark' | | ||
'menu' | | ||
'meta' | | ||
'meter' | | ||
'nav' | | ||
'noscript' | | ||
'object' | | ||
'ol' | | ||
'optgroup' | | ||
'option' | | ||
'output' | | ||
'p' | | ||
'picture' | | ||
'pre' | | ||
'progress' | | ||
'q' | | ||
'rp' | | ||
'rt' | | ||
'ruby' | | ||
's' | | ||
'samp' | | ||
'script' | | ||
'section' | | ||
'select' | | ||
'slot' | | ||
'small' | | ||
'source' | | ||
'span' | | ||
'strong' | | ||
'style' | | ||
'sub' | | ||
'summary' | | ||
'sup' | | ||
'table' | | ||
'tbody' | | ||
'td' | | ||
'template' | | ||
'textarea' | | ||
'tfoot' | | ||
'th' | | ||
'thead' | | ||
'time' | | ||
'title' | | ||
'tr' | | ||
'track' | | ||
'u' | | ||
'ul' | | ||
'var' | | ||
'video' | | ||
'wbr' |
Check warning
Code scanning / ESLint
Disallow unused variables Warning
Copilot Autofix AI 22 days ago
To fix the problem, we need to remove the unused import
ComponentProps
from the import statement on line 1. This will resolve the ESLint error and clean up the code by removing unnecessary imports.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.
seems like valid concern.
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.
eslint should have got this, we need to understand why not