Skip to content

Commit ceb2124

Browse files
authored
Merge pull request #475 from d45/d45_docs_workbookFormat
TFSID:1369666 - workbook formatting
2 parents e2740b9 + 511ce5c commit ceb2124

File tree

8 files changed

+117
-14
lines changed

8 files changed

+117
-14
lines changed

_includes/docs_menu.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
<li>
3939
<a href="{{ site.baseurl }}/docs/trex_tableau_viz.html">Add a Tableau Viz to an Extension</a>
4040
</li>
41+
<li>
42+
<a href="{{ site.baseurl }}/docs/trex_format.html">Add Tableau Workbook Formatting</a>
43+
</li>
4144
<li>
4245
<a href="{{ site.baseurl }}/docs/trex_show_hide.html">Show and Hide Objects in the Dashboard</a>
4346
</li>

docs/Interaction_Guidelines/ux_build_test.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The first thing to do is start running sample extension code from the Extensions
1717

1818
Once you're ready to go, you can start building and customizing your extension. Expect to iterate through cycles of developing and designing your extension using our API documentation and these design guidelines.
1919

20-
#### Get started with these resources:
20+
### Get started with these resources
2121

2222
* [Extensions API Documentation](https://tableau.github.io/extensions-api/)<br>The Extensions API includes all the information you need to build an extension.
2323

@@ -30,6 +30,7 @@ Once you're ready to go, you can start building and customizing your extension.
3030
&nbsp;
3131

3232
## Test
33+
3334
Ensure that your extension works properly for different test cases. Try it on your own dashboards, test it with others, and uncover possible edge cases.
3435

3536
Consider that dashboard extensions can be both **configured** and **viewed** in Tableau. These terms refer to two usage modes we recommend for extensions. To read about these modes and their audiences, learn more at **[Extension Components and Modes]({{ site.baseurl }}/docs/Interaction_Guidelines/ux_components_modes.html)**.
@@ -38,24 +39,22 @@ Consider that dashboard extensions can be both **configured** and **viewed** in
3839
&nbsp;
3940

4041
## Share
42+
4143
After you've completed making your extension, you may want to share your extension for others to use. Here are some places you might think about sharing your extension.
4244

4345

44-
##### Extension Gallery
45-
Tableau has released the [Extension Gallery](https://extensiongallery.tableau.com/), a place to explore and download some extensions that our partners have created. If you would like to share your extension to our gallery, learn more at [Sharing to the Extension Gallery]({{site.baseurl}}/docs/ux_extension_gallery.html).
46+
#### Tableau Exchange
47+
48+
Tableau has created the [Tableau Exchange](https://exchange.tableau.com/), a place to explore and download some extensions that our partners have created. If you would like to share your extension on the Tableau Exchange, see [Submitting your Extension to the Tableau Exchange]({{site.baseurl}}/docs/ux_extension_gallery.html).
49+
50+
#### Community Forums
4651

47-
##### Community Forums
4852
Tableau also has a [Community Forum](https://community.tableau.com/s/topic/0TO4T000000QFALWA4/extensions-api) for developers to discuss extensions and the Extensions API.
4953

5054
----- &nbsp;
5155

5256
While you might not choose to share your extension directly with Tableau, we encourage you to share your extension through other platforms of your choice! Use it internally at your company or for yourself, consider open source platforms, share over social media channels. How you go about sharing your extension with the world is entirely up to you.
5357

54-
&nbsp;
55-
56-
&nbsp;
57-
58-
---
5958
<!--
6059
### <div id="expand-box"><div id="expand-box-header">[<span style="float: right;">2 – Extension Components and Modes &#8594;</span>](2 - Extension Components and Modes.md)</div></div>
6160

docs/Style_Guidelines/ux_fonts.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ layout: guide
55

66
Fonts and typography are essential to how we communicate with our users. When text is used effectively, it grabs attention, evokes emotion, and emphasizes tone and voice.
77

8+
> **Note:** Starting with the Dashboard Extensions API v1.7 library, and supported with Tableau 2021.4 or later, you can apply workbook formatting on the HTML elements in your extension. For more information, see [Add Tableau Workbook Formatting]({{site.baseurl}}/docs/trex_format.html).
9+
810
&nbsp;
911

1012
**In this section**

docs/trex_events.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,4 @@ In most cases, you can create an event listener by chaining the methods to the s
4444
// ...
4545
```
4646

47-
For more information, check out the sample extension, Filtering.
48-
47+
For more information, check out the sample extension, [Filtering](https://github.com/tableau/extensions-api/tree/main/Samples/Filtering).

docs/trex_format.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
title: Add Tableau Workbook Formatting
3+
layout: docs
4+
---
5+
6+
To help your dashboard extension match the look and feel of the dashboard in which it is placed, you can apply the formatting styles used in the workbook to the HTML elements in your extension. When the formatting changes in the workbook, the corresponding styles are updated in your extension.
7+
8+
**In this section:**
9+
10+
* TOC
11+
{:toc}
12+
13+
----
14+
15+
16+
## Apply Tableau classes to HTML elements
17+
18+
Starting with the Dashboard Extensions API v1.7 library, and supported with Tableau 2021.4 or later, you can apply workbook formatting styles by specifying the class on the HTML elements in your extension. The specific Tableau classes to use are defined in the [`ClassNameKey`]({{site.baseurl}}/docs/enums/tableau.classnamekey.html){:target="_blank"} enum.
19+
20+
| HTML style (string literal) | ClassNameKey enum|
21+
| :------------ | :---------- |
22+
| `tableau-dashboard-title` | `tableau.ClassNameKey.DashboardTitle` |
23+
| `tableau-story-title` | `tableau.ClassNameKey.StoryTitle` |
24+
| `tableau-tooltip` | `tableau.ClassNameKey.Tooltip` |
25+
| `tableau-worksheet` | `tableau.ClassNameKey.Worksheet` |
26+
| `tableau-worksheet-title` | `tableau.ClassNameKey.WorksheetTitle` |
27+
28+
29+
### As an HTML class
30+
31+
To apply the formatting in the body of your HTML page to HTML elements, use the string literal `tableau-*` for the `ClassNameKey` enum. For example, to apply the worksheet title formatting you set the `class` for the HTML element in your extension (`h1`, `h2`, etc.) to `"tableau-worksheet-title"`.
32+
33+
```html
34+
<h2 class="tableau-worksheet-title">Subheader, using tableau-worksheet-title class</h2>
35+
36+
```
37+
38+
### In JavaScript code
39+
40+
To reference the workbook formatting in your JavaScript code, use the enum directly. For example, to add the formatting used in the worksheet title, you could use the JQuery method (`.addClass`) to add the `tableau.ClassNameKey.WorksheetTitle` to an element on your page. The following example applies the formatting to a heading with the id `someTitle`.
41+
42+
```javascript
43+
44+
$('#someTitle').addClass(tableau.ClassNameKey.WorksheetTitle);
45+
46+
```
47+
48+
You could also create a JavaScript function that has `ClassNameKey` as an parameter, and use that function to process and apply the formatting in some way.
49+
50+
```javascript
51+
52+
myFormattingFunction(tableau.ClassNameKey.WorksheetTitle);
53+
54+
// does something with the worksheet title
55+
56+
```
57+
58+
## Access information about the formatting styles in the workbook
59+
60+
You can access the formatting used in a Tableau workbook from the `tableau.extensions.environment.workbookFormatting` property. The `workbookFormatting` property, `formattingSheets` contains an array of CSS properties for the workbook, organized by `ClassNameKey`. For example, if you wanted to view the formatting styles available using the Chrome DevTools, you could add the following JavaScript code and then view the results in the Console window by navigating the array.
61+
62+
```javascript
63+
64+
if (tableau.extensions.environment.workbookFormatting) {
65+
console.log(tableau.extensions.environment.workbookFormatting.formattingSheets);
66+
};
67+
68+
```
69+
70+
Or to just print out the formatting information in the Console window you could do something like the following:
71+
72+
```javascript
73+
74+
let formattingSheets = tableau.extensions.environment.workbookFormatting.formattingSheets;
75+
formattingSheets.forEach(function (formattingSheet) {
76+
console.log("The formatting sheet is " + formattingSheet.classNameKey + " " + JSON.stringify(formattingSheet.cssProperties));
77+
});
78+
79+
```
80+
81+
## Set an event listener on workbook format changes
82+
83+
You can set an event listener on changes to the formatting in the workbook. The new event type is `WorkbookFormattingChanged`. The `WorkbookFormattingChanged` event is triggered whenever the workbook formatting is changed in Tableau authoring mode. This includes changes in the font, the font size, whether it is bold, italic, or underlined, and changes in color.
84+
85+
```javascript
86+
87+
dashboard.addEventListener(tableau.TableauEventType.WorkbookFormattingChanged, (event) => {
88+
console.log(event.formatting);
89+
// take some other actions based on the change
90+
});
91+
92+
```
93+
94+
For more information about using event listeners, see [Events and Event Handling]({{site.baseurl}}/docs/trex_events.html).
95+
96+
## What's Next
97+
98+
* To see a working sample dashboard extension that uses workbook formatting, see the JavaScript [Formatting](https://github.com/tableau/extensions-api/tree/main/Samples/Formatting){:target="_blank"} sample in the Samples folder, or the TypeScript [Formatting](https://github.com/tableau/extensions-api/tree/main/Samples-Typescript/Formatting){:target="_blank"} sample in the Samples-Typescript folder.
99+
100+
* For information about accessing the formatting styles in a workbook, see [workbookFormatting]({{site.baseurl}}/docs/interfaces/environment.html#workbookformatting){:target="_blank"} in the API reference documentation.

docs/trex_release-notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ About this release:
9292
</script>
9393
```
9494

95-
You can access the formatting in the Tableau workbook from `tableau.extensions.environment.workbookFormatting`. The property `formattingSheets` contains the array of CSS properties for the workbook, organized by `ClassNameKey`. For more information about using workbook formatting, see the [Formatting](https://github.com/tableau/extensions-api/tree/main/Samples/Formatting){:target="_blank"} sample in the Samples folder.
95+
You can access the formatting in the Tableau workbook from `tableau.extensions.environment.workbookFormatting`. The property `formattingSheets` contains the array of CSS properties for the workbook, organized by `ClassNameKey`. For more information about using workbook formatting, see the [Formatting](https://github.com/tableau/extensions-api/tree/main/Samples/Formatting){:target="_blank"} sample in the Samples folder. Also see [Add Tableau Workbook Formatting]({{site.baseurl}}/docs/trex_format.html).
9696

9797
* You can now set an event listener on changes to the dashboard layout and to the dashboard formatting. The new event types are `DashboardLayoutChanged` and `WorkbookFormattingChanged`.
9898

docs/trex_sandbox_publish.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Be sure to follow the guidelines and requirements to [Create and Test Sandboxed
1515
After you finish developing and testing your Sandboxed Extension, fill out the [Tableau Exchange Submission form](https://tabsoft.co/gallerysubmit){:target="_blank"}{:ref="noopener"} with your information and details about your extension.
1616
For information about what goes in the form, see [Submitting your Extension to the Tableau Exchange]({{site.baseurl}}/docs/ux_extension_gallery.html){:target="_blank"}.
1717

18-
Our developers from the Developer Platform team at Tableau will let you know the next steps including legal agreements after you submit your information. If you have any questions about the gallery please send them to [[email protected]](mailto:[email protected]){:target="_blank"}{:ref="noopener"}.
18+
Our developers from the Developer Platform team at Tableau will let you know the next steps including legal agreements after you submit your information. If you have any questions about the Tableau Exchange, send them to [[email protected]](mailto:[email protected]){:target="_blank"}{:ref="noopener"}.
1919

2020
Once accepted, Tableau will publish your extension and your extension will be available in the [Tableau Exchange](https://extensiongallery.tableau.com/){:target="_blank"}{:ref="noopener"}.
2121

docs/ux_design.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ These guidelines cover the main things you need to know about designing a great
4444
### Deploying your Extension
4545

4646
| ---------| ------- |
47-
|[Submitting your Extension to the Extension Gallery]({{site.baseurl}}/docs/ux_extension_gallery.html) | How to style your extension in accordance with the Tableau brand and your personal/company brand.|
47+
|[Submitting your Extension to the Tableau Exchange]({{site.baseurl}}/docs/ux_extension_gallery.html) | How to style your extension in accordance with the Tableau brand and your personal/company brand.|
4848

4949

5050
---

0 commit comments

Comments
 (0)