npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-barcode-renderer

v1.0.4

Published

Barcode and Qr Code renderer for React Native based on @shopify/react-native-skia

Downloads

91

Readme

rn-barcode-renderer

A Barcode and Qr Code renderer for React Native based on @shopify/react-native-skia.

Features

  • Barcode render
  • Qr code render
  • Add gradient
  • Optional logotype for qr code

Installation

Start by installing the peer dependency of rn-barcode-renderer:

yarn add @shopify/react-native-skia

Then install rn-barcode-renderer:

yarn add rn-barcode-renderer

Usage

Barcode

import { BarcodeView } from "rn-barcode-renderer";

// Simple usage

return <BarcodeView format="CODE128" value="123456" />;

// Add background, bars color, border raidus, background blur effect, padding...

return (
  <BarcodeView
    format="CODE128"
    value="123456"
    padding={10}
    borderRadius={10}
    color="blue"
    bgColor="lightgray"
    bgBlur={5}
  />
);

Barcode Props

| Prop Name | Type | Description | | ------------ | ----------------- | --------------------------------------------------------------------------------------------------------- | | value | string (required) | The value of the barcode. | | format | Format (required) | The format of the barcode. | | barWidth | number | The width of each bar in the barcode. Default is 2. | | height | number | The height of the barcode. Default is 100. | | color | string | The color of the barcode lines. Default is "#000000". | | bgColor | string | The background color of the barcode. Default is "#ffffff". | | onError | () => void | Callback function to handle errors during barcode encoding. Should be wrapped in useCallback. | | maxWidth | number | The maximum width of the barcode. If specified, the barcode will be scaled down to fit within this width. | | padding | number | The padding around the barcode. Default is 0. | | borderRadius | number | The border radius of the wrapper rectangle around the barcode. Default is 0. | | bgBlur | number | The blur radius for the background of the barcode. Default is 0. |

Qr Code

import { QrCode } from "rn-barcode-renderer";

// Simple usage

return <QrCode value="Hello World!" />;

// Add background, color, border raidus, background blur effect, padding, change size...

return (
  <QrCode
    value="Hello World!"
    color="blue"
    bgColor="lightgray"
    padding={10}
    borderRadius={8}
    size={150}
  />
);

Render QR Code with logo

import { QrCode, QrLogo } from "rn-barcode-renderer";

return (
  <QrCode
    value="Hello World!"
    renderLogo={(defaultProps) => (
      <QrLogo
        src={require("./assets/favicon.png")}
        padding={2}
        borderRadius={9999}
        bgColor="white"
        {...defaultProps}
      />
    )}
  />
);

Qr Code props

| Prop name | Type | Description | | ------------ | ----------------------------------------------------- | ----------------------------------------------------------------------------------------- | | value | string (required) | The value of the QR code. | | size | number | The size of the QR code. Default value: 100. | | color | string | The color of the QR code. Default value: "black". | | bgColor | string | The background color of the QR code. Default value: "white". | | borderRadius | number | The border radius of the QR code. Default value: 0. | | bgBlur | number | The blur of the background of the QR code. Default value: 0. | | padding | number | The padding of the QR code. Default value: 0. | | ecl | ErrorCorrectionLevel | The error correction level of the QR code. Default value: "M". | | onError | () => void | Callback function to handle errors. Should be wrapped in useCallback. | | renderLogo | (defaultProps: { qrSize: number }) => React.ReactNode | Function to render a logo on the QR code. Receives the default props: { qrSize: number }. |

Methods (BarcodeView and QrCode)

| Method | Description | | --------------------------------------------------- | ----------------------------------------------------- | | getBytes(format?: ImageFormat, quality?: number) | Returns the barcode image as a Uint8Array. | | getBase64(format?: ImageFormat, quality?: number) | Returns the barcode image as a base64-encoded string. | | getImageInfo() | Returns information about the barcode image. |

Contributing

  1. Fork and clone the repository
  2. Install the project dependencies by running yarn install.
  3. To develop the library in unison with the example app you can run yarn dev
  4. Implement your changes, as well as any documentation.
  5. Create a changeset for your changes by running yarn changeset.
  6. Open a pull request with your changes and changeset.

License

MIT