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: implement phone input component #1533

Merged

Conversation

yvmunayev
Copy link
Contributor

@yvmunayev yvmunayev commented May 8, 2020

fix: #1467

Changes proposed in this PR:

@nexxtway/react-rainbow

@commit-lint
Copy link

commit-lint bot commented May 8, 2020

Features

  • create PhoneInput component (2c4e761)
  • implement behaivor for onChange (039878c)
  • add search filter to countries (d9c6bb2)
  • add key navigation and infinity scroll (08c7967)
  • add useReduxForm and useImperativeHandle hooks (78a9940)

Bug Fixes

  • optimization re-renders and change search input style (f321497)
  • fix style and add optimizition to re-render of countriesList (0fd0b84)
  • change the selected country (c7e7f2d)
  • fix properties and methods table and fix some style (5f02147)
  • fix search input style (08468fc)
  • fix some styled (c9cd167)
  • fix useFocusIndex hook (1a98c41)
  • fix comment (5bcbfe9)

Contributors

@yvmunayev, @LeandroTorresSicilia

@yvmunayev yvmunayev changed the title Implement phone input component feat: implement phone input component May 8, 2020
@TahimiLeonBravo TahimiLeonBravo self-requested a review May 9, 2020 15:48
@maxxgreene maxxgreene self-requested a review May 21, 2020 03:46
@HellWolf93 HellWolf93 self-requested a review May 27, 2020 02:23
src/components/PhoneInput/styled/flagContainer.js Outdated Show resolved Hide resolved
src/components/PhoneInput/styled/inputContainer.js Outdated Show resolved Hide resolved

const StyledIndicator = styled.span`
z-index: 2;
margin-top: -4px;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Negative margins is bad practice, also top and bottom margin has no effect on inline elements

src/components/PhoneInput/styled/indicator.js Outdated Show resolved Hide resolved
@LeandroTorresSicilia
Copy link
Member

@yvmunayev There is a conflict with the src/components/Picklist/menuArrowButton.js since we removed this component from the Picklist, you should create a new one inside the PhoneInput

@LeandroTorresSicilia
Copy link
Member

When pass an empty array to the countries prop it gets broken, when fix it also add a test for this situation
Screen Shot 2020-06-01 at 9 38 52 AM

import { useSimulatedLoading } from './hooks';

const CountriesList = memo(props => {
const { countries, country, itemsRef, handleCountryChange, handleActiveChange } = props;

Choose a reason for hiding this comment

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

normally handle is used to define the function that handles the callback, instead this should be called onCountryChange and onActiveChange, I think it is better simply call them onChange and onHover

onClick={() => handleCountryChange(value)}
onMouseEnter={() => handleActiveChange(index)}
role="option"
aria-selected={false}

Choose a reason for hiding this comment

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

aria-selected will be always false?

if (isFilteredCountry) {
filteredCountries.unshift(country);
}
return filteredCountries;

Choose a reason for hiding this comment

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

take look here: src/components/InternalDropdown/helpers/searchFilter.js
this is a filter function that we use in other projects, maybe we can do similar and simplify this

itemsRef,
handleCountryChange,
setFocusIndex,
);

Choose a reason for hiding this comment

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

for now leave this, but we should avoid pass to much arguments to a function, instead, when they are more than two we pass an object (only one argument with named parameters)

@@ -1,6 +1,6 @@
import styled from 'styled-components';
import attachThemeAttrs from '../../../../styles/helpers/attachThemeAttrs';
import MenuArrowButton from '../../../Picklist/menuArrowButton';
import CheckmarkIcon from '../../../Option/checkmark';

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 get this icon from other component folders since changes to Options could break PhoneInput, in this case it is better to repeat the icon to be inside PhoneInput folder, we are working in a solution in order to not repeat icons any more

@LeandroTorresSicilia LeandroTorresSicilia merged commit 41b22cc into nexxtway:master Jun 7, 2020
@yvmunayev yvmunayev deleted the implement-phone-input-component branch September 29, 2020 20:28
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.

feat: implement PhoneInput component
4 participants