Make navigation user friendly on your Aurelia SPA
Posted on 2016-08-28 in Aurelia
Sommaire
Add a spinner
Add the font awesome files to your project (CSS and fonts files).
Import the font awesome style sheet in your index.html
<link rel="stylesheet" href="/assets/fonts/fontawesome/font-awesome.min.css">
Add the CSS code below to create the spinner either directly in the index.html with style tag or in a CSS file that you load in it:
.splash { text-align: center; margin: 10% 0 0 0; box-sizing: border-box; } .splash .message { font-size: 72px; line-height: 72px; text-shadow: rgba(0, 0, 0, 0.5) 0 0 15px; text-transform: uppercase; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; } .splash .fa-spinner { text-align: center; display: inline-block; font-size: 72px; margin-top: 50px; }
Update the div in which your Aurelia application will be instantiated. Eg, replace:
<body aurelia-app="main"> <div> </div> </body>
By:
<body aurelia-app="main"> <div class="splash"> <div class="message">Arena of Titans</div> <i class="fa fa-spinner fa-spin"></i> </div> </body>
Display a message to no-script user
Some of your users may use an extension like noscript which disable JavaScript on page you visit. By default, you will greet them with either a blank page or a never-ending spinner. I think it is more user friendly to show them a message asking to enable JavaScript. To do, add in your body tag:
<noscript> <p>Arena of Titans cannot work without JavaScript. Please enable it.</p> <p>Arena of Titans ne peut pas fonctionner sans JavaScript. Merci de l'activer.</p> </noscript>
More
To view the full details, look at these two commits: