@hero-design/rn 8.6.0 → 8.7.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/.turbo/turbo-build.log +9 -9
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +473 -420
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +473 -419
- package/package.json +5 -5
- package/src/components/Carousel/CarouselItem.tsx +19 -7
- package/src/components/Carousel/StyledCarousel.tsx +18 -1
- package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +622 -6
- package/src/components/Carousel/__tests__/index.spec.tsx +3 -1
- package/src/components/Carousel/index.tsx +12 -2
- package/src/components/Carousel/types.ts +8 -2
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/IconList.ts +6 -0
- package/src/components/PageControl/StyledPageControl.tsx +17 -0
- package/src/components/PageControl/__tests__/__snapshots__/index.spec.tsx.snap +58 -0
- package/src/components/PageControl/__tests__/index.spec.tsx +21 -0
- package/src/components/PageControl/index.tsx +75 -0
- package/src/components/Typography/Text/StyledText.tsx +1 -0
- package/src/components/Typography/Text/index.tsx +1 -0
- package/src/index.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +18 -12
- package/src/theme/components/carousel.ts +1 -16
- package/src/theme/components/pageControl.ts +25 -0
- package/src/theme/components/typography.ts +2 -0
- package/src/theme/getTheme.ts +3 -0
- package/types/components/Carousel/StyledCarousel.d.ts +14 -2
- package/types/components/Carousel/index.d.ts +5 -1
- package/types/components/Carousel/types.d.ts +7 -2
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/components/{Carousel/CarouselPaginator/StyledCarouselPaginator.d.ts → PageControl/StyledPageControl.d.ts} +3 -3
- package/types/components/PageControl/index.d.ts +21 -0
- package/types/components/Typography/Text/StyledText.d.ts +1 -1
- package/types/components/Typography/Text/index.d.ts +1 -1
- package/types/index.d.ts +2 -1
- package/types/theme/components/carousel.d.ts +0 -12
- package/types/theme/components/pageControl.d.ts +18 -0
- package/types/theme/components/typography.d.ts +2 -0
- package/types/theme/getTheme.d.ts +2 -0
- package/src/components/Carousel/CarouselPaginator/StyledCarouselPaginator.tsx +0 -20
- package/src/components/Carousel/CarouselPaginator/index.tsx +0 -57
- package/types/components/Carousel/CarouselPaginator/index.d.ts +0 -7
|
@@ -17,11 +17,11 @@ import {
|
|
|
17
17
|
} from 'react-native';
|
|
18
18
|
|
|
19
19
|
import { CarouselData } from './types';
|
|
20
|
-
import CarouselPaginator from './CarouselPaginator';
|
|
21
20
|
import {
|
|
22
21
|
StyledBackDrop,
|
|
23
22
|
StyledCarouselFooterWrapper,
|
|
24
23
|
StyledCarouselView,
|
|
24
|
+
StyledPageControl,
|
|
25
25
|
} from './StyledCarousel';
|
|
26
26
|
import CarouselItem from './CarouselItem';
|
|
27
27
|
|
|
@@ -46,6 +46,10 @@ interface CarouselProps extends ViewProps {
|
|
|
46
46
|
* Render action elements function.
|
|
47
47
|
*/
|
|
48
48
|
renderActions?: (pageIndex: number) => JSX.Element;
|
|
49
|
+
/**
|
|
50
|
+
* Should show paginations
|
|
51
|
+
*/
|
|
52
|
+
shouldShowPagination?: (pageIndex: number) => boolean;
|
|
49
53
|
/**
|
|
50
54
|
* Current selected item index.
|
|
51
55
|
*/
|
|
@@ -68,6 +72,7 @@ const Carousel = ({
|
|
|
68
72
|
renderActions,
|
|
69
73
|
selectedItemIndex = 0,
|
|
70
74
|
style,
|
|
75
|
+
shouldShowPagination = () => true,
|
|
71
76
|
...nativeProps
|
|
72
77
|
}: CarouselProps) => {
|
|
73
78
|
const carouselRef = useRef<FlatList>(null);
|
|
@@ -147,7 +152,12 @@ const Carousel = ({
|
|
|
147
152
|
/>
|
|
148
153
|
<StyledCarouselFooterWrapper>
|
|
149
154
|
{renderActions && renderActions(currentSlideIndex)}
|
|
150
|
-
|
|
155
|
+
{shouldShowPagination(currentSlideIndex) && (
|
|
156
|
+
<StyledPageControl
|
|
157
|
+
numberOfPages={items.length}
|
|
158
|
+
currentPage={currentSlideIndex}
|
|
159
|
+
/>
|
|
160
|
+
)}
|
|
151
161
|
</StyledCarouselFooterWrapper>
|
|
152
162
|
</StyledCarouselView>
|
|
153
163
|
</View>
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { ImageSourcePropType } from 'react-native';
|
|
2
|
+
import { ImageSourcePropType, ImageResizeMode } from 'react-native';
|
|
3
|
+
|
|
4
|
+
export type CarouselImageProps = ImageSourcePropType & {
|
|
5
|
+
height?: number;
|
|
6
|
+
width?: number;
|
|
7
|
+
resizeMode?: ImageResizeMode;
|
|
8
|
+
};
|
|
3
9
|
|
|
4
10
|
export type CarouselData = {
|
|
5
|
-
image:
|
|
11
|
+
image: CarouselImageProps | string;
|
|
6
12
|
content?: ReactNode;
|
|
7
13
|
heading: string;
|
|
8
14
|
body?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"activate":59000,"add-emoji":59001,"add-person":59002,"adjustment":59003,"alignment":59004,"antenna":59005,"archive":59006,"assignment-warning":59007,"bank":59008,"bell":59009,"billing":59010,"bookmark-added":59011,"bookmark":59012,"box-check":59013,"box":59014,"
|
|
1
|
+
{"activate":59000,"add-emoji":59001,"add-person":59002,"adjustment":59003,"alignment":59004,"antenna":59005,"archive":59006,"assignment-warning":59007,"bank":59008,"bell":59009,"billing":59010,"bookmark-added":59011,"bookmark":59012,"box-check":59013,"box":59014,"bpay":59015,"buildings":59016,"cake":59017,"calendar-clock":59018,"calendar":59019,"candy-box-menu":59020,"caret-down-small":59021,"caret-down":59022,"caret-left-small":59023,"caret-left":59024,"caret-right-small":59025,"caret-right":59026,"caret-up-small":59027,"caret-up":59028,"check-radio":59029,"circle-add":59030,"circle-cancel":59031,"circle-check":59032,"circle-down":59033,"circle-info":59034,"circle-left":59035,"circle-ok":59036,"circle-pencil":59037,"circle-question":59038,"circle-remove":59039,"circle-right":59040,"circle-up":59041,"circle-warning":59042,"clock-3":59043,"clock":59044,"cloud-download":59045,"cloud-upload":59046,"cog":59047,"coin":59048,"contacts":59049,"credit-card":59050,"diamond":59051,"direction-arrows":59052,"directory":59053,"document":59054,"dollar-coin-shine":59055,"double-buildings":59056,"edit-template":59057,"envelope":59058,"expense":59059,"eye-circle":59060,"eye-invisible":59061,"eye":59062,"face-meh":59063,"face-sad":59064,"face-smiley":59065,"feed":59066,"feedbacks":59067,"file-certified":59068,"file-clone":59069,"file-copy":59070,"file-csv":59071,"file-dispose":59072,"file-doc":59073,"file-excel":59074,"file-export":59075,"file-lock":59076,"file-pdf":59077,"file-powerpoint":59078,"file-search":59079,"file-secured":59080,"file-sheets":59081,"file-slide":59082,"file-verified":59083,"file-word":59084,"file":59085,"filter":59086,"folder-user":59087,"folder":59088,"format-bold":59089,"format-heading1":59090,"format-heading2":59091,"format-italic":59092,"format-list-bulleted":59093,"format-list-numbered":59094,"format-underlined":59095,"funnel-filter":59096,"global-dollar":59097,"globe":59098,"graduation-cap":59099,"graph":59100,"happy-sun":59101,"health-bag":59102,"heart":59103,"home":59104,"image":59105,"import":59106,"incident-siren":59107,"instapay":59108,"list":59109,"loading-2":59110,"loading":59111,"location":59112,"lock":59113,"looks-one":59114,"looks-two":59115,"media-content":59116,"menu":59117,"money-notes":59118,"moneybag":59119,"moon":59120,"multiple-stars":59121,"multiple-users":59122,"node":59123,"open-folder":59124,"paperclip":59125,"payment-summary":59126,"pencil":59127,"phone":59128,"piggy-bank":59129,"plane":59130,"play-circle":59131,"print":59132,"raising-hands":59133,"reply-arrow":59134,"reply":59135,"reschedule":59136,"rostering":59137,"save":59138,"schedule-send":59139,"schedule":59140,"search-person":59141,"send":59142,"speaker-active":59143,"speaker":59144,"star-award":59145,"star-badge":59146,"star-circle":59147,"star-medal":59148,"star":59149,"steps-circle":59150,"stopwatch":59151,"suitcase":59152,"survey":59153,"swag":59154,"switch":59155,"tag":59156,"target":59157,"teams":59158,"timesheet":59159,"touch-id":59160,"trash-bin":59161,"unlock":59162,"user":59163,"video-1":59164,"video-2":59165,"wallet":59166,"warning":59167,"activate-outlined":59168,"add-credit-card-outlined":59169,"add-person-outlined":59170,"add-section-outlined":59171,"add-time-outlined":59172,"add":59173,"adjustment-outlined":59174,"alignment-2-outlined":59175,"alignment-outlined":59176,"all-caps":59177,"arrow-down":59178,"arrow-downwards":59179,"arrow-left":59180,"arrow-leftwards":59181,"arrow-right":59182,"arrow-rightwards":59183,"arrow-up":59184,"arrow-upwards":59185,"article-outlined":59186,"at-sign":59187,"auto-graph-outlined":59188,"bell-active-outlined":59189,"bell-outlined":59190,"bell-slash-outlined":59191,"billing-outlined":59192,"body-outlined":59193,"bold":59194,"bookmark-added-outlined":59195,"bookmark-outlined":59196,"box-check-outlined":59197,"box-outlined":59198,"bullet-points":59199,"cake-outlined":59200,"calendar-dates-outlined":59201,"calendar-star-outlined":59202,"camera-outlined":59203,"cancel":59204,"charging-station-outlined":59205,"chat-bubble-outlined":59206,"chat-unread-outlined":59207,"checkmark":59208,"circle-add-outlined":59209,"circle-cancel-outlined":59210,"circle-down-outlined":59211,"circle-info-outlined":59212,"circle-left-outlined":59213,"circle-ok-outlined":59214,"circle-question-outlined":59215,"circle-remove-outlined":59216,"circle-right-outlined":59217,"circle-up-outlined":59218,"circle-warning-outlined":59219,"clock-2-outlined":59220,"clock-outlined":59221,"cog-outlined":59222,"coin-outlined":59223,"comment-outlined":59224,"contacts-outlined":59225,"contacts-user-outlined":59226,"credit-card-outlined":59227,"cup-outlined":59228,"direction-arrows-outlined":59229,"directory-outlined":59230,"document-outlined":59231,"dollar-box-outlined":59232,"dollar-card-outlined":59233,"dollar-coin-shine-outlined":59234,"dollar-credit-card-outlined":59235,"dollar-sign":59236,"double-buildings-outlined":59237,"double-left-arrows":59238,"double-right-arrows":59239,"download-outlined":59240,"edit-template-outlined":59241,"email-outlined":59242,"enter-arrow":59243,"envelope-outlined":59244,"expense-outlined":59245,"explore-outlined":59246,"external-link":59247,"eye-invisible-outlined":59248,"eye-outlined":59249,"face-id":59250,"face-meh-outlined":59251,"face-open-smiley-outlined":59252,"face-sad-outlined":59253,"face-smiley-outlined":59254,"feed-outlined":59255,"file-certified-outlined":59256,"file-clone-outlined":59257,"file-copy-outlined":59258,"file-dispose-outlined":59259,"file-dollar-certified-outlined":59260,"file-dollar-outlined":59261,"file-download-outlined":59262,"file-export-outlined":59263,"file-lock-outlined":59264,"file-outlined":59265,"file-search-outlined":59266,"file-secured-outlined":59267,"file-statutory-outlined":59268,"file-verified-outlined":59269,"filter-outlined":59270,"folder-outlined":59271,"folder-user-outlined":59272,"funnel-filter-outline":59273,"graph-outlined":59274,"hand-holding-user-outlined":59275,"happy-sun-outlined":59276,"health-bag-outlined":59277,"heart-outlined":59278,"home-active-outlined":59279,"home-outlined":59280,"id-card-outlined":59281,"image-outlined":59282,"import-outlined":59283,"instapay-outlined":59284,"italic":59285,"link-1":59286,"link-2":59287,"list-outlined":59288,"live-help-outlined":59289,"location-on-outlined":59290,"location-outlined":59291,"lock-outlined":59292,"locked-file-outlined":59293,"log-out":59294,"media-content-outlined":59295,"menu-close":59296,"menu-expand":59297,"menu-fold-outlined":59298,"menu-unfold-outlined":59299,"moneybag-outlined":59300,"moon-outlined":59301,"more-horizontal":59302,"more-vertical":59303,"multiple-folders-outlined":59304,"multiple-users-outlined":59305,"near-me-outlined":59306,"node-outlined":59307,"number-points":59308,"number":59309,"overview-outlined":59310,"payment-summary-outlined":59311,"payslip-outlined":59312,"pencil-outlined":59313,"percentage":59314,"phone-outlined":59315,"piggy-bank-outlined":59316,"plane-outlined":59317,"play-circle-outlined":59318,"print-outlined":59319,"qr-code-outlined":59320,"qualification-outlined":59321,"re-assign":59322,"redeem":59323,"refresh":59324,"remove":59325,"reply-outlined":59326,"restart":59327,"return-arrow":59328,"rostering-outlined":59329,"save-outlined":59330,"schedule-outlined":59331,"search-outlined":59332,"search-secured-outlined":59333,"send-outlined":59334,"share-1":59335,"share-2":59336,"share-outlined":59337,"show-chart-outlined":59338,"single-down-arrow":59339,"single-left-arrow":59340,"single-right-arrow":59341,"single-up-arrow":59342,"speaker-active-outlined":59343,"speaker-outlined":59344,"star-circle-outlined":59345,"star-outlined":59346,"stopwatch-outlined":59347,"strikethrough":59348,"suitcase-clock-outlined":59349,"suitcase-outlined":59350,"survey-outlined":59351,"switch-outlined":59352,"sync":59353,"target-outlined":59354,"timesheet-outlined":59355,"today-outlined":59356,"transfer":59357,"trash-bin-outlined":59358,"umbrela-outlined":59359,"unavailable":59360,"underline":59361,"unlock-outlined":59362,"upload-outlined":59363,"user-circle-outlined":59364,"user-gear-outlined":59365,"user-outlined":59366,"user-rectangle-outlined":59367,"video-1-outlined":59368,"video-2-outlined":59369,"wallet-outlined":59370}
|
|
@@ -15,6 +15,7 @@ const IconList = [
|
|
|
15
15
|
'bookmark',
|
|
16
16
|
'box-check',
|
|
17
17
|
'box',
|
|
18
|
+
'bpay',
|
|
18
19
|
'buildings',
|
|
19
20
|
'cake',
|
|
20
21
|
'calendar-clock',
|
|
@@ -204,6 +205,7 @@ const IconList = [
|
|
|
204
205
|
'calendar-star-outlined',
|
|
205
206
|
'camera-outlined',
|
|
206
207
|
'cancel',
|
|
208
|
+
'charging-station-outlined',
|
|
207
209
|
'chat-bubble-outlined',
|
|
208
210
|
'chat-unread-outlined',
|
|
209
211
|
'checkmark',
|
|
@@ -224,11 +226,13 @@ const IconList = [
|
|
|
224
226
|
'coin-outlined',
|
|
225
227
|
'comment-outlined',
|
|
226
228
|
'contacts-outlined',
|
|
229
|
+
'contacts-user-outlined',
|
|
227
230
|
'credit-card-outlined',
|
|
228
231
|
'cup-outlined',
|
|
229
232
|
'direction-arrows-outlined',
|
|
230
233
|
'directory-outlined',
|
|
231
234
|
'document-outlined',
|
|
235
|
+
'dollar-box-outlined',
|
|
232
236
|
'dollar-card-outlined',
|
|
233
237
|
'dollar-coin-shine-outlined',
|
|
234
238
|
'dollar-credit-card-outlined',
|
|
@@ -256,6 +260,7 @@ const IconList = [
|
|
|
256
260
|
'file-clone-outlined',
|
|
257
261
|
'file-copy-outlined',
|
|
258
262
|
'file-dispose-outlined',
|
|
263
|
+
'file-dollar-certified-outlined',
|
|
259
264
|
'file-dollar-outlined',
|
|
260
265
|
'file-download-outlined',
|
|
261
266
|
'file-export-outlined',
|
|
@@ -285,6 +290,7 @@ const IconList = [
|
|
|
285
290
|
'link-2',
|
|
286
291
|
'list-outlined',
|
|
287
292
|
'live-help-outlined',
|
|
293
|
+
'location-on-outlined',
|
|
288
294
|
'location-outlined',
|
|
289
295
|
'lock-outlined',
|
|
290
296
|
'locked-file-outlined',
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Animated, View } from 'react-native';
|
|
2
|
+
import styled from '@emotion/native';
|
|
3
|
+
|
|
4
|
+
const StyledPageControl = styled(View)(() => ({
|
|
5
|
+
flexDirection: 'row',
|
|
6
|
+
alignItems: 'center',
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
const StyledPageControlAnimatedView = styled(Animated.View)(({ theme }) => ({
|
|
10
|
+
height: theme.__hd__.pageControl.sizes.paginatorHeight,
|
|
11
|
+
width: theme.__hd__.pageControl.sizes.paginatorWidth,
|
|
12
|
+
borderRadius: theme.__hd__.pageControl.radii.paginatorBorderRadius,
|
|
13
|
+
backgroundColor: theme.__hd__.pageControl.colors.paginatorBackgroundColor,
|
|
14
|
+
marginHorizontal: theme.__hd__.pageControl.space.paginatorMarginHorizontal,
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
export { StyledPageControl, StyledPageControlAnimatedView };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`RefreshControl renders correctly 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
Array [
|
|
7
|
+
Object {
|
|
8
|
+
"alignItems": "center",
|
|
9
|
+
"flexDirection": "row",
|
|
10
|
+
},
|
|
11
|
+
undefined,
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
>
|
|
15
|
+
<View
|
|
16
|
+
collapsable={false}
|
|
17
|
+
style={
|
|
18
|
+
Object {
|
|
19
|
+
"backgroundColor": "#401960",
|
|
20
|
+
"borderRadius": 999,
|
|
21
|
+
"height": 8,
|
|
22
|
+
"marginHorizontal": 8,
|
|
23
|
+
"opacity": 0.5,
|
|
24
|
+
"width": 8,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
testID="page-control-indicator0"
|
|
28
|
+
/>
|
|
29
|
+
<View
|
|
30
|
+
collapsable={false}
|
|
31
|
+
style={
|
|
32
|
+
Object {
|
|
33
|
+
"backgroundColor": "#401960",
|
|
34
|
+
"borderRadius": 999,
|
|
35
|
+
"height": 8,
|
|
36
|
+
"marginHorizontal": 8,
|
|
37
|
+
"opacity": 1,
|
|
38
|
+
"width": 24,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
testID="page-control-indicator1"
|
|
42
|
+
/>
|
|
43
|
+
<View
|
|
44
|
+
collapsable={false}
|
|
45
|
+
style={
|
|
46
|
+
Object {
|
|
47
|
+
"backgroundColor": "#401960",
|
|
48
|
+
"borderRadius": 999,
|
|
49
|
+
"height": 8,
|
|
50
|
+
"marginHorizontal": 8,
|
|
51
|
+
"opacity": 0.5,
|
|
52
|
+
"width": 8,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
testID="page-control-indicator2"
|
|
56
|
+
/>
|
|
57
|
+
</View>
|
|
58
|
+
`;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
3
|
+
import PageControl from '..';
|
|
4
|
+
|
|
5
|
+
describe('RefreshControl', () => {
|
|
6
|
+
it('renders correctly', () => {
|
|
7
|
+
const { toJSON, getByTestId } = renderWithTheme(
|
|
8
|
+
<PageControl numberOfPages={3} currentPage={1} />
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
expect(toJSON()).toMatchSnapshot();
|
|
12
|
+
|
|
13
|
+
expect(getByTestId('page-control-indicator0')).toBeTruthy();
|
|
14
|
+
expect(getByTestId('page-control-indicator1')).toBeTruthy();
|
|
15
|
+
expect(getByTestId('page-control-indicator2')).toBeTruthy();
|
|
16
|
+
|
|
17
|
+
expect(getByTestId('page-control-indicator0')).toHaveStyle({ width: 8 });
|
|
18
|
+
expect(getByTestId('page-control-indicator1')).toHaveStyle({ width: 24 });
|
|
19
|
+
expect(getByTestId('page-control-indicator2')).toHaveStyle({ width: 8 });
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Animated, StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
StyledPageControlAnimatedView,
|
|
6
|
+
StyledPageControl,
|
|
7
|
+
} from './StyledPageControl';
|
|
8
|
+
import { useTheme } from '../../theme';
|
|
9
|
+
|
|
10
|
+
export interface PageControlProps {
|
|
11
|
+
/**
|
|
12
|
+
* The number of pages to display
|
|
13
|
+
*/
|
|
14
|
+
numberOfPages: number;
|
|
15
|
+
/**
|
|
16
|
+
* The current page to display
|
|
17
|
+
*/
|
|
18
|
+
currentPage: number;
|
|
19
|
+
/**
|
|
20
|
+
* Additional styles
|
|
21
|
+
*/
|
|
22
|
+
style?: StyleProp<ViewStyle>;
|
|
23
|
+
/**
|
|
24
|
+
* Testing id of the component.
|
|
25
|
+
*/
|
|
26
|
+
testID?: string;
|
|
27
|
+
}
|
|
28
|
+
const PageControl = ({
|
|
29
|
+
numberOfPages,
|
|
30
|
+
currentPage = 0,
|
|
31
|
+
testID,
|
|
32
|
+
style,
|
|
33
|
+
}: PageControlProps) => {
|
|
34
|
+
const theme = useTheme();
|
|
35
|
+
|
|
36
|
+
const animatedValue = React.useRef(new Animated.Value(currentPage)).current;
|
|
37
|
+
|
|
38
|
+
React.useEffect(() => {
|
|
39
|
+
animatedValue.setValue(currentPage);
|
|
40
|
+
}, [currentPage]);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<StyledPageControl testID={testID} style={style}>
|
|
44
|
+
{new Array(numberOfPages).fill('').map((_, index) => {
|
|
45
|
+
const inputRange = [index - 1, index, index + 1];
|
|
46
|
+
|
|
47
|
+
const indicatorWidth = animatedValue.interpolate({
|
|
48
|
+
inputRange,
|
|
49
|
+
outputRange: [
|
|
50
|
+
theme.space.small,
|
|
51
|
+
theme.space.large,
|
|
52
|
+
theme.space.small,
|
|
53
|
+
],
|
|
54
|
+
extrapolate: 'clamp',
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const opacity = animatedValue.interpolate({
|
|
58
|
+
inputRange,
|
|
59
|
+
outputRange: [0.5, 1, 0.5],
|
|
60
|
+
extrapolate: 'clamp',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<StyledPageControlAnimatedView
|
|
65
|
+
style={[{ width: indicatorWidth, opacity }]}
|
|
66
|
+
key={index.toString()}
|
|
67
|
+
testID={`page-control-indicator${index}`}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
})}
|
|
71
|
+
</StyledPageControl>
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default PageControl;
|
package/src/index.ts
CHANGED
|
@@ -53,6 +53,7 @@ import Toolbar from './components/Toolbar';
|
|
|
53
53
|
import Typography from './components/Typography';
|
|
54
54
|
import RefreshControl from './components/RefreshControl';
|
|
55
55
|
import RichTextEditor from './components/RichTextEditor';
|
|
56
|
+
import PageControl from './components/PageControl';
|
|
56
57
|
|
|
57
58
|
export {
|
|
58
59
|
theme,
|
|
@@ -92,6 +93,7 @@ export {
|
|
|
92
93
|
List,
|
|
93
94
|
PinInput,
|
|
94
95
|
Progress,
|
|
96
|
+
PageControl,
|
|
95
97
|
Slider,
|
|
96
98
|
Spinner,
|
|
97
99
|
Swipeable,
|
|
@@ -254,9 +254,6 @@ Object {
|
|
|
254
254
|
},
|
|
255
255
|
},
|
|
256
256
|
"carousel": Object {
|
|
257
|
-
"colors": Object {
|
|
258
|
-
"paginatorBackgroundColor": "#401960",
|
|
259
|
-
},
|
|
260
257
|
"fontSizes": Object {
|
|
261
258
|
"heading": 32,
|
|
262
259
|
},
|
|
@@ -266,21 +263,12 @@ Object {
|
|
|
266
263
|
"lineHeights": Object {
|
|
267
264
|
"heading": 44,
|
|
268
265
|
},
|
|
269
|
-
"radii": Object {
|
|
270
|
-
"paginatorBorderRadius": 999,
|
|
271
|
-
},
|
|
272
|
-
"sizes": Object {
|
|
273
|
-
"indicatorWidth": 16,
|
|
274
|
-
"paginatorHeight": 8,
|
|
275
|
-
"paginatorWidth": 8,
|
|
276
|
-
},
|
|
277
266
|
"space": Object {
|
|
278
267
|
"footerMarginBottom": 24,
|
|
279
268
|
"footerPaddingHorizontal": 24,
|
|
280
269
|
"footerPaddingVertical": 16,
|
|
281
270
|
"headingMarginBottom": 16,
|
|
282
271
|
"headingMarginTop": 8,
|
|
283
|
-
"paginatorMarginHorizontal": 8,
|
|
284
272
|
},
|
|
285
273
|
},
|
|
286
274
|
"checkbox": Object {
|
|
@@ -498,6 +486,22 @@ Object {
|
|
|
498
486
|
"leadingStatus": 8,
|
|
499
487
|
},
|
|
500
488
|
},
|
|
489
|
+
"pageControl": Object {
|
|
490
|
+
"colors": Object {
|
|
491
|
+
"paginatorBackgroundColor": "#401960",
|
|
492
|
+
},
|
|
493
|
+
"radii": Object {
|
|
494
|
+
"paginatorBorderRadius": 999,
|
|
495
|
+
},
|
|
496
|
+
"sizes": Object {
|
|
497
|
+
"indicatorWidth": 16,
|
|
498
|
+
"paginatorHeight": 8,
|
|
499
|
+
"paginatorWidth": 8,
|
|
500
|
+
},
|
|
501
|
+
"space": Object {
|
|
502
|
+
"paginatorMarginHorizontal": 8,
|
|
503
|
+
},
|
|
504
|
+
},
|
|
501
505
|
"pinInput": Object {
|
|
502
506
|
"borderWidths": Object {
|
|
503
507
|
"default": 1,
|
|
@@ -938,6 +942,7 @@ Object {
|
|
|
938
942
|
"small": 12,
|
|
939
943
|
"xlarge": 18,
|
|
940
944
|
"xxxlarge": 24,
|
|
945
|
+
"xxxxlarge": 28,
|
|
941
946
|
"xxxxxlarge": 32,
|
|
942
947
|
},
|
|
943
948
|
"fonts": Object {
|
|
@@ -960,6 +965,7 @@ Object {
|
|
|
960
965
|
"small": 20,
|
|
961
966
|
"xlarge": 26,
|
|
962
967
|
"xxxlarge": 32,
|
|
968
|
+
"xxxxlarge": 36,
|
|
963
969
|
"xxxxxlarge": 40,
|
|
964
970
|
},
|
|
965
971
|
},
|
|
@@ -1,29 +1,14 @@
|
|
|
1
1
|
import type { GlobalTheme } from '../global';
|
|
2
2
|
|
|
3
3
|
const getCarouselTheme = (theme: GlobalTheme) => {
|
|
4
|
-
const colors = {
|
|
5
|
-
paginatorBackgroundColor: theme.colors.primary,
|
|
6
|
-
};
|
|
7
|
-
|
|
8
4
|
const space = {
|
|
9
5
|
headingMarginTop: theme.space.small,
|
|
10
6
|
headingMarginBottom: theme.space.medium,
|
|
11
|
-
paginatorMarginHorizontal: theme.space.small,
|
|
12
7
|
footerPaddingHorizontal: theme.space.large,
|
|
13
8
|
footerPaddingVertical: theme.space.medium,
|
|
14
9
|
footerMarginBottom: theme.space.large,
|
|
15
10
|
};
|
|
16
11
|
|
|
17
|
-
const sizes = {
|
|
18
|
-
indicatorWidth: theme.sizes.medium,
|
|
19
|
-
paginatorHeight: theme.sizes.small,
|
|
20
|
-
paginatorWidth: theme.sizes.small,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const radii = {
|
|
24
|
-
paginatorBorderRadius: theme.radii.rounded,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
12
|
const fontSizes = {
|
|
28
13
|
heading: theme.fontSizes['xxxxxlarge'],
|
|
29
14
|
};
|
|
@@ -36,7 +21,7 @@ const getCarouselTheme = (theme: GlobalTheme) => {
|
|
|
36
21
|
heading: theme.lineHeights['6xlarge'],
|
|
37
22
|
};
|
|
38
23
|
|
|
39
|
-
return {
|
|
24
|
+
return { space, fonts, fontSizes, lineHeights };
|
|
40
25
|
};
|
|
41
26
|
|
|
42
27
|
export default getCarouselTheme;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { GlobalTheme } from '../global';
|
|
2
|
+
|
|
3
|
+
const getPageControlTheme = (theme: GlobalTheme) => {
|
|
4
|
+
const colors = {
|
|
5
|
+
paginatorBackgroundColor: theme.colors.primary,
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const sizes = {
|
|
9
|
+
indicatorWidth: theme.sizes.medium,
|
|
10
|
+
paginatorHeight: theme.sizes.small,
|
|
11
|
+
paginatorWidth: theme.sizes.small,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const space = {
|
|
15
|
+
paginatorMarginHorizontal: theme.space.small,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const radii = {
|
|
19
|
+
paginatorBorderRadius: theme.radii.rounded,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return { colors, sizes, space, radii };
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default getPageControlTheme;
|
|
@@ -20,6 +20,7 @@ const getTypographyTheme = (theme: GlobalTheme) => {
|
|
|
20
20
|
large: theme.fontSizes.large,
|
|
21
21
|
xlarge: theme.fontSizes.xlarge,
|
|
22
22
|
xxxlarge: theme.fontSizes.xxxlarge,
|
|
23
|
+
xxxxlarge: theme.fontSizes.xxxxlarge,
|
|
23
24
|
xxxxxlarge: theme.fontSizes.xxxxxlarge,
|
|
24
25
|
'6xlarge': theme.fontSizes['6xlarge'],
|
|
25
26
|
'7xlarge': theme.fontSizes['7xlarge'],
|
|
@@ -31,6 +32,7 @@ const getTypographyTheme = (theme: GlobalTheme) => {
|
|
|
31
32
|
large: theme.lineHeights.large,
|
|
32
33
|
xlarge: theme.lineHeights.xlarge,
|
|
33
34
|
xxxlarge: theme.lineHeights.xxxlarge,
|
|
35
|
+
xxxxlarge: theme.lineHeights.xxxxlarge,
|
|
34
36
|
xxxxxlarge: theme.lineHeights.xxxxxlarge,
|
|
35
37
|
'6xlarge': theme.lineHeights['6xlarge'],
|
|
36
38
|
'7xlarge': theme.lineHeights['7xlarge'],
|
package/src/theme/getTheme.ts
CHANGED
|
@@ -21,6 +21,7 @@ import getFABTheme from './components/fab';
|
|
|
21
21
|
import getIconTheme from './components/icon';
|
|
22
22
|
import getImageTheme from './components/image';
|
|
23
23
|
import getListTheme from './components/list';
|
|
24
|
+
import getPageControlTheme from './components/pageControl';
|
|
24
25
|
import getPinInputTheme from './components/pinInput';
|
|
25
26
|
import getProgressTheme from './components/progress';
|
|
26
27
|
import getRadioTheme from './components/radio';
|
|
@@ -65,6 +66,7 @@ type Theme = GlobalTheme & {
|
|
|
65
66
|
icon: ReturnType<typeof getIconTheme>;
|
|
66
67
|
image: ReturnType<typeof getImageTheme>;
|
|
67
68
|
list: ReturnType<typeof getListTheme>;
|
|
69
|
+
pageControl: ReturnType<typeof getPageControlTheme>;
|
|
68
70
|
pinInput: ReturnType<typeof getPinInputTheme>;
|
|
69
71
|
progress: ReturnType<typeof getProgressTheme>;
|
|
70
72
|
radio: ReturnType<typeof getRadioTheme>;
|
|
@@ -115,6 +117,7 @@ const getTheme = (
|
|
|
115
117
|
icon: getIconTheme(globalTheme),
|
|
116
118
|
image: getImageTheme(globalTheme),
|
|
117
119
|
list: getListTheme(globalTheme),
|
|
120
|
+
pageControl: getPageControlTheme(globalTheme),
|
|
118
121
|
pinInput: getPinInputTheme(globalTheme),
|
|
119
122
|
progress: getProgressTheme(globalTheme),
|
|
120
123
|
radio: getRadioTheme(globalTheme),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { View } from 'react-native';
|
|
1
|
+
import { View, ImageResizeMode } from 'react-native';
|
|
2
2
|
declare const StyledBackDrop: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
|
|
3
3
|
theme?: import("@emotion/react").Theme | undefined;
|
|
4
4
|
as?: import("react").ElementType<any> | undefined;
|
|
@@ -21,6 +21,14 @@ declare const StyledCarouselImage: import("@emotion/native").StyledComponent<imp
|
|
|
21
21
|
theme?: import("@emotion/react").Theme | undefined;
|
|
22
22
|
as?: import("react").ElementType<any> | undefined;
|
|
23
23
|
}, {}, {}>;
|
|
24
|
+
declare const StyledCustomSizeCarouselImage: import("@emotion/native").StyledComponent<import("../Image").ImageProps & {
|
|
25
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
26
|
+
as?: import("react").ElementType<any> | undefined;
|
|
27
|
+
} & {
|
|
28
|
+
height?: number | undefined;
|
|
29
|
+
width?: number | undefined;
|
|
30
|
+
resizeMode?: ImageResizeMode | undefined;
|
|
31
|
+
}, {}, {}>;
|
|
24
32
|
declare const StyledCarouselContentWrapper: import("@emotion/native").StyledComponent<import("../Box").BoxProps & {
|
|
25
33
|
theme?: import("@emotion/react").Theme | undefined;
|
|
26
34
|
as?: import("react").ElementType<any> | undefined;
|
|
@@ -33,4 +41,8 @@ declare const StyledCarouselFooterWrapper: import("@emotion/native").StyledCompo
|
|
|
33
41
|
}, {}, {
|
|
34
42
|
ref?: import("react").Ref<View> | undefined;
|
|
35
43
|
}>;
|
|
36
|
-
|
|
44
|
+
declare const StyledPageControl: import("@emotion/native").StyledComponent<import("../PageControl").PageControlProps & {
|
|
45
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
46
|
+
as?: import("react").ElementType<any> | undefined;
|
|
47
|
+
}, {}, {}>;
|
|
48
|
+
export { StyledBackDrop, StyledCarouselView, StyledCarouselHeading, StyledCarouselImage, StyledCarouselContentWrapper, StyledCarouselFooterWrapper, StyledCustomSizeCarouselImage, StyledPageControl, };
|
|
@@ -22,11 +22,15 @@ interface CarouselProps extends ViewProps {
|
|
|
22
22
|
* Render action elements function.
|
|
23
23
|
*/
|
|
24
24
|
renderActions?: (pageIndex: number) => JSX.Element;
|
|
25
|
+
/**
|
|
26
|
+
* Should show paginations
|
|
27
|
+
*/
|
|
28
|
+
shouldShowPagination?: (pageIndex: number) => boolean;
|
|
25
29
|
/**
|
|
26
30
|
* Current selected item index.
|
|
27
31
|
*/
|
|
28
32
|
selectedItemIndex?: number;
|
|
29
33
|
}
|
|
30
34
|
export declare function useStateFromProp<T>(initialValue: T): [T, Dispatch<SetStateAction<T>>];
|
|
31
|
-
declare const Carousel: ({ items, onItemIndexChange, renderActions, selectedItemIndex, style, ...nativeProps }: CarouselProps) => JSX.Element;
|
|
35
|
+
declare const Carousel: ({ items, onItemIndexChange, renderActions, selectedItemIndex, style, shouldShowPagination, ...nativeProps }: CarouselProps) => JSX.Element;
|
|
32
36
|
export default Carousel;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { ImageSourcePropType } from 'react-native';
|
|
2
|
+
import { ImageSourcePropType, ImageResizeMode } from 'react-native';
|
|
3
|
+
export declare type CarouselImageProps = ImageSourcePropType & {
|
|
4
|
+
height?: number;
|
|
5
|
+
width?: number;
|
|
6
|
+
resizeMode?: ImageResizeMode;
|
|
7
|
+
};
|
|
3
8
|
export declare type CarouselData = {
|
|
4
|
-
image:
|
|
9
|
+
image: CarouselImageProps | string;
|
|
5
10
|
content?: ReactNode;
|
|
6
11
|
heading: string;
|
|
7
12
|
body?: string;
|