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

@financial-times/editorial-o-forms

v1.0.7

Published

> TODO: description

Downloads

195

Readme

@financial-times/editorial-o-forms

Forms consist of many different container and input elements, so the Origami React component version wraps the many o-forms (v8 as at Feb 2020) elements in a React friendly way.

The React structure of forms mirrors the markup of o-forms:

  • FormsField - the field container (.o-forms-field)
  • FormsTitle - the title container (.o-forms-title)
  • FormsInput - the input container (.o-forms-input) with type prop to specify what type of input it is

To simplify usage, there are also higher level React components and helper props:

  • [InputName]Input components create a FormsInput container that wraps the corresponding HTML input element eg, TextInput has a FormsInput of type text which wraps the text input element
  • [InputName]Field components create a FormsField container with the corresponding input component eg, TextField creates a FormsField that wraps a TextInput
  • FormsField and [InputName]Field components have title, titlePrompt and titleModifiers props that can be used to generate a FormsTitle within the field container
  • Field modifiers and input modifiers can be passed into their respective fields and inputs
  • Form component is available as a convenience for wrapping form elements, however no o-forms styles are applied to it

Usage

The simplest way to use form elements is to find the relevant [InputName]Field component eg,

<TextField title="Simple text field" titlePrompt="Small text"
titleModifiers={['shrink']} className="textFormField"
formsFieldModifiers={['inline', 'optional']} />

FormsField can also be used with title* props and include the [InputName]Input component eg,

<FormsField
	className="textFormField"
	title="Mid text forms field"
	titlePrompt="Small text"
	titleModifiers={['shrink']}
	modifiers={['inline', 'optional']}
>
	<TextInput className="someText" />
</FormsField>

FormsTitle can also be explicitly included eg,

<FormsField
	className="textFormField"
	modifiers={['inline', 'optional']}
>
	<FormsTitle
		title="Full text forms field"
		prompt="Small text"
		modifiers={['shrink']}
	/>
	<TextInput className="someText" />
</FormsField>

Example: Radio buttons

import { FormsField, RadioInput } from '@financial-times/editorial-o-forms';

<FormsField title="Background">
	<RadioInput
		type="radio-box"
		options={[
			{ name: 'white', value: WHITE },
			{ name: 'pink', value: FT_PINK },
			{ name: 'dark', value: DARK },
		]}
		onClick={this.setBackground}
	/>
</FormsField>

Error messages

The FormsInput component uses its displayError and isError props to display an error message under child components.

To do this with the SelectField and TextField components, pass in required and errorMessage props. The pattern prop of the TextField component takes a regex which can be used to set a custom error.