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

How to preserve ListItem styling when upgrading to v1? #1565

Closed
lukewlms opened this issue Nov 8, 2018 · 13 comments
Closed

How to preserve ListItem styling when upgrading to v1? #1565

lukewlms opened this issue Nov 8, 2018 · 13 comments

Comments

@lukewlms
Copy link
Contributor

lukewlms commented Nov 8, 2018

After upgrading to v1, ListItem styling has disappeared in our app. It appears this is intended (the styling from <List> is removed).

To make the upgrade path much cleaner, can you give us a simple way to reproduce the style we used to get from List? We don't want our app to change so it should be identical, but reverse engineering it will be pretty annoying (and would have to be repeated by anyone doing the upgrade).

Thanks!

@lukewlms lukewlms changed the title ListItem has no styles (how to quickly replicate <List> styling after upgrade) ListItem has no styling after upgrade to v1 (how to quickly replicate <List> styling after upgrade) Nov 8, 2018
@lukewlms lukewlms changed the title ListItem has no styling after upgrade to v1 (how to quickly replicate <List> styling after upgrade) ListItem has no styling after upgrade to v1 Nov 8, 2018
@lukewlms lukewlms changed the title ListItem has no styling after upgrade to v1 How to preserve ListItem styling when upgrading to v1? Nov 8, 2018
@lukewlms
Copy link
Contributor Author

lukewlms commented Nov 8, 2018

Solved by creating ListItem and ListContainer files to map to legacy ListItem and List, with styles. Files below.

I would strongly suggest having a clear upgrade path that will allow users to retain their styles without needing to figure out how to rebuild them like this, if only a note under ListItem in the documentation!

The documentation also just appears to be incorrect - it doesn't list any styles in the code, but styles are applied in the screenshots which is why I spent 2-3 hours trying to figure out why I wasn't getting the default styles.

Thanks, still love the library.

ListContainer.tsx:

import * as React from "react";
import { StyleSheet, View } from "react-native";
import { legacyRNElementsColors } from "../Styles";

const styles = StyleSheet.create({
  listContainer: {
    marginTop: 20,
    borderTopWidth: 1,
    borderColor: legacyRNElementsColors.greyOutline,
    backgroundColor: legacyRNElementsColors.white,
  },
});

const ListContainer: React.SFC<{ children: React.ReactNode }> = ({
  children,
}) => <View style={styles.listContainer}>{children}</View>;

export default ListContainer;

ListItem.tsx:

import * as React from "react";
import { StyleSheet } from "react-native";
import { ListItem as RneListItem, ListItemProps } from "react-native-elements";
import {legacyRNElementsColors} from "../Styles";

const styles = StyleSheet.create({
  listItemContainer: {
    paddingTop: 10,
    paddingRight: 10,
    paddingBottom: 10,
    borderBottomColor: legacyRNElementsColors.greyOutline,
    borderBottomWidth: 1,
    backgroundColor: "transparent",
  },
});

const ListItem: React.SFC<ListItemProps> = props => (
  <RneListItem
    containerStyle={[styles.listItemContainer, props.containerStyle]}
    {...props}
  />
);

export default ListItem;

In Styles.ts:

export const legacyRNElementsColors = {
  primary: "#9E9E9E",
  primary1: "#4d86f7",
  primary2: "#6296f9",
  secondary: "#8F0CE8",
  secondary2: "#00B233",
  secondary3: "#00FF48",
  grey0: "#393e42",
  grey1: "#43484d",
  grey2: "#5e6977",
  grey3: "#86939e",
  grey4: "#bdc6cf",
  grey5: "#e1e8ee",
  dkGreyBg: "#232323",
  greyOutline: "#bbb",
  searchBg: "#303337",
  disabled: "#dadee0",
  white: "#ffffff",
  error: "#ff190c",
};

@iRoachie
Copy link
Collaborator

iRoachie commented Nov 8, 2018

Hey @lukewlms thanks for bringing this up. We definitely have to put up some instructions for upgrading from 0.19.1 to v1 but we having done it as yet. This is cause we still have a few things we want to change before finish development.

Be sure this is definite walkthrough we will publish on release of v1

@iRoachie iRoachie modified the milestone: 1.0.0 Jan 7, 2019
@iRoachie iRoachie modified the milestone: 1.1.0 Jan 31, 2019
@iRoachie
Copy link
Collaborator

We released a migration guide on the release of v1.0.0 https://react-native-training.github.io/react-native-elements/blog/2019/01/27/1.0-release.html

@lukewlms
Copy link
Contributor Author

@iRoachie Would still strongly recommend putting up a style example so those migrating can achieve parity with their old look! I don't see it in the guide, though looks great otherwise. Otherwise each implementer will have to reinvent the wheel and reverse-engineer or dig for this style in the old code so app appearance doesn't change. Per listItemContainer style above.

@iRoachie
Copy link
Collaborator

iRoachie commented Feb 1, 2019

Are there any particular examples of usage you’d like to see?

@iRoachie iRoachie reopened this Feb 1, 2019
@lukewlms
Copy link
Contributor Author

lukewlms commented Feb 5, 2019

@iRoachie Just parity with previously existing view styles, per https://github.com/react-native-training/react-native-elements/issues/1565#issuecomment-436982251.

@iRoachie
Copy link
Collaborator

Can you be a bit more specific about which props/styles you were using in 0.19.1? It's a bit hard to get all props to work exactly the same in v1.0.0 as some props were removed as well.

The more info you can give about how you were using it(props, styles) then I can try to implement the same styling in v1.

@lukewlms
Copy link
Contributor Author

@iRoachie I didn't implement anything new and wasn't using any styles in 0.19.1 - the thing is that developers must now start using styles for lists and list items, which was not necessary pre-v1.0.

The styles above are identical to the default styles in 0.x that were removed. Adding the styles above to a v1.0 app will ensure the lists and listitems look the same as they did before upgrading to v1.0 so adding them is necessary for developers who are upgrading. They can be copied in by developers as-is above b/c they're pulled directly from the old (now removed) built-in RN Elements styles.

@iRoachie
Copy link
Collaborator

Ahhh i understand you now. Can you make a PR to make a note (link your comment) in the blog post?

@lukewlms
Copy link
Contributor Author

@betoharres
Copy link

I was wondering why on earth the ListItem was not styled. Man, those were hours of searching for this and I couldn't find a single mention on the docs about this. I think we should let users aware that the screenshots DOES NOT represents the sample codes.
I was searching on all change logs for a mention about that, but I only found out by looking at every single issue about list item.. that was pretty sad, but the library is awesome

lukewlms referenced this issue in lukewlms/react-native-elements Jun 6, 2019
This seems like an important change to me because the writing here doesn't match the images.  Adding the example code will _not_ produce the pictured results, because there is no styling in the example code.  The code in this comment does produce nice results.

See one frustrated user here: https://github.com/react-native-training/react-native-elements/issues/1565#issuecomment-499344338 - we also hit this issue and spent probably a couple hours trying to figure out why styling had died after an upgrade.

I believe this issue will be a significant hurdle for new users, and hurts the initial experience quite a lot.   It's just not possible to use ListItems without styling (they will look terrible) and this is a library that usually provides at least reasonable styling right away, so at minimum an example seems called for.  This PR is one way to do it, ofc more docs could be written as well.

Thanks for considering - we use this lib heavily and want it to be a success!
@lukewlms
Copy link
Contributor Author

lukewlms commented Jun 6, 2019

@betoharres
Copy link

@lukewlms Thank you so much for the time you've taken into this, I really appreciate the attention given. ❤️

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

No branches or pull requests

3 participants