Giter Club home page Giter Club logo

gridforms's Introduction

Gridforms

An effort to make beautiful forms for web applications that make data entry less painful. Gridforms is a front-end library which handles the boilerplate necessary to build grid based forms.

Examples

Basic Usage

1. Import Gridforms

There are two ways you can import the Gridforms styles:

Option A: Link the CSS file directly if you're fine using the defaults, like so:
<link rel="stylesheet" type="text/css" href="gridforms.css">
Option B: Import the gridforms.sass file into your SASS or SCSS (recomended):
@import gridforms.sass

2. Markup your Gridform

<form class="grid-form">
	<fieldset>
		<legend>Form Section</legend>
		<div data-row-span="2">
			<div data-field-span="1">
				<label>Field 1</label>
				<input type="text">
			</div>
			<div data-field-span="1">
				<label>Field 2</label>
				<input type="text">
			</div>
		</div>
	</fieldset>
</form>

Marking up a Gridform is quite intuitive, you'll get a handle on it quickly. Start by giving your <form> element a grid-form class to turn it into a Gridform.

rows: A <div> element with the data-row-span attribute makes up a row. Give the attribute a value of 2 to divide it into 2 columns, give it a value of 3 to divide it into 3 columns and so on.

fields: Each row has a set of fields. Fields are wrapped in div elements and have a data-field-span attribute attached to it. Set to "1" in this example, which means the field spans 1 columns.

Optionally use a fieldset with a legend to divide your form into sections.

Advanced Usage

Use the grid-form mixin to customize and override default styles:

.my-custom-grid-form
    +grid-form

The grid-form mixin accepts a bunch of parameters that can be overridden. Here are all the parameters that you can customize and their default values:

$max-columns: 12,
$font-size-large: 18px,
$legend-color: lighten(#333, 5%),
$field-padding: 8px,
$label-font-size: 10px,
$grid-border-color: #333,
$label-color: #333,
$field-focus-color: darken(#FFFDED, 5%)

You can override default options by passing in custom values.

.my-custom-grid-form
    +grid-form($field-padding: 12px)

Compatibility

Include Scott Jehl's Respond.js if you want the form to be responsive in ie8.

Printing

GridForms will use a @media print query in the CSS to ensure that the printed GridForms look as nice on paper as they do on the screen. You can use this to generate an empty form for someone to fill out on paper or you can replace the form input tags with actual content (including multi-line content) and have the form and content printed out. Everything will just scale nicely.

You don't need to do anything special to print your GridForms, you can just print from your browser using File > Print like normal.

However, if you are generating a PDF dynamically, such as using wkhtmltopdf, you will need to include --print-media-type as an option on the command line. This ensures GridForms renders as a printed media type and the special @media print query in the CSS gets called.

Similarly, if you are using wicked_pdf to generate PDFs from your Rails application, you'll need to ensure print_media_type: true is set as a configuration option.

Todo

  • Test forms with all possible field types
  • Reset unknown styles so forms look the same wherever they're used
  • Gracefully handle label overflow
  • Introduce a sass file to style error/help messages
  • Introduce another sass file that can style the various field types (debatable)

If you have ideas on how to improve Gridforms or if you want to contribute to this repo, shoot us an email at [email protected].

gridforms's People

Contributors

ahmedelgabri avatar ericcch avatar furiousdavid avatar insin avatar joshuapinter avatar kkirsche avatar kumailht avatar lacour avatar limonte avatar nuschk avatar sbleon avatar solsticesurfer avatar staabm avatar sumpygump avatar thebradbain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gridforms's Issues

support for dynamically added elements

ATM gridforms will search the DOM at javascript-load-time and works with the elements found at init time all the time.

when elements get created via javascript after gridforms was loaded, gridforms will not take them into account.
either gridforms should detect wether elements have been inserted, or it should provide a method which can be called to re-fresh its el.fieldsRows, el.fieldsContainers etc.

at best one could give a parameter into this re-fresh method to make gridforms work inside this newly added elements instead of searching via DOM operations across the whole document.

jquery dependency

atm. I need to load a 40-70kb (depending on loaded jquery modules) big JS lib - namely jQuery - to use this great and tiny 4kb gridform lib.

would be great if you could get rid of the jquery dependency.. do you think this is possible?
I guess most of the selector things could be achieved with QSA[1].
that would be a big plus!

[1] http://caniuse.com/#search=querySelectorAll

Form Validation

In Banking example how can I validate the form field date is entered properly

Hover CSS is taking precedence over focus

The hover effect is taking precedence over the focus event on grid-form fields. The result is that a field will not use its focus color until the mouse is moved away from the field that has focus. The expected behavior would be to highlight the field when clicked on.

The fix is very easy: in gridforms.css, simply swap the CSS declarations for focus and hover, lines 21-23 from

21: .grid-form [data-row-span] [data-field-span].focus { background: #fffad4; }
22: .grid-form [data-row-span] [data-field-span].focus label { color: #262626; }
23: .grid-form [data-row-span] [data-field-span]:hover { background: #fffded; cursor: text; }

to

21: .grid-form [data-row-span] [data-field-span]:hover { background: #fffded; cursor: text; }
22: .grid-form [data-row-span] [data-field-span].focus { background: #fffad4; }
23: .grid-form [data-row-span] [data-field-span].focus label { color: #262626; }

Rowspan > 1

Any chance you can add a row-span ability.
ie. A few short questions vertically on the left, and one long textarea question on the right.

Love your forms!

Tooltips on Label fields

Hi, love your library, use it to great effect to create sexy forms. Thank you!

Do you have any pro tips on adding help text info tooltips to your labels? Hover over label is ok but doesn't really give the user visual feedback that info is avail, and icons usually mess up the clean look and field of the label data-field.

Cheers

Text Area

I have implemented to form and love it but have one issue. When I use the text area tag and the user enters a CR/LF it pukes the form. Any thoughts here?

image

Data-field with more than 1 select element

Thanks for gridforms. It's really improved my forms. I had a problem with a data-field with more than 1 select element. Specifically, it was a date field, so "month", "day", "year" selects. From line 46 of gridforms.js

$(this).find('input[type="text"], textarea, select').focus();

Focus goes to the last element, which made the selects useless. My quick fix was to remove
'select' from the arguments.

Is there a better way?

Right Border Does Not Carry Down With Cells At Different Heights

I have encountered an issue with using a textarea and text inputs on the same row. If the textarea expands the height of the row, it does not carry the border down on the div that contains the input due to the div height being different. I am currently trying to write some JS to make all the divs in the row the same height to fix this situation. Is there a CSS way of doing it with this framework?

Read only field

I added this line to consider the case of read only fields (notes or so on)

.grid-form [data-row-span] [data-field-span] div { font-size: 18px; margin: 0; width: 100%; margin-top:14px; margin-bottom:3px;}

Example

<div data-field-span="1">
    <div>Amount</div>
</div>

Multi line form field inputs

If an input needs to be multi-line with a line separator (such as the attached image) is there a current way to achieve this?
screen shot 2014-12-05 at 9 45 54 am

"dist" versions

please consider adding "dist" versions of all files into the download, minified etc.

less support

Hi there,
It is a wonderful thing, a pity that only sass. It is a plan to support lesscss?

selecting on radio inputs

When I was testing the example bank application form I was using only the keyboard and came across an issue.

When pressing the space bar on a radio element it correctly selects the element, however it incorrectly moves the focus to the last radio input in the list.

Another I tried to move between the radio inputs using the left and right arrow keys and the focus shifted again to the last element and would not allow me to move using the arrow keys once more.

Hopefully I've described the issue well enough, if not I'm happy to try and record the issue at a later date :-)

increase text input field target size to cover entire grid cell for clicks/taps

Currently there looks to be an affordance to click within the grid anywhere in a cell to input text. There is however a dead zone around the text input field that does not accept clicks or taps. Much as html link padding can be increased to cover adjacent space, we can do the same with input fields by first adding padding, then subtracting an equal amount of margin. This allows the user to click anywhere in the grid cell to focus the input.

Consider increasing target for accepting clicks/taps to focus text inputs as quickly demonstrated in the attachment (red just for visual demo of increased email field target size compared to blue background showing size of location field).

screen shot 2016-12-11 at 20 06 41

zepto compatibility

is gridforms compatible with zepto.js? if so it would be a plus to have this mentioned in the README

Use with WickedPDF or PDFKit.

First off, fantastic little project. I think these forms are the sexiest I've come across and make entering data (almost) fun.

I'm trying to use Gridforms with WickedPDF to generate a 1-page printable form but the width of the form seems to be messed up.

With the following default markup:

<form class="grid-form">
    <fieldset>
        <legend>Form Section</legend>
        <div data-row-span="2">
            <div data-field-span="1">
                <label>Field 1</label>
                <input type="text">
            </div>
            <div data-field-span="1">
                <label>Field 2</label>
                <input type="text">
            </div>
        </div>
    </fieldset>
</form>

It produces something like this in the PDF:

screenshot 2015-03-12 07 23 14

I'd love to be able to generate PDFs using Gridforms. I'm sure others would too.

Any thoughts on this?

Many Thanks!

Josh

[feature-request] Validation errors

I know this is part of the TODO list, and I just wanted to vote that it go on top of the queue. It would really be awesome if there were a place and styling to display any errors that field-specific.

Domo arigato

Integration with Facebook React

I'm trying to integrate Gridforms with React.
The CSS part works but I can integration with the javascript part.
I'm not an expert but I think it's because gridforms.js currently initializes on startup but does not respond to DOM changes.

Do you have an recommendations?

[enhancement] Add missing bower.json.

Hey, maintainer(s) of kumailht/gridforms!

We at VersionEye are working hard to keep up the quality of the bower's registry.

We just finished our initial analysis of the quality of the Bower.io registry:

7530 - registered packages, 224 of them doesnt exists anymore;

We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

Sadly, your library kumailht/gridforms is one of them.

Can you spare 15 minutes to help us to make Bower better?

Just add a new file bower.json and change attributes.

{
  "name": "kumailht/gridforms",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "description": "please add it",
  "license": "Eclipse",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {
    "<dependency_name>": "<semantic_version>",
    "<dependency_name>": "<Local_folder>",
    "<dependency_name>": "<package>"
  },
  "devDependencies": {
    "<test-framework-name>": "<version>"
  }
}

Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

NB! Please validate your bower.json with jsonlint before commiting your updates.

Thank you!

Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!

Reduce public api

Atm all methods are published via the global GridForms object.
Even methods which dont make sense to be called are public.

Public api should be as small as possible. Reduce to the required minimum.

Field alignment (in a straight line) problem in a single row

Suppose we have a row with four different fields like this -

<fieldset>
    <legend>Test form</legend>
    <div data-row-span="8">
        <div data-field-span="2">
            <input type="text">
        </div>
        <div data-field-span="2">
            <input type="text">    
        </div>
        <div data-field-span="2">
            <input type="checkbox">    
        </div>
        <div data-field-span="2">
            <select>
               <option>1</option>
               <option>2</option>
            </select>    
        </div>
     </div>
</fieldset> 

When there are several rows (just like this row) one after another, alignment of the fields shattered. Select field takes more spaces than other fields.* Checkbox* field takes less spaces than other fields.

I have tried to overcome this situation by applying custom CSS having margin-bottom or margin-top property. But it is a very tedious task and at the end for large amount of rows, it is almost impossible.

It would be a best solution, if someone add a built-in feature to handle such cases.

form not responding to show/hide

I have a form with a textarea that is shown or hidden based on a response to a radio button. When I open the textarea it overwrites part of the form. Please let me know where to go to fix this issue.

BEFORE
image

AFTER
image

Inline class

I've recently discovered Gridforms, and I like that its forms are dense enough to print out on the same page where Bootstrap would require two or three. However, I'm facing a situation where I need to simulate an input mask. An input mask is a fixed character that appears between two variable characters, such as the punctuation in a phone number (123-456-7890). I would like to know if there is a class I can add to my that will prevent it from scaling up to 100% and display as "inline-block" next to its following and siblings. Thank you!

Add .scss version

Currently the Sass styles are in the .sass format. It would be nice to also offer a .scss version so it integrates nicely with other popular frameworks and projects.

Print style?

This is a very cool project. Would be super cool if one can directly print the forms! Just a suggestion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.