@semcore/carousel 1.6.2 → 2.0.0
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/CHANGELOG.md +18 -0
- package/lib/cjs/Carousel.js +73 -58
- package/lib/cjs/Carousel.js.map +1 -1
- package/lib/cjs/index.d.ts +59 -0
- package/lib/cjs/index.js +2 -19
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/carousel.shadow.css +22 -17
- package/lib/es6/Carousel.js +74 -57
- package/lib/es6/Carousel.js.map +1 -1
- package/lib/es6/index.d.ts +59 -0
- package/lib/es6/index.js +0 -1
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/carousel.shadow.css +22 -17
- package/lib/types/index.d.ts +4 -1
- package/package.json +4 -1
- package/src/Carousel.jsx +24 -8
- package/src/index.d.ts +4 -1
- package/src/index.js +0 -1
- package/src/style/carousel.shadow.css +22 -17
package/src/Carousel.jsx
CHANGED
|
@@ -39,7 +39,7 @@ const MAP_TRANSFORM = {
|
|
|
39
39
|
ArrowRight: 'right',
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
class
|
|
42
|
+
class CarouselRoot extends Component {
|
|
43
43
|
static displayName = 'Carousel';
|
|
44
44
|
static defaultProps = {
|
|
45
45
|
defaultIndex: 0,
|
|
@@ -331,6 +331,7 @@ class Carousel extends Component {
|
|
|
331
331
|
items: items.map((item, key) => ({
|
|
332
332
|
active: key === index,
|
|
333
333
|
onClick: this.bindHandlerClickIndicator(key),
|
|
334
|
+
key,
|
|
334
335
|
})),
|
|
335
336
|
};
|
|
336
337
|
}
|
|
@@ -383,7 +384,7 @@ const Prev = (props) => {
|
|
|
383
384
|
};
|
|
384
385
|
|
|
385
386
|
Prev.defaultProps = () => ({
|
|
386
|
-
children: <ChevronLeft interactive color="
|
|
387
|
+
children: <ChevronLeft interactive color="gray-300" aria-hidden={true} role="button" />,
|
|
387
388
|
top: 0,
|
|
388
389
|
});
|
|
389
390
|
|
|
@@ -394,29 +395,44 @@ const Next = (props) => {
|
|
|
394
395
|
};
|
|
395
396
|
|
|
396
397
|
Next.defaultProps = () => ({
|
|
397
|
-
children: <ChevronRight interactive color="
|
|
398
|
+
children: <ChevronRight interactive color="gray-300" aria-hidden={true} role="button" />,
|
|
398
399
|
top: 0,
|
|
399
400
|
});
|
|
400
401
|
|
|
401
402
|
const Indicators = ({ items, styles, Children }) => {
|
|
402
403
|
const SIndicators = Root;
|
|
403
|
-
const SIndicator = Box;
|
|
404
404
|
if (Children.origin) {
|
|
405
|
-
return
|
|
405
|
+
return sstyled(styles)(
|
|
406
|
+
<SIndicators render={Box}>
|
|
407
|
+
<Children />
|
|
408
|
+
</SIndicators>,
|
|
409
|
+
);
|
|
406
410
|
}
|
|
407
411
|
return sstyled(styles)(
|
|
408
412
|
<SIndicators render={Box}>
|
|
409
|
-
{items.map((item) => (
|
|
410
|
-
<
|
|
413
|
+
{items.map((item, index) => (
|
|
414
|
+
<Carousel.Indicator key={index} {...item} />
|
|
411
415
|
))}
|
|
412
416
|
</SIndicators>,
|
|
413
417
|
);
|
|
414
418
|
};
|
|
415
419
|
|
|
416
|
-
|
|
420
|
+
const Indicator = ({ styles, Children }) => {
|
|
421
|
+
const SIndicator = Root;
|
|
422
|
+
return sstyled(styles)(
|
|
423
|
+
<SIndicator render={Box}>
|
|
424
|
+
<Children />
|
|
425
|
+
</SIndicator>,
|
|
426
|
+
);
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
const Carousel = createComponent(CarouselRoot, {
|
|
417
430
|
Container,
|
|
418
431
|
Indicators,
|
|
432
|
+
Indicator,
|
|
419
433
|
Item,
|
|
420
434
|
Prev,
|
|
421
435
|
Next,
|
|
422
436
|
});
|
|
437
|
+
|
|
438
|
+
export default Carousel;
|
package/src/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ type ChildRenderFn<Props> = Props & {
|
|
|
7
7
|
items,
|
|
8
8
|
}: {
|
|
9
9
|
items: { active: boolean; onClick: () => void }[];
|
|
10
|
-
}) => React.ReactElement;
|
|
10
|
+
}) => React.ReactElement | React.ReactElement[];
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export interface ICarouselProps {
|
|
@@ -48,6 +48,9 @@ declare const Carousel: (<T>(
|
|
|
48
48
|
) => ReturnEl) & {
|
|
49
49
|
Container: <T>(props: IBoxProps & T) => ReturnEl;
|
|
50
50
|
Indicators: <T>(props: ChildRenderFn<IBoxProps & T>) => ReturnEl;
|
|
51
|
+
Indicator: <T>(
|
|
52
|
+
props: ChildRenderFn<IBoxProps & { active: boolean; onClick: () => void } & T>,
|
|
53
|
+
) => ReturnEl;
|
|
51
54
|
Item: <T>(props: IBoxProps & T) => ReturnEl;
|
|
52
55
|
Prev: <T>(props: IBoxProps & T) => ReturnEl;
|
|
53
56
|
Next: <T>(props: IBoxProps & T) => ReturnEl;
|
package/src/index.js
CHANGED
|
@@ -15,6 +15,8 @@ SItem {
|
|
|
15
15
|
max-width: 100%;
|
|
16
16
|
box-sizing: border-box;
|
|
17
17
|
transform: var(--transform);
|
|
18
|
+
border-radius: 6px;
|
|
19
|
+
overflow: hidden;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
SIndicators {
|
|
@@ -24,28 +26,24 @@ SIndicators {
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
SIndicator {
|
|
27
|
-
margin: 0
|
|
28
|
-
padding: 0 5px;
|
|
29
|
+
margin: 0 6px;
|
|
29
30
|
cursor: pointer;
|
|
31
|
+
display: block;
|
|
32
|
+
width: 12px;
|
|
33
|
+
height: 12px;
|
|
34
|
+
border-radius: 6px;
|
|
35
|
+
background-color: var(--gray-300);
|
|
36
|
+
opacity: 0.3;
|
|
37
|
+
object-fit: cover;
|
|
38
|
+
transition: ease-in-out opacity 0.1s;
|
|
39
|
+
}
|
|
30
40
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
display: block;
|
|
34
|
-
width: 12px;
|
|
35
|
-
height: 12px;
|
|
36
|
-
border-radius: 50%;
|
|
37
|
-
background-color: color-mod(var(--stone) a(30%));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
&:hover::before {
|
|
41
|
-
background-color: color-mod(var(--stone) a(60%));
|
|
42
|
-
}
|
|
41
|
+
SIndicator:hover {
|
|
42
|
+
opacity: 0.6;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
SIndicator[active] {
|
|
46
|
-
|
|
47
|
-
background-color: var(--stone);
|
|
48
|
-
}
|
|
46
|
+
opacity: 1;
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
SPrev,
|
|
@@ -56,6 +54,13 @@ SNext {
|
|
|
56
54
|
cursor: pointer;
|
|
57
55
|
}
|
|
58
56
|
|
|
57
|
+
SPrev {
|
|
58
|
+
margin-right: 12px;
|
|
59
|
+
}
|
|
60
|
+
SNext {
|
|
61
|
+
margin-left: 12px;
|
|
62
|
+
}
|
|
63
|
+
|
|
59
64
|
SPrev[disabled],
|
|
60
65
|
SNext[disabled] {
|
|
61
66
|
opacity: var(--disabled-opacity);
|