Build A Real World Beautiful Web APP with Angular 7 — A to Z Ultimate Guide (2018) — PART I

No more ugly tutorials projects ! No more fictional brands examples!

Today I am going to show you how to build a real world beautiful weather app that is production ready from scratch starting from design to development all the way to deployment using Adobe XD, Angular 7 & Firebase!

Why?

I am sick and tired of developers using background red and basic ugly UI CSS to teach people things that are not production ready and I feel upset when I see thousands of beautiful but practically unusable design projects on Behance and Dribble that designers never took the time to make them useful in any way by taking an extra step to build & deploy those apps so people can benefit from them.

1 man +1 entire project +1 blog post + maybe a video tutorial soon :)

⚡️ Supercharged with all the bells and whistles 😮 🔔

  • Based on the latest & greatest version of Angular v7
  • Firebase Authentication and Firestore (using AngularFire Lite🔥)
  • Server Side Rendered (SEO)
  • 100/100 Lighthouse PWA score
  • Push Notifications
  • Modern CSS: Grid Layout & Flex Box
  • Mobile friendly and full responsive
  • 2 Modes : Dark Mode & Light Mode
  • Unit Testing with Jasmine & Karma
  • End-2–End Testing with Protractor
  • Beautiful Minimalistic Design
  • Note: This tutorial is part of a series that will cover how to build this app and the long list of features listed above progressively and if you want me to notify you when a new tutorial comes up you can signup to my newsletter here. 💌

Step 1: Design

I have designed the weather app in latest version of Adobe XD 2018. You can download the design file from here so you can see how the different layers stack up to form the final design.

A. Branding

I wanted the brand to reflect it’s core values through the design and you can see it screaming: Minimalistic, Simple, Clean and Easy To Use!

  • Colors:

2 saturated primary colors to give it that fresh modern look

  • Typefaces:

No custom fonts in here just the stock ‘Sans Serif’ so we don’t have to load any fonts of the CDN for maximum performance.

  • Logo:

Logos are not rocket science! but logo designers try hard to make you believe so! but in reality they mostly get paid for the ceremony they create and the film they produce to hypnotize the client.

Think about it for a moment the Nike logo ( a check mark shape ) designed for 35$ , Pepsi (rotating the old simple 3 colored waves logo in 2008 costed the company $1,000,000 that is one million dollars folks!)

anyways here the logo I designed a simple M shape that is upside down using two intersecting cards colored using the primary palate of the brand. Simple, effective and most importantly it costs 0$ 😄

B. UI / UX

The app mainly uses cards with a soft shadow as it was pieces of papers floating. Only the most important pieces of information is displayed upfront to avoid cluttering the UI and the fluid animations give us extra points in the UX department.

  • Light Mode (Default) 🌲

Dark Mode ❤️

  • icons:

the user must tell the weather conditions at a glance so I designed a custom pack of icons from scratch to go well with the whole website design and here is the first version of the pack

  • illustrations:

We want to reduce the user efforts to guess as much as possible but in the same time fill up the empty space with a pleasing visual representation of almost everything.

The illustrations I created should help the user identify the selected city without reading any single letter because people are lazy nowadays!

For the cities illustrations I went for a gradient flashy design style with a saturated color palette for a visually rich city details page.

I know how crazy you think I am when I processed to design an illustration for each city the users selects. Obviously, this is an insane amount of work as there is 195 countries in the world but I started with 4 illustrations for now and I kept the rest of the 191 to design throughout the years😅

  1. Tunisia Illustration:

2. Qatar Illustration:

3. Japan Illustration:

4. France Illustration:

and for the complete illustrations project click here to see it on my Behance profile.

Step 2: Development

Here were most guides skip most of the early steps and assume you know everything and then they show you the result to get impressed and nothing more.

But, I am going to try my best to make everyone capable to follow this tutorial even beginners without making the tutorial insanely long and start things off with installing nodejs and the angular CLI which will generate the basic structure and scaffold our Angular 7 app.

install nodejs from the official website from here and open your command line prompt in your OS and install the Angular CLI and typescript globally using the following lines:

npm i -g typescript 
npm i -g @angular/cli

after that just run the following command to generate the App using the Angular CLI and don’t forget to add the routing flag which create a good starting point for the app pagination and routing.

ng new Minimus --routing

once the CLI finishes generating your project files and installs all the dependencies it needs of NPM we are going to start the development server and open our app in the browser using the following command (-o flag is just to open a new browser tab automatically with the correct URL pointing to your app)

ng serve -o 

A. Templates And Styling

But before I start want to make sure that you get the most of this tutorial so please don’t just copy and paste, read the code and then open your editor and browser side by side and type everything down in your own way because that is the only way you can learn. I typed everything myself to build this app and you should too so you can understand everything thing form start to finish.

Now back to the project where we just completed the basic setup of the app and now we are going to start writing our HTML and CSS. So open up your project in your favourite text editor and let’s dive right in Woooho!

  • App Component

we are going to use the root component app.component as our navbar component and we are going to show it and hide it conditionally depending if the user is logged in or not (We will implement Authentication in Part II with Angularfire Lite in the sires).

Here I thought of using some components off the angular material library but I decided to keep the production app as light as possible by avoiding any 3rd party library unless it is really necessary like Angularfire Lite.

First things first open app.component.hml and delete all the boilerplate HTML automatically generated by the CLI and get your HTML to look like something like this:

Bonus Tip (optional):

If you want to use Emmet (an editor plugin) as a faster way of typing HTML you can refer to the plugin cheat sheet I usually refer to.

SVG icons

To get the svg icons and the logo here is a list of gists I created on my Github profile so you can use them (copying and pasting is allowed here) :

— Styling the root component

and it’s time for some css to style our navbar, just take a quick look at the css below and look at the achieved result and then go ahead and write down your own css as it does not have to be exactly the same.

“be inspired don’t copy because everybody is an artist”

CSS explanation:

  • Layout:
display: grid;  
grid-template-columns: auto;
grid-template-rows: 0.5fr auto;

here I am basically using CSS grid layout to divide the page in order to have one small top row for the nav bar and a much larger second row to contain our router outlet which is the main content of the page. Think about it like this small diagram:

  • sidenav
.side-menu__conatiner {
position: fixed;
left: 0;
top: 0 }

places the sidenav container at the top left of the viewport

.side-menu__container::before {...}

used to fade the background with a blue tint when the sidebar slides in

will-change: opacity;

is used to inform the browser ahead of time that the entire background opacity will change so we can achieve a better rendering performance you can read more here.

.slide-menu { transform: translateX(-103%); }

this should pull the side-menu out of the view port and when we click the hamburger menu we should add a .slide-menu-active class which will reset the transform css property and endup sliding the menu from the left of the viewport:

.slide-menu-active {  transform: none; }
  • mode toggle

a small UI element trick that I want to cover is how I styled is the theme toggle button. Basically I set the appearance css property of a standard checkbox input to none just to completely remove any default styling of the input (this is different from display: none which completely hides the element) and then I used two different classes for the toggle button background and the circle to change the color and the position of the circle depending on a boolean variable stored on the component using the built in ngClass directive in Angular which let you toggle css classes easily.

  • Home Component

this is the home component where we show the different weather cards of the user’s favourite cities and from there he can click on the add city card which route him to the add city component to add a new city to his home page.

first we need to generate this component using the CLI using the following command:

ng g c home

the HTML markup has nothing more than a container and two other components for now but we will dynamically add cards depending on the user favourite cities in the upcoming parts of the tutorial:

  • Weather Card Component

Here is used the ngSwitch directive to check for the weather conditions and change

and now to some CSS styling of the component:

DarkMode

In the CSS you can notice that I added two classes for most UI elements and the reason for this is we want to add extra css classes for the dark theme with -dark suffix so we can toggle them afterwards using again the ngClass directive based on the theme toggle button state.

  • Add Card Component

Here is the add card component I have added a div wrapper that has a conditional dark mode ngClass directive like most of the UI element and I have added a the Angular router routerLink attribute to navigate the user to the add city page when the card is clicked

in terms of CSS again nothing complicated here as the main card uses also gird layout to create 2 rows to evenly space its content. don’t forget also to add the box-shadow property to add some light drop shadow to the card.

  • Details Component

Here I injected the weather service to retrieve the weather data (more on that later) and set each day name, temperature and weather condition in a separate public variable that I can access in the template to display it:

Obviously there are a lot of filtering and modification done to the data from the weather service so in the next part will move some of the logic to a service.

Please do not forget also to unsubscribe from each subscription in the ngOnDestroy life cycle hook of the component to avoid memory leaks.

The details component have a lot of svgs which made the HTML very long so here is the full component template including the svg icons so I don’t have to include it here.

with the CSS I have followed the dark mode styling for now:

B. Services

we want to decouple the logic of retrieving the API weather data from a specific component and move it to a separate service that we can use throughout the application and again we are going to use the short hand format to generate a service using the CLI.

  • Weather service
ng g s weather

this service uses the OpenWeatherMap API to retrieve the weather information and makes some modifications before feeding the data to the components at the end. The API does not inform us about the maximum and minimum temperature value and the free plan also restricts us to access only the 5 days/3 hour forecast data so what I ended up doing is I looped through the 3 hours interval temperatures and extracted an approximate max and min value.

and here is the weather.service.ts code:

as you can see all the functions return a Subject which we will use to broadcast the modified data to any component that subscribes to it. This free weather API sucks and I might create a tutorial on how to transform this ugly REST API to a much nicer GraphQL one so stay tuned.

a quick run through on what the different service functions do:

getWeatherState : the current weather state e.g. cloudy - clear…

getCurrentTemp: the current temperature number

getMinTemp: the minimum temperature (based on 3 hours interval)

getMinTemp: the minimum temperature (based on 3 hours interval)

getCurrentHum: current humidity value (number)

getCurrentWind: currenty wind speed (number)

getForecast: get weather data for the 5 upcoming days

getCityWeatherByName: return the entire weather data from the API of city name provided as a string

getCitiesWeathersByNames: returns the entire weather data from the API of the city names provided as an array

  • UI service

this is small service that has functions that we are going to utilize to share the state of the UI like the theme mode selected (dark or light) application wide.

C. Routing

We have already generated the routing module when we created our app with the CLI but we have to make some modifications to the routing.module.ts to tell Angular what are the different routes (URLs) and their associated components (pages).

Conclusion

We made a good progress in this very first part of building the Minimus Weather App we got most of the design work from branding to UI and UX decisions, We wrote a lot of HTML & CSS and we made it look beautiful.

Live Demo: https://minimus-app.firebaseapp.com/

Github Repo: https://github.com/hamedbaatour/Minimus

According to our to-do list here is what we have done so far:

  • Based on the latest & greatest Angular v7 ✅
  • Modern CSS: Grid Layout & Flex Box ✅
  • 2 Modes : Dark Mode & Light Mode ✅
  • Beautiful Minimalistic Design ✅

for the next parts of this series will work on the rest of features so be sure not to miss part II by subscribing to my personal email list:

you can also follow me on twitter @hamedbaatour where I tweet about some cool front end development stuff.

I am available for web development & design projects, you can reach out to me on: hamedbaatour@gmail.com

Want to become an Angular Master? here is the best most recent courses I recommend you invest in:

Angular (Full App) with Angular Material, Angularfire & NgRx. Rating:⭐️⭐️⭐️⭐️⭐️

or this one if you want to go full stack:

Angular & NodeJS — The MEAN Stack Guide.

Rating:⭐️⭐️⭐️⭐️⭐️