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

react-native-palette-picker

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-palette-picker

Android Color-palette API implementation for React Native Apps

  • 0.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-native-palette-picker

Android Color-palette API implementation for React Native Apps

Example 1 musicFumes Demo 1 Android Demo 2 Android

Installation

  • React Native CLI
  • Install this package using npm or yarn

with npm:

npm install react-native-palette-picker

with yarn:

yarn add react-native-palette-picker

Usage

import React from 'react'
import { getPalette, type ImageColorsResult} from 'react-native-palette-picker';

const useImageColors = () => {
  const [colors, setColors] = React.useState<ImageColorsResult>(null);
  const [err, setErr] = React.useState<unknown>();

   React.useEffect(() => {
    const imgUri = "https://i.imgur.com/RCRf1Sx.jpeg";
    (async () => {
      try {
        const res = await getPalette(imgUri, {
          fallback: '#ff0000',
          fallbackTextColor: '#ffffff',
        });
        setColors(res);
      } catch (error) {
        setErr(error);
      }
    })();
  }, []);

  return colors
}

API

getPalette(source: string | number, config?: Config): Promise<ImageColorsResult>
uri

A string which can be:

  • URL:

    https://i.imgur.com/RCRf1Sx.jpeg

  • Local file:

    const img = require('../assets/img.jpg');
    
  • Base64:

    const base64 = 'data:image/jpeg;base64,/9j/4Ri...';
    

    The mime type prefix for base64 is required (e.g. data:image/png;base64).

Config?

The config object is optional.

PropertyDescriptionTypeDefault
fallbackIf a color property couldn't be retrieved, it will default to this hex color stringstring"#000000"
fallbackTextColorText color used when getting color fails.(titleTextColor,bodyTextColor). Must be hexstring"#FFFFFF"
ImageColorsResult
PropertyType
dominantstring
vibrantstring
darkVibrantstring
lightVibrantstring
darkMutedstring
lightMutedstring
mutedstring
titleTextColorstring
bodyTextColorstring

Notes

Future work

  • iOS support (need ios dev)

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

If you are experienced with iOS development and would like to contribute, please feel free to submit pull requests or open issues related to iOS support. Your contributions will be greatly appreciated and will help make this library more versatile.

License

MIT


Made with create-react-native-library

Keywords

FAQs

Package last updated on 19 Aug 2023

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