Skip to content

Syntax lookup widget #111

@ryyppy

Description

@ryyppy
Member

We recently found this really neat widget for discovering JS operators, and we think this is a really great way to look for dedicated syntax constructs as well.

Some rough implementation details on how this widget could be built:

We'd create a SyntaxWidget component, that will import some arbitrary markdown files as React components, and put them in an array of items.

type mdxComponent = Js.t({..}) => React.element
@module("./syntax-widget/decorator-module.mdx") external decoratorModule: mdxComponent = "default"

type item = {
  keywords: array<string>,
  summary: string,
  component: mdxComponent
}

let items = [
  keywords: ["bs.module", "module"],
  component: decoratorModule
];

let make = () => {
  // use state to fuzzy find through the keywords and get the right `component` item
   let component = findMatches(items);


   <div>
    <input type_="text" />
    <div>
        { component(Js.Obj.empty()) }        
    </div>
   </div>
 }

In our markdown file (probably within the pages/docs/manual/latest folder), we'd use our new component like this:

import { make as SyntaxWidget } from "components/SyntaxWidget"

<SyntaxWidget />

Remarks

With this implementation we are pretty flexible with editing the content in a separate syntax folder which could also act as our syntax spec documentation.

In case we need to be flexible with the styling, we could wrap the SyntaxWidget with a MdxProvider with custom a custom components prop.

Activity

amiralies

amiralies commented on Nov 16, 2020

@amiralies
Contributor

This is really interesting.

changed the title [-]Syntax discovery widget[/-] [+]Syntax lookup widget[/+] on Nov 20, 2020
added this to the 2021 / January Release milestone on Jan 3, 2021
ryyppy

ryyppy commented on Sep 8, 2021

@ryyppy
MemberAuthor

I'll close this in favor of #162

The implementation of the syntax widget is good. The rest of the work is writing the copy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ryyppy@amiralies

        Issue actions

          Syntax lookup widget · Issue #111 · rescript-lang/rescript-lang.org