@dnanpm/styleguide 3.12.1 → 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.
- package/build/cjs/components/Breadcrumb/Breadcrumb.d.ts +42 -0
- package/build/cjs/components/Breadcrumb/Breadcrumb.js +90 -0
- package/build/cjs/components/Carousel/Carousel.d.ts +11 -14
- package/build/cjs/components/Carousel/Carousel.js +52 -40
- package/build/cjs/components/Hero/Hero.d.ts +0 -6
- package/build/cjs/components/Hero/Hero.js +3 -3
- package/build/cjs/components/index.d.ts +1 -0
- package/build/cjs/index.js +2 -0
- package/build/cjs/themes/globalStyles.js +1 -0
- package/build/cjs/themes/theme.d.ts +9 -2
- package/build/cjs/themes/themeComponents/breakpoints.d.ts +9 -4
- package/build/cjs/utils/styledUtils.d.ts +22 -1
- package/build/cjs/utils/styledUtils.js +26 -6
- package/build/es/components/Breadcrumb/Breadcrumb.d.ts +42 -0
- package/build/es/components/Breadcrumb/Breadcrumb.js +82 -0
- package/build/es/components/Carousel/Carousel.d.ts +11 -14
- package/build/es/components/Carousel/Carousel.js +52 -40
- package/build/es/components/Hero/Hero.d.ts +0 -6
- package/build/es/components/Hero/Hero.js +3 -3
- package/build/es/components/index.d.ts +1 -0
- package/build/es/index.js +1 -0
- package/build/es/themes/globalStyles.js +1 -0
- package/build/es/themes/theme.d.ts +9 -2
- package/build/es/themes/themeComponents/breakpoints.d.ts +9 -4
- package/build/es/utils/styledUtils.d.ts +22 -1
- package/build/es/utils/styledUtils.js +26 -6
- package/package.json +9 -5
|
@@ -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
|
|
54
|
-
*
|
|
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?:
|
|
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>,
|
|
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
|
-
|
|
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
|
-
|
|
56
|
-
|
|
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
|
|
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 [
|
|
162
|
+
const [autoVisibleItems, setAutoVisibleItems] = React.useState(null);
|
|
158
163
|
React.useEffect(() => {
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
const
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
|
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((
|
|
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
|
-
|
|
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,
|
|
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
|
|
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" })))),
|
|
@@ -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
|
-
${({ $
|
|
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}
|
|
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, { "$
|
|
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)),
|
|
@@ -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';
|
package/build/cjs/index.js
CHANGED
|
@@ -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');
|
|
@@ -176,6 +177,7 @@ exports.Accordion = Accordion.default;
|
|
|
176
177
|
exports.AccordionItem = AccordionItem.default;
|
|
177
178
|
exports.AmountSelector = AmountSelector.default;
|
|
178
179
|
exports.Box = Box.default;
|
|
180
|
+
exports.Breadcrumb = Breadcrumb.default;
|
|
179
181
|
exports.Button = Button.default;
|
|
180
182
|
exports.ButtonArrow = ButtonArrow.default;
|
|
181
183
|
exports.ButtonCard = ButtonCard.default;
|
|
@@ -9,7 +9,14 @@ declare const theme: {
|
|
|
9
9
|
unit: string;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
breakpoints:
|
|
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<
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { css } from '../themes/styled';
|
|
1
2
|
export declare const getMultipliedSize: (base: {
|
|
2
3
|
value: number;
|
|
3
4
|
unit: string;
|
|
@@ -6,4 +7,24 @@ export declare const getDividedSize: (base: {
|
|
|
6
7
|
value: number;
|
|
7
8
|
unit: string;
|
|
8
9
|
}, divide: number) => string;
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Media query helpers for responsive design.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const StyledDiv = styled.div`
|
|
16
|
+
* font-size: 1rem;
|
|
17
|
+
* ${media.md`font-size: 1.2rem;`}
|
|
18
|
+
* ${media.lg`font-size: 1.5rem;`}
|
|
19
|
+
* `;
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Available breakpoints:
|
|
23
|
+
* - `xs`: 480px
|
|
24
|
+
* - `sm`: 576px
|
|
25
|
+
* - `md`: 768px
|
|
26
|
+
* - `lg`: 992px
|
|
27
|
+
* - `xl`: 1200px
|
|
28
|
+
* - `xxl`: 1440px
|
|
29
|
+
*/
|
|
30
|
+
export declare const media: Record<"xxl" | "xl" | "lg" | "md" | "sm" | "xs", (l: TemplateStringsArray, ...p: (string | number)[]) => ReturnType<typeof css>>;
|
|
@@ -5,12 +5,32 @@ var breakpoints = require('../themes/themeComponents/breakpoints.js');
|
|
|
5
5
|
|
|
6
6
|
const getMultipliedSize = (base, multiply) => `${multiply * base.value}${base.unit}`;
|
|
7
7
|
const getDividedSize = (base, divide) => `${base.value / divide}${base.unit}`;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Media query helpers for responsive design.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const StyledDiv = styled.div`
|
|
14
|
+
* font-size: 1rem;
|
|
15
|
+
* ${media.md`font-size: 1.2rem;`}
|
|
16
|
+
* ${media.lg`font-size: 1.5rem;`}
|
|
17
|
+
* `;
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Available breakpoints:
|
|
21
|
+
* - `xs`: 480px
|
|
22
|
+
* - `sm`: 576px
|
|
23
|
+
* - `md`: 768px
|
|
24
|
+
* - `lg`: 992px
|
|
25
|
+
* - `xl`: 1200px
|
|
26
|
+
* - `xxl`: 1440px
|
|
27
|
+
*/
|
|
28
|
+
const media = Object.keys(breakpoints.default).reduce((acc, key) => {
|
|
29
|
+
acc[key] = (literals, ...placeholders) => styledComponents.css `
|
|
30
|
+
@media (min-width: ${breakpoints.default[key]}px) {
|
|
31
|
+
${styledComponents.css(literals, ...placeholders)}
|
|
32
|
+
}
|
|
33
|
+
`;
|
|
14
34
|
return acc;
|
|
15
35
|
}, {});
|
|
16
36
|
|
|
@@ -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,82 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
import { ChevronRight } from '@dnanpm/icons';
|
|
3
|
+
import { styled } from 'styled-components';
|
|
4
|
+
import theme from '../../themes/theme.js';
|
|
5
|
+
import { getMultipliedSize } from '../../utils/styledUtils.js';
|
|
6
|
+
|
|
7
|
+
const BreadcrumbNav = styled.nav `
|
|
8
|
+
font-size: ${theme.fontSize.s};
|
|
9
|
+
font-weight: ${theme.fontWeight.medium};
|
|
10
|
+
`;
|
|
11
|
+
const BreadcrumbList = styled.ol `
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
flex-wrap: nowrap;
|
|
15
|
+
list-style: none;
|
|
16
|
+
margin: ${getMultipliedSize(theme.base.baseHeight, 2)} 0;
|
|
17
|
+
padding: 0;
|
|
18
|
+
gap: ${getMultipliedSize(theme.base.baseHeight, 0.5)};
|
|
19
|
+
overflow: visible;
|
|
20
|
+
container: breadcrumb / inline-size;
|
|
21
|
+
|
|
22
|
+
/* Responsive behavior: show only last 2 items when container < 600px */
|
|
23
|
+
@container (max-width: 599px) {
|
|
24
|
+
li:not(:nth-last-child(-n + 2)) {
|
|
25
|
+
display: none;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
const BreadcrumbListItem = styled.li `
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
gap: ${getMultipliedSize(theme.base.baseHeight, 0.5)};
|
|
33
|
+
|
|
34
|
+
&:last-child {
|
|
35
|
+
min-width: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
a {
|
|
39
|
+
&:focus-visible {
|
|
40
|
+
outline: none;
|
|
41
|
+
border-radius: ${theme.radius.s};
|
|
42
|
+
box-shadow:
|
|
43
|
+
0px 0px 0px 2px ${theme.color.focus.light},
|
|
44
|
+
0px 0px 0px 4px ${theme.color.focus.dark};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
span {
|
|
49
|
+
flex: 1 1 0%;
|
|
50
|
+
white-space: nowrap;
|
|
51
|
+
overflow: hidden;
|
|
52
|
+
text-overflow: ellipsis;
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
const Breadcrumb = ({ 'data-testid': dataTestId, ariaLabel, className, items, linkComponent: LinkComponent, linkProps = {}, }) => {
|
|
56
|
+
if (!items || items.length === 0) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const renderItem = (item, index) => {
|
|
60
|
+
const isLastItem = index === items.length - 1;
|
|
61
|
+
if (isLastItem || !item.href) {
|
|
62
|
+
return React__default.createElement("span", { "aria-current": isLastItem ? 'page' : undefined }, item.label);
|
|
63
|
+
}
|
|
64
|
+
if (LinkComponent) {
|
|
65
|
+
return (React__default.createElement(LinkComponent, Object.assign({ href: item.href, itemProp: "item", itemScope: true, itemType: "https://schema.org/WebPage" }, linkProps),
|
|
66
|
+
React__default.createElement("span", { itemProp: "name" }, item.label)));
|
|
67
|
+
}
|
|
68
|
+
return (React__default.createElement("a", { href: item.href, itemProp: "item", itemScope: true, itemType: "https://schema.org/WebPage" },
|
|
69
|
+
React__default.createElement("span", { itemProp: "name" }, item.label)));
|
|
70
|
+
};
|
|
71
|
+
return (React__default.createElement(BreadcrumbNav, { "aria-label": ariaLabel, className: className, "data-testid": dataTestId },
|
|
72
|
+
React__default.createElement(BreadcrumbList, { itemScope: true, itemType: "https://schema.org/BreadcrumbList" }, items.map((item, index) => {
|
|
73
|
+
var _a;
|
|
74
|
+
const isLastItem = index === items.length - 1;
|
|
75
|
+
return (React__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'}` },
|
|
76
|
+
renderItem(item, index),
|
|
77
|
+
React__default.createElement("meta", { itemProp: "position", content: (index + 1).toString() }),
|
|
78
|
+
!isLastItem && (React__default.createElement(ChevronRight, { color: theme.color.background.pink.default, size: "0.9rem" }))));
|
|
79
|
+
}))));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export { Breadcrumb as default };
|
|
@@ -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
|
|
54
|
-
*
|
|
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?:
|
|
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>,
|
|
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
|
-
|
|
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 */
|
|
@@ -33,7 +33,6 @@ const SlidesWrapper = styled.div `
|
|
|
33
33
|
display: flex;
|
|
34
34
|
width: 100%;
|
|
35
35
|
height: 100%;
|
|
36
|
-
gap: ${({ $gap }) => $gap}rem;
|
|
37
36
|
transition-property: transform;
|
|
38
37
|
transform: translate3d(0px, 0, 0);
|
|
39
38
|
transition-duration: 0ms;
|
|
@@ -44,9 +43,14 @@ const SlideItem = styled.div `
|
|
|
44
43
|
display: block;
|
|
45
44
|
position: relative;
|
|
46
45
|
flex-shrink: 0;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
)
|
|
46
|
+
padding-right: ${({ $gap }) => $gap}rem;
|
|
47
|
+
|
|
48
|
+
${({ $responsive, $visibleItems }) => !$responsive && $visibleItems
|
|
49
|
+
? `flex-basis: calc(100% / ${$visibleItems});`
|
|
50
|
+
: `
|
|
51
|
+
flex-basis: auto;
|
|
52
|
+
width: max-content;
|
|
53
|
+
`}
|
|
50
54
|
|
|
51
55
|
a {
|
|
52
56
|
pointer-events: ${({ $isSwiping }) => ($isSwiping ? 'none' : 'auto')};
|
|
@@ -138,53 +142,51 @@ const Counter = styled.span `
|
|
|
138
142
|
`;
|
|
139
143
|
/** @visibleName Carousel */
|
|
140
144
|
const Carousel = (_a) => {
|
|
141
|
-
var _b;
|
|
145
|
+
var _b, _c;
|
|
142
146
|
var { 'data-testid': dataTestId } = _a, props = __rest(_a, ['data-testid']);
|
|
143
147
|
const slidesWrapperRef = useRef(null);
|
|
144
148
|
const scrollbarRef = useRef(null);
|
|
145
149
|
const knobRef = useRef(null);
|
|
146
|
-
const
|
|
150
|
+
const firstItemRef = useRef(null);
|
|
151
|
+
const { isMobile, width: windowWidth } = useWindowSize(theme.breakpoints.md);
|
|
147
152
|
const [currentIndex, setCurrentIndex] = useState(0);
|
|
148
153
|
const [isSwiping, setIsSwiping] = useState(false);
|
|
149
|
-
const [
|
|
154
|
+
const [autoVisibleItems, setAutoVisibleItems] = useState(null);
|
|
150
155
|
useEffect(() => {
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
if (props.responsive) {
|
|
157
|
+
const container = slidesWrapperRef.current;
|
|
158
|
+
const firstItem = firstItemRef.current;
|
|
159
|
+
if (container && firstItem) {
|
|
160
|
+
Array.from(container.children).forEach(itemElement => {
|
|
161
|
+
const item = itemElement;
|
|
162
|
+
item.style.flexBasis = '';
|
|
163
|
+
item.style.width = '';
|
|
164
|
+
});
|
|
165
|
+
const containerWidth = container.offsetWidth;
|
|
166
|
+
const itemWidth = firstItem.offsetWidth;
|
|
167
|
+
if (itemWidth > 0) {
|
|
168
|
+
const realVisibleItems = containerWidth / itemWidth;
|
|
169
|
+
setAutoVisibleItems(Math.max(1, realVisibleItems));
|
|
170
|
+
}
|
|
160
171
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const timeoutId = setTimeout(() => {
|
|
167
|
-
setCalculatedItems(calculateVisibleItems());
|
|
168
|
-
}, 100);
|
|
169
|
-
return () => clearTimeout(timeoutId);
|
|
170
|
-
}, [width, isMobile, props.responsive, props.visibleItems, props.children]);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
setAutoVisibleItems(null);
|
|
175
|
+
}
|
|
176
|
+
}, [props.responsive, windowWidth, props.children]);
|
|
171
177
|
const getStep = (step, visibleItems) => {
|
|
172
178
|
if (step > visibleItems) {
|
|
173
179
|
return Math.floor(visibleItems);
|
|
174
180
|
}
|
|
175
181
|
return Math.floor(step);
|
|
176
182
|
};
|
|
177
|
-
const visibleItems = props.visibleItems
|
|
183
|
+
const visibleItems = (_b = autoVisibleItems !== null && autoVisibleItems !== void 0 ? autoVisibleItems : props.visibleItems) !== null && _b !== void 0 ? _b : (isMobile ? 1.2 : 1);
|
|
178
184
|
const slidesWrapperGapSizePx = 20;
|
|
179
185
|
const slidesCount = Children.count(props.children);
|
|
180
186
|
const slideScreensCount = Math.max(1, slidesCount - Math.floor(visibleItems) + 1);
|
|
181
|
-
const step = getStep((
|
|
187
|
+
const step = getStep((_c = props.swipeStep) !== null && _c !== void 0 ? _c : 1, visibleItems);
|
|
182
188
|
const currentStepIndex = Math.ceil(currentIndex / step);
|
|
183
189
|
const totalSwipeSteps = Math.ceil(slideScreensCount / step + ((slideScreensCount - 1) % step !== 0 ? 1 : 0));
|
|
184
|
-
const itemWidthCorrectionRatio = (slidesWrapperGapSizePx * visibleItems) % Math.floor(visibleItems) === 0
|
|
185
|
-
? (visibleItems - 1) / visibleItems
|
|
186
|
-
: Math.floor(visibleItems) / visibleItems;
|
|
187
|
-
const itemWidthCorrection = itemWidthCorrectionRatio * slidesWrapperGapSizePx;
|
|
188
190
|
const data = useMemo(() => ({
|
|
189
191
|
startX: 0,
|
|
190
192
|
startTime: 0,
|
|
@@ -320,12 +322,10 @@ const Carousel = (_a) => {
|
|
|
320
322
|
useEffect(() => {
|
|
321
323
|
if (slidesWrapperRef.current && scrollbarRef.current) {
|
|
322
324
|
const isRest = Children.count(props.children) - (currentIndex + visibleItems) < 0;
|
|
323
|
-
data.itemWidth =
|
|
324
|
-
slidesWrapperRef.current.offsetWidth / visibleItems - itemWidthCorrection;
|
|
325
|
+
data.itemWidth = slidesWrapperRef.current.offsetWidth / visibleItems;
|
|
325
326
|
data.scrollWidth = slidesWrapperRef.current.scrollWidth;
|
|
326
327
|
data.lastItemX =
|
|
327
|
-
|
|
328
|
-
(Children.count(props.children) - visibleItems) -
|
|
328
|
+
data.itemWidth * (Children.count(props.children) - visibleItems) -
|
|
329
329
|
(isRest ? slidesWrapperGapSizePx * (Math.ceil(visibleItems) - visibleItems) : 0);
|
|
330
330
|
data.scrollbarToSlidesRatio =
|
|
331
331
|
data.lastItemX /
|
|
@@ -334,14 +334,26 @@ const Carousel = (_a) => {
|
|
|
334
334
|
let slidesTransform = 0;
|
|
335
335
|
if (Children.count(props.children) >= visibleItems) {
|
|
336
336
|
slidesTransform =
|
|
337
|
-
data.itemWidth * currentIndex
|
|
338
|
-
slidesWrapperGapSizePx * currentIndex -
|
|
337
|
+
data.itemWidth * currentIndex -
|
|
339
338
|
(isRest ? data.itemWidth * (visibleItems % 1) + slidesWrapperGapSizePx : 0);
|
|
340
339
|
}
|
|
341
340
|
setElementTransform(slidesWrapperRef, -slidesTransform);
|
|
342
341
|
setElementTransform(knobRef, slidesTransform / data.scrollbarToSlidesRatio);
|
|
343
342
|
}
|
|
344
|
-
}, [currentIndex, data,
|
|
343
|
+
}, [currentIndex, data, props.children, slideScreensCount, visibleItems]);
|
|
344
|
+
useEffect(() => {
|
|
345
|
+
var _a;
|
|
346
|
+
if (props.responsive && autoVisibleItems) {
|
|
347
|
+
const items = (_a = slidesWrapperRef.current) === null || _a === void 0 ? void 0 : _a.children;
|
|
348
|
+
if (items) {
|
|
349
|
+
Array.from(items).forEach(itemElement => {
|
|
350
|
+
const item = itemElement;
|
|
351
|
+
item.style.flexBasis = `calc(100% / ${autoVisibleItems})`;
|
|
352
|
+
item.style.width = '';
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}, [autoVisibleItems, props.responsive]);
|
|
345
357
|
return (React__default.createElement(CarouselWrapper, { id: props.id, className: props.className, "data-testid": dataTestId },
|
|
346
358
|
React__default.createElement(Header, { "data-testid": dataTestId && `${dataTestId}-header` },
|
|
347
359
|
props.title && React__default.createElement(Title, null, props.title),
|
|
@@ -353,7 +365,7 @@ const Carousel = (_a) => {
|
|
|
353
365
|
React__default.createElement(ButtonArrow, { direction: "left", "aria-label": props.previousAriaLabel, onClick: handleNavigationButtonPreviousClick, disabled: currentIndex <= 0, type: "button" }),
|
|
354
366
|
React__default.createElement(ButtonArrow, { direction: "right", "aria-label": props.nextAriaLabel, onClick: handleNavigationButtonNextClick, disabled: currentIndex + visibleItems >= Children.count(props.children), type: "button" }))),
|
|
355
367
|
React__default.createElement(Content, { "data-testid": dataTestId && `${dataTestId}-content` },
|
|
356
|
-
React__default.createElement(SlidesWrapper, { ref: slidesWrapperRef, onPointerDown: handleSlidesPointerDown
|
|
368
|
+
React__default.createElement(SlidesWrapper, { ref: slidesWrapperRef, onPointerDown: handleSlidesPointerDown }, Children.map(props.children, (child, index) => (React__default.createElement(SlideItem, { ref: index === 0 ? firstItemRef : undefined, "$visibleItems": visibleItems, "$isSwiping": isSwiping, onPointerDown: handlePointerDown, "$responsive": Boolean(props.responsive), "$gap": slidesWrapperGapSizePx / 16 }, child))))),
|
|
357
369
|
React__default.createElement(Footer, { "data-testid": dataTestId && `${dataTestId}-footer` },
|
|
358
370
|
React__default.createElement(Pagination, null, [...Array(totalSwipeSteps).keys()].map((value, index) => (React__default.createElement(PaginationItem, { key: value, "aria-label": props.paginationAriaLabel &&
|
|
359
371
|
`${props.paginationAriaLabel} ${index + 1}`, "aria-current": Math.ceil(currentIndex / step) === index, "$isActive": Math.ceil(currentIndex / step) === index, onClick: handlePaginationItemClick, type: "button" })))),
|
|
@@ -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
|
*/
|
|
@@ -27,9 +27,9 @@ const HeroImage = styled.div `
|
|
|
27
27
|
height: ${HERO_CONSTANTS.mobileHeight}px;
|
|
28
28
|
background-color: ${({ $backgroundColor }) => $backgroundColor || 'transparent'};
|
|
29
29
|
|
|
30
|
-
${({ $
|
|
30
|
+
${({ $backgroundColor }) => $backgroundColor &&
|
|
31
31
|
`
|
|
32
|
-
linear-gradient(180deg, ${theme.color.background.plum.default}${theme.color.transparency.T0} 0%, ${theme.color.background.plum.default}${theme.color.transparency.T30}
|
|
32
|
+
background-image: linear-gradient(180deg, ${theme.color.background.plum.default}${theme.color.transparency.T0} 0%, ${theme.color.background.plum.default}${theme.color.transparency.T30} 100%);
|
|
33
33
|
background-size: 100% 33.33%;
|
|
34
34
|
background-repeat: no-repeat;
|
|
35
35
|
background-position: bottom;
|
|
@@ -176,7 +176,7 @@ const Hero = (_a) => {
|
|
|
176
176
|
var { variant = 'default', headingLevel = 'h1', Image = 'img', LogoImage = 'img', 'data-testid': dataTestId } = _a, props = __rest(_a, ["variant", "headingLevel", "Image", "LogoImage", 'data-testid']);
|
|
177
177
|
const HeadingTag = headingLevel;
|
|
178
178
|
return (React__default.createElement(HeroContainer, { "$variant": variant, className: props.className, "data-testid": dataTestId },
|
|
179
|
-
React__default.createElement(HeroImage, { "$
|
|
179
|
+
React__default.createElement(HeroImage, { "$backgroundColor": props.backgroundColor },
|
|
180
180
|
props.logoImageProps && (React__default.createElement(LogoImageWrap, null,
|
|
181
181
|
React__default.createElement(LogoImageContainer, null, renderImage(LogoImage, props.logoImageProps)))),
|
|
182
182
|
!props.logoImageProps && props.imageProps && renderImage(Image, props.imageProps)),
|
|
@@ -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';
|
package/build/es/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export { default as Accordion } from './components/Accordion/Accordion.js';
|
|
|
2
2
|
export { default as AccordionItem } from './components/AccordionItem/AccordionItem.js';
|
|
3
3
|
export { default as AmountSelector } from './components/AmountSelector/AmountSelector.js';
|
|
4
4
|
export { default as Box } from './components/Box/Box.js';
|
|
5
|
+
export { default as Breadcrumb } from './components/Breadcrumb/Breadcrumb.js';
|
|
5
6
|
export { default as Button } from './components/Button/Button.js';
|
|
6
7
|
export { default as ButtonArrow } from './components/ButtonArrow/ButtonArrow.js';
|
|
7
8
|
export { default as ButtonCard } from './components/ButtonCard/ButtonCard.js';
|
|
@@ -9,7 +9,14 @@ declare const theme: {
|
|
|
9
9
|
unit: string;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
breakpoints:
|
|
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<
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { css } from '../themes/styled';
|
|
1
2
|
export declare const getMultipliedSize: (base: {
|
|
2
3
|
value: number;
|
|
3
4
|
unit: string;
|
|
@@ -6,4 +7,24 @@ export declare const getDividedSize: (base: {
|
|
|
6
7
|
value: number;
|
|
7
8
|
unit: string;
|
|
8
9
|
}, divide: number) => string;
|
|
9
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Media query helpers for responsive design.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* const StyledDiv = styled.div`
|
|
16
|
+
* font-size: 1rem;
|
|
17
|
+
* ${media.md`font-size: 1.2rem;`}
|
|
18
|
+
* ${media.lg`font-size: 1.5rem;`}
|
|
19
|
+
* `;
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Available breakpoints:
|
|
23
|
+
* - `xs`: 480px
|
|
24
|
+
* - `sm`: 576px
|
|
25
|
+
* - `md`: 768px
|
|
26
|
+
* - `lg`: 992px
|
|
27
|
+
* - `xl`: 1200px
|
|
28
|
+
* - `xxl`: 1440px
|
|
29
|
+
*/
|
|
30
|
+
export declare const media: Record<"xxl" | "xl" | "lg" | "md" | "sm" | "xs", (l: TemplateStringsArray, ...p: (string | number)[]) => ReturnType<typeof css>>;
|
|
@@ -3,12 +3,32 @@ import breakpoints from '../themes/themeComponents/breakpoints.js';
|
|
|
3
3
|
|
|
4
4
|
const getMultipliedSize = (base, multiply) => `${multiply * base.value}${base.unit}`;
|
|
5
5
|
const getDividedSize = (base, divide) => `${base.value / divide}${base.unit}`;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Media query helpers for responsive design.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const StyledDiv = styled.div`
|
|
12
|
+
* font-size: 1rem;
|
|
13
|
+
* ${media.md`font-size: 1.2rem;`}
|
|
14
|
+
* ${media.lg`font-size: 1.5rem;`}
|
|
15
|
+
* `;
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* Available breakpoints:
|
|
19
|
+
* - `xs`: 480px
|
|
20
|
+
* - `sm`: 576px
|
|
21
|
+
* - `md`: 768px
|
|
22
|
+
* - `lg`: 992px
|
|
23
|
+
* - `xl`: 1200px
|
|
24
|
+
* - `xxl`: 1440px
|
|
25
|
+
*/
|
|
26
|
+
const media = Object.keys(breakpoints).reduce((acc, key) => {
|
|
27
|
+
acc[key] = (literals, ...placeholders) => css `
|
|
28
|
+
@media (min-width: ${breakpoints[key]}px) {
|
|
29
|
+
${css(literals, ...placeholders)}
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
12
32
|
return acc;
|
|
13
33
|
}, {});
|
|
14
34
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dnanpm/styleguide",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "v3.12.
|
|
4
|
+
"version": "v3.12.2",
|
|
5
5
|
"main": "build/cjs/index.js",
|
|
6
6
|
"module": "build/es/index.js",
|
|
7
7
|
"jsnext:main": "build/es/index.js",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
],
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
21
|
-
"url": "git@github.com:DNA-Online-Services/styleguide.git"
|
|
21
|
+
"url": "git@github.com:DNA-Online-Services/styleguide.git",
|
|
22
|
+
"directory": "packages/styleguide"
|
|
22
23
|
},
|
|
23
24
|
"scripts": {
|
|
24
25
|
"build": "rm -rf build && rollup -c",
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
"@babel/preset-react": "^7.26.3",
|
|
49
50
|
"@babel/preset-typescript": "^7.27.1",
|
|
50
51
|
"@dnanpm/icons": "^2.0.9",
|
|
51
|
-
"@rollup/plugin-commonjs": "^
|
|
52
|
+
"@rollup/plugin-commonjs": "^29.0.0",
|
|
52
53
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
53
54
|
"@rollup/plugin-typescript": "^12.1.2",
|
|
54
55
|
"@testing-library/jest-dom": "^6.6.3",
|
|
@@ -88,14 +89,14 @@
|
|
|
88
89
|
"react-dom": "^18.3.1",
|
|
89
90
|
"react-styleguidist": "^13.1.4",
|
|
90
91
|
"rollup": "^3.29.4",
|
|
91
|
-
"rollup-plugin-import-css": "^
|
|
92
|
+
"rollup-plugin-import-css": "^4.1.0",
|
|
92
93
|
"style-loader": "^3.3.3",
|
|
93
94
|
"styled-components": "^6.1.19",
|
|
94
95
|
"ts-jest": "^29.3.2",
|
|
95
96
|
"ts-node": "^10.9.2",
|
|
96
97
|
"tslib": "^2.8.1",
|
|
97
98
|
"typescript": "^5.1.6",
|
|
98
|
-
"webpack": "^5.
|
|
99
|
+
"webpack": "^5.102.1"
|
|
99
100
|
},
|
|
100
101
|
"dependencies": {
|
|
101
102
|
"ramda": "^0.32.0",
|
|
@@ -110,5 +111,8 @@
|
|
|
110
111
|
"react": ">=17.x <=19.x",
|
|
111
112
|
"react-dom": ">=17.x <=19.x",
|
|
112
113
|
"styled-components": "6.x"
|
|
114
|
+
},
|
|
115
|
+
"engines": {
|
|
116
|
+
"node": ">=20"
|
|
113
117
|
}
|
|
114
118
|
}
|