freenowtech / wave

Design System of FREE NOW
https://wave.free-now.com
Apache License 2.0
64 stars 22 forks source link

Enhance FilePicker CTA button #325

Closed div-Leo closed 2 weeks ago

div-Leo commented 1 year ago

Describe the feature you'd like

Allow users to inject a custom component as the CTA button.

ATM we opinionatedly render 2 different CTAs based on desktop/mobile (button for desktop and icon for mobile) The advantage is to have a more flexible implementation so that the user can choose what to show as CTA.

Mobile FilePicker request:

Screenshot 2023-04-19 at 09 27 52

Questions:

Describe alternatives you've considered

We could add another condition to choose whether to force to render the icon or the button in the mobile version.

nlopin commented 1 year ago

How do you see this in the API?

div-Leo commented 1 year ago

To keep it simple I'd add a single component that replaces any state mobile/desktop and empty/uploaded, and it will look something like this:

<FilePicker
  {...}
  ComponentCTA={<TextButton>Add</TextButton>}
/>

The logic for empty/uploaded can be easily reimplemented with the onFileChange callback


<FilePicker
  {...}
  ComponentCTA={selectedFile ? <TextButton>Add</TextButton> : <TextButton>Change</TextButton>}
  onFileChange={(file)=> setSelectedFile(file)}
/>
div-Leo commented 1 year ago

Sync outcome: we should push back to keep consistency and avoid component injection. Status: stand by

arturmiglio commented 2 weeks ago

Not relevant anymore