oddsgate-ds 1.0.113 → 1.0.115
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/dist/cjs/index.js +5 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/atoms/Marquee/Marquee.component.d.ts +1 -1
- package/dist/cjs/types/components/atoms/Marquee/Marquee.interface.d.ts +11 -5
- package/dist/cjs/types/components/organisms/ProductsSlider/ProductsSlider.component.d.ts +4 -0
- package/dist/cjs/types/components/organisms/ProductsSlider/ProductsSlider.interface.d.ts +11 -0
- package/dist/cjs/types/components/organisms/ProductsSlider/ProductsSlider.theme.d.ts +7 -0
- package/dist/cjs/types/components/organisms/ProductsSlider/index.d.ts +1 -0
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/esm/index.js +5 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/atoms/Marquee/Marquee.component.d.ts +1 -1
- package/dist/esm/types/components/atoms/Marquee/Marquee.interface.d.ts +11 -5
- package/dist/esm/types/components/organisms/ProductsSlider/ProductsSlider.component.d.ts +4 -0
- package/dist/esm/types/components/organisms/ProductsSlider/ProductsSlider.interface.d.ts +11 -0
- package/dist/esm/types/components/organisms/ProductsSlider/ProductsSlider.theme.d.ts +7 -0
- package/dist/esm/types/components/organisms/ProductsSlider/index.d.ts +1 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/types.d.ts +26 -7
- package/package.json +1 -1
- package/src/components/atoms/Marquee/Marquee.component.tsx +12 -7
- package/src/components/atoms/Marquee/Marquee.interface.ts +12 -5
- package/src/components/atoms/Marquee/Marquee.stories.tsx +3 -1
- package/src/components/atoms/Marquee/Marquee.theme.ts +35 -27
- package/src/components/organisms/CircularSlider/CircularSlider.theme.ts +1 -7
- package/src/components/organisms/{CircularSliderTeste/CircularSliderTeste.component.tsx → ProductsSlider/ProductsSlider.component.tsx} +74 -55
- package/src/components/organisms/ProductsSlider/ProductsSlider.interface.ts +12 -0
- package/src/components/organisms/ProductsSlider/ProductsSlider.stories.tsx +133 -0
- package/src/components/organisms/ProductsSlider/ProductsSlider.theme.ts +66 -0
- package/src/components/organisms/ProductsSlider/index.ts +1 -0
- package/src/index.ts +1 -0
- package/dist/cjs/types/components/organisms/CircularSliderTeste/CircularSliderTeste.component.d.ts +0 -4
- package/dist/cjs/types/components/organisms/CircularSliderTeste/CircularSliderTeste.interface.d.ts +0 -12
- package/dist/cjs/types/components/organisms/CircularSliderTeste/CircularSliderTeste.theme.d.ts +0 -7
- package/dist/cjs/types/components/organisms/CircularSliderTeste/index.d.ts +0 -1
- package/dist/esm/types/components/organisms/CircularSliderTeste/CircularSliderTeste.component.d.ts +0 -4
- package/dist/esm/types/components/organisms/CircularSliderTeste/CircularSliderTeste.interface.d.ts +0 -12
- package/dist/esm/types/components/organisms/CircularSliderTeste/CircularSliderTeste.theme.d.ts +0 -7
- package/dist/esm/types/components/organisms/CircularSliderTeste/index.d.ts +0 -1
- package/src/components/organisms/CircularSliderTeste/CircularSliderTeste.interface.ts +0 -13
- package/src/components/organisms/CircularSliderTeste/CircularSliderTeste.stories.tsx +0 -134
- package/src/components/organisms/CircularSliderTeste/CircularSliderTeste.theme.ts +0 -65
- package/src/components/organisms/CircularSliderTeste/index.ts +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { IMarquee } from './Marquee.interface';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
declare const Marquee: ({
|
|
3
|
+
declare const Marquee: ({ direction, speed, repeatContent, gap, children, }: IMarquee) => React.JSX.Element;
|
|
4
4
|
export default Marquee;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { CSSProperties } from "styled-components";
|
|
3
|
+
export type Direction = 'left' | 'right' | 'up' | 'down';
|
|
4
|
+
export interface IMarquee {
|
|
5
|
+
direction?: Direction;
|
|
6
|
+
repeatContent?: number;
|
|
7
|
+
duration?: number;
|
|
8
|
+
speed?: number;
|
|
9
|
+
gap?: string;
|
|
4
10
|
className?: string;
|
|
5
11
|
style?: CSSProperties;
|
|
6
|
-
|
|
7
|
-
}
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
export type IProductsSlider = {
|
|
3
|
+
id?: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
style?: CSSProperties;
|
|
6
|
+
content?: {
|
|
7
|
+
title?: string;
|
|
8
|
+
description?: string | React.ReactElement;
|
|
9
|
+
imageElement?: React.ReactElement;
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IProductsSlider } from './ProductsSlider.interface';
|
|
3
|
+
export declare const StyledProductsSlider: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, IProductsSlider>> & string;
|
|
4
|
+
export declare const StyledProductsSliderWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, IProductsSlider>> & string;
|
|
5
|
+
export declare const StyledProductsSliderSlides: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, IProductsSlider>> & string;
|
|
6
|
+
export declare const StyledProductsSliderSlide: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, IProductsSlider>> & string;
|
|
7
|
+
export declare const StyledProductsSliderContent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, IProductsSlider>> & string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ProductsSlider.component';
|
|
@@ -44,6 +44,7 @@ export { default as Slider } from './components/organisms/Slider';
|
|
|
44
44
|
export { default as Cover } from './components/organisms/Cover';
|
|
45
45
|
export { default as Tabs } from './components/organisms/Tabs';
|
|
46
46
|
export { default as CircularSlider } from './components/organisms/CircularSlider';
|
|
47
|
+
export { default as ProductsSlider } from './components/organisms/ProductsSlider';
|
|
47
48
|
export { iconsList } from './helpers/getIcons';
|
|
48
49
|
export { default as GlobalStyles } from './styles/Global';
|
|
49
50
|
export { default as clickOutSideToClose } from './helpers/clickOutsideToClose';
|
package/dist/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import * as React$1 from 'react';
|
|
|
2
2
|
import React__default, { CSSProperties } from 'react';
|
|
3
3
|
import { spaces as spaces$1 } from '@/styles/variables';
|
|
4
4
|
import * as styled_components from 'styled-components';
|
|
5
|
+
import { CSSProperties as CSSProperties$1 } from 'styled-components';
|
|
5
6
|
|
|
6
7
|
declare const pxToRem: (size: number) => string;
|
|
7
8
|
declare const fontName = "MD Nichrome";
|
|
@@ -375,14 +376,19 @@ type ISocialLinks = {
|
|
|
375
376
|
|
|
376
377
|
declare const SocialLinks: ({ variant, socials, className, style, ...props }: ISocialLinks) => React__default.JSX.Element;
|
|
377
378
|
|
|
378
|
-
type
|
|
379
|
-
|
|
379
|
+
type Direction = 'left' | 'right' | 'up' | 'down';
|
|
380
|
+
interface IMarquee {
|
|
381
|
+
direction?: Direction;
|
|
382
|
+
repeatContent?: number;
|
|
383
|
+
duration?: number;
|
|
384
|
+
speed?: number;
|
|
385
|
+
gap?: string;
|
|
380
386
|
className?: string;
|
|
381
|
-
style?: CSSProperties;
|
|
382
|
-
|
|
383
|
-
}
|
|
387
|
+
style?: CSSProperties$1;
|
|
388
|
+
children: React.ReactNode;
|
|
389
|
+
}
|
|
384
390
|
|
|
385
|
-
declare const Marquee: ({
|
|
391
|
+
declare const Marquee: ({ direction, speed, repeatContent, gap, children, }: IMarquee) => React__default.JSX.Element;
|
|
386
392
|
|
|
387
393
|
type PortalComponentProps = {
|
|
388
394
|
wrapperId: string;
|
|
@@ -636,6 +642,19 @@ type ICircularSlider = {
|
|
|
636
642
|
|
|
637
643
|
declare const CircularSlider: ({ cta, content, style, className, }: ICircularSlider) => React__default.JSX.Element;
|
|
638
644
|
|
|
645
|
+
type IProductsSlider = {
|
|
646
|
+
id?: string;
|
|
647
|
+
className?: string;
|
|
648
|
+
style?: CSSProperties;
|
|
649
|
+
content?: {
|
|
650
|
+
title?: string;
|
|
651
|
+
description?: string | React.ReactElement;
|
|
652
|
+
imageElement?: React.ReactElement;
|
|
653
|
+
}[];
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
declare const ProductsSlider: ({ content, style, className, }: IProductsSlider) => React__default.JSX.Element;
|
|
657
|
+
|
|
639
658
|
declare const iconsList: string[];
|
|
640
659
|
|
|
641
660
|
declare const GlobalStyles: React$1.NamedExoticComponent<styled_components.ExecutionProps & object>;
|
|
@@ -648,4 +667,4 @@ declare function useMediaMatch(query?: string): boolean;
|
|
|
648
667
|
|
|
649
668
|
declare const debounce: (callback: any, wait: number) => (...args: any) => void;
|
|
650
669
|
|
|
651
|
-
export { Accordion, AccordionItem, BlogCard, Button, CareersCard, CheckRadioField, Chip, CircularSlider, CloseButton, Column, Counter, Cover, Dropdown, DropdownItem, EmptyState, EventsCard, Flex, FormField, GlobalStyles, Heading, Icon, IconBox, IconTitle, ImageWrapper, LicenseCard, Loader, LogosCard, Marquee, Modal, NewsCard, OffCanvas, PortalComponent, ProductCard, Quote, RichText, Row, ScrollingNav, Separator, ShareModal, Slider, SocialLinks, Spacer, Tabs, TeamCard, Video, VideoEmbed, clickOutSideToClose, debounce, iconsList, isTouchDevice, useMediaMatch, variables };
|
|
670
|
+
export { Accordion, AccordionItem, BlogCard, Button, CareersCard, CheckRadioField, Chip, CircularSlider, CloseButton, Column, Counter, Cover, Dropdown, DropdownItem, EmptyState, EventsCard, Flex, FormField, GlobalStyles, Heading, Icon, IconBox, IconTitle, ImageWrapper, LicenseCard, Loader, LogosCard, Marquee, Modal, NewsCard, OffCanvas, PortalComponent, ProductCard, ProductsSlider, Quote, RichText, Row, ScrollingNav, Separator, ShareModal, Slider, SocialLinks, Spacer, Tabs, TeamCard, Video, VideoEmbed, clickOutSideToClose, debounce, iconsList, isTouchDevice, useMediaMatch, variables };
|
package/package.json
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import Heading from '../Heading/Heading.component'
|
|
2
1
|
import { IMarquee } from './Marquee.interface'
|
|
3
2
|
import React from 'react'
|
|
4
3
|
import { StyledMarquee } from './Marquee.theme'
|
|
5
|
-
import cn from 'classnames'
|
|
6
4
|
|
|
7
|
-
const Marquee = ({
|
|
5
|
+
const Marquee = ({
|
|
6
|
+
direction = 'left',
|
|
7
|
+
speed = 20,
|
|
8
|
+
repeatContent = 5,
|
|
9
|
+
gap = '0px',
|
|
10
|
+
children,
|
|
11
|
+
}: IMarquee) => {
|
|
12
|
+
// To ensure continuous flow, duplicate the children multiple times based on the content size and container.
|
|
13
|
+
const content = Array.from({ length: repeatContent }, () => children);
|
|
14
|
+
|
|
8
15
|
return (
|
|
9
|
-
<StyledMarquee
|
|
16
|
+
<StyledMarquee direction={direction} duration={speed} gap={gap}>
|
|
10
17
|
<div>
|
|
11
|
-
|
|
12
|
-
{text} {text} {text}
|
|
13
|
-
</Heading>
|
|
18
|
+
{content}
|
|
14
19
|
</div>
|
|
15
20
|
</StyledMarquee>
|
|
16
21
|
)
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { CSSProperties } from
|
|
1
|
+
import { CSSProperties } from "styled-components";
|
|
2
2
|
|
|
3
|
-
export type
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export type Direction = 'left' | 'right' | 'up' | 'down';
|
|
4
|
+
|
|
5
|
+
export interface IMarquee {
|
|
6
|
+
direction?: Direction;
|
|
7
|
+
repeatContent?: number;
|
|
8
|
+
duration?: number;
|
|
9
|
+
speed?: number;
|
|
10
|
+
gap?: string;
|
|
11
|
+
className?: string;
|
|
6
12
|
style?: CSSProperties
|
|
7
|
-
|
|
13
|
+
children: React.ReactNode;
|
|
8
14
|
}
|
|
15
|
+
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
2
|
|
|
3
|
+
import Heading from '@/components/atoms/Heading/Heading.component'
|
|
3
4
|
import { IMarquee } from './Marquee.interface'
|
|
4
5
|
import Marquee from './Marquee.component'
|
|
5
6
|
import React from 'react'
|
|
@@ -14,6 +15,7 @@ export default {
|
|
|
14
15
|
export const Simple: StoryObj<IMarquee> = {
|
|
15
16
|
render: args => <Marquee {...args} />,
|
|
16
17
|
args: {
|
|
17
|
-
|
|
18
|
+
gap: "1rem",
|
|
19
|
+
children: <Heading>People • Sustainability • Efficiency • Innovation</Heading>
|
|
18
20
|
}
|
|
19
21
|
}
|
|
@@ -1,40 +1,48 @@
|
|
|
1
|
+
import { Direction, IMarquee } from './Marquee.interface';
|
|
1
2
|
import { colors, radius } from '@/styles/variables';
|
|
2
|
-
import styled, { css } from 'styled-components';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import styled, { css, keyframes } from 'styled-components';
|
|
4
|
+
|
|
5
|
+
const getAnimation = (direction?: Direction) => {
|
|
6
|
+
switch (direction) {
|
|
7
|
+
case 'up':
|
|
8
|
+
case 'down':
|
|
9
|
+
return keyframes`
|
|
10
|
+
from { transform: translateY(0); }
|
|
11
|
+
to { transform: translateY(-100%); }
|
|
12
|
+
`;
|
|
13
|
+
case 'left':
|
|
14
|
+
case 'right':
|
|
15
|
+
return keyframes`
|
|
16
|
+
from { transform: translateX(0); }
|
|
17
|
+
to { transform: translateX(-100%); }
|
|
18
|
+
`;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
5
21
|
|
|
6
22
|
export const StyledMarquee = styled.div<IMarquee>`
|
|
23
|
+
display: flex;
|
|
7
24
|
position: relative;
|
|
8
|
-
top: 0;
|
|
9
|
-
left: 0;
|
|
10
25
|
width: 100%;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
--offset: 20vw;
|
|
15
|
-
--move-initial: calc(-25% + var(--offset));
|
|
16
|
-
--move-final: calc(-50% + var(--offset));
|
|
17
|
-
|
|
18
|
-
color: ${colors.primary50};
|
|
19
|
-
|
|
20
|
-
padding: 8px 0;
|
|
26
|
+
height: 100%;
|
|
27
|
+
overflow: hidden;
|
|
21
28
|
|
|
22
|
-
|
|
23
|
-
position: relative;
|
|
29
|
+
&>div{
|
|
24
30
|
display: flex;
|
|
25
|
-
|
|
31
|
+
${({ gap }) => css`gap: ${gap}`};
|
|
26
32
|
white-space: nowrap;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
33
|
+
width: ${({ direction }) => (direction === 'left' || direction === 'right' ? '200%' : 'auto')};
|
|
34
|
+
height: ${({ direction }) => (direction === 'up' || direction === 'down' ? '200%' : 'auto')};
|
|
35
|
+
flex-direction: ${({ direction }) => (direction === 'up' || direction === 'down' ? 'column' : 'row')};
|
|
30
36
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
37
|
+
animation: ${({ direction, duration }) => css`
|
|
38
|
+
${getAnimation(direction)} ${duration}s linear infinite
|
|
39
|
+
`};
|
|
35
40
|
|
|
36
|
-
|
|
37
|
-
|
|
41
|
+
animation-play-state: running; // Ensures the animation is running by default
|
|
42
|
+
|
|
43
|
+
&:hover {
|
|
44
|
+
animation-play-state: paused; // Pauses the animation when hovered
|
|
38
45
|
}
|
|
39
46
|
}
|
|
47
|
+
|
|
40
48
|
`;
|
|
@@ -12,7 +12,7 @@ export const StyledCircularSlider = styled.div<ICircularSlider>`
|
|
|
12
12
|
position:absolute;
|
|
13
13
|
top:50%;
|
|
14
14
|
left:0;
|
|
15
|
-
width:
|
|
15
|
+
width:66.666%;
|
|
16
16
|
height:auto;
|
|
17
17
|
transform: translate(-50%, -50%)
|
|
18
18
|
}
|
|
@@ -21,14 +21,8 @@ export const StyledCircularSlider = styled.div<ICircularSlider>`
|
|
|
21
21
|
min-height: 100dvh;
|
|
22
22
|
& > svg{
|
|
23
23
|
display: block;
|
|
24
|
-
transition: all 0.8s ease-in-out;
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
|
-
|
|
28
|
-
@keyframes spin {
|
|
29
|
-
0% { transform: rotate(0deg); }
|
|
30
|
-
100% { transform: rotate(80deg); }
|
|
31
|
-
}
|
|
32
26
|
`;
|
|
33
27
|
|
|
34
28
|
export const StyledCircularSliderWrapper = styled.div<ICircularSlider>`
|
|
@@ -1,37 +1,35 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from 'react'
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
} from './
|
|
3
|
+
StyledProductsSlider,
|
|
4
|
+
StyledProductsSliderContent,
|
|
5
|
+
StyledProductsSliderSlide,
|
|
6
|
+
StyledProductsSliderSlides,
|
|
7
|
+
StyledProductsSliderWrapper
|
|
8
|
+
} from './ProductsSlider.theme'
|
|
9
9
|
|
|
10
10
|
import Heading from '@/components/atoms/Heading/Heading.component';
|
|
11
|
-
import {
|
|
11
|
+
import { IProductsSlider } from './ProductsSlider.interface'
|
|
12
|
+
import ProductCard from '@/components/molecules/ProductCard/ProductCard.component';
|
|
12
13
|
import { debounce } from '@/helpers/events';
|
|
13
14
|
import useMediaMatch from '@/helpers/useMediaMatch';
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
-
cta,
|
|
16
|
+
const ProductsSlider = ({
|
|
17
17
|
content,
|
|
18
18
|
style,
|
|
19
19
|
className,
|
|
20
|
-
}:
|
|
20
|
+
}: IProductsSlider) => {
|
|
21
21
|
|
|
22
|
-
const [
|
|
23
|
-
name: content && content[0].name,
|
|
24
|
-
role: content && content[0].role,
|
|
25
|
-
});
|
|
22
|
+
const [activeElement, setActiveElement] = useState(content && content[0]);
|
|
26
23
|
const slider = useRef<HTMLDivElement>();
|
|
27
24
|
const wrapper = useRef<HTMLDivElement>();
|
|
28
25
|
const slidesHolder = useRef<HTMLDivElement>();
|
|
29
26
|
const contentHolder = useRef<HTMLDivElement>();
|
|
27
|
+
const isMobile = useMediaMatch();
|
|
30
28
|
|
|
31
29
|
//force 12 items
|
|
32
|
-
if (content && content.length <
|
|
30
|
+
if (content && content.length < 26) {
|
|
33
31
|
let counter = 0;
|
|
34
|
-
for (let i = content.length; i <=
|
|
32
|
+
for (let i = content.length; i <= 26; i++) {
|
|
35
33
|
content[i] = content[counter];
|
|
36
34
|
counter++;
|
|
37
35
|
}
|
|
@@ -40,53 +38,54 @@ const CircularSliderTeste = ({
|
|
|
40
38
|
useEffect(() => {
|
|
41
39
|
if (!slidesHolder.current) return //bail out;
|
|
42
40
|
|
|
43
|
-
const animationDuration = 600;
|
|
44
|
-
|
|
45
41
|
const slides = Array.prototype.slice.call(slidesHolder?.current?.children);
|
|
46
|
-
|
|
47
42
|
let slidesSize = 0;
|
|
48
|
-
|
|
49
|
-
let currentAngle = -180;
|
|
43
|
+
let currentAngle = 0;
|
|
50
44
|
|
|
51
45
|
const stepAngle = 2 * Math.PI / slidesHolder?.current?.children.length;
|
|
52
46
|
// const stepAngle = 0.52;
|
|
53
47
|
|
|
54
48
|
let currentSlide = 0;
|
|
55
49
|
|
|
56
|
-
slidesHolder.current.style.transitionDuration = animationDuration + 'ms';
|
|
57
50
|
const slidesRepositioning = (r) => {
|
|
51
|
+
if (isMobile) return;
|
|
52
|
+
|
|
58
53
|
for (let i = 0; i < slides.length; i++) {
|
|
59
54
|
|
|
60
55
|
let x = r * Math.cos(stepAngle * i - Math.PI / 2),
|
|
61
56
|
y = r * Math.sin(stepAngle * i - Math.PI / 2);
|
|
62
57
|
|
|
63
|
-
slides[i].style.transform = 'translate( ' + x + 'px, ' + y + 'px ) rotate( ' + ((stepAngle * 180 / Math.PI * i) +
|
|
58
|
+
slides[i].style.transform = 'translate( ' + x + 'px, ' + y + 'px ) rotate( ' + (((stepAngle * 180 / Math.PI * i) + 90)) + 'deg )';
|
|
64
59
|
// slides[i].style.transform = 'translate( ' + x + 'px, ' + y + 'px )';
|
|
65
60
|
};
|
|
66
61
|
}
|
|
67
62
|
const setSize = (radius: number) => {
|
|
68
|
-
if (!wrapper.current || !slidesHolder.current) return //bail out;
|
|
63
|
+
if (!wrapper.current || !slidesHolder.current || isMobile) return //bail out;
|
|
69
64
|
|
|
70
|
-
const slideSize = 0.
|
|
65
|
+
const slideSize = 0.08;
|
|
71
66
|
|
|
72
67
|
wrapper.current.style.width = 2 * radius + 'px';
|
|
73
|
-
wrapper.current.style.height = 2 * radius + 'px';
|
|
68
|
+
// wrapper.current.style.height = 2 * radius + 'px';
|
|
69
|
+
wrapper.current.style.height = '320px';
|
|
74
70
|
|
|
75
71
|
let r = 2 * radius * (1 - slideSize);
|
|
76
|
-
slidesHolder.current.style.width = r
|
|
77
|
-
slidesHolder.current.style.height = r
|
|
72
|
+
slidesHolder.current.style.width = r + 'px'
|
|
73
|
+
slidesHolder.current.style.height = r + 'px';
|
|
78
74
|
slidesRepositioning(r / 2);
|
|
79
75
|
|
|
80
|
-
slidesSize = Math.min(2 * radius * slideSize, stepAngle * radius * (1 - slideSize) -
|
|
76
|
+
slidesSize = Math.min(2 * radius * slideSize, stepAngle * radius * (1 - slideSize) - 80);
|
|
77
|
+
slidesHolder.current.style.marginTop = slidesSize + 'px';
|
|
78
|
+
|
|
81
79
|
|
|
82
80
|
for (let i = 0; i < slides.length; i++) {
|
|
83
|
-
slides[i].style.width =
|
|
81
|
+
slides[i].style.width = slidesSize + 'px';
|
|
84
82
|
};
|
|
85
83
|
|
|
86
84
|
}
|
|
87
85
|
|
|
88
86
|
const sliderResize = debounce(() => {
|
|
89
|
-
|
|
87
|
+
if (isMobile) return;
|
|
88
|
+
const sliderSize = 2.4;
|
|
90
89
|
|
|
91
90
|
let radius,
|
|
92
91
|
w = slider?.current ? slider?.current?.getBoundingClientRect().width : 0,
|
|
@@ -107,7 +106,7 @@ const CircularSliderTeste = ({
|
|
|
107
106
|
contentHolder?.current?.classList.remove('active');
|
|
108
107
|
const prevElement = slides[currentSlide];
|
|
109
108
|
setTimeout(() => {
|
|
110
|
-
content &&
|
|
109
|
+
content && setActiveElement(content[currentSlide] as any)
|
|
111
110
|
prevElement.classList.remove('active');
|
|
112
111
|
}, 400);
|
|
113
112
|
};
|
|
@@ -143,15 +142,27 @@ const CircularSliderTeste = ({
|
|
|
143
142
|
addStyle();
|
|
144
143
|
}
|
|
145
144
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
if (isMobile) {
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
if (wrapper?.current) wrapper.current.removeAttribute('style');
|
|
148
|
+
if (slidesHolder?.current) slidesHolder.current.removeAttribute('style');
|
|
149
|
+
|
|
150
|
+
for (let i = 0; i < slides.length; i++) {
|
|
151
|
+
slides[i].removeAttribute('style');
|
|
152
|
+
slides[i].removeEventListener('click', rotateSlider);
|
|
153
|
+
};
|
|
154
|
+
window.removeEventListener('resize', sliderResize)
|
|
155
|
+
}, 250)
|
|
156
|
+
} else {
|
|
157
|
+
sliderResize();
|
|
158
|
+
addStyle();
|
|
149
159
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
160
|
+
for (let i = 0; i < slides.length; i++) {
|
|
161
|
+
slides[i].addEventListener('click', rotateSlider, { passive: true });
|
|
162
|
+
};
|
|
153
163
|
|
|
154
|
-
|
|
164
|
+
window.addEventListener('resize', sliderResize)
|
|
165
|
+
}
|
|
155
166
|
|
|
156
167
|
return () => {
|
|
157
168
|
for (let i = 0; i < slides.length; i++) {
|
|
@@ -160,31 +171,39 @@ const CircularSliderTeste = ({
|
|
|
160
171
|
|
|
161
172
|
window.removeEventListener('resize', sliderResize)
|
|
162
173
|
}
|
|
163
|
-
}, [])
|
|
174
|
+
}, [isMobile])
|
|
164
175
|
|
|
165
176
|
if (!content) return <></>
|
|
166
177
|
|
|
167
178
|
return (
|
|
168
|
-
<
|
|
169
|
-
<
|
|
170
|
-
<
|
|
179
|
+
<StyledProductsSlider ref={slider as any} className={className} style={style}>
|
|
180
|
+
<StyledProductsSliderWrapper ref={wrapper as any}>
|
|
181
|
+
<StyledProductsSliderSlides ref={slidesHolder as any}>
|
|
171
182
|
{content?.map((item, index) => {
|
|
172
183
|
return (
|
|
173
|
-
<
|
|
184
|
+
<StyledProductsSliderSlide key={`ProductCard-${index}`}>
|
|
185
|
+
<ProductCard
|
|
186
|
+
imageElement={item.imageElement}
|
|
187
|
+
title={item.title}
|
|
188
|
+
description={isMobile ? item?.description : ""}
|
|
189
|
+
/>
|
|
190
|
+
</StyledProductsSliderSlide>
|
|
174
191
|
)
|
|
175
192
|
})}
|
|
176
|
-
</
|
|
177
|
-
</
|
|
178
|
-
|
|
179
|
-
<
|
|
180
|
-
<Heading tag="
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
</StyledProductsSliderSlides>
|
|
194
|
+
</StyledProductsSliderWrapper>
|
|
195
|
+
{!isMobile && (
|
|
196
|
+
<StyledProductsSliderContent ref={contentHolder as any} className='mt-6'>
|
|
197
|
+
<Heading tag="h5" size="h5">
|
|
198
|
+
<strong>{activeElement?.title}</strong>
|
|
199
|
+
<br />
|
|
200
|
+
{activeElement?.description}
|
|
201
|
+
</Heading>
|
|
202
|
+
</StyledProductsSliderContent>
|
|
203
|
+
)}
|
|
204
|
+
</StyledProductsSlider>
|
|
186
205
|
|
|
187
206
|
)
|
|
188
207
|
}
|
|
189
208
|
|
|
190
|
-
export default
|
|
209
|
+
export default ProductsSlider
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
export type IProductsSlider = {
|
|
4
|
+
id?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
style?: CSSProperties;
|
|
7
|
+
content?: {
|
|
8
|
+
title?: string,
|
|
9
|
+
description?: string | React.ReactElement,
|
|
10
|
+
imageElement?: React.ReactElement
|
|
11
|
+
}[],
|
|
12
|
+
}
|