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

grommet-forms

v0.0.4

Published

Collection of higher order components for constructing forms with Grommet UX

Downloads

2

Readme

NOTICE: This library is being actively developed. Use with caution until a proper release has been published.

Grommet Forms

Collection of higher order components for constructing forms with Grommet UX

Inspiration

Forms can often be the most time consuming part of your project. Tons of state? :check: complex hierarchies of data? Yep, you get the point. What we found when we were building our forms was that the best method was to render the form from a data structure stored in your state tree and to alter that state through redux.

Here's an example from a recent project of ours.

// In some reducer in your app

  sectionLayoutForm: {
    title: "Section Layout",
    id: 'section-layout-form',
    fields: [
      {
        label: "Flex Direction",
        error: null,
        help: "How should the content flow?  Row: left to right, Column: top to bottom.",
        name: "direction",
        type: "Select",
        value: 'row',
        fieldProps: {
          options: ["row", "column"],
        }
      },
      {
        label: "Justify Content",
        error: null,
        help: "Justify content to the left / right.",
        name: "justify",
        type: "Select",
        value: 'start',
        fieldProps: {
          options: ["start", "center", "between", "end"],
        }
      },
      {
        label: "Align Items",
        error: null,
        help: "Align items to the top / bottom.",
        name: "align",
        type: "Select",
        value: 'start',
        fieldProps: {
          options: ["start", "center", "end", "baseline", "stretch"],
        }
      },
      {
        label: "Padding",
        error: null,
        name: "pad",
        help: "How much space should the container add around content?",
        type: "Select",
        value: 'small',
        fieldProps: {
          options: ["small", "medium", "large", "none"],
        }
      },
      {
        label: "Full",
        error: null,
        help: "Should the section span the full width / height of the container.",
        name: "full",
        type: "Select",
        value: 'false',
        fieldProps: {
          options: ["horizontal", "vertical", "true", "false"],
        }
      },
      {
        label: 'Wrap',
        error: null,
        help: "Should the content ever wrap onto a new line?",
        name: 'wrap',
        type: 'Select',
        value: 'false',
        fieldProps: {
          options: ["true", "false"],
        }
      },
      {
        label: "Flex Basis",
        error: null,
        help: "The basis of inner items.  Prefer setting item size vs. flex-basis.",
        name: "basis",
        type: "Select",
        value: 'full',
        fieldProps: {
          options: [
            "xsmall", "small",
            "medium", "large",
            "xlarge", "xxlarge",
            "full", "1/2",
            "1/3", "2/3",
            "1/4", "3/4"
          ],
          onSearch: ({ target }, props) => props.options.filter(i => i.includes(target.value))
        }
      }
    ]
  },

// In your connected component

import GrommetForm from 'grommet-forms';
<GrommetForm form={this.props.sectionLayoutForm} />

We love JSX, but sometimes you just end up writing too much of it. The hope with this library is that you will save yourself some keystrokeys. Pass the form renderer a blob of data describing the hierarchy of your form / fields and get back a rendered form whose state is managed automatically by Redux (or not, that part is up to you!).

Field Types

All of the Grommet form components are supported. When you create your field object, set the type property to one of the Grommet Form Field types.

Each object in your fields array must contain a type and a value property, along with FormField properties such as help and label. The fieldProps object can contain any of the props that the field type supports, including functions. Refer to the Grommet Docs website for a list of supported props. You can also reference the source code to see the PropTypes (Flow Types) that we use internally.