@dnanpm/styleguide 3.12.0 → 3.12.1

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.
@@ -260,6 +260,10 @@ const CurrentMonth = styledComponents.styled.div `
260
260
  line-height: ${theme.default.lineHeight.default};
261
261
  font-weight: ${theme.default.fontWeight.bold};
262
262
  `;
263
+ /**
264
+ * TODO: Replace the VisuallyHiddenStatus styled component with the global class name.
265
+ * Ticket: https://jira.dna.fi/browse/STYLE-916
266
+ */
263
267
  const VisuallyHiddenStatus = styledComponents.styled.div `
264
268
  position: absolute;
265
269
  left: -9999px;
@@ -26,6 +26,10 @@ const NotificationBadgeElement = styledComponents.styled.div `
26
26
  background-color: ${theme.default.color.notification.error};
27
27
  border-radius: ${theme.default.radius.circle};
28
28
  `;
29
+ /**
30
+ * TODO: Replace the VisuallyHidden styled component with the global class name.
31
+ * Ticket: https://jira.dna.fi/browse/STYLE-916
32
+ */
29
33
  const VisuallyHidden = styledComponents.styled.span `
30
34
  position: absolute;
31
35
  width: 1px;
@@ -139,6 +139,10 @@ const DropdownList = styledComponents.styled(CoreULStyles) `
139
139
 
140
140
  ${common.default({ elevation: 'low' })}
141
141
  `;
142
+ /**
143
+ * TODO: Replace the VisuallyHidden styled component with the global class name.
144
+ * Ticket: https://jira.dna.fi/browse/STYLE-916
145
+ */
142
146
  const VisuallyHidden = styledComponents.styled.span `
143
147
  position: absolute;
144
148
  width: 1px;
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import { type ThemeInterface } from '../../themes/theme';
3
+ interface Props {
4
+ /**
5
+ * Unique ID for the skeleton
6
+ */
7
+ id?: string;
8
+ /**
9
+ * Background color of the skeleton
10
+ *
11
+ * @param {string} sand Uses theme.color.background.sand.E01
12
+ * @param {string} white Uses white background (#FFFFFF)
13
+ *
14
+ * @default 'sand'
15
+ */
16
+ backgroundColor?: 'sand' | 'white';
17
+ /**
18
+ * Opacity level of the skeleton
19
+ *
20
+ * @param {number} 100 100% opacity
21
+ * @param {number} 50 50% opacity
22
+ * @param {number} 25 25% opacity
23
+ *
24
+ * @default 100
25
+ */
26
+ opacity?: 100 | 50 | 25;
27
+ /**
28
+ * Allows to pass in custom radius value from theme
29
+ */
30
+ borderRadius?: keyof ThemeInterface['radius'];
31
+ /**
32
+ * Width of the skeleton
33
+ *
34
+ * @default '100%'
35
+ */
36
+ width?: string;
37
+ /**
38
+ * Height of the skeleton
39
+ *
40
+ * @default '6.25rem'
41
+ */
42
+ height?: string;
43
+ /**
44
+ * Allows to pass testid string for testing purposes
45
+ */
46
+ 'data-testid'?: string;
47
+ /**
48
+ * Allows to pass a custom className
49
+ */
50
+ className?: string;
51
+ /**
52
+ * If used inside a carousel, pass the slide index (starting from 1)
53
+ */
54
+ carouselIndex?: number;
55
+ /**
56
+ * Screen reader label describing the use of the skeleton,
57
+ * e.g., "Loading content" or "Loading image."
58
+ */
59
+ ariaLabel?: string;
60
+ }
61
+ declare const Skeleton: ({ backgroundColor, opacity, width, height, borderRadius, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
62
+ /** @component */
63
+ export default Skeleton;
@@ -0,0 +1,73 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var React = require('react');
7
+ var styledComponents = require('styled-components');
8
+ var theme = require('../../themes/theme.js');
9
+
10
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
11
+
12
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
13
+
14
+ const shimmer = styledComponents.keyframes `
15
+ 100% {
16
+ transform: translateX(100%);
17
+ }
18
+ `;
19
+ const sandRgba = '248, 244, 241';
20
+ const whiteRgba = '255, 255, 255';
21
+ const getAnimationDelay = (carouselIndex) => {
22
+ switch (carouselIndex) {
23
+ case 1:
24
+ return '0s';
25
+ case 2:
26
+ return '0.6s';
27
+ case 3:
28
+ return '1.2s';
29
+ case 4:
30
+ return '1.9s';
31
+ case 5:
32
+ return '2.5s';
33
+ default:
34
+ return '0s';
35
+ }
36
+ };
37
+ const getBackgroundColor = (backgroundColor) => `linear-gradient(90deg,rgba(${backgroundColor}, 0) 0%,rgba(${backgroundColor}, 0.8) 50%,rgba(${backgroundColor}, 0) 100%)`;
38
+ const SkeletonWrapper = styledComponents.styled.div `
39
+ position: relative;
40
+ overflow: hidden;
41
+ background-color: ${({ $backgroundColor }) => $backgroundColor === 'sand'
42
+ ? theme.default.color.background.sand.E01
43
+ : theme.default.color.background.white.default};
44
+ opacity: ${({ $opacity }) => ($opacity ? $opacity / 100 : 1)};
45
+ width: ${({ $width }) => $width};
46
+ height: ${({ $height }) => $height};
47
+ border-radius: ${({ $borderRadius }) => theme.default.radius[$borderRadius || 's']};
48
+
49
+ &::after {
50
+ position: absolute;
51
+ inset: 0;
52
+ transform: translateX(-100%);
53
+ background: ${({ $backgroundColor }) => getBackgroundColor($backgroundColor === 'sand' ? whiteRgba : sandRgba)};
54
+
55
+ animation: ${shimmer} 1.5s infinite;
56
+ content: '';
57
+ }
58
+
59
+ @media (min-width: 600px) {
60
+ &::after {
61
+ animation: ${shimmer} 2.5s infinite;
62
+ animation-delay: ${({ $carouselIndex }) => getAnimationDelay($carouselIndex)};
63
+ }
64
+ }
65
+ `;
66
+ const Skeleton = (_a) => {
67
+ var { backgroundColor = 'sand', opacity = 100, width = '25rem', height = '6.25rem', borderRadius = 's', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["backgroundColor", "opacity", "width", "height", "borderRadius", 'data-testid']);
68
+ return (React__default.default.createElement(React__default.default.Fragment, null,
69
+ props.ariaLabel && (React__default.default.createElement("span", { id: props.id, "aria-label": props.ariaLabel, role: "status", "aria-atomic": "true", className: "visually-hidden" })),
70
+ React__default.default.createElement(SkeletonWrapper, { className: props.className, "data-testid": dataTestId, "aria-hidden": "true", tabIndex: -1, "$backgroundColor": backgroundColor, "$opacity": opacity, "$width": width, "$height": height, "$carouselIndex": props.carouselIndex, "$borderRadius": borderRadius })));
71
+ };
72
+
73
+ exports.default = Skeleton;
@@ -64,7 +64,7 @@ const StyledReactTooltip = styledComponents.styled(reactTooltip.Tooltip) `
64
64
 
65
65
  border: 1px solid ${theme.default.color.line.L02};
66
66
  padding: ${styledUtils.getMultipliedSize(theme.default.base.baseWidth, 1.5)};
67
- text-align: center;
67
+ text-align: left;
68
68
  font-size: ${theme.default.fontSize.default};
69
69
  line-height: ${theme.default.lineHeight.default};
70
70
  width: max-content;
@@ -46,6 +46,7 @@ export { default as ReadMore } from './ReadMore/ReadMore';
46
46
  export { default as Search } from './Search/Search';
47
47
  export { default as SecondaryNavigation } from './SecondaryNavigation/SecondaryNavigation';
48
48
  export { default as Selectbox } from './Selectbox/Selectbox';
49
+ export { default as Skeleton } from './Skeleton/Skeleton';
49
50
  export { default as Switch } from './Switch/Switch';
50
51
  export { default as Tab } from './Tab/Tab';
51
52
  export { default as Tabs } from './Tabs/Tabs';
@@ -156,6 +156,7 @@ var ReadMore = require('./components/ReadMore/ReadMore.js');
156
156
  var Search = require('./components/Search/Search.js');
157
157
  var SecondaryNavigation = require('./components/SecondaryNavigation/SecondaryNavigation.js');
158
158
  var Selectbox = require('./components/Selectbox/Selectbox.js');
159
+ var Skeleton = require('./components/Skeleton/Skeleton.js');
159
160
  var Switch = require('./components/Switch/Switch.js');
160
161
  var Tab = require('./components/Tab/Tab.js');
161
162
  var Tabs = require('./components/Tabs/Tabs.js');
@@ -328,6 +329,7 @@ exports.ReadMore = ReadMore.default;
328
329
  exports.Search = Search.default;
329
330
  exports.SecondaryNavigation = SecondaryNavigation.default;
330
331
  exports.Selectbox = Selectbox.default;
332
+ exports.Skeleton = Skeleton.default;
331
333
  exports.Switch = Switch.default;
332
334
  exports.Tab = Tab.default;
333
335
  exports.Tabs = Tabs.default;
@@ -251,6 +251,10 @@ const CurrentMonth = styled.div `
251
251
  line-height: ${theme.lineHeight.default};
252
252
  font-weight: ${theme.fontWeight.bold};
253
253
  `;
254
+ /**
255
+ * TODO: Replace the VisuallyHiddenStatus styled component with the global class name.
256
+ * Ticket: https://jira.dna.fi/browse/STYLE-916
257
+ */
254
258
  const VisuallyHiddenStatus = styled.div `
255
259
  position: absolute;
256
260
  left: -9999px;
@@ -18,6 +18,10 @@ const NotificationBadgeElement = styled.div `
18
18
  background-color: ${theme.color.notification.error};
19
19
  border-radius: ${theme.radius.circle};
20
20
  `;
21
+ /**
22
+ * TODO: Replace the VisuallyHidden styled component with the global class name.
23
+ * Ticket: https://jira.dna.fi/browse/STYLE-916
24
+ */
21
25
  const VisuallyHidden = styled.span `
22
26
  position: absolute;
23
27
  width: 1px;
@@ -131,6 +131,10 @@ const DropdownList = styled(CoreULStyles) `
131
131
 
132
132
  ${getElevationShadow({ elevation: 'low' })}
133
133
  `;
134
+ /**
135
+ * TODO: Replace the VisuallyHidden styled component with the global class name.
136
+ * Ticket: https://jira.dna.fi/browse/STYLE-916
137
+ */
134
138
  const VisuallyHidden = styled.span `
135
139
  position: absolute;
136
140
  width: 1px;
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import { type ThemeInterface } from '../../themes/theme';
3
+ interface Props {
4
+ /**
5
+ * Unique ID for the skeleton
6
+ */
7
+ id?: string;
8
+ /**
9
+ * Background color of the skeleton
10
+ *
11
+ * @param {string} sand Uses theme.color.background.sand.E01
12
+ * @param {string} white Uses white background (#FFFFFF)
13
+ *
14
+ * @default 'sand'
15
+ */
16
+ backgroundColor?: 'sand' | 'white';
17
+ /**
18
+ * Opacity level of the skeleton
19
+ *
20
+ * @param {number} 100 100% opacity
21
+ * @param {number} 50 50% opacity
22
+ * @param {number} 25 25% opacity
23
+ *
24
+ * @default 100
25
+ */
26
+ opacity?: 100 | 50 | 25;
27
+ /**
28
+ * Allows to pass in custom radius value from theme
29
+ */
30
+ borderRadius?: keyof ThemeInterface['radius'];
31
+ /**
32
+ * Width of the skeleton
33
+ *
34
+ * @default '100%'
35
+ */
36
+ width?: string;
37
+ /**
38
+ * Height of the skeleton
39
+ *
40
+ * @default '6.25rem'
41
+ */
42
+ height?: string;
43
+ /**
44
+ * Allows to pass testid string for testing purposes
45
+ */
46
+ 'data-testid'?: string;
47
+ /**
48
+ * Allows to pass a custom className
49
+ */
50
+ className?: string;
51
+ /**
52
+ * If used inside a carousel, pass the slide index (starting from 1)
53
+ */
54
+ carouselIndex?: number;
55
+ /**
56
+ * Screen reader label describing the use of the skeleton,
57
+ * e.g., "Loading content" or "Loading image."
58
+ */
59
+ ariaLabel?: string;
60
+ }
61
+ declare const Skeleton: ({ backgroundColor, opacity, width, height, borderRadius, "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
62
+ /** @component */
63
+ export default Skeleton;
@@ -0,0 +1,65 @@
1
+ import { __rest } from 'tslib';
2
+ import React__default from 'react';
3
+ import { keyframes, styled } from 'styled-components';
4
+ import theme from '../../themes/theme.js';
5
+
6
+ const shimmer = keyframes `
7
+ 100% {
8
+ transform: translateX(100%);
9
+ }
10
+ `;
11
+ const sandRgba = '248, 244, 241';
12
+ const whiteRgba = '255, 255, 255';
13
+ const getAnimationDelay = (carouselIndex) => {
14
+ switch (carouselIndex) {
15
+ case 1:
16
+ return '0s';
17
+ case 2:
18
+ return '0.6s';
19
+ case 3:
20
+ return '1.2s';
21
+ case 4:
22
+ return '1.9s';
23
+ case 5:
24
+ return '2.5s';
25
+ default:
26
+ return '0s';
27
+ }
28
+ };
29
+ const getBackgroundColor = (backgroundColor) => `linear-gradient(90deg,rgba(${backgroundColor}, 0) 0%,rgba(${backgroundColor}, 0.8) 50%,rgba(${backgroundColor}, 0) 100%)`;
30
+ const SkeletonWrapper = styled.div `
31
+ position: relative;
32
+ overflow: hidden;
33
+ background-color: ${({ $backgroundColor }) => $backgroundColor === 'sand'
34
+ ? theme.color.background.sand.E01
35
+ : theme.color.background.white.default};
36
+ opacity: ${({ $opacity }) => ($opacity ? $opacity / 100 : 1)};
37
+ width: ${({ $width }) => $width};
38
+ height: ${({ $height }) => $height};
39
+ border-radius: ${({ $borderRadius }) => theme.radius[$borderRadius || 's']};
40
+
41
+ &::after {
42
+ position: absolute;
43
+ inset: 0;
44
+ transform: translateX(-100%);
45
+ background: ${({ $backgroundColor }) => getBackgroundColor($backgroundColor === 'sand' ? whiteRgba : sandRgba)};
46
+
47
+ animation: ${shimmer} 1.5s infinite;
48
+ content: '';
49
+ }
50
+
51
+ @media (min-width: 600px) {
52
+ &::after {
53
+ animation: ${shimmer} 2.5s infinite;
54
+ animation-delay: ${({ $carouselIndex }) => getAnimationDelay($carouselIndex)};
55
+ }
56
+ }
57
+ `;
58
+ const Skeleton = (_a) => {
59
+ var { backgroundColor = 'sand', opacity = 100, width = '25rem', height = '6.25rem', borderRadius = 's', 'data-testid': dataTestId } = _a, props = __rest(_a, ["backgroundColor", "opacity", "width", "height", "borderRadius", 'data-testid']);
60
+ return (React__default.createElement(React__default.Fragment, null,
61
+ props.ariaLabel && (React__default.createElement("span", { id: props.id, "aria-label": props.ariaLabel, role: "status", "aria-atomic": "true", className: "visually-hidden" })),
62
+ React__default.createElement(SkeletonWrapper, { className: props.className, "data-testid": dataTestId, "aria-hidden": "true", tabIndex: -1, "$backgroundColor": backgroundColor, "$opacity": opacity, "$width": width, "$height": height, "$carouselIndex": props.carouselIndex, "$borderRadius": borderRadius })));
63
+ };
64
+
65
+ export { Skeleton as default };
@@ -56,7 +56,7 @@ const StyledReactTooltip = styled(Tooltip$1) `
56
56
 
57
57
  border: 1px solid ${theme.color.line.L02};
58
58
  padding: ${getMultipliedSize(theme.base.baseWidth, 1.5)};
59
- text-align: center;
59
+ text-align: left;
60
60
  font-size: ${theme.fontSize.default};
61
61
  line-height: ${theme.lineHeight.default};
62
62
  width: max-content;
@@ -46,6 +46,7 @@ export { default as ReadMore } from './ReadMore/ReadMore';
46
46
  export { default as Search } from './Search/Search';
47
47
  export { default as SecondaryNavigation } from './SecondaryNavigation/SecondaryNavigation';
48
48
  export { default as Selectbox } from './Selectbox/Selectbox';
49
+ export { default as Skeleton } from './Skeleton/Skeleton';
49
50
  export { default as Switch } from './Switch/Switch';
50
51
  export { default as Tab } from './Tab/Tab';
51
52
  export { default as Tabs } from './Tabs/Tabs';
package/build/es/index.js CHANGED
@@ -154,6 +154,7 @@ export { default as ReadMore } from './components/ReadMore/ReadMore.js';
154
154
  export { default as Search } from './components/Search/Search.js';
155
155
  export { default as SecondaryNavigation } from './components/SecondaryNavigation/SecondaryNavigation.js';
156
156
  export { default as Selectbox } from './components/Selectbox/Selectbox.js';
157
+ export { default as Skeleton } from './components/Skeleton/Skeleton.js';
157
158
  export { default as Switch } from './components/Switch/Switch.js';
158
159
  export { default as Tab } from './components/Tab/Tab.js';
159
160
  export { default as Tabs } from './components/Tabs/Tabs.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dnanpm/styleguide",
3
3
  "sideEffects": false,
4
- "version": "v3.12.0",
4
+ "version": "v3.12.1",
5
5
  "main": "build/cjs/index.js",
6
6
  "module": "build/es/index.js",
7
7
  "jsnext:main": "build/es/index.js",
@@ -49,14 +49,14 @@
49
49
  "@babel/preset-typescript": "^7.27.1",
50
50
  "@dnanpm/icons": "^2.0.9",
51
51
  "@rollup/plugin-commonjs": "^28.0.3",
52
- "@rollup/plugin-node-resolve": "^15.3.0",
52
+ "@rollup/plugin-node-resolve": "^16.0.3",
53
53
  "@rollup/plugin-typescript": "^12.1.2",
54
54
  "@testing-library/jest-dom": "^6.6.3",
55
55
  "@testing-library/react": "^16.3.0",
56
56
  "@testing-library/user-event": "^14.5.2",
57
57
  "@types/jest": "^30.0.0",
58
58
  "@types/node": "^17.0.45",
59
- "@types/ramda": "^0.27.36",
59
+ "@types/ramda": "^0.31.1",
60
60
  "@types/react": "^18.3.11",
61
61
  "@types/react-dom": "^18.3.1",
62
62
  "@types/react-modal": "^3.13.1",
@@ -71,7 +71,7 @@
71
71
  "eslint-config-airbnb-typescript": "^17.1.0",
72
72
  "eslint-config-prettier": "^10.1.8",
73
73
  "eslint-plugin-import": "2.32.0",
74
- "eslint-plugin-jsdoc": "^60.4.0",
74
+ "eslint-plugin-jsdoc": "^61.1.4",
75
75
  "eslint-plugin-jsx-a11y": "^6.10.2",
76
76
  "eslint-plugin-prefer-arrow": "^1.2.3",
77
77
  "eslint-plugin-react": "^7.37.4",
@@ -98,8 +98,8 @@
98
98
  "webpack": "^5.99.8"
99
99
  },
100
100
  "dependencies": {
101
- "ramda": "^0.27.1",
102
- "react-datepicker": "8.7.0",
101
+ "ramda": "^0.32.0",
102
+ "react-datepicker": "8.8.0",
103
103
  "react-modal": "^3.16.1",
104
104
  "react-select": "^5.8.1",
105
105
  "react-spring": "^8.0.27",