Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hint on Type for type of type (e.g. 'typescript', 'flow') #82

Open
bennypowers opened this issue Jul 28, 2021 · 2 comments
Open

Hint on Type for type of type (e.g. 'typescript', 'flow') #82

bennypowers opened this issue Jul 28, 2021 · 2 comments

Comments

@bennypowers
Copy link
Contributor

Screen Shot 2021-07-28 at 9 14 12

coptic: Any interest in improving the controls? For example, size here has three options, so a radio is a little nicer than having to type in something IMO. If there’s 3+ it could default to a select maybe?

bennyp: This could maybe be automated from the type field in a custom elements manifest, however, we'd have to assume the type text is typescript in order to parse the union, where the manifest scema makes no such assumption

coptic: Ya that’s what I was playing around with. That’s a good point though not assuming TS. FWIW, stencils doc schema and generator is nice in that it does parse any union into a values array.

tl;dr: tools can't know for certain what kind of string the type text is. If we added a hint (per file, or per type), they could parse the type to do things like generate radio buttons for demos

per type:

{
  "schemaVersion": "1.0.0",
  "readme": "",
  "modules": [
    {
      "kind": "javascript-module",
      "path": "my-element.js",
      "declarations": [
        {
          "kind": "class",
          "name": "MyElement",
          "members": [
            {
              "kind": "field",
              "name": "type",
              "type": {
                "text": "'number'|'string'|'boolean'",
                "kind": "typescript"
              }
            }
          ]
        }
      ]
    }
  ]
}

per file

{
  "schemaVersion": "1.0.0",
  "readme": "",
  "modules": [
    {
      "kind": "javascript-module",
      "path": "my-element.js",
      "types": "typescript",
      "declarations": [
        {
          "kind": "class",
          "name": "MyElement",
          "members": [
            {
              "kind": "field",
              "name": "type",
              "type": {
                "text": "'number'|'string'|'boolean'",
              }
            }
          ]
        }
      ]
    }
  ]
}
@jogibear9988
Copy link
Contributor

I think #51 means nearly the same

@break-stuff
Copy link

This would be great. Unfortunately, parsing TypeScript values and adding them to the manifest can be tricky. I created this plugin and used it with my Storybook helpers to help get the experience you are looking for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants