@fox-dls/carousels 0.0.1 → 1.0.3

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.
@@ -0,0 +1,134 @@
1
+ /* eslint-disable unused-imports/no-unused-vars */
2
+ import React, { useRef } from 'react';
3
+
4
+ import SwiperCore, { Navigation, Pagination } from 'swiper';
5
+ // eslint-disable-next-line import/extensions
6
+ import { SwiperSlide } from 'swiper/react';
7
+
8
+ import { CarouselSwiper, CarouselPillSvg, CarouselPill } from './styles';
9
+
10
+ SwiperCore.use([Navigation, Pagination]);
11
+
12
+ export const PaginationCarousel: React.FC<any> = ({
13
+ children,
14
+ navigation,
15
+ title,
16
+ controls,
17
+ ...props
18
+ }) => {
19
+ const prevRef = useRef<HTMLDivElement>(null);
20
+ const nextRef = useRef<HTMLDivElement>(null);
21
+ return (
22
+ <>
23
+ <div
24
+ css={`
25
+ @keyframes fadein {
26
+ 0% {
27
+ opacity: 0;
28
+ }
29
+
30
+ 100% {
31
+ opacity: 1;
32
+ }
33
+ }
34
+ position: absolute !important;
35
+ top: 50% !important;
36
+ pointer-events: auto !important;
37
+ transform: translateY(-50%) !important;
38
+ left: 8px !important;
39
+ animation-duration: 0.3s !important;
40
+ animation-name: fadein !important;
41
+ z-index: 180 !important;
42
+ opacity: 0 !important;
43
+ :hover {
44
+ opacity: 1 !important;
45
+ }
46
+ `}
47
+ >
48
+ <CarouselPill ref={prevRef}>
49
+ <span
50
+ css={`
51
+ position: relative !important;
52
+ `}
53
+ >
54
+ <CarouselPillSvg
55
+ viewBox="0 0 16 16"
56
+ role="presentation"
57
+ aria-hidden="true"
58
+ focusable="false"
59
+ >
60
+ <path d="m10.8 16c-.4 0-.7-.1-.9-.4l-6.8-6.7c-.5-.5-.5-1.3 0-1.8l6.8-6.7c.5-.5 1.2-.5 1.7 0s .5 1.2 0 1.7l-5.8 5.9 5.8 5.9c.5.5.5 1.2 0 1.7-.2.3-.5.4-.8.4" />
61
+ </CarouselPillSvg>
62
+ </span>
63
+ </CarouselPill>
64
+ </div>
65
+ <div
66
+ css={`
67
+ @keyframes fadein {
68
+ 0% {
69
+ opacity: 0;
70
+ }
71
+
72
+ 100% {
73
+ opacity: 1;
74
+ }
75
+ }
76
+ position: absolute !important;
77
+ top: 50% !important;
78
+ pointer-events: auto !important;
79
+ transform: translateY(-50%) !important;
80
+ right: 8px !important;
81
+ animation-duration: 0.3s !important;
82
+ animation-name: fadein !important;
83
+ z-index: 180 !important;
84
+ opacity: 0 !important;
85
+ :hover {
86
+ opacity: 1 !important;
87
+ }
88
+ `}
89
+ >
90
+ <CarouselPill ref={nextRef}>
91
+ <span
92
+ css={`
93
+ position: relative !important;
94
+ `}
95
+ >
96
+ <CarouselPillSvg
97
+ viewBox="0 0 16 16"
98
+ role="presentation"
99
+ aria-hidden="true"
100
+ focusable="false"
101
+ >
102
+ <path d="m5.3 16c .3 0 .6-.1.8-.4l6.8-6.7c.5-.5.5-1.3 0-1.8l-6.8-6.7c-.5-.5-1.2-.5-1.7 0s-.5 1.2 0 1.7l5.8 5.9-5.8 5.9c-.5.5-.5 1.2 0 1.7.2.3.5.4.9.4" />
103
+ </CarouselPillSvg>
104
+ </span>
105
+ </CarouselPill>
106
+ </div>
107
+ <CarouselSwiper
108
+ {...props}
109
+ pagination={{
110
+ dynamicBullets: true
111
+ }}
112
+ onInit={swiper => {
113
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
114
+ // @ts-ignore
115
+ // eslint-disable-next-line no-param-reassign
116
+ swiper.params.navigation.prevEl = prevRef.current;
117
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
118
+ // @ts-ignore
119
+ // eslint-disable-next-line no-param-reassign
120
+ swiper.params.navigation.nextEl = nextRef.current;
121
+ swiper.navigation.init();
122
+ swiper.navigation.update();
123
+ // console.log("Swiper", swiper);
124
+ }}
125
+ >
126
+ {React.Children.map(children, child =>
127
+ React.cloneElement(<SwiperSlide>{child}</SwiperSlide>, {
128
+ ...props
129
+ })
130
+ )}
131
+ </CarouselSwiper>
132
+ </>
133
+ );
134
+ };
@@ -0,0 +1,80 @@
1
+ import ButtonUnstyled from '@mui/core/ButtonUnstyled';
2
+ import styled from 'styled-components';
3
+ // eslint-disable-next-line import/extensions
4
+ import { Swiper } from 'swiper/react';
5
+
6
+ export const CarouselContainer = styled.div``;
7
+
8
+ export const CarouselSwiper = styled(Swiper)`
9
+ height: 100%;
10
+ .swiper-pagination {
11
+ .swiper-pagination-bullet-active {
12
+ background-color: #fff;
13
+ }
14
+ .swiper-pagination-bullet-active-next {
15
+ background-color: #ffffff;
16
+ }
17
+ .swiper-pagination-bullet {
18
+ background-color: #ffffff;
19
+ }
20
+ }
21
+ `;
22
+
23
+ export const CarouselPill = styled(ButtonUnstyled)`
24
+ :hover {
25
+ border-color: rgba(0, 0, 0, 0.08) !important;
26
+ background-color: #ffffff !important;
27
+ color: #000000 !important;
28
+ box-shadow: 0px 0px 0px 1px transparent, 0px 0px 0px 4px transparent,
29
+ 0px 6px 16px rgb(0 0 0 / 12%) !important;
30
+ -webkit-transform: scale(1.04) !important;
31
+ -ms-transform: scale(1.04) !important;
32
+ transform: scale(1.04) !important;
33
+ }
34
+
35
+ -webkit-box-pack: center !important;
36
+ -ms-flex-pack: center !important;
37
+ -webkit-box-align: center !important;
38
+ -ms-flex-align: center !important;
39
+ -webkit-appearance: none !important;
40
+ -moz-appearance: none !important;
41
+ appearance: none !important;
42
+ display: -webkit-inline-box !important;
43
+ display: -moz-inline-box !important;
44
+ display: -ms-inline-flexbox !important;
45
+ display: -webkit-inline-flex !important;
46
+ display: inline-flex !important;
47
+ border-radius: 50% !important;
48
+ border: 0px !important;
49
+ outline: none !important;
50
+ margin: 0px !important;
51
+ padding: 0px !important;
52
+ color: #222222 !important;
53
+ background-color: rgba(255, 255, 255, 0.9) !important;
54
+ cursor: pointer !important;
55
+ -ms-touch-action: manipulation !important;
56
+ touch-action: manipulation !important;
57
+ -webkit-align-items: center !important;
58
+ align-items: center !important;
59
+ -webkit-justify-content: center !important;
60
+ justify-content: center !important;
61
+ border-style: solid !important;
62
+ border-width: 1px !important;
63
+ background-clip: padding-box !important;
64
+ border-color: rgba(0, 0, 0, 0.08) !important;
65
+ box-shadow: 0px 0px 0px 1px transparent, 0px 0px 0px 4px transparent,
66
+ 0px 2px 4px rgb(0 0 0 / 18%) !important;
67
+ -webkit-transition: -webkit-transform 0.25s ease, transform 0.25s ease !important;
68
+ -moz-transition: transform 0.25s ease !important;
69
+ transition: -ms-transform 0.25s ease, -webkit-transform 0.25s ease,
70
+ transform 0.25s ease !important;
71
+ width: 32px !important;
72
+ height: 32px !important;
73
+ `;
74
+
75
+ export const CarouselPillSvg = styled.svg`
76
+ height: 10px;
77
+ width: 10px;
78
+ display: block;
79
+ fill: currentcolor;
80
+ `;
@@ -0,0 +1,208 @@
1
+ /* eslint-disable @typescript-eslint/no-shadow */
2
+ /* eslint-disable unused-imports/no-unused-vars */
3
+ import React, { useRef, useState } from 'react';
4
+
5
+ import { css } from 'styled-components';
6
+ import SwiperCore, { Navigation } from 'swiper';
7
+ // eslint-disable-next-line import/extensions
8
+ import { SwiperSlide } from 'swiper/react';
9
+
10
+ import { CarouselSwiper, CarouselPillContainer, CarouselPill } from './styles';
11
+
12
+ SwiperCore.use([Navigation]);
13
+
14
+ export const PillsCarousel: React.FC<any> = ({
15
+ children,
16
+ navigation,
17
+ title,
18
+ controls,
19
+ arrows,
20
+ ...props
21
+ }) => {
22
+ const prevRef = useRef<any>(null);
23
+ const nextRef = useRef<any>(null);
24
+ const [swiperSlides, setSwiperSlides] = useState<any>({
25
+ progress: 0,
26
+ isBeginning: true,
27
+ isEnd: false
28
+ });
29
+ const [swiper, setSwiper] = useState<any>(null);
30
+ return (
31
+ <div
32
+ css={`
33
+ display: flex !important;
34
+ position: relative !important;
35
+ min-width: 0px !important;
36
+ `}
37
+ >
38
+ <div
39
+ css={`
40
+ position: absolute !important;
41
+ left: 0px !important;
42
+ z-index: 3 !important;
43
+ width: 65px !important;
44
+ background: linear-gradient(
45
+ to right,
46
+ rgb(255, 255, 255) 56.77%,
47
+ rgba(255, 255, 255, 0) 94.47%
48
+ ) !important;
49
+ ${swiperSlides.isBeginning &&
50
+ css`
51
+ display: none !important;
52
+ visibility: hidden !important;
53
+ `}
54
+ `}
55
+ >
56
+ {arrows && (
57
+ <CarouselPillContainer>
58
+ <CarouselPill
59
+ left={+true}
60
+ ref={prevRef}
61
+ aria-label="Previous"
62
+ type="button"
63
+ onClick={() => swiper.slidePrev()}
64
+ >
65
+ <span
66
+ css={`
67
+ position: relative !important;
68
+ `}
69
+ >
70
+ <svg
71
+ viewBox="0 0 32 32"
72
+ xmlns="http://www.w3.org/2000/svg"
73
+ aria-hidden="true"
74
+ role="presentation"
75
+ focusable="false"
76
+ css={`
77
+ display: block;
78
+ fill: none;
79
+ height: 12px;
80
+ width: 12px;
81
+ stroke: currentcolor;
82
+ stroke-width: 5.33333;
83
+ overflow: visible;
84
+ `}
85
+ >
86
+ <g fill="none">
87
+ <path d="m20 28-11.29289322-11.2928932c-.39052429-.3905243-.39052429-1.0236893 0-1.4142136l11.29289322-11.2928932" />
88
+ </g>
89
+ </svg>
90
+ </span>
91
+ </CarouselPill>
92
+ </CarouselPillContainer>
93
+ )}
94
+ </div>
95
+
96
+ <CarouselSwiper
97
+ {...props}
98
+ cssMode={false}
99
+ slidesPerView="auto"
100
+ onInit={(swiper: any) => {
101
+ setSwiper(swiper);
102
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
103
+ // @ts-ignore
104
+ // eslint-disable-next-line no-param-reassign
105
+ swiper.params.navigation.prevEl = prevRef.current;
106
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
107
+ // @ts-ignore
108
+ // eslint-disable-next-line no-param-reassign
109
+ swiper.params.navigation.nextEl = nextRef.current;
110
+ swiper.navigation.init();
111
+ swiper.navigation.update();
112
+ setSwiperSlides({
113
+ progress: swiper.progress,
114
+ isBeginning: swiper.isBeginning,
115
+ isEnd: swiper.isEnd
116
+ });
117
+ // console.log("Swiper", swiper);
118
+ }}
119
+ onSlideChange={swiper => {
120
+ // console.log("Swiper Change", swiper);
121
+
122
+ setSwiperSlides({
123
+ progress: swiper.progress,
124
+ isBeginning: swiper.isBeginning,
125
+ isEnd: swiper.isEnd
126
+ });
127
+ }}
128
+ >
129
+ {React.Children.map(children, child => (
130
+ <SwiperSlide>
131
+ <div
132
+ css={`
133
+ display: inline-block !important;
134
+ white-space: nowrap !important;
135
+ padding-right: 8px !important;
136
+ padding-top: 4px !important;
137
+ padding-bottom: 4px !important;
138
+ `}
139
+ >
140
+ {child}
141
+ </div>
142
+ </SwiperSlide>
143
+ ))}
144
+ </CarouselSwiper>
145
+
146
+ <div
147
+ css={`
148
+ -webkit-box-pack: end !important;
149
+ position: absolute !important;
150
+ right: 0px !important;
151
+ z-index: 3 !important;
152
+ width: 75px !important;
153
+ display: flex !important;
154
+ justify-content: flex-end !important;
155
+ background: linear-gradient(
156
+ to left,
157
+ rgb(255, 255, 255) 56.77%,
158
+ rgba(255, 255, 255, 0) 94.47%
159
+ ) !important;
160
+ ${swiperSlides.isEnd &&
161
+ css`
162
+ display: none !important;
163
+ visibility: hidden !important;
164
+ `}
165
+ `}
166
+ >
167
+ {arrows && (
168
+ <CarouselPillContainer>
169
+ <CarouselPill
170
+ right={+true}
171
+ aria-label="Next"
172
+ type="button"
173
+ ref={nextRef}
174
+ onClick={() => swiper.slideNext()}
175
+ >
176
+ <span
177
+ css={`
178
+ position: relative !important;
179
+ `}
180
+ >
181
+ <svg
182
+ viewBox="0 0 32 32"
183
+ xmlns="http://www.w3.org/2000/svg"
184
+ aria-hidden="true"
185
+ role="presentation"
186
+ focusable="false"
187
+ css={`
188
+ display: block;
189
+ fill: none;
190
+ height: 12px;
191
+ width: 12px;
192
+ stroke: currentcolor;
193
+ stroke-width: 5.33333;
194
+ overflow: visible;
195
+ `}
196
+ >
197
+ <g fill="none">
198
+ <path d="m12 4 11.2928932 11.2928932c.3905243.3905243.3905243 1.0236893 0 1.4142136l-11.2928932 11.2928932" />
199
+ </g>
200
+ </svg>
201
+ </span>
202
+ </CarouselPill>
203
+ </CarouselPillContainer>
204
+ )}
205
+ </div>
206
+ </div>
207
+ );
208
+ };
@@ -0,0 +1,58 @@
1
+ import ButtonUnstyled from '@mui/core/ButtonUnstyled';
2
+ import styled from 'styled-components';
3
+ // eslint-disable-next-line import/extensions
4
+ import { Swiper } from 'swiper/react';
5
+
6
+ export const CarouselContainer = styled.div``;
7
+
8
+ export const CarouselSwiper = styled(Swiper)`
9
+ margin: 0px !important;
10
+ .swiper-wrapper {
11
+ .swiper-slide {
12
+ scroll-snap-align: start !important;
13
+ width: auto !important;
14
+ }
15
+ }
16
+ `;
17
+
18
+ export const CarouselPillContainer = styled.div`
19
+ display: inline-block !important;
20
+ padding-right: 8px !important;
21
+ padding-top: 4px !important;
22
+ padding-bottom: 4px !important;
23
+ `;
24
+
25
+ export const CarouselPill = styled(ButtonUnstyled)<any>`
26
+ -webkit-box-pack: center !important;
27
+ -webkit-box-align: center !important;
28
+ appearance: none !important;
29
+ display: inline-flex !important;
30
+ border-radius: 50% !important;
31
+ border: 1px solid rgb(221, 221, 221) !important;
32
+ outline: none !important;
33
+ margin: 0px !important;
34
+ padding: 0px !important;
35
+ color: rgb(34, 34, 34) !important;
36
+ cursor: pointer !important;
37
+ touch-action: manipulation !important;
38
+ position: relative !important;
39
+ background: transparent !important;
40
+ transition: -ms-transform 0.25s ease 0s, -webkit-transform 0.25s ease 0s,
41
+ transform 0.25s ease 0s !important;
42
+ align-items: center !important;
43
+ justify-content: center !important;
44
+ width: 36px !important;
45
+ height: 36px !important;
46
+ ::before {
47
+ content: '' !important;
48
+ display: block !important;
49
+ position: absolute !important;
50
+ top: 50% !important;
51
+ left: 50% !important;
52
+ transform: translate(-50%, -50%) !important;
53
+ width: 36px !important;
54
+ height: 36px !important;
55
+ border-radius: 50% !important;
56
+ border: 1px solid rgb(221, 221, 221) !important;
57
+ }
58
+ `;
@@ -0,0 +1,168 @@
1
+ import ButtonUnstyled from '@mui/core/ButtonUnstyled';
2
+ import styled from 'styled-components';
3
+
4
+ export const CarouselContainer = styled.div`
5
+ position: relative !important;
6
+ z-index: 0 !important;
7
+ `;
8
+
9
+ export const CarouselNavbar = styled.div`
10
+ -webkit-box-pack: justify !important;
11
+ -ms-flex-pack: justify !important;
12
+ -webkit-box-align: center !important;
13
+ -ms-flex-align: center !important;
14
+ color: #222222 !important;
15
+ display: -webkit-box !important;
16
+ display: -moz-box !important;
17
+ display: -ms-flexbox !important;
18
+ display: -webkit-flex !important;
19
+ display: flex !important;
20
+ -webkit-align-items: center !important;
21
+ align-items: center !important;
22
+ -webkit-justify-content: space-between !important;
23
+ justify-content: space-between !important;
24
+ margin-bottom: 16px !important;
25
+ `;
26
+
27
+ export const NavbarTitleContainer = styled.div`
28
+ margin-right: 24px !important;
29
+ width: auto !important;
30
+ `;
31
+
32
+ export const NavbarTitle = styled.div`
33
+ @media (min-width: 744px) {
34
+ font-size: 32px !important;
35
+ line-height: 36px !important;
36
+ font-weight: 800 !important;
37
+ text-align: left !important;
38
+ color: #222222 !important;
39
+ margin-bottom: 15px !important;
40
+ }
41
+ font-size: 22px !important;
42
+ line-height: 26px !important;
43
+ font-weight: 600 !important;
44
+ margin-bottom: 10px !important;
45
+ `;
46
+
47
+ export const NavbarControlsContainer = styled.div`
48
+ display: flex !important;
49
+ align-items: center !important;
50
+ margin-left: auto !important;
51
+ `;
52
+
53
+ export const NavbarControlsQuick = styled.a`
54
+ @media (max-width: 744px) {
55
+ display: none !important;
56
+ }
57
+ font-size: inherit !important;
58
+ font-family: inherit !important;
59
+ font-style: inherit !important;
60
+ font-variant: inherit !important;
61
+ line-height: inherit !important;
62
+ color: #222222 !important;
63
+ text-decoration: underline !important;
64
+ border-radius: 4px !important;
65
+ font-weight: 600 !important;
66
+ outline: none !important;
67
+ `;
68
+
69
+ export const NavbarControlsSpace = styled.span`
70
+ display: inline-block !important;
71
+ height: 32px !important;
72
+ width: 1px !important;
73
+ margin-right: 16px !important;
74
+ padding: 0px !important;
75
+ border: none !important;
76
+ `;
77
+
78
+ export const ArrowsContainer = styled.div`
79
+ -webkit-box-align: center !important;
80
+ color: rgb(34, 34, 34) !important;
81
+ display: flex !important;
82
+ align-items: center !important;
83
+ margin-left: auto !important;
84
+ `;
85
+
86
+ export const ArrowsFlex = styled.div`
87
+ display: -webkit-box !important;
88
+ display: -moz-box !important;
89
+ display: -ms-flexbox !important;
90
+ display: -webkit-flex !important;
91
+ display: flex !important;
92
+ `;
93
+
94
+ export const ArrowsButton = styled(ButtonUnstyled)<any>`
95
+ -webkit-box-pack: center !important;
96
+ -webkit-box-align: center !important;
97
+ appearance: none !important;
98
+ display: inline-flex !important;
99
+ border-radius: 50% !important;
100
+ border: none !important;
101
+ outline: none !important;
102
+ margin: 0px !important;
103
+ padding: 0px !important;
104
+ color: rgb(34, 34, 34) !important;
105
+ cursor: pointer !important;
106
+ touch-action: manipulation !important;
107
+ position: relative !important;
108
+ background: transparent !important;
109
+ transition: -ms-transform 0.25s ease 0s, -webkit-transform 0.25s ease 0s,
110
+ transform 0.25s ease 0s !important;
111
+ align-items: center !important;
112
+ justify-content: center !important;
113
+ width: 32px !important;
114
+ height: 32px !important;
115
+ :focus {
116
+ box-shadow: none !important;
117
+ }
118
+ ::before {
119
+ content: '' !important;
120
+ display: block !important;
121
+ position: absolute !important;
122
+ top: 50% !important;
123
+ left: 50% !important;
124
+ transform: translate(-50%, -50%) !important;
125
+ width: 32px !important;
126
+ height: 32px !important;
127
+ border-radius: 50% !important;
128
+ background: rgb(255, 255, 255) !important;
129
+ border: 1px solid rgb(221, 221, 221) !important;
130
+ }
131
+ :disabled {
132
+ opacity: 0.5 !important;
133
+ cursor: not-allowed !important;
134
+ color: rgb(221, 221, 221) !important;
135
+ transform: scale(1) !important;
136
+ }
137
+ :hover:not([disabled]) {
138
+ color: rgb(0, 0, 0) !important;
139
+ transform: scale(1.04) !important;
140
+ }
141
+ `;
142
+
143
+ export const ArrowsDivider = styled.span`
144
+ margin-left: 8px !important;
145
+ `;
146
+
147
+ export const ArrowsIconClip = styled.span`
148
+ border: 0px !important;
149
+ clip: rect(0 0 0 0) !important;
150
+ -webkit-clip-path: inset(100%) !important;
151
+ clip-path: inset(100%) !important;
152
+ height: 1px !important;
153
+ overflow: hidden !important;
154
+ padding: 0px !important;
155
+ position: absolute !important;
156
+ white-space: nowrap !important;
157
+ width: 1px !important;
158
+ `;
159
+
160
+ export const ArrowsSvg = styled.svg`
161
+ display: block;
162
+ fill: none;
163
+ height: 12px;
164
+ width: 12px;
165
+ stroke: currentcolor;
166
+ stroke-width: 4;
167
+ overflow: visible;
168
+ `;
@@ -0,0 +1,21 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": "./src",
5
+ "target": "esnext",
6
+ "module": "esnext",
7
+ "jsx": "react-jsx",
8
+ "jsxFactory": "",
9
+ "jsxFragmentFactory": "",
10
+ "composite": false
11
+ },
12
+ "exclude": [
13
+ "**/*.spec.ts",
14
+ "**/*.spec.tsx",
15
+ "dist",
16
+ "./plugins/**/*",
17
+ "./dist/**/*",
18
+ "dist/**/*"
19
+ ],
20
+ "include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
21
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "ts-node": {
3
+ "compilerOptions": {
4
+ "module": "CommonJS"
5
+ }
6
+ },
7
+ "compilerOptions": {
8
+ "moduleResolution": "node",
9
+ "baseUrl": ".",
10
+ "declaration": true,
11
+ "esModuleInterop": true,
12
+ "jsx": "react-jsx",
13
+ "rootDir": "./src",
14
+ "outDir": "./dist",
15
+ "skipLibCheck": true,
16
+ "sourceMap": true,
17
+ "module": "esnext",
18
+ "target": "es2015"
19
+ },
20
+ "exclude": ["node_modules"],
21
+ "include": ["src/**/*.ts", "src/**/*.tsx"]
22
+ }