Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-slider-intro",
"version": "2.0.4",
"version": "2.0.5",
"description": "A simple and full customizable React Native package which implements a unique slider.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down Expand Up @@ -71,6 +71,7 @@
"@release-it/conventional-changelog": "^5.0.0",
"@types/jest": "^29.5.5",
"@types/react": "^18.2.44",
"@types/react-test-renderer": "^18.0.7",
"commitlint": "^17.0.2",
"del-cli": "^5.1.0",
"eslint": "^8.51.0",
Expand All @@ -81,6 +82,7 @@
"react": "18.2.0",
"react-native": "0.73.6",
"react-native-builder-bob": "^0.23.2",
"react-test-renderer": "^18.2.0",
"release-it": "^15.0.0",
"typescript": "^5.2.2"
},
Expand Down
18 changes: 18 additions & 0 deletions src/__tests__/Button.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import renderer from 'react-test-renderer';
import Button from '../components/Button';
import { Text } from 'react-native';

describe('Button', () => {
it('renders correctly', () => {
const tree = renderer.create(<Button label="test" type="done" />).toJSON();
expect(tree).toMatchSnapshot();
});

it('displays the correct label', () => {
const component = renderer.create(<Button label="test" type="done" />);
const instance = component.root;
const textComponent = instance.findByType(Text);
expect(textComponent.props.children).toBe('test');
});
});
16 changes: 16 additions & 0 deletions src/__tests__/__snapshots__/Button.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Button renders correctly 1`] = `
<Text
style={
{
"color": "white",
"fontSize": 14,
"fontWeight": "bold",
"textTransform": "uppercase",
}
}
>
test
</Text>
`;
1 change: 0 additions & 1 deletion src/__tests__/index.test.tsx

This file was deleted.

29 changes: 29 additions & 0 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import type { IButton } from '../interfaces/IButton.interface';

const styles = StyleSheet.create({
skipButton: {
justifyContent: 'center',
alignItems: 'center',
},
label: {
textTransform: 'uppercase',
fontWeight: 'bold',
color: 'white',
fontSize: 14,
},
});

const Button = ({ label, type }: IButton) => {
if (type === 'skip') {
return (
<View style={styles.skipButton}>
<Text style={styles.label}>{label}</Text>
</View>
);
}
return <Text style={styles.label}>{label}</Text>;
};

export default Button;
18 changes: 0 additions & 18 deletions src/components/DoneButton.tsx

This file was deleted.

18 changes: 0 additions & 18 deletions src/components/NextButton.tsx

This file was deleted.

24 changes: 0 additions & 24 deletions src/components/SkipButton.tsx

This file was deleted.

10 changes: 4 additions & 6 deletions src/components/SliderIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ import {
import type { IItem } from 'interfaces/IItem.interface';
import type { ISliderIntro } from 'interfaces/ISliderIntro.interface';
import type { ISlide } from '../interfaces/ISlide.interface';
import DoneButton from './DoneButton';
import Button from './Button';
import DotContainer from './DotContainer';
import Item from './Item';
import NextButton from './NextButton';
import NextContainer from './NextContainer';
import PrevContainer from './PrevContainer';
import SkipButton from './SkipButton';
import StatusBarContainer from './StatusBarContainer';
import React from 'react';

Expand Down Expand Up @@ -351,13 +349,13 @@ const defaultProps: ISliderIntro = {
nextLabel: 'Next',
doneLabel: 'Done',
renderSkipButton: (skipLabel: string | undefined) => (
<SkipButton skipLabel={skipLabel} />
<Button label={skipLabel} type="skip" />
),
renderNextButton: (nextLabel: string | undefined) => (
<NextButton nextLabel={nextLabel} />
<Button label={nextLabel} type="next" />
),
renderDoneButton: (doneLabel: string | undefined) => (
<DoneButton doneLabel={doneLabel} />
<Button label={doneLabel} type="done" />
),
onDone: () => {},
onSkip: () => {},
Expand Down
4 changes: 4 additions & 0 deletions src/interfaces/IButton.interface.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface IButton {
type: 'skip' | 'done' | 'next' | 'prev';
label?: string;
}
3 changes: 0 additions & 3 deletions src/interfaces/IDoneButton.interface.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions src/interfaces/INextButton.interface.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions src/interfaces/ISkipButton.interface.tsx

This file was deleted.

4 changes: 1 addition & 3 deletions src/interfaces/index.d.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
export * from './IAnimatedValues.interface';
export * from './IDoneButton.interface';
export * from './IButton.interface';
export * from './IDotContainer.interface';
export * from './IItem.interface';
export * from './INextButton.interface';
export * from './INextContainer.interface';
export * from './IPrevContainer.interface';
export * from './ISkipButton.interface';
export * from './ISlide.interface';
export * from './ISliderIntro.interface';
export * from './IStatusBar.interface';
26 changes: 25 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4025,6 +4025,15 @@ __metadata:
languageName: node
linkType: hard

"@types/react-test-renderer@npm:^18.0.7":
version: 18.0.7
resolution: "@types/react-test-renderer@npm:18.0.7"
dependencies:
"@types/react": "*"
checksum: 701d7d815fe7b921712ebdb2c4434e99b92403d37c51b33a01ce1b62fed7d1efbf9f749971d9031a5b137c6d5e194249c378106768aa69725a01f150fef0ec7f
languageName: node
linkType: hard

"@types/react@npm:^18.2.44":
version: 18.2.67
resolution: "@types/react@npm:18.2.67"
Expand Down Expand Up @@ -14787,7 +14796,7 @@ __metadata:
languageName: node
linkType: hard

"react-is@npm:^16.12.0 || ^17.0.0 || ^18.0.0, react-is@npm:^18.0.0":
"react-is@npm:^16.12.0 || ^17.0.0 || ^18.0.0, react-is@npm:^18.0.0, react-is@npm:^18.2.0":
version: 18.2.0
resolution: "react-is@npm:18.2.0"
checksum: e72d0ba81b5922759e4aff17e0252bd29988f9642ed817f56b25a3e217e13eea8a7f2322af99a06edb779da12d5d636e9fda473d620df9a3da0df2a74141d53e
Expand Down Expand Up @@ -14892,6 +14901,7 @@ __metadata:
"@release-it/conventional-changelog": ^5.0.0
"@types/jest": ^29.5.5
"@types/react": ^18.2.44
"@types/react-test-renderer": ^18.0.7
commitlint: ^17.0.2
del-cli: ^5.1.0
eslint: ^8.51.0
Expand All @@ -14902,6 +14912,7 @@ __metadata:
react: 18.2.0
react-native: 0.73.6
react-native-builder-bob: ^0.23.2
react-test-renderer: ^18.2.0
release-it: ^15.0.0
typescript: ^5.2.2
peerDependencies:
Expand Down Expand Up @@ -15011,6 +15022,19 @@ __metadata:
languageName: node
linkType: hard

"react-test-renderer@npm:^18.2.0":
version: 18.2.0
resolution: "react-test-renderer@npm:18.2.0"
dependencies:
react-is: ^18.2.0
react-shallow-renderer: ^16.15.0
scheduler: ^0.23.0
peerDependencies:
react: ^18.2.0
checksum: 6b6980ced93fa2b72662d5e4ab3b4896833586940047ce52ca9aca801e5432adf05fcbe28289b0af3ce6a2a7c590974e25dcc8aa43d0de658bfe8bbcd686f958
languageName: node
linkType: hard

"react@npm:18.2.0":
version: 18.2.0
resolution: "react@npm:18.2.0"
Expand Down