@hero-design/rn 8.2.3 → 8.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/.turbo/turbo-build.log +9 -9
  2. package/es/index.js +316 -53
  3. package/lib/index.js +315 -51
  4. package/package.json +5 -5
  5. package/src/components/Carousel/CarouselItem.tsx +44 -0
  6. package/src/components/Carousel/CarouselPaginator/StyledCarouselPaginator.tsx +20 -0
  7. package/src/components/Carousel/CarouselPaginator/index.tsx +57 -0
  8. package/src/components/Carousel/StyledCarousel.tsx +58 -0
  9. package/src/components/Carousel/__tests__/StyledCarousel.spec.tsx +13 -0
  10. package/src/components/Carousel/__tests__/__snapshots__/StyledCarousel.spec.tsx.snap +20 -0
  11. package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +600 -0
  12. package/src/components/Carousel/__tests__/index.spec.tsx +94 -0
  13. package/src/components/Carousel/index.tsx +157 -0
  14. package/src/components/Carousel/types.ts +10 -0
  15. package/src/components/Typography/Text/StyledText.tsx +1 -0
  16. package/src/components/Typography/Text/index.tsx +1 -0
  17. package/src/index.ts +2 -0
  18. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +34 -0
  19. package/src/theme/components/carousel.ts +42 -0
  20. package/src/theme/components/typography.ts +2 -0
  21. package/src/theme/getTheme.ts +3 -0
  22. package/src/theme/global/typography.ts +3 -0
  23. package/types/components/Carousel/CarouselItem.d.ts +6 -0
  24. package/types/components/Carousel/CarouselPaginator/StyledCarouselPaginator.d.ts +14 -0
  25. package/types/components/Carousel/CarouselPaginator/index.d.ts +7 -0
  26. package/types/components/Carousel/StyledCarousel.d.ts +36 -0
  27. package/types/components/Carousel/index.d.ts +32 -0
  28. package/types/components/Carousel/types.d.ts +9 -0
  29. package/types/components/Typography/Text/StyledText.d.ts +1 -1
  30. package/types/components/Typography/Text/index.d.ts +1 -1
  31. package/types/index.d.ts +2 -1
  32. package/types/theme/components/carousel.d.ts +32 -0
  33. package/types/theme/components/typography.d.ts +2 -0
  34. package/types/theme/getTheme.d.ts +2 -0
  35. package/types/theme/global/typography.d.ts +1 -0
@@ -0,0 +1,20 @@
1
+ import { Animated, View } from 'react-native';
2
+ import styled from '@emotion/native';
3
+
4
+ const StyledCarouselPaginator = styled(View)(() => ({
5
+ flexDirection: 'row',
6
+ alignItems: 'center',
7
+ marginStart: 'auto',
8
+ }));
9
+
10
+ const StyledCarouselPaginatorAnimatedView = styled(Animated.View)(
11
+ ({ theme }) => ({
12
+ height: theme.__hd__.carousel.sizes.paginatorHeight,
13
+ width: theme.__hd__.carousel.sizes.paginatorWidth,
14
+ borderRadius: theme.__hd__.carousel.radii.paginatorBorderRadius,
15
+ backgroundColor: theme.__hd__.carousel.colors.paginatorBackgroundColor,
16
+ marginHorizontal: theme.__hd__.carousel.space.paginatorMarginHorizontal,
17
+ })
18
+ );
19
+
20
+ export { StyledCarouselPaginator, StyledCarouselPaginatorAnimatedView };
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import { Animated, useWindowDimensions } from 'react-native';
3
+
4
+ import {
5
+ StyledCarouselPaginatorAnimatedView,
6
+ StyledCarouselPaginator,
7
+ } from './StyledCarouselPaginator';
8
+ import { useTheme } from '../../../theme';
9
+
10
+ interface CarouselPaginatorProps {
11
+ numberOfSlides: number;
12
+ scrollX: Animated.Value;
13
+ }
14
+ const CarouselPaginator = ({
15
+ numberOfSlides,
16
+ scrollX,
17
+ }: CarouselPaginatorProps) => {
18
+ const { width } = useWindowDimensions();
19
+ const theme = useTheme();
20
+
21
+ return (
22
+ <StyledCarouselPaginator>
23
+ {new Array(numberOfSlides).fill('').map((_, index) => {
24
+ const inputRange = [
25
+ (index - 1) * width - 1,
26
+ index * width - 1,
27
+ (index + 1) * width,
28
+ ];
29
+
30
+ const indicatorWidth = scrollX.interpolate({
31
+ inputRange,
32
+ outputRange: [
33
+ theme.space.small,
34
+ theme.space.large,
35
+ theme.space.small,
36
+ ],
37
+ extrapolate: 'clamp',
38
+ });
39
+
40
+ const opacity = scrollX.interpolate({
41
+ inputRange,
42
+ outputRange: [0.5, 1, 0.5],
43
+ extrapolate: 'clamp',
44
+ });
45
+
46
+ return (
47
+ <StyledCarouselPaginatorAnimatedView
48
+ style={[{ width: indicatorWidth, opacity }]}
49
+ key={index.toString()}
50
+ />
51
+ );
52
+ })}
53
+ </StyledCarouselPaginator>
54
+ );
55
+ };
56
+
57
+ export default CarouselPaginator;
@@ -0,0 +1,58 @@
1
+ import { View } from 'react-native';
2
+ import styled from '@emotion/native';
3
+ import Typography from '../Typography';
4
+ import Image from '../Image';
5
+ import Box from '../Box';
6
+
7
+ const StyledBackDrop = styled(View)<{
8
+ themeSlideBackground: string;
9
+ }>(({ themeSlideBackground }) => ({
10
+ position: 'absolute',
11
+ backgroundColor: themeSlideBackground,
12
+ top: 0,
13
+ bottom: 0,
14
+ right: 0,
15
+ left: 0,
16
+ }));
17
+
18
+ const StyledCarouselView = styled(View)(() => ({
19
+ flexGrow: 2,
20
+ justifyContent: 'space-between',
21
+ }));
22
+
23
+ const StyledCarouselHeading = styled(Typography.Text)(({ theme }) => ({
24
+ marginTop: theme.__hd__.carousel.space.headingMarginTop,
25
+ marginBottom: theme.__hd__.carousel.space.headingMarginBottom,
26
+ fontFamily: theme.__hd__.carousel.fonts.heading,
27
+ fontSize: theme.__hd__.carousel.fontSizes.heading,
28
+ lineHeight: theme.__hd__.carousel.lineHeights.heading,
29
+ }));
30
+
31
+ const StyledCarouselImage = styled(Image)(() => ({
32
+ flex: 1,
33
+ width: '100%',
34
+ resizeMode: 'contain',
35
+ }));
36
+
37
+ const StyledCarouselContentWrapper = styled(Box)<{
38
+ width: number;
39
+ }>(({ width }) => ({
40
+ width,
41
+ }));
42
+
43
+ const StyledCarouselFooterWrapper = styled(View)(({ theme }) => ({
44
+ paddingHorizontal: theme.__hd__.carousel.space.footerPaddingHorizontal,
45
+ flexDirection: 'row',
46
+ justifyContent: 'space-between',
47
+ paddingVertical: theme.__hd__.carousel.space.footerPaddingVertical,
48
+ marginBottom: theme.__hd__.carousel.space.footerMarginBottom,
49
+ }));
50
+
51
+ export {
52
+ StyledBackDrop,
53
+ StyledCarouselView,
54
+ StyledCarouselHeading,
55
+ StyledCarouselImage,
56
+ StyledCarouselContentWrapper,
57
+ StyledCarouselFooterWrapper,
58
+ };
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import renderWithTheme from '../../../testHelpers/renderWithTheme';
3
+ import { StyledBackDrop } from '../StyledCarousel';
4
+ import theme from '../../../theme';
5
+
6
+ describe('StyledBackDrop', () => {
7
+ it('renders correct basic style', () => {
8
+ const { toJSON } = renderWithTheme(
9
+ <StyledBackDrop themeSlideBackground={theme.colors.highlightedSurface} />
10
+ );
11
+ expect(toJSON()).toMatchSnapshot();
12
+ });
13
+ });
@@ -0,0 +1,20 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`StyledBackDrop renders correct basic style 1`] = `
4
+ <View
5
+ style={
6
+ Array [
7
+ Object {
8
+ "backgroundColor": "#ece8ef",
9
+ "bottom": 0,
10
+ "left": 0,
11
+ "position": "absolute",
12
+ "right": 0,
13
+ "top": 0,
14
+ },
15
+ undefined,
16
+ ]
17
+ }
18
+ themeSlideBackground="#ece8ef"
19
+ />
20
+ `;