@spaced-out/ui-design-system 0.1.102 → 0.1.103
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 +7 -0
- package/lib/components/Shimmer/Shimmer.js +85 -0
- package/lib/components/Shimmer/Shimmer.js.flow +97 -0
- package/lib/components/Shimmer/Shimmer.module.css +63 -0
- package/lib/components/Shimmer/index.js +16 -0
- package/lib/components/Shimmer/index.js.flow +3 -0
- package/lib/components/index.js +11 -0
- package/lib/components/index.js.flow +1 -0
- package/lib/utils/string/string.js +9 -2
- package/lib/utils/string/string.js.flow +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.1.103](https://github.com/spaced-out/ui-design-system/compare/v0.1.102...v0.1.103) (2024-07-03)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* ⭕️ shimmer component ([#233](https://github.com/spaced-out/ui-design-system/issues/233)) ([bad30af](https://github.com/spaced-out/ui-design-system/commit/bad30af1ca6b4b2b713b69b35dc3b78871eba6fe))
|
|
11
|
+
|
|
5
12
|
### [0.1.102](https://github.com/spaced-out/ui-design-system/compare/v0.1.101...v0.1.102) (2024-07-03)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Shimmer = exports.SHIMMER_TYPE_TO_BORDER_RADIUS_MAP = exports.SHIMMER_TYPES = exports.KPIShimmer = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _border = require("../../styles/variables/_border");
|
|
9
|
+
var _size = require("../../styles/variables/_size");
|
|
10
|
+
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
11
|
+
var _string = require("../../utils/string");
|
|
12
|
+
var _ShimmerModule = _interopRequireDefault(require("./Shimmer.module.css"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
16
|
+
|
|
17
|
+
const SHIMMER_TYPES = Object.freeze({
|
|
18
|
+
text: 'text',
|
|
19
|
+
rounded: 'rounded',
|
|
20
|
+
circular: 'circular',
|
|
21
|
+
rectangular: 'rectangular'
|
|
22
|
+
});
|
|
23
|
+
exports.SHIMMER_TYPES = SHIMMER_TYPES;
|
|
24
|
+
const SHIMMER_TYPE_TO_BORDER_RADIUS_MAP = Object.freeze({
|
|
25
|
+
text: _border.borderRadiusXSmall,
|
|
26
|
+
rounded: _border.borderRadiusMedium,
|
|
27
|
+
circular: _border.borderRadiusCircle,
|
|
28
|
+
rectangular: _border.borderRadiusNone
|
|
29
|
+
});
|
|
30
|
+
exports.SHIMMER_TYPE_TO_BORDER_RADIUS_MAP = SHIMMER_TYPE_TO_BORDER_RADIUS_MAP;
|
|
31
|
+
const Shimmer = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
32
|
+
let {
|
|
33
|
+
classNames,
|
|
34
|
+
show = true,
|
|
35
|
+
type = SHIMMER_TYPES.text,
|
|
36
|
+
children,
|
|
37
|
+
width = _size.size40,
|
|
38
|
+
height = _size.sizeFluid,
|
|
39
|
+
borderRadius
|
|
40
|
+
} = _ref;
|
|
41
|
+
if (!show) {
|
|
42
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
43
|
+
}
|
|
44
|
+
const borderRadiusValue = borderRadius ?? SHIMMER_TYPE_TO_BORDER_RADIUS_MAP[type];
|
|
45
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
46
|
+
ref: ref,
|
|
47
|
+
"data-testid": "Shimmer",
|
|
48
|
+
className: (0, _classify.default)(_ShimmerModule.default.wrapper, _ShimmerModule.default[type], classNames?.wrapper),
|
|
49
|
+
style: {
|
|
50
|
+
'--width': (0, _string.appendPx)(width),
|
|
51
|
+
'--height': (0, _string.appendPx)(height),
|
|
52
|
+
'--border-radius': (0, _string.appendPx)(borderRadiusValue)
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
exports.Shimmer = Shimmer;
|
|
57
|
+
const KPIShimmer = _ref2 => {
|
|
58
|
+
let {
|
|
59
|
+
textWidth = 150
|
|
60
|
+
} = _ref2;
|
|
61
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
className: _ShimmerModule.default.kpiBox
|
|
63
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
className: _ShimmerModule.default.section
|
|
65
|
+
}, /*#__PURE__*/React.createElement(Shimmer, {
|
|
66
|
+
type: "rounded",
|
|
67
|
+
width: 60,
|
|
68
|
+
height: 60
|
|
69
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: _ShimmerModule.default.section
|
|
71
|
+
}, /*#__PURE__*/React.createElement(Shimmer, {
|
|
72
|
+
type: "text",
|
|
73
|
+
width: textWidth,
|
|
74
|
+
height: 15
|
|
75
|
+
}), /*#__PURE__*/React.createElement(Shimmer, {
|
|
76
|
+
type: "text",
|
|
77
|
+
width: textWidth,
|
|
78
|
+
height: 25
|
|
79
|
+
}), /*#__PURE__*/React.createElement(Shimmer, {
|
|
80
|
+
type: "text",
|
|
81
|
+
width: textWidth,
|
|
82
|
+
height: 15
|
|
83
|
+
})));
|
|
84
|
+
};
|
|
85
|
+
exports.KPIShimmer = KPIShimmer;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// @flow strict
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
borderRadiusCircle,
|
|
7
|
+
borderRadiusMedium,
|
|
8
|
+
borderRadiusNone,
|
|
9
|
+
borderRadiusXSmall,
|
|
10
|
+
} from '../../styles/variables/_border';
|
|
11
|
+
import {size40, sizeFluid} from '../../styles/variables/_size';
|
|
12
|
+
import classify from '../../utils/classify';
|
|
13
|
+
import {appendPx} from '../../utils/string';
|
|
14
|
+
|
|
15
|
+
import css from './Shimmer.module.css';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
19
|
+
|
|
20
|
+
export const SHIMMER_TYPES = Object.freeze({
|
|
21
|
+
text: 'text',
|
|
22
|
+
rounded: 'rounded',
|
|
23
|
+
circular: 'circular',
|
|
24
|
+
rectangular: 'rectangular',
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const SHIMMER_TYPE_TO_BORDER_RADIUS_MAP = Object.freeze({
|
|
28
|
+
text: borderRadiusXSmall,
|
|
29
|
+
rounded: borderRadiusMedium,
|
|
30
|
+
circular: borderRadiusCircle,
|
|
31
|
+
rectangular: borderRadiusNone,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export type ShimmerType = $Values<typeof SHIMMER_TYPES>;
|
|
35
|
+
|
|
36
|
+
export type ShimmerProps = {
|
|
37
|
+
classNames?: ClassNames,
|
|
38
|
+
show?: boolean,
|
|
39
|
+
type?: ShimmerType,
|
|
40
|
+
width?: number | string,
|
|
41
|
+
height?: number | string,
|
|
42
|
+
borderRadius?: number | string,
|
|
43
|
+
children?: React.Node,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const Shimmer: React$AbstractComponent<ShimmerProps, HTMLSpanElement> =
|
|
47
|
+
React.forwardRef<ShimmerProps, HTMLSpanElement>(
|
|
48
|
+
(
|
|
49
|
+
{
|
|
50
|
+
classNames,
|
|
51
|
+
show = true,
|
|
52
|
+
type = SHIMMER_TYPES.text,
|
|
53
|
+
children,
|
|
54
|
+
width = size40,
|
|
55
|
+
height = sizeFluid,
|
|
56
|
+
borderRadius,
|
|
57
|
+
}: ShimmerProps,
|
|
58
|
+
ref,
|
|
59
|
+
) => {
|
|
60
|
+
if (!show) {
|
|
61
|
+
return <>{children}</>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const borderRadiusValue =
|
|
65
|
+
borderRadius ?? SHIMMER_TYPE_TO_BORDER_RADIUS_MAP[type];
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<span
|
|
69
|
+
ref={ref}
|
|
70
|
+
data-testid="Shimmer"
|
|
71
|
+
className={classify(css.wrapper, css[type], classNames?.wrapper)}
|
|
72
|
+
style={{
|
|
73
|
+
'--width': appendPx(width),
|
|
74
|
+
'--height': appendPx(height),
|
|
75
|
+
'--border-radius': appendPx(borderRadiusValue),
|
|
76
|
+
}}
|
|
77
|
+
></span>
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
export type KPIShimmerProps = {
|
|
83
|
+
textWidth?: number | string,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const KPIShimmer = ({textWidth = 150}: KPIShimmerProps): React.Node => (
|
|
87
|
+
<div className={css.kpiBox}>
|
|
88
|
+
<div className={css.section}>
|
|
89
|
+
<Shimmer type="rounded" width={60} height={60}></Shimmer>
|
|
90
|
+
</div>
|
|
91
|
+
<div className={css.section}>
|
|
92
|
+
<Shimmer type="text" width={textWidth} height={15}></Shimmer>
|
|
93
|
+
<Shimmer type="text" width={textWidth} height={25}></Shimmer>
|
|
94
|
+
<Shimmer type="text" width={textWidth} height={15}></Shimmer>
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
@value (colorFillPrimary, colorNeutralLightest, colorNeutralLight, colorBackgroundTertiary) from '../../styles/variables/_color.css';
|
|
2
|
+
@value (spaceXSmall, spaceNone, spaceLarge, spaceMedium, spaceSmall) from '../../styles/variables/_space.css';
|
|
3
|
+
@value (sizeFluid, size40, size252) from '../../styles/variables/_size.css';
|
|
4
|
+
@value (borderRadiusXSmall, borderRadiusMedium) from '../../styles/variables/_border.css';
|
|
5
|
+
@value (opacity20, opacity40, opacity60) from '../../styles/variables/_opacity.css';
|
|
6
|
+
@value (motionDurationSlowest) from '../../styles/variables/_motion.css';
|
|
7
|
+
|
|
8
|
+
@value backgroundSizeInitial: calc(sizeFluid * 2);
|
|
9
|
+
@value backgroundSizeFinal: calc(sizeFluid * -2);
|
|
10
|
+
@value motionDuration: calc(motionDurationSlowest * 1.5);
|
|
11
|
+
|
|
12
|
+
.wrapper {
|
|
13
|
+
--width: size40;
|
|
14
|
+
--border-radius: borderRadiusXSmall;
|
|
15
|
+
--height: sizeFluid;
|
|
16
|
+
display: flex;
|
|
17
|
+
height: var(--height);
|
|
18
|
+
width: var(--width);
|
|
19
|
+
border-radius: var(--border-radius);
|
|
20
|
+
background: linear-gradient(
|
|
21
|
+
to right,
|
|
22
|
+
colorNeutralLightest opacity20,
|
|
23
|
+
colorNeutralLight opacity40,
|
|
24
|
+
colorNeutralLightest opacity60
|
|
25
|
+
);
|
|
26
|
+
background-size: backgroundSizeInitial sizeFluid;
|
|
27
|
+
animation: shimmer motionDuration infinite linear;
|
|
28
|
+
vertical-align: middle;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.text {
|
|
32
|
+
margin: spaceNone spaceXSmall;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.kpiBox {
|
|
36
|
+
display: flex;
|
|
37
|
+
composes: borderPrimary from '../../styles/border.module.css';
|
|
38
|
+
min-width: size252;
|
|
39
|
+
width: fit-content;
|
|
40
|
+
height: fit-content;
|
|
41
|
+
align-items: center;
|
|
42
|
+
gap: spaceSmall;
|
|
43
|
+
background-color: colorBackgroundTertiary;
|
|
44
|
+
border-radius: borderRadiusMedium;
|
|
45
|
+
padding: spaceLarge spaceMedium;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.section {
|
|
49
|
+
display: flex;
|
|
50
|
+
width: sizeFluid;
|
|
51
|
+
flex-flow: column;
|
|
52
|
+
gap: spaceXSmall;
|
|
53
|
+
align-items: center;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@keyframes shimmer {
|
|
57
|
+
from {
|
|
58
|
+
background-position: backgroundSizeInitial spaceNone;
|
|
59
|
+
}
|
|
60
|
+
to {
|
|
61
|
+
background-position: backgroundSizeFinal spaceNone;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _Shimmer = require("./Shimmer");
|
|
7
|
+
Object.keys(_Shimmer).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _Shimmer[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _Shimmer[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
package/lib/components/index.js
CHANGED
|
@@ -454,6 +454,17 @@ Object.keys(_SearchInput).forEach(function (key) {
|
|
|
454
454
|
}
|
|
455
455
|
});
|
|
456
456
|
});
|
|
457
|
+
var _Shimmer = require("./Shimmer");
|
|
458
|
+
Object.keys(_Shimmer).forEach(function (key) {
|
|
459
|
+
if (key === "default" || key === "__esModule") return;
|
|
460
|
+
if (key in exports && exports[key] === _Shimmer[key]) return;
|
|
461
|
+
Object.defineProperty(exports, key, {
|
|
462
|
+
enumerable: true,
|
|
463
|
+
get: function () {
|
|
464
|
+
return _Shimmer[key];
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
});
|
|
457
468
|
var _SideMenuLink = require("./SideMenuLink");
|
|
458
469
|
Object.keys(_SideMenuLink).forEach(function (key) {
|
|
459
470
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.truncateString = exports.formatWord = exports.escapeRegExp = exports.capitalize = void 0;
|
|
6
|
+
exports.truncateString = exports.formatWord = exports.escapeRegExp = exports.capitalize = exports.appendPx = void 0;
|
|
7
7
|
|
|
8
8
|
const capitalize = word => {
|
|
9
9
|
if (!word) {
|
|
@@ -22,4 +22,11 @@ const truncateString = (inputString, maxLength) => {
|
|
|
22
22
|
}
|
|
23
23
|
return inputString;
|
|
24
24
|
};
|
|
25
|
-
exports.truncateString = truncateString;
|
|
25
|
+
exports.truncateString = truncateString;
|
|
26
|
+
const appendPx = value => {
|
|
27
|
+
if (typeof value === 'number') {
|
|
28
|
+
return `${value}px`;
|
|
29
|
+
}
|
|
30
|
+
return value ?? '';
|
|
31
|
+
};
|
|
32
|
+
exports.appendPx = appendPx;
|