-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add skeleton loading component (#378)
* 308: Add skeleton loading component * fix eslint * Add support for 'as' for components and 'color' - add changeset * Add readme content * Remove default aria-label --------- Co-authored-by: HenriqueLimas <[email protected]>
- Loading branch information
1 parent
ba897f7
commit 5f6b738
Showing
14 changed files
with
684 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,5 @@ | ||
--- | ||
"@ebay/ui-core-react": minor | ||
--- | ||
|
||
feat(EbaySkeleton): add new skeleton component |
This file contains 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
This file contains 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,108 @@ | ||
# EbaySkeleton | ||
|
||
## Demo | ||
|
||
[Storybook](https://opensource.ebay.com/ebayui-core-react/main/?path=/docs/building-blocks-ebay-skeleton--docs) | ||
|
||
## Import JS | ||
|
||
```jsx harmony | ||
import { | ||
EbaySkeleton, | ||
EbaySkeletonAvatar, | ||
EbaySkeletonButton, | ||
EbaySkeletonImage, | ||
EbaySkeletonText, | ||
EbaySkeletonTextbox, | ||
} from "@ebay/ui-core-react/ebay-skeleton"; | ||
``` | ||
|
||
## Import following styles from SKIN | ||
|
||
```js | ||
import "@ebay/skin/skeleton"; | ||
``` | ||
|
||
## Import styles using SCSS/CSS | ||
|
||
```js | ||
import "@ebay/skin/skeleton.css"; | ||
``` | ||
|
||
## Usage | ||
|
||
```jsx | ||
<EbaySkeleton aria-label="Loading..."> | ||
<EbaySkeletonImage style={{ width: "220px", height: "220px" }} /> | ||
<EbaySkeletonText multiline /> | ||
</EbaySkeleton> | ||
``` | ||
|
||
## Attributes | ||
|
||
### EbaySkeleton | ||
|
||
| Name | Type | Required | Description | | ||
| ------- | ------ | -------- | -------------------------------------------------- | | ||
| `color` | string | No | Color of the Skeleton, `purple`, `green` or `blue` | | ||
|
||
### EbaySkeletonAvatar | ||
|
||
| Name | Type | Required | Description | | ||
| ---- | ------ | -------- | ------------------------------------------------------ | | ||
| `as` | string | No | Attribute to define the element to use `div` or `span` | | ||
|
||
### EbaySkeletonButton | ||
|
||
| Name | Type | Required | Description | | ||
| ------ | ------ | -------- | ------------------------------------------------------ | | ||
| `as` | string | No | Attribute to define the element to use `div` or `span` | | ||
| `size` | string | No | size of the button can be `small` or `large` | | ||
|
||
### EbaySkeletonImage | ||
|
||
| Name | Type | Required | Description | | ||
| ---- | ------ | -------- | ------------------------------------------------------ | | ||
| `as` | string | No | Attribute to define the element to use `div` or `span` | | ||
|
||
### EbaySkeletonText | ||
|
||
| Name | Type | Required | Description | | ||
| ----------- | ------- | -------- | ------------------------------------------------------ | | ||
| `as` | string | No | Attribute to define the element to use `div` or `span` | | ||
| `multiline` | boolean | No | Attribute to define the text as multiline | | ||
| `size` | string | No | size of the text can be `small` or `large` | | ||
|
||
### EbaySkeletonTextbox | ||
|
||
| Name | Type | Required | Description | | ||
| ---- | ------ | -------- | ------------------------------------------------------ | | ||
| `as` | string | No | Attribute to define the element to use `div` or `span` | | ||
|
||
## Examples | ||
|
||
### Composite | ||
|
||
```jsx | ||
<EbaySkeleton color={color} style={{ width: "300px" }}> | ||
<div> | ||
<EbaySkeletonAvatar as="span" /> | ||
<EbaySkeletonText | ||
multiline={multiline} | ||
as="span" | ||
size={size} | ||
style={{ width: "220px", verticalAlign: "top" }} | ||
/> | ||
</div> | ||
<EbaySkeletonButton size={size} /> | ||
</EbaySkeleton> | ||
``` | ||
|
||
### Tile | ||
|
||
```jsx | ||
<EbaySkeleton color={color} style={{ width: "220px" }}> | ||
<EbaySkeletonImage style={{ width: "220px", height: "220px" }} /> | ||
<EbaySkeletonText multiline={multiline} size={size} /> | ||
</EbaySkeleton> | ||
``` |
272 changes: 272 additions & 0 deletions
272
src/ebay-skeleton/__tests__/__snapshots__/render.spec.tsx.snap
This file contains 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,272 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeleton color blue component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton skeleton--blue" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<div | ||
class="skeleton__textbox" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeleton color green component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton skeleton--green" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<div | ||
class="skeleton__textbox" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeleton color purple component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton skeleton--purple" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<div | ||
class="skeleton__textbox" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeleton component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<div | ||
class="skeleton__textbox" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeleton composite component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
style="width: 300px;" | ||
> | ||
<div> | ||
<span | ||
class="skeleton__avatar" | ||
/> | ||
<span | ||
class="skeleton__text skeleton__text--multiline" | ||
style="width: 220px; vertical-align: top;" | ||
/> | ||
</div> | ||
<div | ||
class="skeleton__button" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeleton tile component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<div | ||
class="skeleton__image" | ||
style="width: 220px; height: 220px;" | ||
/> | ||
<div | ||
class="skeleton__text skeleton__text--multiline skeleton__text--large" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeletonAvatar component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
> | ||
<div | ||
class="skeleton__avatar" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeletonAvatar with "as" prop component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
> | ||
<span | ||
class="skeleton__avatar" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeletonButton component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<div | ||
class="skeleton__button" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeletonButton with "as" prop component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<span | ||
class="skeleton__button" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeletonButton with size prop large component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<div | ||
class="skeleton__button skeleton__button--large" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeletonButton with size prop small component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<div | ||
class="skeleton__button skeleton__button--small" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeletonImage component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
> | ||
<div | ||
class="skeleton__image" | ||
style="width: 220px; height: 220px;" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeletonImage with "as" prop component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
> | ||
<span | ||
class="skeleton__image" | ||
style="width: 220px; height: 220px;" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeletonText component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<div | ||
class="skeleton__text" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeletonText with "as" prop component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<span | ||
class="skeleton__text" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeletonText with multiline prop component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<div | ||
class="skeleton__text skeleton__text--multiline" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeletonText with size prop component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<div | ||
class="skeleton__text skeleton__text--large" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeletonTextBox component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<div | ||
class="skeleton__textbox" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`Render <EbaySkeleton /> component should render the EbaySkeletonTextBox with "as" prop component 1`] = ` | ||
<div | ||
aria-label="Loading..." | ||
class="skeleton" | ||
role="img" | ||
style="width: 220px;" | ||
> | ||
<span | ||
class="skeleton__textbox" | ||
/> | ||
</div> | ||
`; |
Oops, something went wrong.