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] Allow labelIdle to be a component #111

Open
kino90 opened this issue Sep 6, 2019 · 10 comments
Open

[feature request] Allow labelIdle to be a component #111

kino90 opened this issue Sep 6, 2019 · 10 comments
Labels
enhancement New feature or request

Comments

@kino90
Copy link

kino90 commented Sep 6, 2019

Hello, thanks for this repo, it's really awesome.

I'm trying to use it in a project, but my template is a little different and I'd have to customize the labelIdle prop with something more than a static markup (e.g a custom component)

Is it possible? I didn't see anything in the docs..

👍

@rikschennink
Copy link
Collaborator

Hi, this is currently not possible, you can only set a label

@kino90
Copy link
Author

kino90 commented Sep 9, 2019

Ok, I see. Will it be added sooner or later? shouldn't be a problem to accept a component OR a string 😉

@rikschennink
Copy link
Collaborator

Well, it's not a "native" React component so the React render loop stops at the FilePond init. So there's currently no way to "wrap" a React component.

@rikschennink
Copy link
Collaborator

That said, I am exploring ways to add it but that will probably not be anytime soon.

@kino90
Copy link
Author

kino90 commented Sep 9, 2019

Oh, I see.. Thank you for your quick reply!

@romainbessugesmeusy
Copy link

Maybe we could use the ReactDOM.createPortal method to render the component if it is supplied as prop to the Filepond component.

@rikschennink
Copy link
Collaborator

@romainbessugesmeusy feel free to submit a PR

@multidest
Copy link

If it helps anyone stumbling on this. I solved this for myself by rendering the component as a string and setting that string as the label.

You should be able to do this using different frameworks or libraries.
Here is an example in React.

import { renderToString } from 'react-dom/server';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faStar } from "@fortawesome/free-solid-svg-icons";

const ImagePicker: React.FC<_Props> = () => {
  const pond = useRef<FilePond | null>(null);

  function genLabel() {
    return renderToString(
      <FontAwesomeIcon
        style={{
          height: "4em",
          width: "4em",
        }}
        className="event-image-picker-icon" icon={faStar} size="2x" />
    )
  }

return (

    <FilePond
      ref={ref => { pond.current = ref }}
      labelIdle={genLabel()}
      ...
      />

@rikschennink rikschennink added the enhancement New feature or request label Jul 27, 2020
@thunderwin
Copy link

thunderwin commented Jan 18, 2022

or just keep it simple. Just put a svg file there..

       <file-pond
  name="test"
  ref="pond"
  class="filepond"
  label-idle='<svg class="w-10 h-10 dark:text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 14l9-5-9-5-9 5 9 5z"></path><path d="M12 14l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 14l9-5-9-5-9 5 9 5zm0 0l6.16-3.422a12.083 12.083 0 01.665 6.479A11.952 11.952 0 0012 20.055a11.952 11.952 0 00-6.824-2.998 12.078 12.078 0 01.665-6.479L12 14zm-4 6v-7.5l4-2.222"></path></svg>'
  v-bind:allow-multiple="multiple"
  accepted-file-types="image/jpeg, image/png"
  :server="server"
  @addfile="addFile"
  @processfiles="processfiles"
  v-bind:files="myFiles"
  v-on:init="handleFilePondInit"
/>

@oalexdoda
Copy link

Is this dead?

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

6 participants