Skip to content

feat: support <details> tag for GithubHtmlView (#528) #819

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

Merged
merged 6 commits into from
Oct 24, 2018

Conversation

whitedogg13
Copy link
Contributor

Question Response
Version? v1.4.1
Devices tested? iPhone X
Bug fix? no
New feature? yes
Includes tests? no
All Tests pass? yes
Related ticket? #528

Screenshots

Before (not support details tag)
image

After 1 (detail not expanded)
image

After 2 (detail expanded)
image

Description

Support <details> tag in GithubHtmlView, as mentioned in #528 .

First try to find <summary> tag inside <details>, then render a toggle-able view if found, otherwise do a rollback rendering. Also try to prettify the text in <summary> if we got only one text child inside it.

Thanks!

@coveralls
Copy link

coveralls commented Oct 2, 2018

Coverage Status

Coverage increased (+1.8%) to 44.189% when pulling 7cfed74 on whitedogg13:html-details-support into 027dfc5 on gitpoint:master.

@chinesedfan chinesedfan requested a review from machour October 2, 2018 16:36
@lex111
Copy link
Member

lex111 commented Oct 2, 2018

@whitedogg13 it's awesome! 👏

What do you think can write a small test for this component?

@lex111 lex111 requested a review from chinesedfan October 2, 2018 23:15
@whitedogg13
Copy link
Contributor Author

@lex111 Sure, love to do so. I will update it later.

@whitedogg13
Copy link
Contributor Author

Hi @lex111 , I have just added test cases to test this PR. Please feel free to feedback!

BTW, in this case I use react-test-renderer rather then enzyme, which is different from the convention in this project, and I'd like to briefly explain why:

In GithubHtmlView we depends on 3rd party react-native-htmlview to perform html rendering. However this library only renders a skeleton view in first render (it triggers state change to render actual content in componentDidMount...), which makes enzyme's shallow or render won't be able to test. On the other hand, react-test-render can capture this case.

Thanks!

Copy link
Member

@lex111 lex111 left a comment

Choose a reason for hiding this comment

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

This is good for me, but I would like to hear the opinions of other members, so for now I will not merge PR. Thanks!

Copy link
Member

@chinesedfan chinesedfan left a comment

Choose a reason for hiding this comment

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

@whitedogg13 Great attempt. Maybe you can check #609 to get some inspirations. For example,

  • enhance toggle-view.component.js to replace WithToggle
  • handle the summary tag
  • add different edge cases to tests

@whitedogg13
Copy link
Contributor Author

Hi @chinesedfan , thanks for the review!

I made some enhancement over your first and third suggestions:

  • enhance toggle-view.component.js to replace WithToggle
  • add different edge cases to tests

It's always good to test and reuse code.

However, about the handling for <summary/> tag, I have checked #609, some points listed:

  • it adds a extra <hidden/> tag in order to parse <summary/>, since <hidden/> is not a valid HTML tag, so more or less like a hack to me.
  • it renders <summary/> with <View>{defaultRenderer(node.children, parent)}</View>, however, this basically means we don't even need to handle this case since it simply do the default behavior.

Because of above reasons, I think current version makes more sense to me.

Thanks!

Copy link
Member

@chinesedfan chinesedfan left a comment

Choose a reason for hiding this comment

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

@whitedogg13 I tested in iOS simulator to visit #528 and #609. It worked very well. Good job!

Forgive my little OCD to mention 2 other things.

  • Current test files are named as component names.
  • If descriptions of test cases are well-written, you can remove those inner comments. Keeping them in the same format like do blabla when xxx or should xxx if/when xx.

@whitedogg13
Copy link
Contributor Author

@chinesedfan Thanks for suggestions, I will update it later :)

@whitedogg13
Copy link
Contributor Author

Hi @chinesedfan , I have pushed the changes, thanks!

@lex111
Copy link
Member

lex111 commented Oct 16, 2018

@machour hi, can we merge this PR?

@machour
Copy link
Member

machour commented Oct 17, 2018

Hey @lex111, sorry I've been away from computer these days. Have this PR been tested on Android? If it's working there too then you have my blessing :)

@lex111
Copy link
Member

lex111 commented Oct 19, 2018

@machour I currently have no opportunity to check, maybe you have?

@whitedogg13
Copy link
Contributor Author

Hi @lex111 I have just tested this on Nexus 5 using Genymotion Emulator, and it works correctly. For further PR, I will test it in Android as well :)

Copy link
Member

@housseindjirdeh housseindjirdeh left a comment

Choose a reason for hiding this comment

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

So amazing, thank you so much for this @whitedogg13 ⭐️

{this.props.TouchableView}
{this.props.renderTouchable
? this.props.renderTouchable(this.state.collapsed)
: this.props.TouchableView}
Copy link
Member

Choose a reason for hiding this comment

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

👏

@andrewda andrewda mentioned this pull request Dec 1, 2018
63 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants