Configuring our project with Aurelia-Materialize

As we said in the last section, Material Design is not a library. However, many libraries are based on Material philosophy, so we will choose Materialize CSS. Their components look very natural, and the best part is that Aurelia has its own implementation of this library called Aurelia-Materialize, which will facilitate us a lot in the development process and integration.

Let's open our created FIFA World Cup application and set the Terminal into the root folder; then we need to install some dependencies. Execute the following commands in the next order:

  • $ au install jquery
  • $ au install tslib
  • $ au install materialize-amd
  • $ au install aurelia-materialize-bridge

In our index.html file, lets include the Material Design icons to be imported into our project:

<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

Next, in our main.js file, we need to configure our new plugin:

aurelia.use.plugin('aurelia-materialize-bridge', b => b.useAll().preventWavesAttach());

The b => b.useAll() script allows us to load all Aurelia-materialize components into our project. If you only need a few of them, you can specify each one in the next way:

.plugin('aurelia-materialize-bridge', bridge => {
bridge
.useButton()
.useCollapsible()
.useModal()
.useTabs()
.useWaves().preventWavesAttach();
});
Then, we need to add our generated .css to the index.html file:
<link rel="stylesheet" href="styles/css/materialize.min.css">
Since we have the Aurelia CLI installed from the previous chapter, we are using this feature to get the new dependencies. Make sure you have at least the 0.32.0 version.

You are done! We are finally ready to start developing our generated, configured, and running web application.

At this point, your application folder should contain the following (or similar) project structure:

If you are using an earlier version of Aurelia-CLI (0.33.1), please read the following recommendations:

  • Add  node_modules/jquery/dist/jquery.js to the prepend section of the vendor-bundle.js configuration in the aurelia.json file and remove jquery from dependencies section. 
  • Add  node_modules/materialize-amd/dist/js/materialize.amd.js at the end of prepend section of the vendor-bundle.js configuration in the aurelia.json and remove the materialize-amd configuration from dependencies section.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.184.0