Wednesday, December 9, 2015

Introducing New Tools for Polymer Development

Last September, Google held the Polymer Summit 2015. During this conference, developers supplied a great deal of input about new things made possible by Polymer. Polymer 1.0 had been released earlier, which added to the anticipation that so many had for this year’s conference. Among the speakers of this years, there was Addy Osmani, a Google engineer known for his important contributions to several open source projects.

In his talk, he has introduced some new tools which have been released for Polymer development. These tools provide everything a developer may need to know about Polymer development, regardless of prior experiences. Many of the tools I’m going to describe need to be downloaded via npm, and can subsequently be used directly inside your computer’s command line.

Continue reading %Introducing New Tools for Polymer Development%


by Thomas Greco via SitePoint

Presentation Slideshow with CSS and jQuery

A tutorial about creating simple presentation template in CSS and jQuery.

Navigation can be with keyboard arrow keys or click or by scroll.


by via jQuery-Plugins.net RSS Feed

A Simple Case for Hybrid Mobile App Development

This article is part of a web development series from Microsoft. Thank you for supporting the partners who make SitePoint possible.

What is a Hybrid Mobile App?

A hybrid mobile app is similar to any app that you download from an App Store, but the fundamentals of how they work is different from native apps.

Like websites, hybrid mobile apps are built using web technologies like HTML, CSS, and JavaScript, so most of the JS libraries developers use over the web can be reused for hybrid apps too. The key difference is that hybrid apps are hosted inside a native application that utilizes a mobile platform’s WebView. This enables them to use device capabilities like the accelerometer, camera, and many other system APIs. These capabilities are often not accessible by a website running on mobile. The web is also more interoperable than ever—including modern browser engines like Microsoft Edge’s EdgeHTML—so if you've previously ruled out hybrid solutions, it’s a good time to reconsider a hosted web app solution (more on that below).

Where Do Hybrid Mobile Apps Come From?

Mobile and Desktop Users graphical representation

The above graph clearly communicates that the number of mobile users have clearly overtaken desktop users, which is resulting in businesses refocusing priorities to cater to mobile users. While businesses already had a presence on the web—in most cases a website—the easiest option for them to scale up to all mobile platforms is to consider the hybrid approach. It helps them to keep teams with similar skillsets without having to invest hugely in iOS, Android, or Windows Native developers in one go. It sounds like a cost effective strategy, so let’s dig deeper.

HTML5, CSS3 & ES6 in a Mobile App. Really?

In recent years the web has moved towards standards. We rarely find new web apps with metatags for compatibility with IE6. These HTML5, CSS3 and ES6 standards means the web is now cleaner, working across standard browsers without having to change code. In fact, you can scan your website for interoperability best practices here that also help development of cross-platform hybrid apps.

  • Looking at this, we can leverage the standards to ensure we end up using the same DOM even in hybrid mobile apps across all platforms. This approach helps us write clean code and helps easily maintain it. Check out the code for the native-looking header bar for iOS, Android and Windows Phone on JSFiddle.
  • With new HTML5 and CSS elements, we can take care of various screen resolutions that our hybrid apps will run on. In order to make your images look crisp for everyone, you usually have to deliver twice the dimensions than what is actually shown in your app. Serving properly sized images for all different resolutions is one of the most discussed topics in responsive web design. There are various approaches, each with its benefits and drawbacks related to bandwidth, code maintainability and browser support. Let’s quickly review the most popular ones:
  • CSS3 media query works out well for loading logos appropriately based on screen size the hybrid app gets rendered on:
    
    /* Normal-resolution CSS */
    .logo {
      width: 120px;
      background: url(logo.png) no-repeat 0 0;
    }
    
    /* HD and Retina CSS */
    @media only screen and (-webkit-min-device-pixel-ratio: 1.25),
    only screen and ( min--moz-device-pixel-ratio: 1.25),
    only screen and ( -o-min-device-pixel-ratio: 1.25/1),
    only screen and ( min-device-pixel-ratio: 1.25),
    only screen and ( min-resolution: 200dpi),
    only screen and ( min-resolution: 1.25dppx) {
      .logo {
        background: url(logo@2x.png) no-repeat 0 0;
        background-size: 120px; /* Equal to normal logo width */
      }
    }
    
    
  • Similarly, we can use platform specific fonts by querying device type.
    
    /* Windows Phone */
    font-family: 'Segoe UI', Segoe, Tahoma, Geneva, sans-serif;
    
    /* Android */
    font-family: 'RobotoRegular', 'Droid Sans', sans-serif;
    
    /* iOS */
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    
    
  • Single-page application (SPA) is a web application that fits on a single web page with the goal of providing a more fluid user experience akin to a desktop application. There are libraries which help web developers make more fluid web experiences:

Continue reading %A Simple Case for Hybrid Mobile App Development%


by Abhishek Narain via SitePoint

Decorating the Web with CSS Border Images

Not too long ago, adding decorative elements like fancy borders to a web page involved slicing images and patiently tweaking away at the CSS until it looked just right.

CSS has changed all this. A few lines of code are all you need to decorate your website with quite sophisticated borders. This article will show you how you can do so.

Border Image Properties

A common way of styling borders is by using preset border-style rules. These are: dotted, dashed, solid, double, groove, ridge, inset, and outset.

These styles already give you quite a bit of choice. But you can go a step further and add appealing background images to your borders with the following CSS properties.

The border-image-source Property

With this property you assign a background image to an element's border. The value is usually the image's URL:

[code language="css"]
element {
border-image-source: url('myimage.png');
}
[/code]

You'll find that a CSS gradient works just as well:

[code language="css"]
element {
border-image-source: linear-gradient(10deg, #fe01f5 0%, #2e113d 100%);
}
[/code]

In the browser it looks something like this:

Border image with a gradient instead of an image.

If you set this property to the value none, or the image can't be displayed, the browser will use the values set for the border-style property. Therefore, it's a good idea to use border-style as a fallback.

The image you use doesn't need to match the width and height of your border. The beauty of CSS border images is that a small image is all you need to decorate an element's border of any width and height, including elements that responsively adapt to varying screen sizes.

The border-image-slice Property

After you select an image using the border-image-source property, you apply it to the border using the border-image-slice property.

[code language="css"]
element {
border-image-slice: 19;
}
[/code]

Let's get into a bit more details. This property designs inner offsets from the top, right, bottom, and left sides. The offsets end up slicing your small image into nine areas: four corners, four edges and a middle.

The border image sliced up into nine areas: four corners, four edges and a middle area.

You can specify one to four numbers or percentage values. When you specify four values, they apply to the top, right, bottom and left offsets. If you skip the left offset, this will be the same as the right. If you miss the bottom offset, this will be the same as the top one. Omitting the value for the right offset will make this the same as the top. If you only use one value, it will be used for all four offsets.

Percentage values refer to percentages of the size of the image – the image width for horizontal offsets and the image height for vertical offsets.

Numbers stand for pixels in the image, or for coordinates in case of a vector image. One more thing, don't add px after the number, it won't work if you do!

Here's how you can use border-image-slice:

[code language="html"]
<div class="box">
Border Image
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</div>
[/code]

[code language="css"]
.box {
border: 19px dotted #c905c6;
border-image-source: url(border-bg.png);
border-image-slice: 19;
}
[/code]

Using a 100 x 100px image for your border that looks like this:

The original border background image

We end up with something looking like this:

Simple example of border image with border-image-slice.

The middle region renders as fully transparent, therefore it's not visible. If you'd like to make it visible, add the fill keyword.

For instance, using an image with a fully opaque middle area, without adding the fill keyword, will display exactly like the example above. However, apply the fill keyword like so:

[code language="css"]
.box {
border: 19px dotted #c905c6;
border-image-source: url(border-fill.png);
border-image-slice: 19 fill;
}
[/code]

With an image with a middle area containing details:

The original border filled background image

We then will find the image's middle area is fully visible on the page, albeit somewhat blurred and squashed:

Border image with fill applied.

The border-image-width Property

This property is drawn inside what's called the border-image-area. By default, the boundaries of this area are those of the border box. Just like the border-image-slice property, the border-image-width designs inner offsets which divide the image into nine areas.

Continue reading %Decorating the Web with CSS Border Images%


by Maria Antonietta Perna via SitePoint

Access Hulu, Netflix, and More Anywhere in the World

Traveling outside of the country usually means a break from your favorite shows, thanks to geo-restrictions that block streaming services like Netflix and Hulu. Unless you have Getflix. Get lifetime access for just $39 at SitePoint Shop. Netflix is the fastest, simplest way to bypass geo-restrictions—instead of resorting all of your traffic through a different […]

Continue reading %Access Hulu, Netflix, and More Anywhere in the World%


by SitePoint Offers via SitePoint

What’s New in WordPress 4.4

WordPress 4.4 has just landed, named ‘Clifford’ in honor of the jazz trumpeter Clifford Brown. We’ve covered previous releases and there’s always something that excites me, but nothing comes close to this release. This is due to native responsive image support, WordPress now becoming an oEmbed provider and the introduction of the first half of […]

Continue reading %What’s New in WordPress 4.4%


by Chris Burgess via SitePoint

iOS From Scratch With Swift: Swift in a Nutshell