Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@groupcards/gif-picker-react

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@groupcards/gif-picker-react

Tenor Gif Picker for React

  • 1.4.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
15
increased by650%
Maintainers
0
Weekly downloads
 
Created
Source

Gif Picker React | Live Demo

npm GitHub Workflow Status npm bundle size downloads

demo

An Tenor GIF picker component for React applications that runs on Tenor API V2. This picker fits styling of emoji-picker-react and can be used next to it.

What to know before using

  • In order to access Tenor API you are required to provide API key. This is a free and simple process that takes less than 60 seconds.
  • Tenor requires attribution from products that use their API. This library comply with that rule by adding Search Tenor placeholder to the search bar.

Installation

npm install gif-picker-react

Obtaining Tenor API v2 key

In order to use GifPicker element you are required to provide Tenor API key via tenorApiKey prop. To obtain this key please follow this simple guide:

  1. Login in to Google Cloud Console
  2. Create a new project
  3. In Google Cloud Marketplace navigate to Tenor API
  4. Click on Enable
  5. In navigation menu go to APIs and services tab and select Credentials
  6. Click + create credentials and create API key, copy generated API key
  7. Pass this key as prop to tenorApiKey

Usage

import GifPicker from 'gif-picker-react';

function App() {
  return (
    <div>
      <GifPicker tenorApiKey={"YOUR_API_KEY"} />
    </div>
  );
}

Props

The following props are accepted by the picker:

PropTypeDefaultDescription
tenorApiKeystringRequiredTenor v2 API key, obtained from Google Cloud Console
onGifClickfunctionCallback function that is called when an gif is clicked. The function receives the TenorImage object as a parameter.
themeThemeTheme.LIGHTControls the theme of the picker. If you are using Typescript you can use Theme enum. Possible values are light, dark and auto.
autoFocusSearchbooleantrueControls the auto focus of the search input.
contentFilterContentFilterContentFilter.OFFControls the Tenor Content filtering options. If you are using Typescript you can use ContentFilter enum. Possible values are high, medium, low, off
clientKeystringgif-picker-reactName of your application. Used to differentiate multiple applications using same API key.
countrystringUSSpecify the country of origin for the request. To do so, provide its two-letter ISO 3166-1 country code.
localestring (xx_YY)en_USSpecify the default language to interpret the search string. xx is the language's ISO 639-1 language code, while the optional _YY value is the two-letter ISO 3166-1 country code.
widthnumber / string350Controls the width of the picker. You can provide a number that will be treated as pixel size, or your any accepted css width as string.
heightnumber / string450Controls the height of the picker. You can provide a number that will be treated as pixel size, or your any accepted css width as string.
categoryHeightnumber / string100Controls the height of the home page reaction category. You can provide a number that will be treated as pixel size, or your any accepted css width as string.
initialSearchTermstringSets the initial search term when the picker is opened.

TenorImage

This object is provided as an argument to callback specified in onGifClick:

PropertyTypeDescription
idstringTenor result identifier
tenorUrlstringThe full URL to view the post on tenor.com
shortTenorUrlstringShort URL to view the post on tenor.com
descriptionstringTextual description of the content. You can use this do populate image object alt attribute
createdAtDateDate object that represents when this post was created.
tagsstring[]Array of tags for the post
urlstringDirect URL to the image source
heightnumberHeight of the image in pixels
widthnumberWidth of the image in pixels
previewTenorImagePreviewGif preview object with dimensions scaled down

TenorImagePreview

This object is used for displaying the preview image gifs in the picker. You can use it to render smaller and lower-resolution versions of the gifs.

PropertyTypeDescription
urlstringDirect URL to the preview image source
heightnumberHeight of the preview image in pixels
widthnumberWidth of the preview image in pixels

This is an example TenorImage object:

{
  id: "16596569648018104856",
  tenorUrl: "https://tenor.com/view/american-psycho-patrick-bateman-american-psycho-gif-7212093",
  shortTenorUrl: "https://tenor.com/Eqmf.gif",
  description: "American Psycho Patrick Bateman GIF",
  createdAt: Date,
  tags: [ "American Psycho", "Patrick Bateman", "American", "psycho"],
  url: "https://media.tenor.com/5lLcKZgmIhgAAAAC/american-psycho-patrick-bateman.gif",
  height: 240,
  width: 244,
  preview: {
    url: "https://media.tenor.com/5lLcKZgmIhgAAAAM/american-psycho-patrick-bateman.gif",
    height: 120,
    width: 122
  }
}

Customization

Custom Picker Width and Height

To customize the dimensions of the picker, use the height and width props. You can pass in a number that will be treated as pixel size, or your any accepted css width/height as string.

<GifPicker height={500} width={400} />
<GifPicker height="100%" width="15em" />

CSS Variables

The picker can be customized via CSS variables. The root selector for the picker is .GifPickerReact, when overriding, make sure to provide a more specific selector.

The list of possible variables is quite extensive, but the main ones you may want to override are:

  • --gpr-bg-color - Background color of the picker.
  • --gpr-text-color - Font color on the picker.
  • --gpr-highlight-color - Color on the hover on focus on some search bar, categories and gif.

You can find full list of all variables in GifPickerReact.css.

Contributing

Want to contribute to the project?

First of all, thanks! Check CONTRIBUTING.md for more details.

Keywords

FAQs

Package last updated on 07 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc