@spaced-out/ui-design-system 0.1.102 → 0.1.104

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 CHANGED
@@ -2,6 +2,20 @@
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.104](https://github.com/spaced-out/ui-design-system/compare/v0.1.103...v0.1.104) (2024-07-04)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * 🪛 text wrap fix for text based shimmer ([#234](https://github.com/spaced-out/ui-design-system/issues/234)) ([50d4e6c](https://github.com/spaced-out/ui-design-system/commit/50d4e6c424b0675d1e761553cd8f2f652dd0f48e))
11
+
12
+ ### [0.1.103](https://github.com/spaced-out/ui-design-system/compare/v0.1.102...v0.1.103) (2024-07-03)
13
+
14
+
15
+ ### Features
16
+
17
+ * ⭕️ shimmer component ([#233](https://github.com/spaced-out/ui-design-system/issues/233)) ([bad30af](https://github.com/spaced-out/ui-design-system/commit/bad30af1ca6b4b2b713b69b35dc3b78871eba6fe))
18
+
5
19
  ### [0.1.102](https://github.com/spaced-out/ui-design-system/compare/v0.1.101...v0.1.102) (2024-07-03)
6
20
 
7
21
 
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ShimmerWrapper = 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
+ /**
32
+ * Note(Nishant): ShimmerWrapper is a wrapper component for Shimmer component. This should only be used for Text based Shimmers
33
+ * This solves a very annoying problem with out text components where the display prop is set to flex.
34
+ * Genesis assumes that every element is flexible for simplicity and for text text shimmers to work in use cases
35
+ * where text wraps across multiple lines, we need to wrap the shimmer in a span element.
36
+ * to avoid the misuse where consumers use there own / other block level components, we have this wrapper.
37
+ * This would ensure the layout remains same even when you toggle the shimmer to show your actual content
38
+ * @param {React.Node} children - The children to be rendered
39
+ */
40
+ const ShimmerWrapper = _ref => {
41
+ let {
42
+ children
43
+ } = _ref;
44
+ return /*#__PURE__*/React.createElement("span", null, children);
45
+ };
46
+ exports.ShimmerWrapper = ShimmerWrapper;
47
+ const Shimmer = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
48
+ let {
49
+ classNames,
50
+ show = true,
51
+ type = SHIMMER_TYPES.text,
52
+ children,
53
+ width = _size.size40,
54
+ height = _size.sizeFluid,
55
+ borderRadius
56
+ } = _ref2;
57
+ if (!show) {
58
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children);
59
+ }
60
+ const borderRadiusValue = borderRadius ?? SHIMMER_TYPE_TO_BORDER_RADIUS_MAP[type];
61
+ return /*#__PURE__*/React.createElement("span", {
62
+ ref: ref,
63
+ "data-testid": "Shimmer",
64
+ className: (0, _classify.default)(_ShimmerModule.default.wrapper, _ShimmerModule.default[type], classNames?.wrapper),
65
+ style: {
66
+ '--width': (0, _string.appendPx)(width),
67
+ '--height': (0, _string.appendPx)(height),
68
+ '--border-radius': (0, _string.appendPx)(borderRadiusValue)
69
+ }
70
+ });
71
+ });
72
+ exports.Shimmer = Shimmer;
73
+ const KPIShimmer = _ref3 => {
74
+ let {
75
+ textWidth = 150
76
+ } = _ref3;
77
+ return /*#__PURE__*/React.createElement("div", {
78
+ className: _ShimmerModule.default.kpiBox
79
+ }, /*#__PURE__*/React.createElement("div", {
80
+ className: _ShimmerModule.default.section
81
+ }, /*#__PURE__*/React.createElement(Shimmer, {
82
+ type: "rounded",
83
+ width: 60,
84
+ height: 60
85
+ })), /*#__PURE__*/React.createElement("div", {
86
+ className: _ShimmerModule.default.section
87
+ }, /*#__PURE__*/React.createElement(Shimmer, {
88
+ type: "text",
89
+ width: textWidth,
90
+ height: 15
91
+ }), /*#__PURE__*/React.createElement(Shimmer, {
92
+ type: "text",
93
+ width: textWidth,
94
+ height: 25
95
+ }), /*#__PURE__*/React.createElement(Shimmer, {
96
+ type: "text",
97
+ width: textWidth,
98
+ height: 15
99
+ })));
100
+ };
101
+ exports.KPIShimmer = KPIShimmer;
@@ -0,0 +1,114 @@
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 type ShimmerWrapperProps = {
47
+ children?: React.Node,
48
+ };
49
+
50
+ /**
51
+ * Note(Nishant): ShimmerWrapper is a wrapper component for Shimmer component. This should only be used for Text based Shimmers
52
+ * This solves a very annoying problem with out text components where the display prop is set to flex.
53
+ * Genesis assumes that every element is flexible for simplicity and for text text shimmers to work in use cases
54
+ * where text wraps across multiple lines, we need to wrap the shimmer in a span element.
55
+ * to avoid the misuse where consumers use there own / other block level components, we have this wrapper.
56
+ * This would ensure the layout remains same even when you toggle the shimmer to show your actual content
57
+ * @param {React.Node} children - The children to be rendered
58
+ */
59
+ export const ShimmerWrapper = ({
60
+ children,
61
+ }: ShimmerWrapperProps): React$Element<'span'> => <span>{children}</span>;
62
+
63
+ export const Shimmer: React$AbstractComponent<ShimmerProps, HTMLSpanElement> =
64
+ React.forwardRef<ShimmerProps, HTMLSpanElement>(
65
+ (
66
+ {
67
+ classNames,
68
+ show = true,
69
+ type = SHIMMER_TYPES.text,
70
+ children,
71
+ width = size40,
72
+ height = sizeFluid,
73
+ borderRadius,
74
+ }: ShimmerProps,
75
+ ref,
76
+ ) => {
77
+ if (!show) {
78
+ return <>{children}</>;
79
+ }
80
+
81
+ const borderRadiusValue =
82
+ borderRadius ?? SHIMMER_TYPE_TO_BORDER_RADIUS_MAP[type];
83
+
84
+ return (
85
+ <span
86
+ ref={ref}
87
+ data-testid="Shimmer"
88
+ className={classify(css.wrapper, css[type], classNames?.wrapper)}
89
+ style={{
90
+ '--width': appendPx(width),
91
+ '--height': appendPx(height),
92
+ '--border-radius': appendPx(borderRadiusValue),
93
+ }}
94
+ ></span>
95
+ );
96
+ },
97
+ );
98
+
99
+ export type KPIShimmerProps = {
100
+ textWidth?: number | string,
101
+ };
102
+
103
+ export const KPIShimmer = ({textWidth = 150}: KPIShimmerProps): React.Node => (
104
+ <div className={css.kpiBox}>
105
+ <div className={css.section}>
106
+ <Shimmer type="rounded" width={60} height={60}></Shimmer>
107
+ </div>
108
+ <div className={css.section}>
109
+ <Shimmer type="text" width={textWidth} height={15}></Shimmer>
110
+ <Shimmer type="text" width={textWidth} height={25}></Shimmer>
111
+ <Shimmer type="text" width={textWidth} height={15}></Shimmer>
112
+ </div>
113
+ </div>
114
+ );
@@ -0,0 +1,64 @@
1
+ @value (colorFillPrimary, colorNeutralLightest, colorNeutralLight, colorBackgroundTertiary) from '../../styles/variables/_color.css';
2
+ @value (spaceXSmall,spaceXXSmall, 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
+ height: var(--height);
17
+ width: var(--width);
18
+ border-radius: var(--border-radius);
19
+ background: linear-gradient(
20
+ to right,
21
+ colorNeutralLightest opacity20,
22
+ colorNeutralLight opacity40,
23
+ colorNeutralLightest opacity60
24
+ );
25
+ background-size: backgroundSizeInitial sizeFluid;
26
+ animation: shimmer motionDuration infinite linear;
27
+ vertical-align: middle;
28
+
29
+ &.text {
30
+ margin-right: spaceXXSmall;
31
+ width: initial;
32
+ padding-left: var(--width);
33
+ }
34
+ }
35
+
36
+ .kpiBox {
37
+ display: flex;
38
+ composes: borderPrimary from '../../styles/border.module.css';
39
+ min-width: size252;
40
+ width: fit-content;
41
+ height: fit-content;
42
+ align-items: center;
43
+ gap: spaceSmall;
44
+ background-color: colorBackgroundTertiary;
45
+ border-radius: borderRadiusMedium;
46
+ padding: spaceLarge spaceMedium;
47
+ }
48
+
49
+ .section {
50
+ display: flex;
51
+ width: sizeFluid;
52
+ flex-flow: column;
53
+ gap: spaceXSmall;
54
+ align-items: center;
55
+ }
56
+
57
+ @keyframes shimmer {
58
+ from {
59
+ background-position: backgroundSizeInitial spaceNone;
60
+ }
61
+ to {
62
+ background-position: backgroundSizeFinal spaceNone;
63
+ }
64
+ }
@@ -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
+ });
@@ -0,0 +1,3 @@
1
+ // @flow strict
2
+
3
+ export * from './Shimmer';
@@ -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;
@@ -41,6 +41,7 @@ export * from './Pagination';
41
41
  export * from './Panel';
42
42
  export * from './RadioButton';
43
43
  export * from './SearchInput';
44
+ export * from './Shimmer';
44
45
  export * from './SideMenuLink';
45
46
  export * from './StatusIndicator';
46
47
  export * from './Stepper';
@@ -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;
@@ -24,3 +24,10 @@ export const truncateString = (
24
24
  }
25
25
  return inputString;
26
26
  };
27
+
28
+ export const appendPx = (value?: number | string): string => {
29
+ if (typeof value === 'number') {
30
+ return `${value}px`;
31
+ }
32
+ return value ?? '';
33
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spaced-out/ui-design-system",
3
- "version": "0.1.102",
3
+ "version": "0.1.104",
4
4
  "main": "index.js",
5
5
  "description": "Sense UI components library",
6
6
  "author": {