Wednesday, September 13, 2017

#307: Debugging JavaScript with Chrome DevTools

Frontend Focus
Issue 307 — September 13, 2017
Ditch console.log debugging once and for all by learning to use breakpoints to debug code within the DevTools.
Brandon Morelli

Browsers try to render SVG images on every frame, this can be slow. Here, Jake shows us how the createImageBitmap method can speed things up.
Jake Archibald

Secure a year of access to 1st-rate training that advances your skills and expands your professional horizons. Frontend Masters' catalog of expert courses is continually added and updated throughout the year. Don't delay—discount ends September 18th.
Frontend Masters   Sponsor

The trick to learning Flexbox is simply by playing with it, so these 7 examples and walkthroughs provide a lot of food for thought.
Ohans Emmanuel

How can we make the Web better by designing and developing with performance in mind? A look at various ways of making impactful performance improvements.
Karolina Szczur

Explains the reasoning behind Webpack, and what makes it more than a mere bundler.
Jack Histon

With a single line of CSS, we can completely reorient any element. Dan Wilson gets into the transform property and how you can use it to change your site.
Heart Internet

Jobs

Can't find the right job? Want companies to apply to you? Try Hired.com.

In Brief

Watch Microsoft Edge Web Summit 2017 Live On Channel 9 Today news
Starts today (Weds Sep 13) at 9am Pacific/12pm Eastern.
Kyle Pflug

Web Content Accessibility Guidelines 2.1 Working Draft news
W3C

Web Share API Goes Live in Chrome 61 on Android news
Google Developers

Chrome’s Plan to Distrust Symantec Certificates news
Google

The Developer Has Spoken 
HEVC is rising and HLS is still king. Get the 2017 Video Developer Report and see for yourself.
BITMOVIN  Sponsor

Getting Started with Website Accessibility tutorial
Carie Fisher

Accessible SVG Line Graphs tutorial
Adding ARIA roles to improve the accessibility of SVG graphs.
Léonie Watson

Building Skeleton Screens with CSS Custom Properties tutorial
Max Böck

2 Ways to Break CSS Grid and How to Fix It tutorial
Dave Rupert

HTML Templates via JavaScript Template Literals tutorial
Chris Coyier

Switching Your Site to HTTPS on a Shoestring Budget tutorial
Christopher Schmitt

How I Recreated The Gorillaz Andromeda Music Video using WebGL story
Yağız Gürgül

Experimenting with WebAssembly and Computer Vision story
Mozilla Hacks

Micro Frontends: Extending Microservice Ideas to Frontend Development opinion
Micro Frontends

CSS-in-JS Is Like Replacing A Broken Screwdriver with Your Favorite Hammer opinion
Kevin Ball

Disabled Form Buttons Suck, and Here's Why opinion
Hampus Sethfors

The Zen of Just Writing CSS opinion
Svelte

Full-stack app monitoring with Datadog 
Get real-time metrics from your web applications with Datadog. Start quickly with auto-instrumentation.
Datadog  Sponsor

src2png: Turn Source Code Into Beautiful Syntax-Highlighted Images tools
Matt Lewis

Stencil: A Tool for Building Modern Web Components tools
Ionic


by via Frontend Focus

Which Industries Have the Best Content Marketing? [Infographic]

The reason for such emphatic coverage is simple: Great stories leave an emotional resin on readers, imprinting them in a way traditional marketing copy does not. But as our CMO likes to remind us, storytelling alone is not a strategy. Plenty of brands are interested in telling stories, but that...

[ This is a content summary only. Visit our website http://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Web Desk via Digital Information World

Introducing Microsoft’s Fluent Design System

Fluent Design System by Microsoft

We've seen leading companies implementing either their own design languages, or existing ones such as Google's Material Design. Think of a design language as a well-documented guideline for creating apps and websites with an intuitive, engaging and consistent appearance.

Microsoft recently unveiled their Fluent Design System, which is intended for use on a wide range of Windows 10-based devices (i.e. Universal Windows Platform (UWP) Apps). It's meant to extend the already-existing "Microsoft Design Language 2", unofficially yet broadly known as "Metro". Also, at the time of writing, 80% of the Fluent Design System has been integrated into Microsoft's already-existing web framework, named Microsoft Web Framework (MWF).

While that's a story for another time, it's worth knowing that the design concepts outlined in the Fluent Design System (which we'll discuss) can be implemented for both the web and apps.

Let's lay out the key characteristics of the the Fluent Design System and acquaint ourselves with its methodologies, and how developers can implement the language into Windows UWP apps.

TL;DR…

If you're curious about Fluent Design and you'd rather watch a summarising video, here are the official Introduction to Fluent Design and Build Amazing Apps with Fluent Design videos that were watched at the Build 2017 event.

It should be noted that the Fluent Design System is in active development, so some of the design principles and features may change as the design language progresses. Always make sure to check the official documentation for up-to-date information.

Design Concepts and Principles

Fluent Design System Playground

We're living in the era of smart devices, which goes beyond desktop, laptop or tablet devices to include any kind of equipment with networking capabilities (i.e. wearable technology and so on…). Many of them (e.g. smartphones) are bundled with screens of different sizes and resolutions, while others (e.g. sensors) don't offer a display. Microsoft aims to make their design language adaptive to all these kinds of devices.

Microsoft's new Fluent Design System is based on the following five foundational elements. Each and every element brings a unique look and feel to the UI and UX respectively.

  • Light: enhancing user orientation during selection and navigation, creating the necessary atmosphere for user guidance.
  • Depth: utilizing the z-axis to add an extra dimension to the 2D display, a sort of revision of flat design withed added layers, stacks of elements and 10000% more clarity.
  • Motion: introducing smooth, natural transition between elements as well as seamless shifting between windows and screens, giving the feel of continuity between each user action.
  • Material: equipping elements with an exclusive feel and touch experience, tempting users to interact.
  • Scale: focusing on design consistency and interoperability across all kinds of devices, from 2D to 3D.

Getting Started

Fluent Design System Waves

Let's take a look at the new features that've been adopted into the Universal Windows Platform framework, and how the Fluent Design System concepts ads their implementation. The four features are:

Acrylic

Fluent Design System Acrylic

Acrylic enables us to apply tint and opacity to graphical objects and subsequently offers the UI a materialized look which does not innately rely on solid colors. For the developers out there, it exists as a C# brush class. It's also worth noting that Fluent Design incorporates Microsoft's Universal Color Palette, a diverse set of colors frequently used in Windows apps. UWP apps generally use 48 colors, whereas on Xbox recommends 21 TV-safe colors.*

Fluent Design System Acrylic Properties

How the design concepts are applied:

  • Light: light draws the user's attention. In the words of Microsoft, it's "warm and inviting", so it's a terrific way to illuminate information by establishing optimal contrast between the foreground and background elements in a natural way.
  • Depth: soft shadows allow for layered elements, creating a sense of visual hierarchy.
  • Motion: illuminating and harmonious UI transitions.
  • Material/Scale: works with displays of varying sizes and resolutions, offering a natural and consistent sensory visual style across Windows as a whole.

Parallax

Fluent Design System Parallax

Parallax is becoming an increasingly trendy technique for establishing depth, where two or more objects need to shift at different rhythms as the user scrolls through the content. Parallax can be a pretty awful experience for the user when handled poorly, especially when there was no need to implement such an experience. Fluent Design lets us handle it with care.

How the concepts are applied:

  • Depth: by designing emerging and submering elements, we can create the impression of deepness and immersion.
  • Motion: combined with the Connected Animation features of the UWP framework, we can create scrolling effects that feel natural and expected while bringing content to life.

Reveal

Fluent Design System Reveal

Reveal is an effect that uses lighting to assist the user when navigating through the UI. Not only can it be used it reveal, like the name suggests, hidden elements and borders, but it also helps to reaffirm the user selection by highlighting it.

Continue reading %Introducing Microsoft’s Fluent Design System%


by Giannis Konstantinidis via SitePoint

Koya Bound

‘Koya Bound’ is a beautiful interactive One Pager and photographic record of Dan Rubin and Craig Mod’s eight days walking on the Japanese pilgrimage path, Kumano Kodo. As you scroll down, the photos correlate with the map to the right, giving more context to the journey. At the bottom they promote the (limited edition) print version of the adventure. A great reference to long-form journalism in a Single Page website – also promoting a product. (this screenshot was very difficult to capture and it’s about 1/50th of the actual site length, so make sure you check out the live site)


by Rob Hope via One Page Love

What Is the Android Activity Lifecyle?

In my previous post, you learned that Intents let us send messages from one Android component to another. Well, one very important kind of component is an Activity. 

Activities are a fundamental part of Android app development. And it's impossible to understand Activities without also understanding their lifecycles. In this post, you'll learn all about the Activity lifecycle.

  • Android SDK
    What Are Android Intents?
    Chinedu Izuchukwu

Activity Lifecycle

An Activity is a single screen in Android. It is like a window in a desktop app, or a Frame in a Java program. An Activity allows you place all your UI components or widgets together on the screen.

It's important to understand that an Activity has a lifecycle: that is to say that it can be in one of several different states, depending on what is happening with the app and with the user interaction. 

Lifecycle Methods

Let's look more closely at the lifecycle of an Android Activity. Each time the Activity state changes, one of the following lifecycle methods will be called on the Activity class. 

onCreate(): This is called when the Activity is first initialized. You need to implement this method in order to do any initialization specific to your Activity.

onStart(): This is called the first time that the Activity is about to become visible to the user, as the Activity prepares to come to the foreground become interactive. Once this callback finishes, the onResume() method will be called.

onResume(): When the Activity goes into this state, it begins to interacts with the user. The Activity continues in this state till something happen to take focus from the app or Activity (such as an incoming call). When this happens, the onPause() method will be called.

onPause(): This method is used to pause operations that should not happen when the Activity is in paused state. A call to this method indicates that the user is leaving the app. For example, in a music player app, an incoming call will cause the app to transition into a paused state. This should mute or pause the currently playing music. When the user returns to the app, the onResume() method will be called.

onStop(): This method is called when the Activity is no longer visible in the app. It can happen, for example, when another Activity has been loaded and is taking the full screen of the device. When this method is called, the Activity is said to be in a stopped state. In this state, the system either calls the onRestart() to bring back interactivity with Activity. Or it calls the onDestroy() method to destroy the Activity.

onDestroy(): This gets called before the Activity is destroyed. The system calls this method when a user terminates the Activity, or because the system is temporarily destroying the process that contains the Activity to save space. Be sure to free up any resources your Activity has created in this method, or else your app will have a memory leak!

onRestart(): This gets called when an Activity restarts after it had been stopped.

Starting an Activity

Most user interactions with an app cause the active Activity to be changed. So an app transitions between Activities many times during its lifetime.

It's necessary to link Activities together when one Activity needs to start another Activity. To start an Activity, you either use startActivity() or startActivityForResult(). You have to pass an Intent in either case.

Starting an Activity With No Expected Result

startActivity() is used if the newly started Activity does not need to return a result.

The following code snippet shows how to start another Activity using this method:

You can also perform actions such as passing data from one Activity to another. In this case, your current Activity (the calling Activity) wants to pass data a target Activity. This is where Intents come in handy. To learn about using Intents to start an Activity, check out my previous article.

Starting an Activity With a Result

startActivityForResult() is used to start another Activity and expects to get data back from the newly started Activity. In other words, use this when you want to get a result from the target Activity back to the calling Activity, e.g. if the target Activity is collecting some user information in a modal dialog.

You receive the result from the Activity in the onActivityResult(int requestCode, int resultCode, Intent data) method. The result will be returned as an Intent.

Example of Starting an Activity

Here is an example to show how starting an Activity works.

First, you create your MainActivity with your onCreate() method, a layout file, and a request code.

In your onCreate() method, you'll create a new instance of an intent to start your second Activity. 

When you're ready to start that Activity, say in response to a button click, you'll call startActivityForResult(), which will pass the newly created intent and the request code.

Still, in your MainActivity, you need to handle Activity result events. You do this by implementing the onActivityResult()  method. This is how you will receive the result from the other Activity. 

Here's how it should look:

Now go ahead and create your SecondActivity. It should look something like the code below.

Terminating an Activity

Before an Activity terminates, the corresponding lifecycle methods will be called.

The onPause() method should stop all listeners and UI updates. The onStop() method should save the application data. Finally, the onDestroy() method will free up any resources that the Activity has allocated. 

When the user switches back to an app that has been terminated by the system, the onResume() method is called. Based on saved data, it can re-register listeners and trigger UI updates.

Activity Instance State

An Activity needs a way to keep valuable state and user data that it has obtained. These data might be obtained from user input or created while the Activity was not on-screen.

For example, a change of device orientation can cause an Activity to be destroyed and recreated. In such a scenario, you need to make sure to save all Activity state before it is destroyed and reload it again when it is recreated. Otherwise, any data your Activity has at that time can be completely lost.

To save Activity state, you can override the onSaveInstanceState() method. This method is passed a Bundle object as a parameter. A bundle can contain strings, primitive data types, or objects. In this method, simply add any important state data to the bundle. This bundle will be returned to the Activity later so you can restore the Activity state.

To extract the saved state from the bundle and restore it, implement the onRestoreInstanceState() method. This callback is invoked between the onStart() and the onResume() lifecycle methods.

We will look deeper into Activity instance state in a future article.

Conclusion

After following this post, you'll have a good understanding of how an Activity lifecycle works. And you've learned that there are two ways to start an Activity, as well as getting some pointers to how instance state is handled in the Activity lifecycle.

Thanks for reading, and while you're here, check out some of our other posts on coding Android apps.

  • Android
    Android From Scratch: An Overview of Android Application Development
    Ashraff Hathibelagal
  • Android SDK
    How to Monetize Your Android Apps With AdMob
    Chike Mgbemena
  • Kotlin
    Kotlin From Scratch: Variables, Basic Types, and Arrays
    Chike Mgbemena

by Chinedu Izuchukwu via Envato Tuts+ Code

5 Journalist Secrets for Creating Astonishingly Great Blog Content

80 million. That’s the number of blog entries posted last month on WordPress, alone. It’s a lot of competition for attention—the attention that you want your blog to get to draw website traffic, build an online reputation, or establish your expertise. So, how do you create the kind of blog...

[ This is a content summary only. Visit our website http://ift.tt/1b4YgHQ for full links, other content, and more! ]

by Web Desk via Digital Information World

Object-Oriented Programming With JavaScript