Giter Club home page Giter Club logo

fluent-editors's Introduction

Playground for Fluent Editors

This react app should at some point help us play with different kinds of Fluent editors.

Basic structure is that App is the top-level component, which holds a MessageList.

MessageList loads an example ftl file, and parses that and set's that as state. It then renders each Message and Term. That is done via a React Component per AST node. These components are automatically created via scripts/ast-gen.js. Please don't edit them directly, but modify the generation script and commit the result.

The component instantiation is done via a Factory module that knows how to map AST nodes to ReactComponents or s.

The idea for experimentation is that one can just subclass individual components, create a different rendering function, and benefit from most of the existing AST components. Check out the preview and editing subclasses of the Factory for examples.

Be my guest.

fluent-editors's People

Contributors

pike avatar

Stargazers

Adrian Gaudebert avatar Denis Denisov avatar Vishal Sharma avatar Jarek avatar

Watchers

James Cloos avatar

fluent-editors's Issues

Choose names for js libraries

Right now, the AST components and the review/preview/edit modes are in pretty randomly named files.

Wouldn't hurt to put them into local packages, if only

  • I knew how to do that and have both local npm start and npm run build still work
  • had any good idea of how to name these

Things to throw into the mix might be fluent, react, components, edit.

@stasm, w/out trying to get you into yak shaving down in a rabbit hole, any ideas?

What is the purpose of generating the AST components?

So far I've only skimmed through the code. I don't claim to have the full picture. I wonder about the purpose of ast-gen.js, though. Looking at the code it generates, it would seem that the similar effect could be achieved with a single component which can be dynamically used with any AST nodes. Something like the following:

function printableFields(ast) {
    // Remove span and type, rename key, etc.
    return Object.entries(ast).map().filter();
}

function ASTNode({factory, ast}) {
    return (
        <span className={ast.type}>
            {printableFields(ast).map(
                ([fieldName, fieldValue]) =>
                    factory.createComponent(fieldValue, fieldName)
            )}
        </span>
    );
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.