This article presents the overview of the internal organization of the Aurelia-Materialize-Bridge project developed by the team of Aurelia UI Toolkits organization, dedicated to help Aurelia's wide spread adoption .
The internal organization of this bridge is slightly different than Aurelia's standard plugin. We believe that it is more convenient. Image 1 below, shows the overall structure.
Image 1
The following three sections describe the details of the plugin structure and building process
3.1 Plugin code
Image 2
The plugin's src folder contains the common subfolder with utilities used by more than one Materialize component "wrapped" by this plugin. In addition to the just described utility of the common folder, the src folder contains a subfolder for each of the Materialize components that is wrapped by this plugin.
Note: At the time of writing this, not all components have been implemented. There are more available than this screenshot shows.
The code in the plugin defines its content via the config-builder.js file
File config-builder.js
exportclassConfigBuilder { useGlobalResources:boolean=true; globalResources = [];useAll():ConfigBuilder {returnthis.useBox().useButton().useCard().useCarousel().useCheckbox().useCollapsible().useColors().useDropdown().useNavbar().useSelect().useSidenav().useSlider().useSwitch().useTabs().useTooltip().useTransitions().useWaves().useWell(); }useBox():ConfigBuilder {this.globalResources.push('./box/box');returnthis; }useButton():ConfigBuilder {this.globalResources.push('./button/button');returnthis; }useCarousel():ConfigBuilder {this.globalResources.push('./carousel/carousel');this.globalResources.push('./carousel/carousel-item');returnthis; }useCard():ConfigBuilder {this.globalResources.push('./card/card');returnthis; }useCheckbox():ConfigBuilder {this.globalResources.push('./checkbox/checkbox');returnthis; }/** * Use my control */useClickCounter():ConfigBuilder {this.globalResources.push('./click-counter');returnthis; }useCollapsible():ConfigBuilder {this.globalResources.push('./collapsible/collapsible');returnthis; }useColors() :ConfigBuilder {this.globalResources.push('./colors/md-colors.html');returnthis; }useDropdown() :ConfigBuilder {// this.globalResources.push('./dropdown/dropdown-element');this.globalResources.push('./dropdown/dropdown');returnthis; }useNavbar():ConfigBuilder {this.globalResources.push('./navbar/navbar');returnthis; }useSelect():ConfigBuilder {this.globalResources.push('./select/select');returnthis; }useSidenav():ConfigBuilder {this.globalResources.push('./sidenav/sidenav');this.globalResources.push('./sidenav/sidenav-collapse');returnthis; }useSlider():ConfigBuilder {this.globalResources.push('./slider/slider');this.globalResources.push('./slider/slide');returnthis; }useSwitch():ConfigBuilder {this.globalResources.push('./switch/switch');returnthis; }/** * Use materialized tabs */useTabs():ConfigBuilder {this.globalResources.push('./tabs/tabs');returnthis; }useTooltip():ConfigBuilder {this.globalResources.push('./tooltip/tooltip');returnthis; }useTransitions():ConfigBuilder {this.globalResources.push('./transitions/fadein-image');this.globalResources.push('./transitions/staggered-list');returnthis; }/** * Use ripple/waves effect */useWaves():ConfigBuilder {this.globalResources.push('./waves/waves');returnthis; }useWell():ConfigBuilder {this.globalResources.push('./well/md-well.html');returnthis; }/** * Don't globalize any resources * Allows you to import yourself via <require></require> */withoutGlobalResources():ConfigBuilder {this.useGlobalResources =false;returnthis; }}
Note that this file defines the controls that are available to Aurelia developers at the time of writing this article.
Let's also show the actual Aurelia plugin implementation of one of the simplest Materialize controls - switch
3.2 Sample Application that acts as the Plugin consumer
As mentioned before Aurelia-Materialize-Bridge has a special structure, with the plugin consumer application being a part of the same project (see the content of the blue rectangle on the image 3 below)
Image 3
#### Color codes: * **orange**: Materialize controls hosted by this sample app (these controls are the consumers of the Aurelia-Materialize-Bridge) * **blueish**: Standard Aurelia application files collection
#### Sample application showing the Materialize Button control: