|
2 | 2 |
|
3 | 3 | ## Background |
4 | 4 |
|
5 | | -_Description and use cases of this component_ |
| 5 | +The `Skeleton` component is a temporary placeholder for UI that is in a loading state. |
6 | 6 |
|
7 | 7 | ## Prior Art |
8 | 8 |
|
9 | | -_Include background research done for this component_ |
| 9 | +| Library | Component Name | Spec Link | Notes | |
| 10 | +| ----------- | -------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 11 | +| Ant Design | Skeleton | [Skeleton](https://ant.design/components/skeleton/) | Has an `avatar`, `button`, `list`, and `togglebutton`. Has animated and non-animated versions, and shape variants for the component skeletons(rounded or rectangular). | |
| 12 | +| Fast | Skeleton | [Skeleton](https://explore.fast.design/components/fast-skeleton) | Has three components: `Avatar`, `List`, and `Button`. No shape variants. | |
| 13 | +| Semantic UI | Placeholder | [Placeholder](https://react.semantic-ui.com/elements/placeholder/) | Has `Header` and `Paragraph` subcomponents. The `Header` can take in an image as a prop | |
| 14 | +| UI Fabric | Shimmer | [Shimmer](https://developer.microsoft.com/en-us/fluentui#/controls/web/shimmer) | Shimmer has a way to pass in custom elements as well as the defaults. There is also a prop to change the colors of the Skeleton components. | |
10 | 15 |
|
11 | | -- _Link to Open UI research_ |
12 | | -- _Link to comparison of v7 and v0_ |
13 | | -- _Link to GitHub epic issue for the converged component_ |
| 16 | +### Comparison of v8 and v0 |
| 17 | + |
| 18 | +The existing components are: |
| 19 | + |
| 20 | +- v8 |
| 21 | + - `Shimmer` |
| 22 | +- v0 |
| 23 | + - Does not have an existing `Skeleton` component. |
14 | 24 |
|
15 | 25 | ## Sample Code |
16 | 26 |
|
17 | | -_Provide some representative example code that uses the proposed API for the component_ |
| 27 | +Basic example: |
| 28 | + |
| 29 | +```jsx |
| 30 | +import { Skeleton, SkeletonItem } from '@fluentui/react-skeleton'; |
| 31 | + |
| 32 | +function App() { |
| 33 | + return ( |
| 34 | + <Skeleton> |
| 35 | + <SkeletonItem shape="circle" size={24} /> |
| 36 | + <SkeletonItem shape="rectangle" size={16} /> |
| 37 | + </Skeleton> |
| 38 | + ); |
| 39 | +} |
| 40 | +``` |
18 | 41 |
|
19 | 42 | ## Variants |
20 | 43 |
|
21 | | -_Describe visual or functional variants of this control, if applicable. For example, a slider could have a 2D variant._ |
| 44 | +- There are three basic `Skeleton` shapes |
| 45 | + - `Rectangle` |
| 46 | + - `Circle` |
| 47 | + - `Square` |
| 48 | + |
| 49 | +### Shape |
| 50 | + |
| 51 | +The `Skeleton` is a combination of any of the two shapes in order to represent the content that will be loaded onto the screen. That is, it is a combination of rectangles and circles that is a visual representation of the wireframe of a page. |
22 | 52 |
|
23 | 53 | ## API |
24 | 54 |
|
25 | | -_List the **Props** and **Slots** proposed for the component. Ideally this would just be a link to the component's `.types.ts` file_ |
| 55 | +### Slots |
| 56 | + |
| 57 | +- `root` - The root slot of the `Skeleton` is the container that will contain the items that make up a `Skeleton` in representation of the data that is loading. The default html element is a `svg`. |
| 58 | + |
| 59 | +### Props |
| 60 | + |
| 61 | +See API at: |
| 62 | + |
| 63 | +- [Skeleton.types.ts](./src/components/Skeleton/Skeleton.types.ts). |
| 64 | +- [SkeletonItem.types.ts](./src/components/SkeletonItem/SkeletonItem.types.ts). |
26 | 65 |
|
27 | 66 | ## Structure |
28 | 67 |
|
29 | | -- _**Public**_ |
30 | | -- _**Internal**_ |
31 | | -- _**DOM** - how the component will be rendered as HTML elements_ |
| 68 | +```html |
| 69 | +<!-- Container for Skeleton --> |
32 | 70 |
|
33 | | -## Migration |
| 71 | +<div class="fui-Skeleton"> |
| 72 | + <!-- Container for SkeletonElement --> |
34 | 73 |
|
35 | | -_Describe what will need to be done to upgrade from the existing implementations:_ |
| 74 | + <div class="fui-SkeletonItem" /> |
| 75 | +</div> |
| 76 | +``` |
36 | 77 |
|
37 | | -- _Migration from v8_ |
38 | | -- _Migration from v0_ |
| 78 | +## Migration |
| 79 | + |
| 80 | +See [MIGRATION.md](./MIGRATION.md). |
39 | 81 |
|
40 | 82 | ## Behaviors |
41 | 83 |
|
42 | | -_Explain how the component will behave in use, including:_ |
| 84 | +### States |
| 85 | + |
| 86 | +- **Display** - The `Skeleton` will use the following priority: |
| 87 | + |
| 88 | + - The `appearance` prop will allow the use of a `translucent` appearance. |
| 89 | + - Specifying `wave` or `pulse` will change the animation style of the `Skeleton` |
| 90 | + - The component also has `rtl` support and will animate the `Skeleton` from right to left if set. |
| 91 | + - Setting the `shape` prop in `<SkeletonItem />` will render a `rectangle`, `square`, or a `circle` (default is `rectangle`). |
| 92 | + - Setting the `size` prop in `<SkeletonItem />` will allow the user to specify the size of the element (default is 16). |
| 93 | + |
| 94 | +### Interaction |
| 95 | + |
| 96 | +The Skeleton is non-interactive. |
| 97 | + |
| 98 | +- **Keyboard** - Not keyboard focusable. |
| 99 | +- **Mouse** - Nothing |
43 | 100 |
|
44 | | -- _Component States_ |
45 | | -- _Interaction_ |
46 | | - - _Keyboard_ |
47 | | - - _Cursor_ |
48 | | - - _Touch_ |
49 | | - - _Screen readers_ |
| 101 | +- **Touch** - Nothing |
50 | 102 |
|
51 | 103 | ## Accessibility |
52 | 104 |
|
53 | | -Base accessibility information is included in the design document. After the spec is filled and review, outcomes from it need to be communicated to design and incorporated in the design document. |
54 | | - |
55 | | -- Decide whether to use **native element** or folow **ARIA** and provide reasons |
56 | | -- Identify the **[ARIA](https://www.w3.org/TR/wai-aria-practices-1.2/) pattern** and, if the component is listed there, follow its specification as possible. |
57 | | -- Identify accessibility **variants**, the `role` ([ARIA roles](https://www.w3.org/TR/wai-aria-1.1/#role_definitions)) of the component, its `slots` and `aria-*` props. |
58 | | -- Describe the **keyboard navigation**: Tab Oder and Arrow Key Navigation. Describe any other keyboard **shortcuts** used |
59 | | -- Specify texts for **state change announcements** - [ARIA live regions |
60 | | - ](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/ARIA_Live_Regions) (number of available items in dropdown, error messages, confirmations, ...) |
61 | | -- Identify UI parts that appear on **hover or focus** and specify keyboard and screen reader interaction with them |
62 | | -- List cases when **focus** needs to be **trapped** in sections of the UI (for dialogs and popups or for hierarchical navigation) |
63 | | -- List cases when **focus** needs to be **moved programatically** (if parts of the UI are appearing/disappearing or other cases) |
| 105 | +- An `aria-label` is added to the `Skeleton` container to let users know that content is loading |
0 commit comments