Overview
The components on a screen have properties for applying styles which affect their look and feel. For example, you can add a background colour or set how a button reacts when the mouse passes over it. Styles can be applied using a shared style which is reusable and provides a consistent look and feel across your application, or a style can be applied to a single component as a one-off object-level style.
Style Ordering
PhixFlow applies styles using the principle of cascading style sheets (CSS). PhixFlow applies styles in order, starting with 1. Shared Styles and ending with 5. Positioning Settings. A component can have styles from one, some or all of the following:
Where two or more styles are applied to the same aspect of a component, the later settings overrides the earlier settings:
For example, the style for a button border is set to:
- 10px and black in a shared style
- 2px and red in the component's style settings,
the button will have a 2 pixel, red border set.
Shared Style
Shared styles are the recommended approach a they give an application a consistent look and feel. Rarely is a style used only once!
In chapter 12. Screen Design Fundamentals of this course we set the same style in multiple places, a minWidth for our tiles. Applying the same style in multiple locations is a nightmare to maintain and inevitably leads to inconsistency in the application layout. Lets go back into our Invoicing Screen and remove replace these style with a single shared style.
- Open the invoicing Screen and ensure it is unlocked.
- Open the properties for Tile 2 and pin this tab.
- Click the Styles tab.
- In the Shared Style section click Error rendering macro 'excerpt-include' : No link could be created for '_styles'..
- In the repository window that opens, under My Application → Styles, click .
- Drag the New Style window next to the Tile 2 properties.
- Set the Name to,
My Minimum Width
- Click Apply to allow us to set the styles.
- We can set styles here manually, however if you have built up a style and want to make it a shared style we can simply copy the CSS Properties as follows:
- With both properties windows visible from Tile 2 drag the CSS Property minWidth to the CSS Properties of the new Shared Style.
- Remove the minWidth CSS Property from Tile 2.
- Add the new shared style to the Shared Styles of Tile 2. This can be done one of the following ways:
- Drag the Error rendering macro 'excerpt-include' : No link could be created for '_styles'.icon from the open shared style into the Shared Style on Tile 2.
- In Share Styles on Tile 2, click the Error rendering macro 'excerpt-include' : No link could be created for '_styles'.icon and then drag the My Minimum Width into Shared Styles.
- Drag the
- Save all your changes.
- Remove minWidth from the CSS Properties on Tile 3 and add the new shared style.
This means we can now amend the minWidth set in our shared style and it will be applied anywhere the style is used
Updating Shared Styles
In the example above we created the shared style and know where it is applied, this means we can edit it to suit our requirements. However when updating shared styles be careful as another screen, component or application could be using it and therefore will be impacted by your change.
When setting up your base style, for example if you have just installed PhixFlow and want to update the Serene Grey style with your own design, updating the shared styles should be no issue. However once your system is established, we recommend overriding styles with a new style rather than changing them.
Remember styles are applied in the order they appear, so if you have two Shared Styles the second style will take precedence over the first.
Updating the Serene Grey shared Style will impact all applications using this template package.
While we recommend proceeding with caution, you can update the serene grey template package to suit your needs. This is most easily achieved when the system is new. Alternatively you can create a copy of the Serene Grey Template Package and work with that. See Copying Configuration. We will cover Template Package setup in /wiki/spaces/HELP100/pages/9106729632.
Formatting Rules
Formatting Rules require an expression for the condition logic, which must resolve to true for the shared style to be applied; see Expressions and PhixScripts. Earlier in this course we set industry icons in a grid based on the value of the Industry column's value, for example if industry column is Manufacturing use the manufacturing icon style.
For details on formatting rules see Formatting Rule
Useful Syntax
dummy
Variable | Description | Example Use |
---|---|---|
Acts on the record | Provides access the the data currently displayed on the form. e.g. _form.MyAttribute | To gain access to data held in form fields. |
Acts on the record(s) | References the record currently selected on a grid. e.g. _grid.MyColumn | Can be used in to get details of the currently selected record in a grid. Can be used in an expression external to a grid. |
Acts on the record(s) | use _current in expressions for the CSS Properties of grid rows or cards. e.g. _current.AnyColumn | Can be used to access data in the currently selected record in a grid. This is where we want to appply formatting rules within a grid. For example, colour a row red if the _current.status == "Rejected". |
Acts on the record | The currently selected item, i.e. The selected record or card. e.g. _selected.AnyField | This is useful for styling a card component or row in a grid |
The value held in the form field. | The value held in the form field. e.g. if _field.value > 100 | n/a |
dummy