cheatcode / joystick

A full-stack JavaScript framework for building stable, easy-to-maintain apps and websites.
https://cheatcode.co/joystick
Other
209 stars 11 forks source link

Add a render method for generating forms #374

Closed rglover closed 2 months ago

rglover commented 8 months ago

Not 100% sure of the API for this yet, but something like this would be helpful:

form('signup', {
  classes: {
    labels: 'mod-label',
    inputs: 'mod-input',
  },
  rows: [{
    fields: [
      { label: 'Email Address', type: 'email', name: 'email_address', placeholder: 'Email Address', value: '', columns: 6 },
      { label: 'Password', type: 'password', name: 'password', placeholder: 'Password', value: '', columns: 6, hint: 'Use at least eight characters, one uppercase letter, one lowercase letter, and a special character.' },
    ]
  }]
})

This would also allow for tracking form instances on the component instance at something like instance.forms.signup which would point to the DOM node for that form for convenience. It may be out of scope, but you could even add a validation schema directly to this that would automate calling to the instance.validate_form() method.