Skip to content

Migrate Slider, GradientSlider and ColorSliderGroup components to TypeScript. #1408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Aug 5, 2021

Conversation

saulve
Copy link
Contributor

@saulve saulve commented Jul 15, 2021

Description

This PR migrates the aforementioned components to TS with minor improvements.

Changelog

Migrated Slider context files
Deleted Slider.d.ts
Added default color prop for GradientSlider (the color prop is optional, however when it's not provided the slider component crashes.)

@@ -20,7 +20,6 @@ import Text from '../text';
import TouchableOpacity from '../touchableOpacity';
import Dialog, {DialogProps} from '../dialog';
import Button from '../button';
//@ts-expect-error
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shows as an error in TS compile, however I don't see a reason for it, so I removed it.

/**
* If true the component will have accessibility features enabled
*/
accessible?: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added accessible prop to toggle accessibility

/**
* If true the component will have accessibility features enabled
*/
accessible?: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added accessible, containerStyle, and disabled prop definitions.

super(props);

this.state = {
prevColor: props.color,
color: props.color ? Colors.getHSL(props.color) : undefined
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this.state.color undefined causes this component crash. Added color in defaultProps to prevent this.

/**
* If true the component will have accessibility features enabled
*/
accessible?: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added accessible prop type definition here

@saulve saulve requested review from Inbal-Tish and Niryo July 15, 2021 13:30
@ethanshar ethanshar requested review from mendyEdri and removed request for Niryo July 15, 2021 15:34
@@ -2,6 +2,16 @@ type Constructor<T, TA = any> = new(...args: TA[]) => T;
type ExtendTypeWith<T extends Constructor<any>, OtherObject extends object> = Constructor<InstanceType<T> & OtherObject, ConstructorParameters<T>>;
type Dictionary<TYPE> = {[key: string]: TYPE};

declare module 'react-native-color' {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure where non-typed js dependencies are declared, so I've added these dependencies here. Is this the right place?

@ethanshar
Copy link
Collaborator

@mendyEdri
Can you please take a look, it's been waiting for some time..

Copy link
Contributor

@mendyEdri mendyEdri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. I think just the docs need to point the .jsx files

@saulve
Copy link
Contributor Author

saulve commented Aug 2, 2021

@mendyEdri good catch. I've changed the example to point to tsx files

@saulve saulve requested a review from mendyEdri August 2, 2021 08:34
@ethanshar ethanshar removed the request for review from Inbal-Tish August 3, 2021 05:45
@ethanshar
Copy link
Collaborator

I think the CI here is stuck for some reason..
I merged PR with master to trigger another CI build, let's see how it goes..

@saulve
Copy link
Contributor Author

saulve commented Aug 4, 2021

@ethanshar seems to be still stuck

@ethanshar
Copy link
Collaborator

@ethanshar seems to be still stuck

Yes, I wrote in mobile-oss-ci channel

@saulve saulve merged commit 0b403f7 into master Aug 5, 2021
@saulve saulve deleted the typescript/slider branch August 5, 2021 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants