1.0.78 • Published 8 months ago

payload-color-swatch-field-test v1.0.78

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

payload-color-swatch-field

A color swatch field for Payload 3

Installation

npm i @modernaut/payload-color-swatch-field

NOTE: At the time of writing this, you may experience package conflicts with Payload Beta. You may need to use npm i with --force

Usage

import type { CollectionConfig } from "payload";
import { colorSwatchField } from "@modernaut/payload-color-swatch-field";

const Lorem: CollectionConfig = {
  slug: "lorem",
  admin: {
    useAsTitle: "title",
  },
  fields: [
    {
      name: "title",
      type: "text",
      required: true,
    },
    colorSwatchField({
      defaultColors: ['#000000', '#777', '#ffffff', 'bg-amber-500', 'bg-teal-500', 'bg-violet-500', 'text-amber-700', 'text-teal-700', 'text-violet-700'],
      overrides: {
        required: true,
      },
    }),
  ],
};

export default Lorem;

Options

  • defaultColors: Provide an array of color options (supports hex and Tailwind colors)
  • lockDefaultColors: Enable to ensure default color options can't be removed by users (default: true)
  • allowNull: Adds a null option to default colors (default: true)
  • allowUserPreferences: Enable to allow users to remove and add colors and build their own palette (default: true)
  • useGlobalPreferences: Disabling this will allow custom user color options on a per-field basis (default: true)
  • allowTailwindColors: Enable to allow Tailwind color options (default: true)
  • tailwindColorWhitelist: Provide a list of Tailwind color options. NOTE: You must specify the full color class (e.g. 'text-amber-700' vs 'amber-500') in order for Tailwind to detect/generate the proper colors in its CSS. Otherwise, you'll need to safelist the full class in your tailwind config file. See https://tailwindcss.com/docs/content-configuration#safelisting-classes for more details (default: all bg and text Tailwind colors are allowed)
  • allowHexColors: Enable to allow hex colors (default: true)
  • overrides: Any Payload field type overrides

To Do

  • Special color options: Gradients, transparency etc.
  • Cell support: Adding swatch styles to column sorting UI
  • Restricting hex options in the 'Add' prompt

Credit

1.0.62

8 months ago

1.0.61

8 months ago

1.0.60

8 months ago

1.0.66

8 months ago

1.0.65

8 months ago

1.0.64

8 months ago

1.0.63

8 months ago

1.0.69

8 months ago

1.0.68

8 months ago

1.0.67

8 months ago

1.0.29

8 months ago

1.0.28

8 months ago

1.0.73

8 months ago

1.0.72

8 months ago

1.0.71

8 months ago

1.0.70

8 months ago

1.0.77

8 months ago

1.0.33

8 months ago

1.0.76

8 months ago

1.0.32

8 months ago

1.0.75

8 months ago

1.0.31

8 months ago

1.0.74

8 months ago

1.0.37

8 months ago

1.0.36

8 months ago

1.0.35

8 months ago

1.0.78

8 months ago

1.0.34

8 months ago

1.0.39

8 months ago

1.0.38

8 months ago

1.0.40

8 months ago

1.0.44

8 months ago

1.0.43

8 months ago

1.0.42

8 months ago

1.0.41

8 months ago

1.0.48

8 months ago

1.0.47

8 months ago

1.0.46

8 months ago

1.0.45

8 months ago

1.0.49

8 months ago

1.0.51

8 months ago

1.0.50

8 months ago

1.0.55

8 months ago

1.0.54

8 months ago

1.0.53

8 months ago

1.0.52

8 months ago

1.0.59

8 months ago

1.0.58

8 months ago

1.0.57

8 months ago

1.0.56

8 months ago

1.0.27

8 months ago

1.0.26

8 months ago

1.0.25

8 months ago

1.0.24

8 months ago

1.0.23

8 months ago

1.0.22

8 months ago

1.0.20

8 months ago

1.0.19

8 months ago

1.0.18

8 months ago

1.0.17

8 months ago

1.0.16

8 months ago

1.0.15

8 months ago

1.0.14

8 months ago

1.0.13

8 months ago

1.0.12

8 months ago

1.0.11

8 months ago

1.0.10

8 months ago

1.0.9

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago