-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat: DataTable component #446
Conversation
5e819e4
to
3d79fac
Compare
/** | ||
* Content of the `DataTableCell`. | ||
*/ | ||
children: string | React.Node, |
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.
can be just React.Node (https://flow.org/en/docs/react/types/#toc-react-node)
|
||
import React from 'react'; | ||
import { StyleSheet, TouchableOpacity, View } from 'react-native'; | ||
import Text from './../Typography/Text'; |
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.
'../Typography/Text'
should be enough. Same for other imports. That's minor though :)
} | ||
} | ||
|
||
render(): Object { |
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.
is the Object type here needed?
* Customize the rows per page label. Invoked with a `{ from, to, count, page }` | ||
* object. | ||
*/ | ||
labelRowsPerPage?: () => mixed, |
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.
string here maybe?
import DataTableRow from './DataTableRow'; | ||
|
||
type Props = { | ||
style?: any, |
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.
missing children prop
import { View } from 'react-native'; | ||
|
||
type Props = { | ||
style?: any, |
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.
missing children prop
@@ -0,0 +1,141 @@ | |||
/* @flow */ | |||
|
|||
import React from 'react'; |
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.
try import * as React, breaks flow otherwise
@@ -0,0 +1,94 @@ | |||
/* @flow */ | |||
|
|||
import React from 'react'; |
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.
try import * as React, breaks flow
size: 1, | ||
}; | ||
|
||
constructor(props) { |
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.
flow wants props: Props
here
}); | ||
const icon = sortDirection ? ( | ||
<Animated.View style={[styles.icon, { transform: [{ rotate: spin }] }]}> | ||
<Icon source="arrow-downward" size={16} /> |
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.
color is required for the icon
import { grey100 } from './../../styles/colors'; | ||
|
||
type Props = { | ||
/** |
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.
missing children prop
@gawrysiak thanks for the comments! Will do the changes and update you. Sorry for the flow issues but I had to skip them locally since it runs into an infinite loop locally. Any idea why this is the case? |
@jaulz yeah, other than the comments, there's quite a long list of reported flow issues. Visually looks nice though. @satya164 can probably give you some more API feedback. As for the flow issue, it's worth a try to run flow through the local node_modules instead of the globally installed one. It should be possible with most of the plugins, e.g. VSC: Then look into your processes and kill any flow servers that shouldn't be running (when editor is off). As for the terminal, normally killing the global process and running |
b57352b
to
c5d4eb9
Compare
Okay, fixes are in. Though there is one left regarding theming, e.g.:
Any idea why this occurs? Compared my component to the existing ones and can't find the difference... shouldn't |
Not sure. Will need to check later. |
How is this PR going @satya164 ? |
c5d4eb9
to
169a8dd
Compare
@satya164 just pushed an update so it's properly passing the build |
Waitting for it. 👍 |
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.
Need to remove {}
{children} | ||
</Text> | ||
) : ( | ||
{ children } |
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.
There is a bug, {}
should not used right here
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.
@Trancever :this bug was not resolved yet, why you accept the PR?
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.
Will check it tomorrow 😊 it's anyway not yet merged...
@jaulz : no, {typeof children === 'string' || typeof children === 'number' ? (
<Text
style={[
styles.cell,
numeric ? styles.numeric : styles.text,
this.props.style,
]}
numberOfLines={1}
>
{children}
</Text>
) : (
children // <---- no need `{}` right here.
)} |
{children} | ||
</Text> | ||
) : ( | ||
{ children } |
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.
@giautm is right. We should get rid of that curly braces in this case.
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.
Sorry, actually I meant to wait for feedback for this PR in general. As long as I don't know if this PR will be considered in this way at all it does not make sense to fix issues, does it?
Once I receive green light from your side, I am more than happy to fix issues...
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.
Ok, I understand :) For me this PR looks great, I like the api of components. The only thing that those components misses for me are styles based on theme. There is no way to change theme to dark, we have to pass style prop to every component, am I right?
@satya164 Could you take a look on this PR?
|
||
displayedRows: { | ||
marginLeft: 30, | ||
marginRight: 44, |
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.
return ( | ||
<View style={[styles.container, this.props.style]}> | ||
<Text style={[styles.text, styles.rowsPerPage]} numberOfLines={1}> | ||
{labelRowsPerPage} {rowsPerPage} |
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.
Should remove the spacing between {labelRowsPerPage}
and {rowsPerPage}
. And set default props of labelRowsPerPage
to 'Rows per page: '
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.
Or simply use the custom render right here. 😄
1fed58c
to
1cf7ae9
Compare
What's the status of this one @jaulz ? |
I pushed some changes in https://github.com/callstack/react-native-paper/tree/%40satya164/data-table, but it still needs typescript definitions. ANybody up for adding the defs? |
@satya164 will take it up next week, thanks! |
@satya164 types are created in your branch. shall we create a separate PR or merge the changes in this one here? |
@jaulz thanks! merging the changes to this branch works for me :) |
Motivation
New component Data Table according to https://material.io/design/components/data-tables.html.
Test plan