Skip to content

Commit 37e978b

Browse files
Merge pull request #1 from DriveWorks/develop
Initial release (1.0.0)
2 parents b68f4d2 + 21c4241 commit 37e978b

File tree

13 files changed

+446
-22
lines changed

13 files changed

+446
-22
lines changed

LICENSE

Lines changed: 0 additions & 21 deletions
This file was deleted.

LICENSE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright (C) 2021 DriveWorks Ltd
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this example and associated documentation files (the "Example"), to deal in the Example without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Example, and to permit persons to whom the Example is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Example.
6+
7+
THE EXAMPLE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE EXAMPLE OR THE USE OR OTHER DEALINGS IN THE EXAMPLE.

README.md

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,90 @@
1-
# IntegrationThemeExample-StylingWithCSS
1+
# Integration Theme Example: Styling with CSS
2+
### Version: 1.0.0
3+
#### Minimum DriveWorks Version: 18.0
4+
5+
A distributable example that demonstrates how to style DriveWorks controls using CSS.
6+
7+
Please note: DriveWorks are not accepting pull requests for this example.
8+
Join our [online community](https://my.driveworks.co.uk) for discussion, resources and to suggest other examples.
9+
10+
### This example:
11+
- Demonstrates using basic metadata & CSS selectors, and further advanced styling that CSS enables.
12+
- Provides 2 DriveWorks Packages (.drivepkg), each containing an example Project that demonstrate use of the Metadata property and styling various properties.
13+
- **BasicStyles18.drivepkg** - Demonstrates using metadata & basic CSS selectors to target DriveWorks controls (see also: /basic-styles/style.css)
14+
- **AdvancedStyles18.drivepkg** - Demonstrates some possibilities for advanced styling made available via CSS (see also: /advanced-styles/advanced-styles.css)
15+
16+
The CSS selectors/styles demonstrated can be viewed without installing the provided Projects, for quick reference. Simply open the included `.css` files.
17+
18+
### /basic-styles
19+
20+
![Basic Example](/images/basic.png)
21+
22+
- Creates a new Specification
23+
- Loads in a custom stylesheet (/basic-styles/style.css)
24+
- Styles a single button control - using the Project 'BasicStyles18'
25+
- Demonstrates:
26+
- Targeting controls with the `Metadata` property (data-metadata)
27+
- Using CSS Attribute Selectors
28+
- Rounded Corners (border-radius)
29+
- Shadows (box-shadow)
30+
- Animating styles (transition)
31+
- Rotate and Scale (transform)
32+
- Gradients (linear-gradient)
33+
- Hover styles (:hover)
34+
- Styling child elements
35+
36+
### /advanced-styles
37+
38+
![Advanced Example](/images/advanced.png)
39+
40+
- Creates a new Specification
41+
- Loads in an alternate custom stylesheet (/advanced-styles/advanced-styles.css)
42+
- Styles multiple controls - using the Project 'AdvancedStyles18'
43+
- Demonstrates:
44+
- Various button styles
45+
- CSS Transforms (rotate/scale/skew)
46+
- CSS Filters (blur, grayscale)
47+
- Animating position changes
48+
49+
### To use:
50+
1. Clone this repository, or download as a .zip
51+
52+
2. Extract each of the supplied .drivepkg files using the DriveWorks Package Wizard to access the included Project files.
53+
54+
3. Open the extracted Groups in DriveWorks Administrator and use 'Form Design' to view each Controls and its properties.
55+
* Most importantly: the 'Metadata' properties that are targeted via CSS.
56+
57+
4. In `DriveWorksLiveConfigUser.xml`, add a new Group Alias for the each new Group containing the example Projects.
58+
* See [Integration Theme Settings](https://docs.driveworkspro.com/Topic/IntegrationThemeSettings) for additional guidance.
59+
60+
5. Open the extracted Groups in DriveWorks Live and start the Integration Theme.
61+
* See [Selecting the Integration Theme](https://docs.driveworkspro.com/Topic/IntegrationThemeSelect) for additional guidance.
62+
63+
6. Enter your Integration Theme details into `config.js` for each example.
64+
* `serverUrl` - The URL that hosts your Integration Theme, including any ports.
65+
* `groupAlias` - The public alias created for the Group containing the DriveApps to render - as configured in DriveWorksConfigUser.xml.
66+
* This *must* be specified for each Group you wish to use.
67+
* This allows you to mask the true Group name publicly, if desired.
68+
* See [Integration Theme Settings](https://docs.driveworkspro.com/Topic/IntegrationThemeSettings) for additional guidance.
69+
* `projectName` - The name of the Project to render a Specification from.
70+
* These are pre-filled with supplied Project names, but can be changed if required.
71+
72+
7. Open the example HTML files locally (localhost) or on a remote server.
73+
* Ensure `<corsOrigins>` in DriveWorksConfigUser.xml permits request from this location.
74+
See [Integration Theme Settings](https://docs.driveworkspro.com/Topic/IntegrationThemeSettings) for additional guidance.
75+
76+
8. If encountering any issues, check the browser's console for error messages (F12)
77+
78+
### Potential Issues:
79+
* 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.
80+
* This appears as "Error: 401 Unauthorized" in the browser console, even with the correct configuration set.
81+
* To resolve:
82+
* Ensure you are running DriveWorks 18.2 or above, HTTPS is enabled in DriveWorks Live's settings and a valid SSL certificate has been configured via DriveWorksConfigUser.xml.
83+
* See [Integration Theme Settings](https://docs.driveworkspro.com/Topic/IntegrationThemeSettings) for additional guidance.
84+
85+
---
86+
87+
This source code has been made available to demonstrate how you can integrate with DriveWorks using the DriveWorks Live API.
88+
This code is provided under the MIT license, for more details see LICENSE.md.
89+
90+
The example requires that you have the latest DriveWorks Live SDK installed, operational and remotely accessible.
49.7 KB
Binary file not shown.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
3+
Example Styles
4+
--------------
5+
6+
This example demonstrates further styling opportunities when using the "Metadata" property in DriveWorks.
7+
These styles can be combined, tweaked and removed - this aims only to provide inspiration.
8+
9+
IMPORTANT NOTE: CSS styles should be seen as a 'progressive enhancement'.
10+
Your Forms should function fully without these additional styles, as they may not be loaded in all environments the Integration is accessed.
11+
12+
For more detailed information on these selectors, see: https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors
13+
14+
## Note: the use of !important allows the default inline styles to be overwritten (style="...") - and should be used carefully.
15+
For more information, see: https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity#The_!important_exception
16+
17+
*/
18+
19+
/* Set re-usable colours - update in one central location, apply to many rules */
20+
:root {
21+
--color-brand-primary: #4299e1;
22+
--color-brand-secondary: #48bb78;
23+
}
24+
25+
/* Global button default style */
26+
[data-metadata*="button"] button {
27+
background: none !important; /* ## See note above when using !important */
28+
border: none !important;
29+
cursor: pointer !important;
30+
}
31+
32+
/* Background color */
33+
[data-metadata*="button"] {
34+
background-color: var(--color-brand-primary);
35+
}
36+
37+
/* Text color */
38+
[data-metadata*="button"] [data-id*="CaptionElement"] {
39+
color: #fff !important;
40+
}
41+
42+
/* Rounded Button */
43+
[data-metadata*="rounded"] {
44+
border-radius: 5px;
45+
}
46+
47+
/* 'Pill' Button */
48+
[data-metadata*="pill"] {
49+
border-radius: 100em;
50+
}
51+
52+
/* Inactive Button */
53+
[data-metadata*="inactive"] {
54+
opacity: 50% !important;
55+
}
56+
[data-metadata*="inactive"] button {
57+
cursor: not-allowed !important;
58+
}
59+
60+
/* Change color on hover, with ease */
61+
[data-metadata*="hover-green"]:hover {
62+
background-color: var(--color-brand-secondary);
63+
}
64+
65+
/* Lighten on hover */
66+
[data-metadata*="hover-light"]:hover {
67+
filter: brightness(115%);
68+
}
69+
70+
/* Darken on hover */
71+
[data-metadata*="hover-dark"]:hover {
72+
filter: brightness(85%);
73+
}
74+
75+
/* Circle */
76+
[data-metadata*="circle"] {
77+
border-radius: 50%;
78+
}
79+
80+
/* Border Styles */
81+
[data-metadata*="border-dashed"] {
82+
border: 1px dashed #aaa !important;
83+
}
84+
85+
/* Drop Shadow */
86+
[data-metadata*="shadow"] {
87+
box-shadow: 0 2px 10px rgba(0,0,0,.5);
88+
}
89+
90+
/* Background Gradient */
91+
[data-metadata*="gradient"] {
92+
background: linear-gradient(45deg, #833ab4 0%, #4299e1 100%);
93+
}
94+
95+
/* Custom Shape (clip-path) */
96+
[data-metadata*="shaped"] {
97+
clip-path: polygon(5% 0, 100% 0%, 95% 100%, 0% 100%);
98+
}
99+
100+
/* Blur */
101+
[data-metadata*="blur"] {
102+
filter: blur(3px);
103+
}
104+
105+
/* Rotate */
106+
[data-metadata*="rotate"] {
107+
transform: rotate(10deg);
108+
}
109+
110+
/* Scale */
111+
[data-metadata~="scale"] {
112+
transform: scale(0.5);
113+
}
114+
115+
/* Skew */
116+
[data-metadata*="skew"] {
117+
transform: skewX(-15deg);
118+
}
119+
120+
/* Grayscale */
121+
[data-metadata*="grayscale"] {
122+
filter: grayscale(1);
123+
}
124+
125+
/* Animate background color */
126+
[data-metadata*="animate-background"] {
127+
transition: background-color .5s ease;
128+
}
129+
130+
/* Animate position */
131+
[data-metadata*="animate-position"] {
132+
transition: left .5s ease;
133+
}

advanced-styles/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Config
2+
const config = {
3+
serverUrl: "",
4+
groupAlias: "",
5+
projectName: "AdvancedStyles18",
6+
};

advanced-styles/index.html

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Advanced Styling with CSS | DriveWorks</title>
8+
9+
<!-- Comment/remove the line below to view the Form in it's original state -->
10+
<link rel="stylesheet" href="advanced-styles.css" />
11+
</head>
12+
13+
<body>
14+
15+
<div id="form-output">
16+
Advanced styles example loading...
17+
</div>
18+
19+
<script src="config.js"></script>
20+
<script>
21+
const output = document.getElementById("form-output");
22+
23+
// Run on client load
24+
async function dwClientLoaded() {
25+
try {
26+
27+
// Create DriveWorks API client
28+
const DW_CLIENT = new window.DriveWorksLiveClient(config.serverUrl);
29+
30+
// Login to group
31+
await DW_CLIENT.loginGroup(config.groupAlias);
32+
33+
// Create Specification
34+
const specification = await DW_CLIENT.createSpecification(config.groupAlias, config.projectName);
35+
36+
// Render Specification
37+
output.innerHTML = "";
38+
await specification.render(output);
39+
40+
} catch (error) {
41+
console.log(error);
42+
output.innerHTML = error;
43+
}
44+
}
45+
</script>
46+
47+
<!-- Option A) Directly load Client Library -->
48+
<!-- <script src="https://YOUR-THEME-SERVER.COM/DriveworksLiveIntegrationClient.min.js" onload="dwClientLoaded()"></script> -->
49+
50+
<!-- Option B) Inject Client Library dynamically from server url in config file -->
51+
<script>
52+
(function(doc, script) {
53+
script = doc.createElement("script");
54+
script.src = config.serverUrl + "/DriveWorksLiveIntegrationClient.min.js";
55+
script.onload = () => dwClientLoaded(); // Custom local function run when client has loaded
56+
doc.body.appendChild(script);
57+
}(document));
58+
</script>
59+
60+
</body>
61+
</html>
19.6 KB
Binary file not shown.

basic-styles/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Config
2+
const config = {
3+
serverUrl: "",
4+
groupAlias: "",
5+
projectName: "BasicStyles18",
6+
};

basic-styles/index.html

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Basic Styling with CSS | DriveWorks</title>
8+
9+
<!-- Comment/remove the line below to view the Form in it's original state -->
10+
<link rel="stylesheet" href="style.css" />
11+
</head>
12+
13+
<body>
14+
15+
<div id="form-output">
16+
Basic styles example loading...
17+
</div>
18+
19+
<script src="config.js"></script>
20+
<script>
21+
const output = document.getElementById("form-output");
22+
23+
// Run on client load
24+
async function dwClientLoaded() {
25+
try {
26+
// Create DriveWorks API client
27+
const DW_CLIENT = new window.DriveWorksLiveClient(config.serverUrl);
28+
29+
// Login to group
30+
await DW_CLIENT.loginGroup(config.groupAlias);
31+
32+
// Create Specification
33+
const specification = await DW_CLIENT.createSpecification(config.groupAlias, config.projectName);
34+
35+
// Render Specification
36+
output.innerHTML = "";
37+
await specification.render(output);
38+
} catch (error) {
39+
console.log(error);
40+
output.innerHTML = error;
41+
}
42+
}
43+
</script>
44+
45+
<!-- Option A) Directly load Client Library -->
46+
<!-- <script src="https://YOUR-THEME-SERVER.COM/DriveworksLiveIntegrationClient.min.js" onload="dwClientLoaded()"></script> -->
47+
48+
<!-- Option B) Inject Client Library dynamically from server url in config file -->
49+
<script>
50+
(function(doc, script) {
51+
script = doc.createElement("script");
52+
script.src = config.serverUrl + "/DriveWorksLiveIntegrationClient.min.js";
53+
script.onload = () => dwClientLoaded(); // Custom local function run when client has loaded
54+
doc.body.appendChild(script);
55+
}(document));
56+
</script>
57+
58+
</body>
59+
</html>

0 commit comments

Comments
 (0)