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

feat: DataTable component #446

Merged
merged 2 commits into from
Nov 27, 2018
Merged

feat: DataTable component #446

merged 2 commits into from
Nov 27, 2018

Conversation

jaulz
Copy link
Collaborator

@jaulz jaulz commented Jul 9, 2018

Motivation

New component Data Table according to https://material.io/design/components/data-tables.html.

Test plan

image

@callstack-bot
Copy link

callstack-bot commented Jul 9, 2018

Hey @jaulz, thank you for your pull request 🤗. The documentation from this branch can be viewed here. Please remember to update Typescript types if you changed API.

@jaulz jaulz force-pushed the patch-7 branch 2 times, most recently from 5e819e4 to 3d79fac Compare July 9, 2018 17:27
/**
* Content of the `DataTableCell`.
*/
children: string | React.Node,
Copy link
Collaborator

Choose a reason for hiding this comment

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


import React from 'react';
import { StyleSheet, TouchableOpacity, View } from 'react-native';
import Text from './../Typography/Text';
Copy link
Collaborator

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 {
Copy link
Collaborator

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,
Copy link
Collaborator

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,
Copy link
Collaborator

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,
Copy link
Collaborator

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';
Copy link
Collaborator

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';
Copy link
Collaborator

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) {
Copy link
Collaborator

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} />
Copy link
Collaborator

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 = {
/**
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing children prop

@jaulz
Copy link
Collaborator Author

jaulz commented Jul 9, 2018

@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?

@gawrysiak
Copy link
Collaborator

@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:
screen shot 2018-07-09 at 21 10 08
or Nuclide:
screen shot 2018-07-09 at 21 09 53

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 yarn flow should do.

@jaulz jaulz force-pushed the patch-7 branch 3 times, most recently from b57352b to c5d4eb9 Compare July 10, 2018 09:03
@jaulz
Copy link
Collaborator Author

jaulz commented Jul 10, 2018

Okay, fixes are in. Though there is one left regarding theming, e.g.:

Cannot create DataTable.HeaderCell element because property theme is missing in props [1] but exists in Props [2].

Any idea why this occurs? Compared my component to the existing ones and can't find the difference... shouldn't withTheme provide the theme parameter?

@satya164
Copy link
Member

Not sure. Will need to check later.

@ferrannp
Copy link
Collaborator

How is this PR going @satya164 ?

@satya164 satya164 changed the base branch from material-next to master September 2, 2018 18:59
@jaulz jaulz force-pushed the patch-7 branch 3 times, most recently from c5d4eb9 to 169a8dd Compare September 7, 2018 06:27
@jaulz
Copy link
Collaborator Author

jaulz commented Sep 10, 2018

@satya164 just pushed an update so it's properly passing the build

@giautm
Copy link

giautm commented Sep 20, 2018

Waitting for it. 👍

Copy link

@giautm giautm left a 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 }
Copy link

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

Copy link

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?

Copy link
Collaborator Author

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
Copy link
Collaborator Author

jaulz commented Sep 25, 2018

@giautm thanks for the hint! Though, I would rather wait for feedback from the team before I do any more changes...
@ferrannp @satya164 any comments from your side? I would be happy to incorporate any requested changes.

@giautm
Copy link

giautm commented Sep 25, 2018

@jaulz : no, {} make an object with property children. That will cause:
image

        {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 }
Copy link
Contributor

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.

Copy link
Collaborator Author

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...

Copy link
Contributor

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,
Copy link

Choose a reason for hiding this comment

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

I think we should not use the fixed margin like this. That cause some render issues on the device with the small screen width. (ex: iPhone SE.)
image

return (
<View style={[styles.container, this.props.style]}>
<Text style={[styles.text, styles.rowsPerPage]} numberOfLines={1}>
{labelRowsPerPage} {rowsPerPage}
Copy link

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: '

Copy link

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. 😄

@satya164 satya164 force-pushed the master branch 4 times, most recently from 1fed58c to 1cf7ae9 Compare October 11, 2018 12:28
@ferrannp
Copy link
Collaborator

ferrannp commented Nov 9, 2018

What's the status of this one @jaulz ?

@jaulz
Copy link
Collaborator Author

jaulz commented Nov 9, 2018

@ferrannp if @satya164 could take a look at the component first and confirms then I could adapt the component to the dark theme as well.

@satya164
Copy link
Member

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?

@jaulz
Copy link
Collaborator Author

jaulz commented Nov 23, 2018

@satya164 will take it up next week, thanks!

@jaulz
Copy link
Collaborator Author

jaulz commented Nov 26, 2018

@satya164 types are created in your branch. shall we create a separate PR or merge the changes in this one here?

@satya164
Copy link
Member

@jaulz thanks! merging the changes to this branch works for me :)

@satya164 satya164 merged commit 68a5b78 into callstack:master Nov 27, 2018
@jaulz
Copy link
Collaborator Author

jaulz commented Nov 27, 2018

@satya164 thanks! Though, I just created another PR #684 which I was working on in parallel and allows not only text and numbers in cells.

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.

7 participants