question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Proposal: Expressive spec

See original GitHub issue

What problem does this feature solve?

We already have some issues with improving the spec:

With a more expressive spec, we can tell more about a component/trait/application to the user or the editor.

What does the proposed API look like?

Component

Metadata

To keep the metadata area clean and maintainable, we will only add one field annotations to its schema.

The annotations will have a type of JSONSchemaObject.

{
  "name": "Table",
  "description": "A Table component",
  "annotations": {
    "maintainer": "developer@sunmao-ui",
    "git": {
      "revision": "v1.0-hash",
      "repo_url": "https://github.com/webzard-io/sunmao-ui"
    },
    "have_a_pricing_plan": true
  }
}

ComponentSpec

properties

Since we are using JSON schema to describe properties, we will follow JSON schema to describe more information of a component.

I’m going to propose three ways to organize the information.

1: Without namespace

{
  "width": {
    "type": "number",
    "title": "Width",
    "description": "width of the component in pixel",
    "widget": "WidthSlider"
  }
}

2: With nested namespace

{
  "width": {
    "type": "number",
    "editor": {
      "title": "Width",
      "description": "width of the component in pixel",
      "widget": "WidthSlider"
    }
  }
}

3: With plain namespace

{
  "width": {
    "type": "number",
    "editor:title": "Width",
    "editor:description": "width of the component in pixel",
    "editor:widget": "WidthSlider"
  }
}

To tell the editor how to display property in the form, we define the following fields:

  • title: will display as the label of the form control
  • description: will display as the help text of the form control
  • widget: will determine which form control will be used
  • category: properties will be grouped by category in the form, properties without a category will fall back to the basic category.

Trait

Metadata

Same as the Component metadata.

TraitSpec

properties

Same as the ComponentSpec properties.

Application

Metadata

Same as the Component metadata.

To tell the runtime how to render the head of the HTML, we define the following rules of the annotation fields:

  • title: will render <title> in the <head>
  • meta: will render <meta> in the <head>
  • link: will render <link> in the <head>

An example of application’s annotation:

{
  "name": "Blog",
  "description": "My Blog Website",
  "annotations": {
    "title": "sunmao-ui developer blog",
    "meta": [
      {
        "name": "viewport",
        "content": "width=device-width"
      },
      {
        "name": "description",
        "content": "the blog website to record our thought on the sunmao-ui project"
      }
    ],
    "link": [
      {
        "rel": "alternate icon",
        "type": "image/png",
        "href": "https://github.githubassets.com/favicons/favicon.png"
      }
    ]
  }
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Yuyz0112commented, Feb 8, 2022

An update:

How about fallback entities without category to advance instead of basic? This pushes developers to define categories explicitly.

1reaction
tanbowensgcommented, Feb 8, 2022

I preffer 3: With plain namespace. It can avoid conflict when a property is an object and has a key called title or description.

{
  "width": {
    "type": "number",
    "editor:title": "Width",
    "editor:description": "width of the component in pixel",
    "editor:widget": "WidthSlider"
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

The 'Expressive MIDI' Proposal and Animoog
“The goal of this specification is to provide an agreed method for hardware and software manufacturers to communicate multidimensional data ...
Read more >
GitHub - tc39/proposal-pattern-matching
Spec Text: https://tc39.github.io/proposal-pattern-matching ... Guards provide a space for additional logic when patterns aren't expressive enough.
Read more >
Expressive Activities Held on UCSF Property
Expressive Activities Held on UCSF Property · 1. Compliance with University Policies and the Law · 2. Fundraising · 3. Alcohol · 4....
Read more >
Art Therapy Proposal - School of Applied Sciences | Ole Miss
While the HILL. Class helps children ages 3-5 with receptive and expressive language delay, hearing impairment, Down. Syndrome, autism spectrum disorder, and ...
Read more >
Re: shapes-ISSUE-97 (sh:derivedValues): Proposal to define ...
... Peter F. Patel-Schneider wrote: > What issue with the spec is this proposal addressing? ... Does this proposal add any expressive power...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found