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

Feature Request: Add slot to render Icon next to FlagButton #68

Open
spicattutti opened this issue Apr 24, 2023 · 2 comments
Open

Feature Request: Add slot to render Icon next to FlagButton #68

spicattutti opened this issue Apr 24, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@spicattutti
Copy link
Contributor

spicattutti commented Apr 24, 2023

Heya, props for the lib.

I would like an arrow/chevron to be shown so that it is clearer to the user that the flag is actually a button revealing a dropwdown.

I sketched a solution where the consumer can set a renderIcon prop, which is of shape

(isFlagsMenuOpened: boolean) => React.ReactNode 

But it would need a little thinking and tweaking on the button styles, because the Icon enlarges the button area, which looks weird depending on the size of the Icon. This is how it looks for a (dummy-)Icon:

const renderIcon: MuiTelInputProps['renderIcon'] = (isFlagsMenuOpened) => {
  return (
    <div
      style={{
        paddingLeft: '0.5rem'
      }}
    >
      <div
        style={{
          transition: `transform 0.1s ease-out`,
          transform: `rotate(90deg) scaleX(${isFlagsMenuOpened ? -1 : 1})`
        }}
      >
        <span
          style={{
            fontSize: '0.8rem'
          }}
        >
          &gt;
        </span>
      </div>
    </div>
  )
}

image

@viclafouch Do you see a better way to achieve the desired behavior?

Shall I raise a PR so that the first solution can be discussed?

@albertus-andito
Copy link

I was about to open an issue for this. Thank you.

After using and deploying this component. I have found that a lot of people don't realise that the country code box is a button for a dropdown. It resulted in them to just use the default country code.

@viclafouch viclafouch added the enhancement New feature or request label May 21, 2023
@drod3763
Copy link

I was looking for an issue just like this. Would love to use this library but I would like the option to add a chevron next to the flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants