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

wupjs-glyph-input-text

v0.4.0

Published

Generic input[type="text"] using React

Downloads

4

Readme

wupjs-glyph-input-text

Generic input[type="text"] using React

Content

Usage

A glyph input text is a purely representational React component. It consists of a text input node and a submit button which has as text a single symbol character. By default, we use Bootstrap 4 and Font Awesome classes to theme the component. But these settings can be overridden.

import React from 'react';
import {render} from 'react-dom';
import GlyphInputText from './glyph-input-text';

render(<div>
  <h5>GlyphInputText</h5>
  <GlyphInputText
    glyph="save"
    onSubmit={e => {
      e.preventDefault();
      console.log(e.target.value);
    }}
    autoFocus
    autoClear
  />
</div>, document.getElementById('app'));

Required properties

glyph

By default, glyph is the name of a character as defined by Font Awesome. You may use it in combination with property glyphBaseClass to use a totally different character set. See Overriding GlyphInputText defaults.

onSubmit

onSubmit property must be a function which will be called whenever the input box content is submitted. As shown in the Usage example, it takes as input a 'submit' event. Internally, its preventDefault is called so that the component never provokes a page reload. Moreover the event is not exactly the event that is automatically generated on submit (which is related to the wrapping form) but a mixin of that event with {target: inputNode}, so that you can access the underlying data by using e.target.value.

Theming GlyphInputText

There are 5 props provided to help theme the component:

  • groupAddClass: To theme the outtermost wrapper
  • groupButtonAddClass: To theme the button group
  • inputAddClass: To theme the input element
  • buttonAddClass: To theme the button element
  • glyphAddClass: To theme the symbol within the button.

But all come on top of the Bootstrap and Font Awesome defaults. See below to override them.

Overriding GlyphInputText defaults

There are 5 props provided to override the theming of the component:

  • groupBaseClass: Overrides Bootstrap4 for the outtermost wrapper
  • groupButtonBaseClass: Overrides Bootstrap4 for the button group
  • inputBaseClass: Overrides Bootstrap4 for the input element
  • buttonBaseClass: Overrides Bootstrap4 for the button element
  • glyphBaseClass: Overrides FontAwesome for the symbol within the button.

Special props

  • placeholder: Placeholder text within the underlying text input
  • autoFocus: Have the underlying input autofocus
  • autoClear: Have the underlying input autoclear on submit
  • inhibitBlurOnSubmit: As it says: Submitting always blurs first if not inhibited and this is probably unwanted behavior if bluring somehow destroys/detaches the widget
  • defaultValue: Initial value to appear in the text input (not a placeholder, but an actual value that will be submitted by default)
  • onFocus: A function called when the underlying input gets focus
  • onBlur: A function called when the underlying input loses focus

License

wupjs-glyph-input-text is MIT licensed.

© 2017 Jason Lenoble