Styling Component PartsProblem DescriptionHow do you style skin parts independently from styling the overall component? For example, making the Panel title "bold" while the rest of the text in the Panel is "normal". See these bugs for more background: Decisionpending... Decision Criteria
Proposed Solution(s):1. Hard-coded into skin definitionsThis is the current approach used by the Gumbo components. The majority of styles are defined once, on the global selector. If a skin part requires a different style, it is hard-coded into the skin. Example: global {
font-weight: normal; /* global font weight */
}
FxPanelSkin.mxml
<Skin>
...
<!-- Panel title is bold. -->
<TextBox id="titleField" fontWeight="bold" />
....
</Skin>
Pros:
Cons:
2. Use Advanced CSSUse the new advanced CSS features added to Flex 4 for specifying styles. For example, the Panel titleField is made bold with the following selector: Example: Panel #titleField {
font-weight: bold;
}
Pros:
Cons:
3. Expose selectors for skin partsThis is the solution used for most Halo components. Example: FxPanel {
titleFieldStyleName: panelTitleField;
}
.titleFieldStyleName {
font-weight: bold;
}
Pros:
Cons:
4. Create new types for specific skin partsThis is the solution used by some Halo components like FormItem/FormItemLabel. Example: PanelTitleTextBox {
font-weight: bold;
}
Pros:
Cons:
Recommended Solution:Solution #1, for the following reasons:
A 3rd party developer could easily create a theme that uses advanced CSS (ie proposal #2), if desired.
|
|
