json-schema-form / json-ui-schema

TBD
MIT License
3 stars 0 forks source link

[Proposal] Grid: Add layout definition for view framework independent control #2

Open Anthropic opened 8 years ago

Anthropic commented 8 years ago

Currently the combined use of type section and fieldset with css properties defines the layout for the bootstrap decorator and the material decorator is adding a grid system, but a generalised layout model is needed for a standard that can be implemented by any library.

The key elements will always be: horizontal grouping, vertical grouping, width & height with additional support for passing alignment and more view specific details if needed.

ASF Bootstrap is very bootstrap centric

{
  "type": "section",
  "htmlClass": "row",
  "items": [
    {
      "type": "section",
      "htmlClass": "col-xs-6",
      "items": [ "name" ]
    },
    {
      "type": "section",
      "htmlClass": "col-xs-6",
      "items": [ "email" ]
    }
  ]
}

ASF Material is currently a little flex centric

{
  "type": "section",
  "grid": { "layout": "column" },
  "items": [
    {
      "type": "section",
      "grid": { "layout": "row", "flex": 50 },
      "items": [
        {
          "key": "firstname",
          "grid": { "flex": 50 }
        },
        {
          "key": "lastname",
          "grid": { "flex": "" }
        }
      ]
    }
  ]
}

Proposed

{
  "type": "section",
  "grid": { "layout": "column" },
  "items": [
    {
      "type": "section",
      "grid": { "layout": "row", "span": 50 },
      "items": [
        {
          "key": "firstname",
          "grid": { "span": 50 }
        },
        {
          "key": "lastname",
          "grid": { "span": "auto" }
        }
      ]
    }
  ]
}

The grid attribute is short and to the point although I was also partial to structure early on. Grid being a parent object for anything layout related can help separate structure and make it easier to find and operate on or set defaults for.