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

sanity-qr-code-generator

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sanity-qr-code-generator

QR code generator component for the Sanity v3

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Sanity QR Code Generator Plugin (for Sanity Studio v3)

Installation

To install this plugin, use the following command:

npm install sanity-qr-code-generator

Usage

To use this plugin, add it as a plugin to your sanity.config.ts (or .js) file, as shown in the example below:

import { defineConfig } from "sanity";
import { QRCodeGenerator } from "sanity-qr-code-generator";

export default defineConfig({
  plugins: [QRCodeGenerator()],
});

Then you can use qrCode as a custom type in your schemas.

defineField({
  title: "Generate your QR code",
  name: "qrCode",
  type: "qrCode",
});

Configuration

By default, a rendered field will ask to provide a value which has to be encoded in the QR code. But if you want to provide that value automatically, define the dependOn option. That option accepts a document's field name which value should be encoded.

defineField({
  title: "Generate your QR code",
  name: "qrCode",
  type: "qrCode",
  options: {
    dependOn: "slug",
  },
});

You can refer only to fields of the document where QR code field is defined.

If you want to depend on a property of some inner object, provide an array with property names which can lead to the wanted value.

defineField({
  title: "Generate your QR code",
  name: "qrCode",
  type: "qrCode",
  options: {
    dependOn: ["someObject", "propertyOfSomeObject"],
  },
});

Additionally, you can configure the size, background and foreground colours of the code image and its level.

defineField({
  title: "Generate your QR code",
  name: "qrCode",
  type: "qrCode",
  options: {
    size: 400, // px. Default is 500
    level: "H", // Default is "L". Allowed values are "L" | "M" | "H" | "Q"
    bgColor: "#e3ea15", // Default is #FFFFFF
    fgColor: "#111111", // Default is #000000
  },
});

Example

  1. The plugin requires manually entering a value to encode.
QR generator plugin in use
  1. The plugin automatically gets a value from the document.
QR generator plugin in use

Word from author

Have fun ✌️

Supported by Halo lab

Keywords

FAQs

Package last updated on 04 Jul 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