Code Monkey home page Code Monkey logo

sanity-plugin-user-select-input's Introduction

This is a Sanity Studio v3 plugin.

sanity-plugin-user-select-input

This is a Sanity Studio v3 plugin

Adds a searchable dropdown for all users on the project, and stores their User ID as a string field.

Note: Think of the string as a weak reference. Users can be removed from the project without first checking if their ID is used in any Document. And once removed their ID will remain stored as the field value.

This is not a replacement for creating your schema types like staff, author, profile, person etc. It's useful for using a single field to link a document to a user. For example a field like brief, task, reviewer etc.

Installation

npm install sanity-plugin-user-select-input

Screenshot 2023-03-20 at 19 34 18

Usage

Add it as a plugin in sanity.config.ts (or .js):

// ./sanity.config.ts

import {defineConfig} from 'sanity'
import {userSelect} from 'sanity-plugin-user-select-input'

export default defineConfig({
  //...
  plugins: [userSelect()],
})

Add a userSelect type field to any document type. It will act like a string field and so can be extended such as using validation rules such as required.

defineField({
  name: 'userId',
  type: 'userSelect',
}),

License

MIT © Simeon Griggs

Develop & test

This plugin uses @sanity/plugin-kit with default configuration for build & watch scripts.

See Testing a plugin in Sanity Studio on how to run this plugin with hotreload in the studio.

Release new version

Run "CI & Release" workflow. Make sure to select the main branch and check "Release new version".

Semantic release will only release on configured branches, so it is safe to run release on any branch.

sanity-plugin-user-select-input's People

Contributors

semantic-release-bot avatar simeongriggs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.