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

Syntax lookup widget #111

Closed
ryyppy opened this issue Nov 16, 2020 · 2 comments
Closed

Syntax lookup widget #111

ryyppy opened this issue Nov 16, 2020 · 2 comments

Comments

@ryyppy
Copy link
Member

ryyppy commented Nov 16, 2020

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.

@amiralies
Copy link
Contributor

This is really interesting.

@ryyppy ryyppy changed the title Syntax discovery widget Syntax lookup widget Nov 20, 2020
@ryyppy ryyppy added the manual label Jan 1, 2021
@ryyppy ryyppy added this to the 2021 / January Release milestone Jan 3, 2021
@ryyppy
Copy link
Member Author

ryyppy commented Sep 8, 2021

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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants