O'Reilly logo

Enyo: Up and Running, 2nd Edition by Roy Sutton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 6. Fit and Finish

In the preceding chapters we laid down the foundations you need to create Enyo apps. In this chapter, we’ll explore some of the pieces necessary to make those apps more memorable. We’ll cover how to style your apps, how to tune them to perform well on less powerful platforms, how to prepare them for translation to other languages, and how to troubleshoot bugs that inevitably arise. As always, we’ll explore these concepts through interactive samples.

Styling

Enyo provides some very nice looking controls with the Onyx and Moonstone libraries. However, an app can set itself apart from others by having a unique user interface. Fortunately, it’s very easy to change the look of controls. We’ll explore several ways to accomplish that.

Styles and Classes

All Enyo controls have two properties to aid in styling: style and classes. These two properties correspond to an HTML element’s style and class attributes. The style property can be used to apply a specific style to a single control. To work with the classes property, you must add CSS classes to a style sheet. In general, it is better to use classes in an app for two reasons: first, components are more reusable if styling is not embedded within them; second, using CSS classes allows you to keep the styling in a single, centralized location.

Enyo provides applyStyle() to update an individual style and addStyles() to add styles onto the existing styles of a control. We used the applyStyle() function in the traffic light ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required