Git Product home page Git Product logo

tcomb-form-templates-bootstrap's Introduction

Default templates used by tcomb-form, so you are not supposed to do a manual setup.

Manual setup

npm install tcomb-form
npm install tcomb-form-templates-bootstrap
import t from 'tcomb-form/lib'
import en from 'tcomb-form/lib/i18n/en'
import templates from 'tcomb-form-templates-bootstrap'

t.form.Form.i18n = en
t.form.Form.templates = templates

tcomb-form-templates-bootstrap's People

Contributors

cjcheshire avatar enoshixi avatar gcanti avatar rnewstead1 avatar tsmmark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tcomb-form-templates-bootstrap's Issues

Support React 15

When I migrated my universal app (browser + node) to React 15 I've noticed that I have 2 react versions in my webpack bundle.
Appeared that this package has "react": "^0.14.0" as its dep.
I tried to change it to ^0.14.0 || ^15.0.0 and everything seemed fine except this "attempted to reuse markup" error:

warning.js:44 Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
 (client) put type="password" id="0" name="current
 (server) put type="password" name="currentPasswor

Looks like this package adds some id's to form fields on client but doesn't do it on server.
And also I think react dep should be under peerDependencies to throw an error in such situations. As I can see you've already done it for tcomb-form.

Thanks!

Can you also export the `create` function?

I noticed that the create function is not being exported from the file. That makes it impossible to use the overrides facility of this function. Just for the sake of extensibility, can you import this function as well? Thanks.

Checkbox is positioned oddly if `config.horizontal` columns don't add to 12

When rendering a checkbox with horizontal configuration, and the column widths for a non-mobile breakpoint do not sum to 12, the checkbox is offset in a weird position.

I would expect the position of the checkboxes to be aligned with the form inputs. Less ideally, the requirement to have 2 columns that sum to 12 could be documented in the Guide.

Example component:

import React, { Component } from 'react';
import t from 'tcomb-form'
import 'bootstrap/dist/css/bootstrap.min.css'

const FormSchema = t.struct({
  name: t.String,
  age: t.maybe(t.Number),
  rememberMe: t.Boolean
})

const options = {
  config: {
    horizontal: {
      md: [1, 6],
      sm: [1, 8]
    },
  }
};

class MyForm extends Component {
  render() {
    return (
      <form onSubmit={this.onSubmit} className="tcomb-form form-horizontal label-left">
        <t.form.Form ref="form" type={type} options={options} />
        <div className="form-group">
          <button type="submit" className="btn btn-primary">Save</button>
        </div>
      </form>
    );
  }
}

Result:

screen shot 2018-03-07 at 3 34 18 pm

I can prepare a fix, but at a glance it will require quite a bit of refactoring to Breakpoints.js.

Support Bootstrap 4

Could be great to think about Bootstrap 4 implementation, the current version is not working well with Bootstrap 4.

Example: On error form field (highlighted in red)

Before (BS3)

<div class="form-group has-error">
    <label class="control-label" for="inputError1">Input with error</label>
    <input type="text" class="form-control" id="inputError1">
</div>

After (BS4)

<div class="form-group has-danger">
    <label class="form-control-label" for="inputDanger1">Input with danger</label>
    <input type="text" class="form-control form-control-danger" id="inputDanger1">
    <div class="form-control-feedback">Sorry, that username's taken. Try another?</div>
</div>

Differences:

  • Use of has-danger class instead of has-error on form-group (turns label in red)
  • Input is red because of the form-control-danger class on it
  • form-control-feedback class for error message under the input

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.