Skip to content
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

Add typescript/#42 #47

Merged
merged 15 commits into from
Apr 22, 2020
Merged

Conversation

talesdsp
Copy link
Contributor

No description provided.

@talesdsp
Copy link
Contributor Author

Obs: I found that sometimes running tests with dist folder created throws an Emit skip error. Just warning in case it happens with you.

src/Block.tsx Outdated
shadowRadius: elevation
},
space && { justifyContent: `space-${space}` },
card && { borderRadius: 12 },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apparently SIZES.border is not declared, and I don't know what the value should be

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to add a new value for SIZES.borderRadius

src/theme.ts Outdated
info: "#4DA1FF"
};

export const SIZES: Sizes = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The SIZES constant. It should be radius?

Copy link
Contributor

Choose a reason for hiding this comment

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

SIZES is an object with values for different usage.
For example: radius is used for borderRadius

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! I should have been clear than that. What I mean is, the SIZES.radius is the correct value for the failing test below?

src/global.ts Outdated
info: string;
};

export type Sizes = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The SIZES type

@@ -421,7 +421,8 @@ describe("<Block />", () => {

const style = StyleSheet.flatten(component.props.style);
expect(instance.props.card).toEqual(true);
expect(style.borderRadius).toEqual(SIZES.border);
//!TODO: border value
expect(style.borderRadius).toEqual(SIZES.height);
});
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Needs fix too

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 test

Copy link
Contributor

@hetmann hetmann left a comment

Choose a reason for hiding this comment

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

I notice that the latest changes for #33 where not included in your PR.

src/Button.tsx Outdated
const {
disabled,
opacity,
outlined,
flex,
height,
borderWidth,
Copy link
Contributor

Choose a reason for hiding this comment

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

The last commit had the fix for borderWidth & borderColor

src/Button.tsx Outdated
if (disabled) {
const backgroundColor = StyleSheet.flatten(buttonStyles).backgroundColor;
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be extracted outside the if condition as it is used multiple times. See the last PR merge

@hetmann
Copy link
Contributor

hetmann commented Apr 13, 2020

@taleco22 I would like to add ONLY the type definitions for components as requested in #42
This will keep the library as light as possible, using a .d.ts file for the component/s.

@talesdsp
Copy link
Contributor Author

talesdsp commented Apr 22, 2020

I 've fixed what was missing from #33. Extracted the background. Removed the .tsx files. And kept just the type definitions now 😅👍

Is there anything else?

src/Button.js Outdated
@@ -205,7 +209,7 @@ function Button(props) {
buttonStyles.backgroundColor = "transparent";
}

const ButtonType = highlight
const touch = highlight
Copy link
Contributor

Choose a reason for hiding this comment

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

touch can be named Touchable or ButtonInstance and instead of RenderButton you can call it like this:

<Touchable
  {...extraProps}
  disabled={disabled}
  activeOpacity={opacity}
  style={buttonStyles}>
  {children}
</Touchable>

@hetmann
Copy link
Contributor

hetmann commented Apr 22, 2020

I 've fixed what was missing from #33. Extracted the background. Removed the .tsx files. And kept just the type definitions now 😅👍

Is there anything else?

@taleco22 Yes, I reviewed the code and I have left a comment on the Button component

@hetmann hetmann merged commit 7900837 into react-ui-kit:master Apr 22, 2020
@msanvarov
Copy link

Hey @hetmann, love the work that is being done with this library, but I plead that you allow @talesdsp to continue with Typescript development. In my attempts to extend and even use this component library, I have come across some issues that can be solved if this library is ported back to Typescript. I'm willing to contribute along with @talesdsp to get it back to the state it was in before. I think declaration files are not enough for this type of ui library. Here is an example of another popular react native library built with Typescript: https://github.com/akveo/react-native-ui-kitten.

@talesdsp
Copy link
Contributor Author

talesdsp commented May 8, 2020

@msanvarov
Issues with usage? Can you be more specific?
Well, if the project turns out to typescript again mostly is already done up here. Won't be a pain to re-add it.

@hetmann
Copy link
Contributor

hetmann commented May 8, 2020

@talesdsp @msanvarov guys you can create a new branch named "ts" or "typescript" and use that in your projects, would that be helpful?

@msanvarov
Copy link

msanvarov commented May 8, 2020

@msanvarov
Issues with usage? Can you be more specific?
Well, if the project turns out to typescript again mostly is already done up here. Won't be a pain to re-add it.

To begin with the utility helpers don't have types, so using them means I have to copy the test cases to understand the implementation. In terms of the implementation, stuff like this const isArray = typeof padding === "object"; seems weird because to check if a variable is an array, the following can be used Array.isArray(padding)

I also don't understand why this is done:

export interface CardProps extends CardOptions, ThemeProps {
  [key: string]: any;
}

This defeats the purpose of typing if you are going to allow any key value to be accepted as a prop.

@hetmann
Copy link
Contributor

hetmann commented May 8, 2020

@msanvarov
Issues with usage? Can you be more specific?
Well, if the project turns out to typescript again mostly is already done up here. Won't be a pain to re-add it.

To begin with the utility helpers don't have types, so using them means I have to copy the test cases to understand the implementation. In terms of the implementation, stuff like this const isArray = typeof padding === "object"; seems weird because to check if a variable is an array, the following can be used Array.isArray(padding)

I also don't understand why this is done:

export interface CardProps extends CardOptions, ThemeProps {
  [key: string]: any;
}

This defeats the purpose of typing if you are going to allow any key value to be accepted as a prop.

I was using the old style "typeof" checking for types :)
To understand the utils you can read the comments, I did my best to add an easy to understand usage.

@msanvarov
Copy link

@msanvarov
Issues with usage? Can you be more specific?
Well, if the project turns out to typescript again mostly is already done up here. Won't be a pain to re-add it.

To begin with the utility helpers don't have types, so using them means I have to copy the test cases to understand the implementation. In terms of the implementation, stuff like this const isArray = typeof padding === "object"; seems weird because to check if a variable is an array, the following can be used Array.isArray(padding)
I also don't understand why this is done:

export interface CardProps extends CardOptions, ThemeProps {
  [key: string]: any;
}

This defeats the purpose of typing if you are going to allow any key value to be accepted as a prop.

I was using the old style "typeof" checking for types :)
To understand the utils you can read the comments, I did my best to add an easy to understand usage.

I think it will be cool is get jsdoc integration for the examples you made then when we create a gitbook to detail using this library, it will be easier to showcase some use cases for it.

@hetmann
Copy link
Contributor

hetmann commented May 9, 2020

@msanvarov
Issues with usage? Can you be more specific?
Well, if the project turns out to typescript again mostly is already done up here. Won't be a pain to re-add it.

To begin with the utility helpers don't have types, so using them means I have to copy the test cases to understand the implementation. In terms of the implementation, stuff like this const isArray = typeof padding === "object"; seems weird because to check if a variable is an array, the following can be used Array.isArray(padding)
I also don't understand why this is done:

export interface CardProps extends CardOptions, ThemeProps {
  [key: string]: any;
}

This defeats the purpose of typing if you are going to allow any key value to be accepted as a prop.

I was using the old style "typeof" checking for types :)
To understand the utils you can read the comments, I did my best to add an easy to understand usage.

I think it will be cool is get jsdoc integration for the examples you made then when we create a gitbook to detail using this library, it will be easier to showcase some use cases for it.

I have in plan to do an actual app for this UI kit :) see #23
Also the jsdoc or gitbook would be nice to have

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants