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.
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:
classes. These two properties correspond to an HTML element’s
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.
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 ...