-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Conversation
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 }, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The SIZES type
src/__tests__/Block.test.tsx
Outdated
@@ -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); | |||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs fix too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test
There was a problem hiding this 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, |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
@taleco22 I would like to add ONLY the type definitions for components as requested in #42 |
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 |
There was a problem hiding this comment.
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>
@taleco22 Yes, I reviewed the code and I have left a comment on the Button component |
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. |
@msanvarov |
@talesdsp @msanvarov guys you can create a new branch named "ts" or "typescript" and use that in your projects, would that be helpful? |
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 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 :) |
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 |
No description provided.