For styling via CSS in DriveWorks 20.3 and below, see: Integration Theme Example - Styling with External CSS
A distributable example that demonstrates how to style DriveWorks Controls using CSS via ProjectStyles.css
.
ProjectStyles.css
is the optional custom stylesheet automatically loaded in DriveWorks desktop applications and Live when placed next to a .driveprojx
file.
Please note: DriveWorks are not accepting pull requests for this example.
Join our online community for discussion, resources and to suggest other examples.
- Provides a DriveWorks Package (
.drivepkg
) containing an example Project that demonstrates usingProjectStyles.css
and the "Metadata" Property. - Demonstrates:
- Using
ProjectStyles.css
to apply additional styling in Desktop and Live Forms. - Using CSS Attribute Selectors
- Targeting Controls with the "Metadata" property (
data-metadata
) - Using the
::part()
Selector - State-based styles (
:hover
,:focus
,:active
) - Rounded Corners (
border-radius
) - Shadows (
box-shadow
) - Animating styles (
transition
) - CSS Transforms (
rotate
,scale
,skew
) - CSS Filters (
blur
,grayscale
) - Gradients (
linear-gradient
)
- Using
The CSS selectors/styles demonstrated can be viewed without extracting the provided Project, for quick reference.
Simply open the included ProjectStyles.css
file.
-
Clone this repository, or download as a
.zip
. -
Extract the supplied
.drivepkg
file using the DriveWorks Content Installer to access the included Project file.- Ensure the included
ProjectStyles.css
file remains alongside the included.driveprojx
Project file.
- Ensure the included
-
Open the extracted Group in DriveWorks Administrator and use 'Form Design' to view each Controls and its Properties.
- Most importantly: the "Metadata" properties that are targeted via CSS.
-
In
DriveWorksLiveConfigUser.xml
, add a new Group Alias for the Group containing the example Project.- See Integration Theme Settings for additional guidance.
-
Open the extracted Group in DriveWorks Live and start the Integration Theme.
- See Selecting the Integration Theme for additional guidance.
-
Enter your Integration Theme details into
config.js
for the example.serverUrl
- The URL that hosts your Integration Theme, including any ports.groupAlias
- The public alias created for the Group containing the DriveApps to render - as configured inDriveWorksConfigUser.xml
.- This must be specified for each Group you wish to use.
- This allows you to mask the true Group name publicly, if desired.
- See Integration Theme Settings for additional guidance.
projectName
- The name of the Project to render a Specification from.- These are pre-filled with supplied Project's name, but can be changed if required.
-
Ensure that the Integration Theme server is running, using any of the available methods (e.g. Personal Web Edition, DriveWorks Live, IIS)
- For more information, see Selecting the Integration Theme.
-
Open the example HTML files locally (localhost) or on a remote server.
- Ensure
<corsOrigins>
inDriveWorksConfigUser.xml
permits request from this location. See Integration Theme Settings for additional guidance.
- Ensure
-
If encountering any issues, check the browser's console for error messages (F12)
- When serving this example for a domain different to your DriveWorks Live server, e.g. api.my-site.com from company.com, 'SameSite' cookie warnings may be thrown when the Client SDK attempts to store the current session id.
- This appears as "Error: 401 Unauthorized" in the browser console, even with the correct configuration set.
- To resolve:
- Ensure you are running a DriveWorks version compatible with this example (21.0 or above), HTTPS is enabled in DriveWorks Live's settings and a valid SSL certificate has been configured via
DriveWorksConfigUser.xml
. - See Integration Theme Settings for additional guidance.
- Ensure you are running a DriveWorks version compatible with this example (21.0 or above), HTTPS is enabled in DriveWorks Live's settings and a valid SSL certificate has been configured via
- If serving your site over HTTPS, you may encounter issues with the
ProjectStyles.css
hashed resource URL not loading as it is blocked by the browser.- This appears as "Error: Mixed Content" in the browser console.
- To resolve:
- Try setting
httpsForceSslOnResources
toTrue
inDriveWorksConfigUser.xml
. - See Integration Theme Settings - httpsForceSslOnResources for additional guidance.
- Try setting
This source code has been made available to demonstrate how you can integrate with DriveWorks using the DriveWorks Live API. This code is provided under the MIT license. For more details, see the included LICENSE file.
The example requires that you have the latest DriveWorks Live SDK installed, operational and remotely accessible.