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

@studyportals/form-generator

v0.2.0

Published

General forms for Studyportals B.V. complete styling and functionality.

Downloads

179

Readme

Studyportals form-generator

Maintainability Test Coverage

This package is a component which turns the provided form element snippets into a D² visualized element.

Getting Started

Implement form-generator

There are multiple ways of importing the styles. If you require compiled styles, you can use the dist.

Importing styles

Uncompiled (preferred way)

form#StudyportalsForm {
  @import './node_modules/@studyportals/form-generator/src/sass/FormGenerator';
}

Compiled

@import './node_modules/@studyportals/form-generator/dist/css/FormGenerator.css';
//OR
@import './node_modules/@studyportals/form-generator/dist/css/FormGenerator.min.css';

Importing javascript

import FormGenerator from '@studyportals/form-generator';

const form = document.getElementById('StudyportalsForm');
const fgForm = new FormGenerator(form);
fgForm.generate();

Inserting HTML snippets

Example with mandatory HTML

To successfully implement an minimal version of the input you need the follow HTML snippet. Remember this is the smallest possible version of an input form.

Important: The order of FgInput, FgLabel & .FgMessageContainer are not to be switched.

<form class="FgForm" name="ExampleForm" novalidate autocomplete="off">
  <div class="FgElementWrapper">
    <input
      id="ExampleId"
      name="ExampleName"
      class="FgInput js-Input"
      type="text"
    >

    <label class="FgLabel" for="ExampleId">Example</label>
  </div>
</form>

Example with mandatory with optional HTML

There are some extensions for the input:

  • Input that needs validation based on input type: data-need-validation="true"
  • Input fields that are required: <span class="FgMessage RequiredMessage">Mandatory</span>
  • Input fields that need explanation when the user focus on it: <span class="FgMessage HelperMessage">This message should help people.</span>
  • Input fields that are required and have validation that explains the user what is wrong: <span class="FgMessage ErrorMessage">This is not a valid Example.</span>
<form class="FgForm" name="ExampleForm" novalidate autocomplete="off">
  <div class="FgElementWrapper">
    <input
      id="ExampleId"
      name="ExampleName"
      class="FgInput js-Input"
      type="text"
      data-need-validation="true"
      required
    >

    <label class="FgLabel" for="ExampleId">Example</label>

    <div class="FgMessageContainer">
      <span class="FgMessage RequiredMessage">Mandatory</span>
      <span class="FgMessage HelperMessage">This message should help people.</span>
      <span class="FgMessage ErrorMessage">This is not a valid Example.</span>
    </div>
  </div>
</form>

Develop on project

1. npm run dev

The distribution files will be automatically generated while committing changes.

Distributed files

|- dist/
  |- css/
    |- FormGenerator.css
    |- FormGenerator.min.css
|- src/
  |- sass/
    |- FormGenerator.scss

License

The code is available under the BSD 3-Clause License.