adaptlearning / adapt_framework

A toolkit for creating responsive, accessible, multilanguage HTML5 e-learning courses.
https://www.adaptlearning.org/
GNU General Public License v3.0
578 stars 248 forks source link

Facilitate component-style sub views #2185

Closed oliverfoster closed 4 years ago

oliverfoster commented 6 years ago

Subject of the enhancement

In some places in Adapt we inject DOM elements from one extension into another. This practise isn't possible with frameworks like VueJS and React. We need to allow instantiation of registered 'component style' views in Adapt.

External examples

VueJS: https://vuejs.org/v2/guide/components-registration.html React: https://reactjs.org/docs/components-and-props.html#composing-components

Expected outcome

This should allow us to move to a more appropriate style of injection, ready for future frameworks, without changing too much.

Suggested implementation

Handlebars

Pass the Adapt model by id.

{{subview name="menu:progress" id=this._id}}

Create a model from the data specified.

{{subview name="component:completionIndicator" model=this}}

JavaScript

var MenuProgress = Backbone.View.extend({
    initialize: function() {

    }
});
Adapt.subviews.register("menu:progress", MenuProgress);
Link2Twenty commented 5 years ago

When it comes time to pick a framework it may be worth looking here for pros and cons https://custom-elements-everywhere.com/