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

Add search component #176

Merged
merged 2 commits into from
Nov 4, 2019
Merged

Add search component #176

merged 2 commits into from
Nov 4, 2019

Conversation

aleks-elkin
Copy link
Contributor

Added a Search component according to #110 issue and provided design.
Main features:

  • Have a debounced "idle" event which will be dispatched only after provided idle timeout.
  • Have a separate "search" event which will be triggered on "Enter" keydown.
  • Have an "autofocus" property which is based on the standard HTML autofocus property.
  • No hotkeys, I believe it would be better to implement on an app side.
  • No spinner yet.

Also, added a generic debounce function to helpers. It increases the bundle's size on 200 bytes.

Screenshots:
Basic search:
Search basic
Search with some search text:
Search with text
RTL support:
Search RTL

@Kian-Esmaeilpour Kian-Esmaeilpour changed the title Elkin/add search component Add search component Oct 15, 2019
@aleks-elkin aleks-elkin marked this pull request as ready for review October 15, 2019 11:36
@aleks-elkin aleks-elkin requested a review from a team as a code owner October 15, 2019 11:36
index.html Outdated Show resolved Hide resolved
packages/components/search/README.md Show resolved Hide resolved
"lib/*"
],
"dependencies": {
"@tradeshift/elements": "^0.4.5"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add @tradeshift/elements.icon as dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I added it.

}

.search-icon {
margin: 7px;
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for this number?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it actually a result of some non-trivial calculations. I replaced it with calc expression and added a comment with some details.


.close-icon {
cursor: pointer;
margin: 11px;
Copy link
Contributor

Choose a reason for hiding this comment

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

What about this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a result of some non-trivial calculations. I replaced it with calc expression and added a comment with some details.


constructor() {
super();
this.autofocus = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to define default value for them? Since we have the reflect: true it makes the DOM messy if you set default values!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just followed the docs about lit-element static properties getter:

If you implement a static properties getter, initialize your property values in the element constructor.

I remove default values for boolean properties, because the element still working as expected.

@tradeshiftci
Copy link

SonarQube analysis reported 1 issue

  • MAJOR 1 major

Watch the comments in this conversation to review them.

@aleks-elkin aleks-elkin force-pushed the elkin/add-search-component branch 2 times, most recently from 07c4e37 to aea6314 Compare October 17, 2019 11:15
| dir | dir | string | '' | Direction 'rtl' or 'ltr' |
| focused | focused | boolean | false | Set the focus on element |
| idleTime | idle-time | number | 300 | timeout in ms for the 'idle' event |
| placeholder | placeholder | string | 'Search...' | Message when an input is empty |
Copy link
Contributor

@Kian-Esmaeilpour Kian-Esmaeilpour Oct 22, 2019

Choose a reason for hiding this comment

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

We should prioritize translation integration for next sprint!!! @Tradeshift/ui

Copy link
Contributor

Choose a reason for hiding this comment

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

}

handleKeyDown(e) {
if (e.key === 'Enter') {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if it's causing an issue, @zdlm where we can find the list of the supported browsers by Tradeshift?
https://caniuse.com/#feat=keyboardevent-key

Copy link
Contributor

@Kian-Esmaeilpour Kian-Esmaeilpour left a comment

Choose a reason for hiding this comment

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

@aleks-elkin aleks-elkin force-pushed the elkin/add-search-component branch from 7c122b0 to 7eea205 Compare October 28, 2019 10:08
@focus="${this.handleFocus}"
@blur="${this.handleBlur}"
/>
<div class="icon-container">
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't have strong opinion about this one but what do you say if we put this part to a getter for cancelIconTemplate or some other name? like this one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think with this separate getter code looks cleaner. I moved the close icon html template to a separate getter.

Copy link
Contributor

@Kian-Esmaeilpour Kian-Esmaeilpour left a comment

Choose a reason for hiding this comment

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

Focus state in IE11 is borken in happo

@aleks-elkin aleks-elkin force-pushed the elkin/add-search-component branch from 3d4629b to 45630c4 Compare November 4, 2019 15:04
@aleks-elkin aleks-elkin merged commit e20f3c2 into master Nov 4, 2019
@aleks-elkin aleks-elkin deleted the elkin/add-search-component branch November 4, 2019 16:05
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.

3 participants