@dnanpm/styleguide 3.12.0 → 3.12.2

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.
Files changed (39) hide show
  1. package/build/cjs/components/Breadcrumb/Breadcrumb.d.ts +42 -0
  2. package/build/cjs/components/Breadcrumb/Breadcrumb.js +90 -0
  3. package/build/cjs/components/Carousel/Carousel.d.ts +11 -14
  4. package/build/cjs/components/Carousel/Carousel.js +52 -40
  5. package/build/cjs/components/DateTimePicker/DateTimePicker.js +4 -0
  6. package/build/cjs/components/Hero/Hero.d.ts +0 -6
  7. package/build/cjs/components/Hero/Hero.js +3 -3
  8. package/build/cjs/components/NotificationBadge/NotificationBadge.js +4 -0
  9. package/build/cjs/components/PriorityNavigation/PriorityNavigation.js +4 -0
  10. package/build/cjs/components/Skeleton/Skeleton.d.ts +63 -0
  11. package/build/cjs/components/Skeleton/Skeleton.js +73 -0
  12. package/build/cjs/components/Tooltip/Tooltip.js +1 -1
  13. package/build/cjs/components/index.d.ts +2 -0
  14. package/build/cjs/index.js +4 -0
  15. package/build/cjs/themes/globalStyles.js +1 -0
  16. package/build/cjs/themes/theme.d.ts +9 -2
  17. package/build/cjs/themes/themeComponents/breakpoints.d.ts +9 -4
  18. package/build/cjs/utils/styledUtils.d.ts +22 -1
  19. package/build/cjs/utils/styledUtils.js +26 -6
  20. package/build/es/components/Breadcrumb/Breadcrumb.d.ts +42 -0
  21. package/build/es/components/Breadcrumb/Breadcrumb.js +82 -0
  22. package/build/es/components/Carousel/Carousel.d.ts +11 -14
  23. package/build/es/components/Carousel/Carousel.js +52 -40
  24. package/build/es/components/DateTimePicker/DateTimePicker.js +4 -0
  25. package/build/es/components/Hero/Hero.d.ts +0 -6
  26. package/build/es/components/Hero/Hero.js +3 -3
  27. package/build/es/components/NotificationBadge/NotificationBadge.js +4 -0
  28. package/build/es/components/PriorityNavigation/PriorityNavigation.js +4 -0
  29. package/build/es/components/Skeleton/Skeleton.d.ts +63 -0
  30. package/build/es/components/Skeleton/Skeleton.js +65 -0
  31. package/build/es/components/Tooltip/Tooltip.js +1 -1
  32. package/build/es/components/index.d.ts +2 -0
  33. package/build/es/index.js +2 -0
  34. package/build/es/themes/globalStyles.js +1 -0
  35. package/build/es/themes/theme.d.ts +9 -2
  36. package/build/es/themes/themeComponents/breakpoints.d.ts +9 -4
  37. package/build/es/utils/styledUtils.d.ts +22 -1
  38. package/build/es/utils/styledUtils.js +26 -6
  39. package/package.json +14 -10
@@ -0,0 +1,42 @@
1
+ import type { ComponentType } from 'react';
2
+ import React from 'react';
3
+ export interface BreadcrumbItem {
4
+ /**
5
+ * Display text for the breadcrumb item
6
+ */
7
+ label: string;
8
+ /**
9
+ * URL/path for the breadcrumb item. If not provided, item will be rendered as text only
10
+ */
11
+ href?: string;
12
+ }
13
+ interface Props {
14
+ /**
15
+ * Array of breadcrumb items to display
16
+ */
17
+ items?: BreadcrumbItem[];
18
+ /**
19
+ * Custom link component to use instead of default anchor element
20
+ * Useful for router integration (e.g., Next.js Link, React Router Link)
21
+ */
22
+ linkComponent?: ComponentType<any>;
23
+ /**
24
+ * Props to pass to the link component
25
+ */
26
+ linkProps?: Record<string, unknown>;
27
+ /**
28
+ * Screen reader label describing the breadcrumb navigation
29
+ */
30
+ ariaLabel?: string;
31
+ /**
32
+ * Allows to pass testid string for testing purposes
33
+ */
34
+ 'data-testid'?: string;
35
+ /**
36
+ * Allows to pass a custom className
37
+ */
38
+ className?: string;
39
+ }
40
+ declare const Breadcrumb: ({ "data-testid": dataTestId, ariaLabel, className, items, linkComponent: LinkComponent, linkProps, }: Props) => React.JSX.Element | null;
41
+ /** @component */
42
+ export default Breadcrumb;
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var React = require('react');
6
+ var icons = require('@dnanpm/icons');
7
+ var styledComponents = require('styled-components');
8
+ var theme = require('../../themes/theme.js');
9
+ var styledUtils = require('../../utils/styledUtils.js');
10
+
11
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
12
+
13
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
14
+
15
+ const BreadcrumbNav = styledComponents.styled.nav `
16
+ font-size: ${theme.default.fontSize.s};
17
+ font-weight: ${theme.default.fontWeight.medium};
18
+ `;
19
+ const BreadcrumbList = styledComponents.styled.ol `
20
+ display: flex;
21
+ align-items: center;
22
+ flex-wrap: nowrap;
23
+ list-style: none;
24
+ margin: ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 2)} 0;
25
+ padding: 0;
26
+ gap: ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 0.5)};
27
+ overflow: visible;
28
+ container: breadcrumb / inline-size;
29
+
30
+ /* Responsive behavior: show only last 2 items when container < 600px */
31
+ @container (max-width: 599px) {
32
+ li:not(:nth-last-child(-n + 2)) {
33
+ display: none;
34
+ }
35
+ }
36
+ `;
37
+ const BreadcrumbListItem = styledComponents.styled.li `
38
+ display: flex;
39
+ align-items: center;
40
+ gap: ${styledUtils.getMultipliedSize(theme.default.base.baseHeight, 0.5)};
41
+
42
+ &:last-child {
43
+ min-width: 0;
44
+ }
45
+
46
+ a {
47
+ &:focus-visible {
48
+ outline: none;
49
+ border-radius: ${theme.default.radius.s};
50
+ box-shadow:
51
+ 0px 0px 0px 2px ${theme.default.color.focus.light},
52
+ 0px 0px 0px 4px ${theme.default.color.focus.dark};
53
+ }
54
+ }
55
+
56
+ span {
57
+ flex: 1 1 0%;
58
+ white-space: nowrap;
59
+ overflow: hidden;
60
+ text-overflow: ellipsis;
61
+ }
62
+ `;
63
+ const Breadcrumb = ({ 'data-testid': dataTestId, ariaLabel, className, items, linkComponent: LinkComponent, linkProps = {}, }) => {
64
+ if (!items || items.length === 0) {
65
+ return null;
66
+ }
67
+ const renderItem = (item, index) => {
68
+ const isLastItem = index === items.length - 1;
69
+ if (isLastItem || !item.href) {
70
+ return React__default.default.createElement("span", { "aria-current": isLastItem ? 'page' : undefined }, item.label);
71
+ }
72
+ if (LinkComponent) {
73
+ return (React__default.default.createElement(LinkComponent, Object.assign({ href: item.href, itemProp: "item", itemScope: true, itemType: "https://schema.org/WebPage" }, linkProps),
74
+ React__default.default.createElement("span", { itemProp: "name" }, item.label)));
75
+ }
76
+ return (React__default.default.createElement("a", { href: item.href, itemProp: "item", itemScope: true, itemType: "https://schema.org/WebPage" },
77
+ React__default.default.createElement("span", { itemProp: "name" }, item.label)));
78
+ };
79
+ return (React__default.default.createElement(BreadcrumbNav, { "aria-label": ariaLabel, className: className, "data-testid": dataTestId },
80
+ React__default.default.createElement(BreadcrumbList, { itemScope: true, itemType: "https://schema.org/BreadcrumbList" }, items.map((item, index) => {
81
+ var _a;
82
+ const isLastItem = index === items.length - 1;
83
+ return (React__default.default.createElement(BreadcrumbListItem, { itemProp: "itemListElement", itemScope: true, itemType: "https://schema.org/ListItem", key: `breadcrumb-${item.label}-${(_a = item.href) !== null && _a !== void 0 ? _a : 'nolink'}` },
84
+ renderItem(item, index),
85
+ React__default.default.createElement("meta", { itemProp: "position", content: (index + 1).toString() }),
86
+ !isLastItem && (React__default.default.createElement(icons.ChevronRight, { color: theme.default.color.background.pink.default, size: "0.9rem" }))));
87
+ }))));
88
+ };
89
+
90
+ exports.default = Breadcrumb;
@@ -1,11 +1,5 @@
1
1
  import type { MouseEvent, ReactNode } from 'react';
2
2
  import React from 'react';
3
- interface Responsive {
4
- minItems: number;
5
- maxItems: number;
6
- minWidth: number;
7
- maxWidth: number;
8
- }
9
3
  interface Props {
10
4
  /**
11
5
  * Unique ID for the component
@@ -50,10 +44,12 @@ interface Props {
50
44
  */
51
45
  className?: string;
52
46
  /**
53
- * Allows to define responsive configuration
54
- * If not provided, visibleItems property will be used
47
+ * Allows for responsive behavior in the carousel.
48
+ * Shows as many items as possible; each item requires a defined width.
49
+ * This overrides the `visibleItems` prop.
50
+ * @default false
55
51
  */
56
- responsive?: Partial<Responsive>;
52
+ responsive?: boolean;
57
53
  /**
58
54
  * Allows to pass a screen reader label for the pagination item next to the current slide number
59
55
  */
@@ -73,12 +69,13 @@ interface Props {
73
69
  */
74
70
  swipeStep?: number;
75
71
  }
76
- declare const SlideItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, Required<{
77
- $visibleItems?: Props["visibleItems"];
78
- }> & {
79
- $itemWidthCorrection: number;
72
+ declare const SlideItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {
80
73
  $isSwiping: boolean;
81
- }>> & string;
74
+ $responsive: boolean;
75
+ $gap: number;
76
+ } & Partial<Required<{
77
+ $visibleItems: Props["visibleItems"];
78
+ }>>>> & string;
82
79
  /** @visibleName Carousel */
83
80
  declare const Carousel: ({ "data-testid": dataTestId, ...props }: Props) => React.JSX.Element;
84
81
  /** @component */
@@ -41,7 +41,6 @@ const SlidesWrapper = styledComponents.styled.div `
41
41
  display: flex;
42
42
  width: 100%;
43
43
  height: 100%;
44
- gap: ${({ $gap }) => $gap}rem;
45
44
  transition-property: transform;
46
45
  transform: translate3d(0px, 0, 0);
47
46
  transition-duration: 0ms;
@@ -52,9 +51,14 @@ const SlideItem = styledComponents.styled.div `
52
51
  display: block;
53
52
  position: relative;
54
53
  flex-shrink: 0;
55
- flex-basis: calc(
56
- ${({ $visibleItems, $itemWidthCorrection }) => `(100% / ${$visibleItems}) - ${$itemWidthCorrection}px`}
57
- );
54
+ padding-right: ${({ $gap }) => $gap}rem;
55
+
56
+ ${({ $responsive, $visibleItems }) => !$responsive && $visibleItems
57
+ ? `flex-basis: calc(100% / ${$visibleItems});`
58
+ : `
59
+ flex-basis: auto;
60
+ width: max-content;
61
+ `}
58
62
 
59
63
  a {
60
64
  pointer-events: ${({ $isSwiping }) => ($isSwiping ? 'none' : 'auto')};
@@ -146,53 +150,51 @@ const Counter = styledComponents.styled.span `
146
150
  `;
147
151
  /** @visibleName Carousel */
148
152
  const Carousel = (_a) => {
149
- var _b;
153
+ var _b, _c;
150
154
  var { 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ['data-testid']);
151
155
  const slidesWrapperRef = React.useRef(null);
152
156
  const scrollbarRef = React.useRef(null);
153
157
  const knobRef = React.useRef(null);
154
- const { isMobile, width } = useWindowSize.default(theme.default.breakpoints.md);
158
+ const firstItemRef = React.useRef(null);
159
+ const { isMobile, width: windowWidth } = useWindowSize.default(theme.default.breakpoints.md);
155
160
  const [currentIndex, setCurrentIndex] = React.useState(0);
156
161
  const [isSwiping, setIsSwiping] = React.useState(false);
157
- const [calculatedItems, setCalculatedItems] = React.useState(props.visibleItems || (isMobile ? 1.2 : 1));
162
+ const [autoVisibleItems, setAutoVisibleItems] = React.useState(null);
158
163
  React.useEffect(() => {
159
- const calculateVisibleItems = () => {
160
- const defaultValue = props.visibleItems || (isMobile ? 1.2 : 1);
161
- const { minItems, maxItems, minWidth, maxWidth } = props.responsive || {};
162
- if (!width || !minItems || !maxItems || !minWidth || !maxWidth) {
163
- return defaultValue;
164
- }
165
- const calculatedMaxItems = React.Children.count(props.children) === 1 ? 1 : maxItems;
166
- if (width < minWidth) {
167
- return minItems;
164
+ if (props.responsive) {
165
+ const container = slidesWrapperRef.current;
166
+ const firstItem = firstItemRef.current;
167
+ if (container && firstItem) {
168
+ Array.from(container.children).forEach(itemElement => {
169
+ const item = itemElement;
170
+ item.style.flexBasis = '';
171
+ item.style.width = '';
172
+ });
173
+ const containerWidth = container.offsetWidth;
174
+ const itemWidth = firstItem.offsetWidth;
175
+ if (itemWidth > 0) {
176
+ const realVisibleItems = containerWidth / itemWidth;
177
+ setAutoVisibleItems(Math.max(1, realVisibleItems));
178
+ }
168
179
  }
169
- if (width > maxWidth) {
170
- return calculatedMaxItems;
171
- }
172
- return minItems + ((width - minWidth) / (maxWidth - minWidth)) * (maxItems - minItems);
173
- };
174
- const timeoutId = setTimeout(() => {
175
- setCalculatedItems(calculateVisibleItems());
176
- }, 100);
177
- return () => clearTimeout(timeoutId);
178
- }, [width, isMobile, props.responsive, props.visibleItems, props.children]);
180
+ }
181
+ else {
182
+ setAutoVisibleItems(null);
183
+ }
184
+ }, [props.responsive, windowWidth, props.children]);
179
185
  const getStep = (step, visibleItems) => {
180
186
  if (step > visibleItems) {
181
187
  return Math.floor(visibleItems);
182
188
  }
183
189
  return Math.floor(step);
184
190
  };
185
- const visibleItems = props.visibleItems || calculatedItems;
191
+ const visibleItems = (_b = autoVisibleItems !== null && autoVisibleItems !== void 0 ? autoVisibleItems : props.visibleItems) !== null && _b !== void 0 ? _b : (isMobile ? 1.2 : 1);
186
192
  const slidesWrapperGapSizePx = 20;
187
193
  const slidesCount = React.Children.count(props.children);
188
194
  const slideScreensCount = Math.max(1, slidesCount - Math.floor(visibleItems) + 1);
189
- const step = getStep((_b = props.swipeStep) !== null && _b !== void 0 ? _b : 1, visibleItems);
195
+ const step = getStep((_c = props.swipeStep) !== null && _c !== void 0 ? _c : 1, visibleItems);
190
196
  const currentStepIndex = Math.ceil(currentIndex / step);
191
197
  const totalSwipeSteps = Math.ceil(slideScreensCount / step + ((slideScreensCount - 1) % step !== 0 ? 1 : 0));
192
- const itemWidthCorrectionRatio = (slidesWrapperGapSizePx * visibleItems) % Math.floor(visibleItems) === 0
193
- ? (visibleItems - 1) / visibleItems
194
- : Math.floor(visibleItems) / visibleItems;
195
- const itemWidthCorrection = itemWidthCorrectionRatio * slidesWrapperGapSizePx;
196
198
  const data = React.useMemo(() => ({
197
199
  startX: 0,
198
200
  startTime: 0,
@@ -328,12 +330,10 @@ const Carousel = (_a) => {
328
330
  React.useEffect(() => {
329
331
  if (slidesWrapperRef.current && scrollbarRef.current) {
330
332
  const isRest = React.Children.count(props.children) - (currentIndex + visibleItems) < 0;
331
- data.itemWidth =
332
- slidesWrapperRef.current.offsetWidth / visibleItems - itemWidthCorrection;
333
+ data.itemWidth = slidesWrapperRef.current.offsetWidth / visibleItems;
333
334
  data.scrollWidth = slidesWrapperRef.current.scrollWidth;
334
335
  data.lastItemX =
335
- (data.itemWidth + slidesWrapperGapSizePx) *
336
- (React.Children.count(props.children) - visibleItems) -
336
+ data.itemWidth * (React.Children.count(props.children) - visibleItems) -
337
337
  (isRest ? slidesWrapperGapSizePx * (Math.ceil(visibleItems) - visibleItems) : 0);
338
338
  data.scrollbarToSlidesRatio =
339
339
  data.lastItemX /
@@ -342,14 +342,26 @@ const Carousel = (_a) => {
342
342
  let slidesTransform = 0;
343
343
  if (React.Children.count(props.children) >= visibleItems) {
344
344
  slidesTransform =
345
- data.itemWidth * currentIndex +
346
- slidesWrapperGapSizePx * currentIndex -
345
+ data.itemWidth * currentIndex -
347
346
  (isRest ? data.itemWidth * (visibleItems % 1) + slidesWrapperGapSizePx : 0);
348
347
  }
349
348
  setElementTransform(slidesWrapperRef, -slidesTransform);
350
349
  setElementTransform(knobRef, slidesTransform / data.scrollbarToSlidesRatio);
351
350
  }
352
- }, [currentIndex, data, itemWidthCorrection, props.children, slideScreensCount, visibleItems]);
351
+ }, [currentIndex, data, props.children, slideScreensCount, visibleItems]);
352
+ React.useEffect(() => {
353
+ var _a;
354
+ if (props.responsive && autoVisibleItems) {
355
+ const items = (_a = slidesWrapperRef.current) === null || _a === void 0 ? void 0 : _a.children;
356
+ if (items) {
357
+ Array.from(items).forEach(itemElement => {
358
+ const item = itemElement;
359
+ item.style.flexBasis = `calc(100% / ${autoVisibleItems})`;
360
+ item.style.width = '';
361
+ });
362
+ }
363
+ }
364
+ }, [autoVisibleItems, props.responsive]);
353
365
  return (React__default.default.createElement(CarouselWrapper, { id: props.id, className: props.className, "data-testid": dataTestId },
354
366
  React__default.default.createElement(Header, { "data-testid": dataTestId && `${dataTestId}-header` },
355
367
  props.title && React__default.default.createElement(Title, null, props.title),
@@ -361,7 +373,7 @@ const Carousel = (_a) => {
361
373
  React__default.default.createElement(ButtonArrow.default, { direction: "left", "aria-label": props.previousAriaLabel, onClick: handleNavigationButtonPreviousClick, disabled: currentIndex <= 0, type: "button" }),
362
374
  React__default.default.createElement(ButtonArrow.default, { direction: "right", "aria-label": props.nextAriaLabel, onClick: handleNavigationButtonNextClick, disabled: currentIndex + visibleItems >= React.Children.count(props.children), type: "button" }))),
363
375
  React__default.default.createElement(Content, { "data-testid": dataTestId && `${dataTestId}-content` },
364
- React__default.default.createElement(SlidesWrapper, { ref: slidesWrapperRef, onPointerDown: handleSlidesPointerDown, "$gap": slidesWrapperGapSizePx / 16 }, React.Children.map(props.children, child => (React__default.default.createElement(SlideItem, { "$visibleItems": visibleItems, "$itemWidthCorrection": itemWidthCorrection, "$isSwiping": isSwiping, onPointerDown: handlePointerDown }, child))))),
376
+ React__default.default.createElement(SlidesWrapper, { ref: slidesWrapperRef, onPointerDown: handleSlidesPointerDown }, React.Children.map(props.children, (child, index) => (React__default.default.createElement(SlideItem, { ref: index === 0 ? firstItemRef : undefined, "$visibleItems": visibleItems, "$isSwiping": isSwiping, onPointerDown: handlePointerDown, "$responsive": Boolean(props.responsive), "$gap": slidesWrapperGapSizePx / 16 }, child))))),
365
377
  React__default.default.createElement(Footer, { "data-testid": dataTestId && `${dataTestId}-footer` },
366
378
  React__default.default.createElement(Pagination, null, [...Array(totalSwipeSteps).keys()].map((value, index) => (React__default.default.createElement(PaginationItem, { key: value, "aria-label": props.paginationAriaLabel &&
367
379
  `${props.paginationAriaLabel} ${index + 1}`, "aria-current": Math.ceil(currentIndex / step) === index, "$isActive": Math.ceil(currentIndex / step) === index, onClick: handlePaginationItemClick, type: "button" })))),
@@ -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;
@@ -34,12 +34,6 @@ interface HeroProps {
34
34
  * Background color when no image is provided
35
35
  */
36
36
  backgroundColor?: string;
37
- /**
38
- * Enable gradient overlay on background
39
- *
40
- * @default false
41
- */
42
- hasGradient?: boolean;
43
37
  /**
44
38
  * Logo image component for logo-style heroes
45
39
  */
@@ -35,9 +35,9 @@ const HeroImage = styledComponents.styled.div `
35
35
  height: ${HERO_CONSTANTS.mobileHeight}px;
36
36
  background-color: ${({ $backgroundColor }) => $backgroundColor || 'transparent'};
37
37
 
38
- ${({ $hasGradient }) => $hasGradient &&
38
+ ${({ $backgroundColor }) => $backgroundColor &&
39
39
  `
40
- linear-gradient(180deg, ${theme.default.color.background.plum.default}${theme.default.color.transparency.T0} 0%, ${theme.default.color.background.plum.default}${theme.default.color.transparency.T30} 100%);
40
+ background-image: linear-gradient(180deg, ${theme.default.color.background.plum.default}${theme.default.color.transparency.T0} 0%, ${theme.default.color.background.plum.default}${theme.default.color.transparency.T30} 100%);
41
41
  background-size: 100% 33.33%;
42
42
  background-repeat: no-repeat;
43
43
  background-position: bottom;
@@ -184,7 +184,7 @@ const Hero = (_a) => {
184
184
  var { variant = 'default', headingLevel = 'h1', Image = 'img', LogoImage = 'img', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["variant", "headingLevel", "Image", "LogoImage", 'data-testid']);
185
185
  const HeadingTag = headingLevel;
186
186
  return (React__default.default.createElement(HeroContainer, { "$variant": variant, className: props.className, "data-testid": dataTestId },
187
- React__default.default.createElement(HeroImage, { "$hasGradient": props.hasGradient, "$backgroundColor": props.backgroundColor },
187
+ React__default.default.createElement(HeroImage, { "$backgroundColor": props.backgroundColor },
188
188
  props.logoImageProps && (React__default.default.createElement(LogoImageWrap, null,
189
189
  React__default.default.createElement(LogoImageContainer, null, renderImage(LogoImage, props.logoImageProps)))),
190
190
  !props.logoImageProps && props.imageProps && renderImage(Image, props.imageProps)),
@@ -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;
@@ -2,6 +2,7 @@ export { default as Accordion } from './Accordion/Accordion';
2
2
  export { default as AccordionItem } from './AccordionItem/AccordionItem';
3
3
  export { default as AmountSelector } from './AmountSelector/AmountSelector';
4
4
  export { default as Box } from './Box/Box';
5
+ export { default as Breadcrumb } from './Breadcrumb/Breadcrumb';
5
6
  export { default as Button } from './Button/Button';
6
7
  export { default as ButtonArrow } from './ButtonArrow/ButtonArrow';
7
8
  export { default as ButtonCard } from './ButtonCard/ButtonCard';
@@ -46,6 +47,7 @@ export { default as ReadMore } from './ReadMore/ReadMore';
46
47
  export { default as Search } from './Search/Search';
47
48
  export { default as SecondaryNavigation } from './SecondaryNavigation/SecondaryNavigation';
48
49
  export { default as Selectbox } from './Selectbox/Selectbox';
50
+ export { default as Skeleton } from './Skeleton/Skeleton';
49
51
  export { default as Switch } from './Switch/Switch';
50
52
  export { default as Tab } from './Tab/Tab';
51
53
  export { default as Tabs } from './Tabs/Tabs';
@@ -4,6 +4,7 @@ var Accordion = require('./components/Accordion/Accordion.js');
4
4
  var AccordionItem = require('./components/AccordionItem/AccordionItem.js');
5
5
  var AmountSelector = require('./components/AmountSelector/AmountSelector.js');
6
6
  var Box = require('./components/Box/Box.js');
7
+ var Breadcrumb = require('./components/Breadcrumb/Breadcrumb.js');
7
8
  var Button = require('./components/Button/Button.js');
8
9
  var ButtonArrow = require('./components/ButtonArrow/ButtonArrow.js');
9
10
  var ButtonCard = require('./components/ButtonCard/ButtonCard.js');
@@ -156,6 +157,7 @@ var ReadMore = require('./components/ReadMore/ReadMore.js');
156
157
  var Search = require('./components/Search/Search.js');
157
158
  var SecondaryNavigation = require('./components/SecondaryNavigation/SecondaryNavigation.js');
158
159
  var Selectbox = require('./components/Selectbox/Selectbox.js');
160
+ var Skeleton = require('./components/Skeleton/Skeleton.js');
159
161
  var Switch = require('./components/Switch/Switch.js');
160
162
  var Tab = require('./components/Tab/Tab.js');
161
163
  var Tabs = require('./components/Tabs/Tabs.js');
@@ -175,6 +177,7 @@ exports.Accordion = Accordion.default;
175
177
  exports.AccordionItem = AccordionItem.default;
176
178
  exports.AmountSelector = AmountSelector.default;
177
179
  exports.Box = Box.default;
180
+ exports.Breadcrumb = Breadcrumb.default;
178
181
  exports.Button = Button.default;
179
182
  exports.ButtonArrow = ButtonArrow.default;
180
183
  exports.ButtonCard = ButtonCard.default;
@@ -328,6 +331,7 @@ exports.ReadMore = ReadMore.default;
328
331
  exports.Search = Search.default;
329
332
  exports.SecondaryNavigation = SecondaryNavigation.default;
330
333
  exports.Selectbox = Selectbox.default;
334
+ exports.Skeleton = Skeleton.default;
331
335
  exports.Switch = Switch.default;
332
336
  exports.Tab = Tab.default;
333
337
  exports.Tabs = Tabs.default;
@@ -1,3 +1,4 @@
1
+ import "../assets/fonts/fonts.css";
1
2
  'use strict';
2
3
 
3
4
  var styledUtils = require('../utils/styledUtils.js');
@@ -9,7 +9,14 @@ declare const theme: {
9
9
  unit: string;
10
10
  };
11
11
  };
12
- breakpoints: import("./themeComponents/breakpoints").ViewBreakpoints;
12
+ breakpoints: {
13
+ readonly xxl: 1440;
14
+ readonly xl: 1200;
15
+ readonly lg: 992;
16
+ readonly md: 768;
17
+ readonly sm: 576;
18
+ readonly xs: 480;
19
+ };
13
20
  color: {
14
21
  default: {
15
22
  pink: string;
@@ -155,7 +162,7 @@ declare const theme: {
155
162
  h1: string;
156
163
  h2: string;
157
164
  };
158
- media: Record<string | number, (l: TemplateStringsArray, ...p: (string | number)[]) => string>;
165
+ media: Record<"xxl" | "xl" | "lg" | "md" | "sm" | "xs", (l: TemplateStringsArray, ...p: (string | number)[]) => ReturnType<typeof import("styled-components").css>>;
159
166
  radius: {
160
167
  default: string;
161
168
  s: string;
@@ -1,5 +1,10 @@
1
- export interface ViewBreakpoints {
2
- [key: string]: number;
3
- }
4
- declare const breakpoints: ViewBreakpoints;
1
+ declare const breakpoints: {
2
+ readonly xxl: 1440;
3
+ readonly xl: 1200;
4
+ readonly lg: 992;
5
+ readonly md: 768;
6
+ readonly sm: 576;
7
+ readonly xs: 480;
8
+ };
9
+ export type ViewBreakpoints = typeof breakpoints;
5
10
  export default breakpoints;