@instructure/ui-skeleton 0.0.0-stage → 11.7.11-snapshot-4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/LICENSE.md +28 -0
- package/README.md +50 -2
- package/es/SkeletonCircle/index.js +68 -0
- package/es/SkeletonCircle/props.js +26 -0
- package/es/SkeletonCircle/styles.js +47 -0
- package/es/SkeletonLoader/index.js +104 -0
- package/es/SkeletonLoader/props.js +26 -0
- package/es/SkeletonLoader/styles.js +45 -0
- package/es/SkeletonRectangle/index.js +74 -0
- package/es/SkeletonRectangle/props.js +26 -0
- package/es/SkeletonRectangle/styles.js +52 -0
- package/es/SkeletonText/index.js +76 -0
- package/es/SkeletonText/props.js +26 -0
- package/es/SkeletonText/styles.js +95 -0
- package/es/index.js +25 -0
- package/es/utils/shimmer.js +81 -0
- package/lib/SkeletonCircle/index.js +75 -0
- package/lib/SkeletonCircle/props.js +31 -0
- package/lib/SkeletonCircle/styles.js +53 -0
- package/lib/SkeletonLoader/index.js +110 -0
- package/lib/SkeletonLoader/props.js +31 -0
- package/lib/SkeletonLoader/styles.js +51 -0
- package/lib/SkeletonRectangle/index.js +81 -0
- package/lib/SkeletonRectangle/props.js +31 -0
- package/lib/SkeletonRectangle/styles.js +58 -0
- package/lib/SkeletonText/index.js +83 -0
- package/lib/SkeletonText/props.js +31 -0
- package/lib/SkeletonText/styles.js +101 -0
- package/lib/index.js +12 -0
- package/lib/package.json +1 -0
- package/lib/utils/shimmer.js +87 -0
- package/package.json +70 -3
- package/src/SkeletonCircle/index.tsx +71 -0
- package/src/SkeletonCircle/props.ts +58 -0
- package/src/SkeletonCircle/styles.ts +61 -0
- package/src/SkeletonLoader/README.md +237 -0
- package/src/SkeletonLoader/index.tsx +126 -0
- package/src/SkeletonLoader/props.ts +100 -0
- package/src/SkeletonLoader/styles.ts +51 -0
- package/src/SkeletonRectangle/index.tsx +71 -0
- package/src/SkeletonRectangle/props.ts +81 -0
- package/src/SkeletonRectangle/styles.ts +69 -0
- package/src/SkeletonText/index.tsx +74 -0
- package/src/SkeletonText/props.ts +91 -0
- package/src/SkeletonText/styles.ts +115 -0
- package/src/index.ts +38 -0
- package/src/utils/shimmer.ts +101 -0
- package/tsconfig.build.json +32 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +4 -0
- package/types/SkeletonCircle/index.d.ts +18 -0
- package/types/SkeletonCircle/index.d.ts.map +1 -0
- package/types/SkeletonCircle/props.d.ts +23 -0
- package/types/SkeletonCircle/props.d.ts.map +1 -0
- package/types/SkeletonCircle/styles.d.ts +13 -0
- package/types/SkeletonCircle/styles.d.ts.map +1 -0
- package/types/SkeletonLoader/index.d.ts +27 -0
- package/types/SkeletonLoader/index.d.ts.map +1 -0
- package/types/SkeletonLoader/props.d.ts +52 -0
- package/types/SkeletonLoader/props.d.ts.map +1 -0
- package/types/SkeletonLoader/styles.d.ts +11 -0
- package/types/SkeletonLoader/styles.d.ts.map +1 -0
- package/types/SkeletonRectangle/index.d.ts +18 -0
- package/types/SkeletonRectangle/index.d.ts.map +1 -0
- package/types/SkeletonRectangle/props.d.ts +36 -0
- package/types/SkeletonRectangle/props.d.ts.map +1 -0
- package/types/SkeletonRectangle/styles.d.ts +16 -0
- package/types/SkeletonRectangle/styles.d.ts.map +1 -0
- package/types/SkeletonText/index.d.ts +17 -0
- package/types/SkeletonText/index.d.ts.map +1 -0
- package/types/SkeletonText/props.d.ts +43 -0
- package/types/SkeletonText/props.d.ts.map +1 -0
- package/types/SkeletonText/styles.d.ts +16 -0
- package/types/SkeletonText/styles.d.ts.map +1 -0
- package/types/index.d.ts +7 -0
- package/types/index.d.ts.map +1 -0
- package/types/utils/shimmer.d.ts +28 -0
- package/types/utils/shimmer.d.ts.map +1 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [11.7.11-snapshot-4](https://github.com/instructure/instructure-ui/compare/v11.7.10...v11.7.11-snapshot-4) (2026-10-22)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **INSTUI-5156:** new skeleton loader ([#2720](https://github.com/instructure/instructure-ui/issues/2720)) ([f83433e](https://github.com/instructure/instructure-ui/commit/f83433ee71854ecc409ee042fabbcf9b92336a3a))
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: The MIT License (MIT)
|
|
3
|
+
category: Getting Started
|
|
4
|
+
order: 9
|
|
5
|
+
isWIP: true
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# The MIT License (MIT)
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2015 Instructure, Inc.
|
|
11
|
+
|
|
12
|
+
**Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions.**
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
## ui-skeleton
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[![npm][npm]][npm-url]
|
|
4
|
+
[![MIT License][license-badge]][license]
|
|
5
|
+
[![Code of Conduct][coc-badge]][coc]
|
|
6
|
+
|
|
7
|
+
Placeholders to show while content loads. They're sized with CSS only, so they
|
|
8
|
+
also work in server-rendered HTML.
|
|
9
|
+
|
|
10
|
+
### Components
|
|
11
|
+
|
|
12
|
+
The `ui-skeleton` package contains the following:
|
|
13
|
+
|
|
14
|
+
- [SkeletonLoader](SkeletonLoader)
|
|
15
|
+
|
|
16
|
+
### Installation
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
npm install @instructure/ui-skeleton
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Usage
|
|
23
|
+
|
|
24
|
+
```jsx
|
|
25
|
+
import React from 'react'
|
|
26
|
+
import { SkeletonLoader } from '@instructure/ui-skeleton'
|
|
27
|
+
|
|
28
|
+
const CourseList = ({ isLoading, courses }) => {
|
|
29
|
+
return (
|
|
30
|
+
<SkeletonLoader
|
|
31
|
+
isLoading={isLoading}
|
|
32
|
+
loadingLabel="Loading courses"
|
|
33
|
+
loadedLabel={`${courses.length} courses`}
|
|
34
|
+
skeleton={<SkeletonLoader.Text lines={5} />}
|
|
35
|
+
>
|
|
36
|
+
<ul>
|
|
37
|
+
{courses.map((c) => (
|
|
38
|
+
<li key={c.id}>{c.name}</li>
|
|
39
|
+
))}
|
|
40
|
+
</ul>
|
|
41
|
+
</SkeletonLoader>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
[npm]: https://img.shields.io/npm/v/@instructure/ui-skeleton.svg
|
|
47
|
+
[npm-url]: https://npmjs.com/package/@instructure/ui-skeleton
|
|
48
|
+
[license-badge]: https://img.shields.io/npm/l/instructure-ui.svg?style=flat-square
|
|
49
|
+
[license]: https://github.com/instructure/instructure-ui/blob/master/LICENSE.md
|
|
50
|
+
[coc-badge]: https://img.shields.io/badge/code%20of-conduct-ff69b4.svg?style=flat-square
|
|
51
|
+
[coc]: https://github.com/instructure/instructure-ui/blob/master/CODE_OF_CONDUCT.md
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { useContext } from 'react';
|
|
26
|
+
import { useStyleNew } from '@instructure/emotion';
|
|
27
|
+
import { TextDirectionContext } from '@instructure/ui-i18n';
|
|
28
|
+
import { omitProps } from '@instructure/ui-react-utils';
|
|
29
|
+
import generateStyle from './styles.js';
|
|
30
|
+
import { allowedProps } from './props.js';
|
|
31
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
|
+
/**
|
|
33
|
+
---
|
|
34
|
+
parent: SkeletonLoader
|
|
35
|
+
id: SkeletonLoader.Circle
|
|
36
|
+
---
|
|
37
|
+
A placeholder for avatars and other round content. It's hidden from screen
|
|
38
|
+
readers.
|
|
39
|
+
**/
|
|
40
|
+
function SkeletonCircle(props) {
|
|
41
|
+
const {
|
|
42
|
+
animate,
|
|
43
|
+
diameter,
|
|
44
|
+
elementRef
|
|
45
|
+
} = props;
|
|
46
|
+
const textDirection = useContext(TextDirectionContext);
|
|
47
|
+
const styles = useStyleNew({
|
|
48
|
+
generateStyle,
|
|
49
|
+
componentId: 'SkeletonLoader',
|
|
50
|
+
displayName: 'SkeletonCircle',
|
|
51
|
+
params: {
|
|
52
|
+
animate,
|
|
53
|
+
diameter,
|
|
54
|
+
textDirection
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return _jsx("span", {
|
|
58
|
+
...omitProps(props, allowedProps),
|
|
59
|
+
ref: elementRef,
|
|
60
|
+
css: styles.skeletonCircle,
|
|
61
|
+
"aria-hidden": "true",
|
|
62
|
+
"data-skeleton-shape": "circle"
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
SkeletonCircle.displayName = 'SkeletonCircle';
|
|
66
|
+
SkeletonCircle.allowedProps = allowedProps;
|
|
67
|
+
export default SkeletonCircle;
|
|
68
|
+
export { SkeletonCircle };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const allowedProps = ['animate', 'diameter', 'elementRef'];
|
|
26
|
+
export { allowedProps };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { shimmerStyles } from '../utils/shimmer.js';
|
|
26
|
+
const generateStyle = (componentTheme, params, _sharedTokens) => {
|
|
27
|
+
const {
|
|
28
|
+
animate = true,
|
|
29
|
+
diameter = '2rem',
|
|
30
|
+
textDirection
|
|
31
|
+
} = params;
|
|
32
|
+
return {
|
|
33
|
+
skeletonCircle: {
|
|
34
|
+
label: 'skeletonCircle',
|
|
35
|
+
display: 'inline-block',
|
|
36
|
+
verticalAlign: 'middle',
|
|
37
|
+
boxSizing: 'border-box',
|
|
38
|
+
width: diameter,
|
|
39
|
+
height: diameter,
|
|
40
|
+
flex: '0 0 auto',
|
|
41
|
+
borderRadius: componentTheme.avatarBorderRadius,
|
|
42
|
+
...shimmerStyles(componentTheme, textDirection === 'rtl', animate)
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export default generateStyle;
|
|
47
|
+
export { generateStyle };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { useEffect, useState } from 'react';
|
|
26
|
+
import { useIsHydratedContext, omitProps } from '@instructure/ui-react-utils';
|
|
27
|
+
import generateStyle from './styles.js';
|
|
28
|
+
import { allowedProps } from './props.js';
|
|
29
|
+
import { SkeletonText } from "../SkeletonText/index.js";
|
|
30
|
+
import { SkeletonRectangle } from "../SkeletonRectangle/index.js";
|
|
31
|
+
import { SkeletonCircle } from "../SkeletonCircle/index.js";
|
|
32
|
+
/**
|
|
33
|
+
---
|
|
34
|
+
category: components
|
|
35
|
+
---
|
|
36
|
+
Shows a placeholder while part of the page is loading, and tells screen reader
|
|
37
|
+
users when loading starts and finishes.
|
|
38
|
+
|
|
39
|
+
Use one `SkeletonLoader` for each loading area, not one per card or row, so
|
|
40
|
+
screen readers announce it once.
|
|
41
|
+
@module SkeletonLoader
|
|
42
|
+
**/
|
|
43
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
44
|
+
function SkeletonLoader(props) {
|
|
45
|
+
const {
|
|
46
|
+
announcementDelay = 400,
|
|
47
|
+
children,
|
|
48
|
+
elementRef,
|
|
49
|
+
errorLabel,
|
|
50
|
+
isError = false,
|
|
51
|
+
isLoading,
|
|
52
|
+
loadedLabel,
|
|
53
|
+
loadingLabel,
|
|
54
|
+
skeleton
|
|
55
|
+
} = props;
|
|
56
|
+
const isHydrated = useIsHydratedContext();
|
|
57
|
+
|
|
58
|
+
// If `isLoading` is set, it decides. If not, we're loading until hydration
|
|
59
|
+
// finishes. An error always ends loading, so the skeleton is never shown
|
|
60
|
+
// together with an error.
|
|
61
|
+
const loading = isError ? false : isLoading ?? !isHydrated;
|
|
62
|
+
|
|
63
|
+
// Starts empty so screen readers treat the first label as a change and
|
|
64
|
+
// announce it.
|
|
65
|
+
const [status, setStatus] = useState('');
|
|
66
|
+
const styles = generateStyle();
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (isError) {
|
|
69
|
+
setStatus('');
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (loading) {
|
|
73
|
+
const timeout = setTimeout(() => setStatus(loadingLabel), announcementDelay);
|
|
74
|
+
return () => clearTimeout(timeout);
|
|
75
|
+
}
|
|
76
|
+
setStatus(loadedLabel);
|
|
77
|
+
return undefined;
|
|
78
|
+
}, [loading, isError, loadingLabel, loadedLabel, announcementDelay]);
|
|
79
|
+
return _jsxs(_Fragment, {
|
|
80
|
+
children: [_jsx("span", {
|
|
81
|
+
role: "status",
|
|
82
|
+
"aria-live": "polite",
|
|
83
|
+
"aria-atomic": "true",
|
|
84
|
+
css: styles.srOnly,
|
|
85
|
+
children: status
|
|
86
|
+
}), _jsx("div", {
|
|
87
|
+
...omitProps(props, allowedProps),
|
|
88
|
+
ref: elementRef,
|
|
89
|
+
"aria-busy": loading || undefined,
|
|
90
|
+
children: loading ? skeleton : children
|
|
91
|
+
}), isError && errorLabel ? _jsx("span", {
|
|
92
|
+
role: "alert",
|
|
93
|
+
css: styles.srOnly,
|
|
94
|
+
children: errorLabel
|
|
95
|
+
}) : null]
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
SkeletonLoader.displayName = 'SkeletonLoader';
|
|
99
|
+
SkeletonLoader.allowedProps = allowedProps;
|
|
100
|
+
SkeletonLoader.Text = SkeletonText;
|
|
101
|
+
SkeletonLoader.Rectangle = SkeletonRectangle;
|
|
102
|
+
SkeletonLoader.Circle = SkeletonCircle;
|
|
103
|
+
export default SkeletonLoader;
|
|
104
|
+
export { SkeletonLoader };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const allowedProps = ['announcementDelay', 'children', 'elementRef', 'errorLabel', 'isError', 'isLoading', 'loadedLabel', 'loadingLabel', 'skeleton'];
|
|
26
|
+
export { allowedProps };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Visually hidden but still announced. Not `display: none`, which would remove
|
|
27
|
+
* the live region from the accessibility tree and stop it announcing at all.
|
|
28
|
+
*/
|
|
29
|
+
const generateStyle = () => ({
|
|
30
|
+
srOnly: {
|
|
31
|
+
label: 'skeletonLoader__srOnly',
|
|
32
|
+
position: 'absolute',
|
|
33
|
+
width: '1px',
|
|
34
|
+
height: '1px',
|
|
35
|
+
margin: '-1px',
|
|
36
|
+
padding: 0,
|
|
37
|
+
border: 0,
|
|
38
|
+
overflow: 'hidden',
|
|
39
|
+
clip: 'rect(0 0 0 0)',
|
|
40
|
+
clipPath: 'inset(50%)',
|
|
41
|
+
whiteSpace: 'nowrap'
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
export default generateStyle;
|
|
45
|
+
export { generateStyle };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { useContext } from 'react';
|
|
26
|
+
import { useStyleNew } from '@instructure/emotion';
|
|
27
|
+
import { TextDirectionContext } from '@instructure/ui-i18n';
|
|
28
|
+
import { omitProps } from '@instructure/ui-react-utils';
|
|
29
|
+
import generateStyle from './styles.js';
|
|
30
|
+
import { allowedProps } from './props.js';
|
|
31
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
|
+
/**
|
|
33
|
+
---
|
|
34
|
+
parent: SkeletonLoader
|
|
35
|
+
id: SkeletonLoader.Rectangle
|
|
36
|
+
---
|
|
37
|
+
A placeholder for images, video, and other media. It's hidden from screen
|
|
38
|
+
readers.
|
|
39
|
+
**/
|
|
40
|
+
function SkeletonRectangle(props) {
|
|
41
|
+
const {
|
|
42
|
+
animate,
|
|
43
|
+
aspectRatio,
|
|
44
|
+
elementRef,
|
|
45
|
+
height,
|
|
46
|
+
radius,
|
|
47
|
+
width
|
|
48
|
+
} = props;
|
|
49
|
+
const textDirection = useContext(TextDirectionContext);
|
|
50
|
+
const styles = useStyleNew({
|
|
51
|
+
generateStyle,
|
|
52
|
+
componentId: 'SkeletonLoader',
|
|
53
|
+
displayName: 'SkeletonRectangle',
|
|
54
|
+
params: {
|
|
55
|
+
animate,
|
|
56
|
+
aspectRatio,
|
|
57
|
+
height,
|
|
58
|
+
radius,
|
|
59
|
+
width,
|
|
60
|
+
textDirection
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
return _jsx("span", {
|
|
64
|
+
...omitProps(props, allowedProps),
|
|
65
|
+
ref: elementRef,
|
|
66
|
+
css: styles.skeletonRectangle,
|
|
67
|
+
"aria-hidden": "true",
|
|
68
|
+
"data-skeleton-shape": "rectangle"
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
SkeletonRectangle.displayName = 'SkeletonRectangle';
|
|
72
|
+
SkeletonRectangle.allowedProps = allowedProps;
|
|
73
|
+
export default SkeletonRectangle;
|
|
74
|
+
export { SkeletonRectangle };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const allowedProps = ['animate', 'aspectRatio', 'elementRef', 'height', 'radius', 'width'];
|
|
26
|
+
export { allowedProps };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { shimmerStyles } from '../utils/shimmer.js';
|
|
26
|
+
const generateStyle = (componentTheme, params, _sharedTokens) => {
|
|
27
|
+
const {
|
|
28
|
+
animate = true,
|
|
29
|
+
aspectRatio = '16 / 9',
|
|
30
|
+
height,
|
|
31
|
+
radius,
|
|
32
|
+
width,
|
|
33
|
+
textDirection
|
|
34
|
+
} = params;
|
|
35
|
+
return {
|
|
36
|
+
skeletonRectangle: {
|
|
37
|
+
label: 'skeletonRectangle',
|
|
38
|
+
display: 'block',
|
|
39
|
+
boxSizing: 'border-box',
|
|
40
|
+
width: width ?? '100%',
|
|
41
|
+
...(height ? {
|
|
42
|
+
height
|
|
43
|
+
} : {
|
|
44
|
+
aspectRatio
|
|
45
|
+
}),
|
|
46
|
+
borderRadius: radius ?? componentTheme.imageBorderRadius,
|
|
47
|
+
...shimmerStyles(componentTheme, textDirection === 'rtl', animate)
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export default generateStyle;
|
|
52
|
+
export { generateStyle };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { useContext } from 'react';
|
|
26
|
+
import { useStyleNew } from '@instructure/emotion';
|
|
27
|
+
import { TextDirectionContext } from '@instructure/ui-i18n';
|
|
28
|
+
import { omitProps } from '@instructure/ui-react-utils';
|
|
29
|
+
import generateStyle from './styles.js';
|
|
30
|
+
import { allowedProps } from './props.js';
|
|
31
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
32
|
+
/**
|
|
33
|
+
---
|
|
34
|
+
parent: SkeletonLoader
|
|
35
|
+
id: SkeletonLoader.Text
|
|
36
|
+
---
|
|
37
|
+
A placeholder for one or more lines of text. It's hidden from screen readers.
|
|
38
|
+
**/
|
|
39
|
+
function SkeletonText(props) {
|
|
40
|
+
const {
|
|
41
|
+
animate,
|
|
42
|
+
elementRef,
|
|
43
|
+
lineHeight,
|
|
44
|
+
lines,
|
|
45
|
+
size,
|
|
46
|
+
width
|
|
47
|
+
} = props;
|
|
48
|
+
const textDirection = useContext(TextDirectionContext);
|
|
49
|
+
const styles = useStyleNew({
|
|
50
|
+
generateStyle,
|
|
51
|
+
componentId: 'SkeletonLoader',
|
|
52
|
+
displayName: 'SkeletonText',
|
|
53
|
+
params: {
|
|
54
|
+
animate,
|
|
55
|
+
lineHeight,
|
|
56
|
+
lines,
|
|
57
|
+
size,
|
|
58
|
+
width,
|
|
59
|
+
textDirection
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return _jsx("span", {
|
|
63
|
+
...omitProps(props, allowedProps),
|
|
64
|
+
ref: elementRef,
|
|
65
|
+
css: styles.skeletonText,
|
|
66
|
+
"aria-hidden": "true",
|
|
67
|
+
"data-skeleton-shape": "text",
|
|
68
|
+
children: styles.rows.map((rowStyle, i) => _jsx("span", {
|
|
69
|
+
css: rowStyle
|
|
70
|
+
}, i))
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
SkeletonText.displayName = 'SkeletonText';
|
|
74
|
+
SkeletonText.allowedProps = allowedProps;
|
|
75
|
+
export default SkeletonText;
|
|
76
|
+
export { SkeletonText };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The MIT License (MIT)
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const allowedProps = ['animate', 'elementRef', 'lineHeight', 'lines', 'size', 'width'];
|
|
26
|
+
export { allowedProps };
|