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(Highlight): New Highlight Component #202

Merged
merged 9 commits into from
Nov 19, 2019
Merged

feat(Highlight): New Highlight Component #202

merged 9 commits into from
Nov 19, 2019

Conversation

bajcmartinez
Copy link
Contributor

Types of Changes

Prerequisites

Please make sure you can check the following two boxes:

  • I have read the CONTRIBUTING document
  • My code follows the code style of this project

Contribution Type

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue, please reference the issue id)
  • New feature (non-breaking change which adds functionality, make sure to open an associated issue first)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Description

This new component allows developers to highlight text based on a term
condition

This new component allows developers to highlight text based on a term
condition
@CLAassistant
Copy link

CLAassistant commented Nov 14, 2019

CLA assistant check
All committers have signed the CLA.

src/components/Hightlight/Index.tsx Outdated Show resolved Hide resolved
src/components/Hightlight/Index.tsx Outdated Show resolved Hide resolved
src/components/index.ts Outdated Show resolved Hide resolved
 * Fix visual tests by adding the visual snapshot
 * Add example on how to change the color of the highlight
 * Rename component folder from Hightlight to Highlight
Copy link
Collaborator

@dimabory dimabory left a comment

Choose a reason for hiding this comment

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

  1. <Highlight text="Hello World!" highlight="!" /> renders the last span as an empty span, which can be avoided.

  2. <Highlight text="Hello World!" highlight="H" /> renders the first span as an empty span, which can be avoided.

  3. <Highlight text="A" highlight="a" /> renders three spans instead of a single one.

  4. <Highlight text="Hello World!" highlight="\Hello" /> highlights Hello, which is not expected behavior I guess.

@dimabory dimabory changed the title feat(Hightlight): New Hightlight Comnponent feat(Highlight): New Highlight Component Nov 15, 2019
@guiherzog
Copy link
Contributor

@bajcmartinez could you sign the license/cla?

@dimabory Are you finished with your review?

@bajcmartinez
Copy link
Contributor Author

I did already the other day:
image

@dimabory
Copy link
Collaborator

@bajcmartinez could you sign the license/cla?

@dimabory Are you finished with your review?

We should resolve this -> #202 (review)

Avoid generating empty spans, and generate tests for the edge cases
@bajcmartinez
Copy link
Contributor Author

bajcmartinez commented Nov 19, 2019

@bajcmartinez could you sign the license/cla?
@dimabory Are you finished with your review?

We should resolve this -> #202 (review)

@dimabory I've pushed new changes with test coverage for those cases and the resolution

Comment on lines 31 to 49
it('should render <Highlight> without trailing empty span', () => {
const wrapper = shallow(<Highlight text="Hello World!" highlight="!" />);
expect(wrapper.children()).toHaveLength(2);
});

it('should render <Highlight> without leading empty span', () => {
const wrapper = shallow(<Highlight text="Hello World!" highlight="H" />);
expect(wrapper.children()).toHaveLength(2);
});

it('should render <Highlight> a single span if no match', () => {
const wrapper = shallow(<Highlight text="A" highlight="a" />);
expect(wrapper.children()).toHaveLength(1);
});

it('should render <Highlight> should escape \\', () => {
const wrapper = shallow(<Highlight text="Hello World!" highlight="\world" />);
expect(wrapper.children()).toHaveLength(1);
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add snapshots for these cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Collaborator

@dimabory dimabory left a comment

Choose a reason for hiding this comment

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

Great job! 👍
Thank you @bajcmartinez

@guiherzog guiherzog merged commit edc4991 into ZEISS:develop Nov 19, 2019
@bajcmartinez bajcmartinez deleted the feature/highlight branch December 16, 2019 13:16
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.

5 participants