O'Reilly logo

Enyo: Up and Running 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 5. 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 diagnose things when bugs occur. As always, we’ll explore these concepts through interactive samples.

Styling

Enyo provides some very nice looking controls with the Onyx library. 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 the Onyx widget set. We’ll explore several ways to accomplish that.

Styles and Classes

All Enyo controls have two published 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: a component is more reusable if a style is not embedded within it and by using a CSS class you can modify the style from a single place.

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 sample at the start of the book. ...

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