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

Allow custom GIF selector #1937

Open
oatsoda opened this issue Feb 14, 2023 · 1 comment
Open

Allow custom GIF selector #1937

oatsoda opened this issue Feb 14, 2023 · 1 comment
Labels
cluster:message-input Issues related to message input and its textarea enhancement New feature or request feature New capability

Comments

@oatsoda
Copy link

oatsoda commented Feb 14, 2023

Motivation
Users aren't necessarily going to know that they can/must type / in order to be able to send a GIF.

Proposed solution
We're looking at ways to provide, ideally, a button which pops up a GIF selection screen, but it seems at the moment we would need to provider an entire MessageInput component (keeping all existing functionality) to add this.

Possible solutions roughly in descending order of complexity:

  • Add a button which pops up a GIF selector window (like the EmojiPicker) that you can search, scroll and pick the appropriate GIF, then click on the one you wish to send.
  • Add an (optional) button to the standard MessageInputFlat next to the File Upload which creates the existing GIF input (With the Send, Shuffle, Cancel buttons),
    • Potentially allow a custom handler so that a custom popup could be implemented by us to select and then send a GIF
  • Add the CommandButton facility like there is in the react-native implementation which at least gives the visual element so that users don't need to know to type / to send a GIF.
@oatsoda oatsoda added the feature New capability label Feb 14, 2023
@arnautov-anton
Copy link
Contributor

Hey, @oatsoda, thank you for your feature submission; we're aware of this issue but we do not plan on adding such feature anytime soon. I'll keep the issue open as we'll definitely revisit it in the future to at least make it close to what our React Native SDK does but in the meantime I can only suggest this crude solution you could use - there's no need to re-implement the whole MessageInput component, slight changes to styling should be sufficient:

const CustomGIFSelector = () => {
  const { sendMessage } = useChannelActionContext();
  const [open, setOpen] = useState(false);

  const GIFSelectionHandler = (url) => {
    sendMessage({
      attachments: [
        {
          type: 'image',
          image_url: url,
        },
      ],
    });
  };

  return (
    <>
      {open && <GIFListWithSearch onGIFSelected={GIFSelectionHandler} />}
      <button onClick={() => setOpen((pv) => !pv)}>GIF</button>
    </>
  );
};

And to integrate it with our input you'd do something like this:

<Channel>
  {/*...other components...*/}

  <div style={{ display: 'flex', alignItems: 'center' }}>
    <CustomGIFSelector />
    <MessageInput />
  </div>
<Channel />

Hope this helps, let me know if you have any other questions. :)

cc @DannyBiezen

@arnautov-anton arnautov-anton added the enhancement New feature or request label Feb 22, 2023
@MartinCupela MartinCupela added the cluster:message-input Issues related to message input and its textarea label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cluster:message-input Issues related to message input and its textarea enhancement New feature or request feature New capability
Projects
None yet
Development

No branches or pull requests

3 participants