Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

main - release sync #268

Merged
merged 45 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
bfa4fab
Update react-components_intro.adoc
bryanthowell-ts Dec 8, 2024
a49db7f
Update react-components_intro.adoc
bryanthowell-ts Dec 8, 2024
ec50c8e
Update react-components_intro.adoc
bryanthowell-ts Dec 8, 2024
d1b57ba
Update react-components_intro.adoc
bryanthowell-ts Dec 8, 2024
120bf1f
Update react-components_intro.adoc
bryanthowell-ts Dec 8, 2024
5718526
Create react-components_lesson-01.adocon-01
bryanthowell-ts Dec 8, 2024
09f2675
Update react-components_intro.adoc
bryanthowell-ts Dec 8, 2024
056ad04
Update react-components_intro.adoc
bryanthowell-ts Dec 8, 2024
8cb359c
Update react-components_intro.adoc
bryanthowell-ts Dec 8, 2024
a24b294
Rename react-components_lesson-01.adocon-01 to react-components_lesso…
bryanthowell-ts Dec 8, 2024
fd9639c
Update react-components_lesson-01.adoc
bryanthowell-ts Dec 8, 2024
2db1576
Update react-components_lesson-01.adoc
bryanthowell-ts Dec 9, 2024
d8d73de
Update react-components_lesson-01.adoc
bryanthowell-ts Jan 2, 2025
bf0b9cf
Update react-components_lesson-01.adoc
bryanthowell-ts Jan 2, 2025
e5c42d6
Create react-components_lesson-02.adoc
bryanthowell-ts Jan 2, 2025
cdbe925
Update react-components_intro.adoc
bryanthowell-ts Jan 2, 2025
70407e2
Update nav.adoc
bryanthowell-ts Jan 2, 2025
7eee34c
Update react-components_intro.adoc
bryanthowell-ts Jan 2, 2025
891f8e8
Update react-components_lesson-02.adoc
bryanthowell-ts Jan 3, 2025
6afc491
Create react-components_lesson-03.adoc
bryanthowell-ts Jan 3, 2025
963755a
Update react-components_lesson-02.adoc
bryanthowell-ts Jan 3, 2025
86c7023
Update react-components_lesson-03.adoc
bryanthowell-ts Jan 7, 2025
77568fd
Update nav.adoc
bryanthowell-ts Jan 15, 2025
8f4768c
Create react-components_lesson-04.adoc
bryanthowell-ts Jan 15, 2025
f4a619a
Update react-components_intro.adoc
bryanthowell-ts Jan 21, 2025
da6c7e1
Create readme.txt
bryanthowell-ts Jan 21, 2025
21cfefa
Add files via upload
bryanthowell-ts Jan 21, 2025
f19db57
Update react-components_intro.adoc
bryanthowell-ts Jan 21, 2025
7695b13
Update react-components_intro.adoc
bryanthowell-ts Jan 21, 2025
0d1b631
Update react-components_lesson-01.adoc
bryanthowell-ts Jan 21, 2025
578e367
Update react-components_intro.adoc
bryanthowell-ts Jan 21, 2025
c40faac
Update react-components_lesson-03.adoc
bryanthowell-ts Jan 22, 2025
5cc28d2
Update react-components_lesson-03.adoc
bryanthowell-ts Jan 22, 2025
c998ea6
Update react-components_lesson-02.adoc
bryanthowell-ts Jan 22, 2025
5cd6bc0
Update react-components_lesson-03.adoc
bryanthowell-ts Jan 22, 2025
bf4bf5e
Update react-components_lesson-04.adoc
bryanthowell-ts Jan 22, 2025
6f8ab6a
Update react-components_intro.adoc
bryanthowell-ts Jan 23, 2025
90f2cd1
SCAL-239166 fixes
ShashiSubramanya Jan 31, 2025
e05fefa
sdk version update
ShashiSubramanya Jan 31, 2025
0fb9531
typos, formatting fixes
ShashiSubramanya Jan 31, 2025
6439e92
edits and typo fixes
ShashiSubramanya Feb 4, 2025
2c0fc77
typo fixes, file removal
ShashiSubramanya Feb 4, 2025
d3404ad
typo fixes and nav update
ShashiSubramanya Feb 4, 2025
1b3fd3e
heading text
ShashiSubramanya Feb 4, 2025
d87f392
Merge pull request #244 from thoughtspot/react-component-tutorial-1
ShashiSubramanya Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion modules/ROOT/pages/common/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@
*** link:{{navprefix}}/tutorials/tse-fundamentals/lesson-10[10 - Style embedded app]
*** link:{{navprefix}}/tutorials/tse-fundamentals/lesson-11[11 - Course summary]
** link:{{navprefix}}/tutorials/style-customization/tutorial[Style customization]
** link:{{navprefix}}/tutorials/react-components/intro[React components]
*** link:{{navprefix}}/tutorials/react-components/lesson-01[01 - Initialize Visual Embed SDK]
*** link:{{navprefix}}/tutorials/react-components/lesson-02[02 - ThoughtSpot component pages]
*** link:{{navprefix}}/tutorials/react-components/lesson-03[03 - Menus and navigation elements]
*** link:{{navprefix}}/tutorials/react-components/lesson-04[04 - Event handling]
** link:{{navprefix}}/tutorials/rest-api/intro[REST API]
*** link:{{navprefix}}/tutorials/rest-api/lesson-01[01 - REST API overview]
*** link:{{navprefix}}/tutorials/rest-api/lesson-02[02 - Simple Python implementation]
*** link:{{navprefix}}/tutorials/rest-api/lesson-03[03 - Complex REST API workflows]
*** link:{{navprefix}}/tutorials/rest-api/lesson-04[04 - Browser JavaScript REST API implementation]
*** link:{{navprefix}}/tutorials/rest-api/lesson-04[04 - Event handling]
** Spotter
*** link:{{navprefix}}/tutorials/spotter/integrate-into-chatbot[Integrate Spotter into your Chatbot]

Expand Down
143 changes: 87 additions & 56 deletions modules/ROOT/pages/customize-icons.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,61 @@

You can customize the icons on a ThoughtSpot page using an icon sprite SVG file and load it from a Web server or CDN.

To override an icon:
== Before you begin

. Open the ThoughtSpot application page and locate the icon you want to replace.
.. Right-click on the icon and select *Inspect*.
* Identify the icons that you want to override.
.. On your ThoughtSpot instance, right-click on the icon and select *Inspect*.
.. Inspect the `<svg>` element.
.. Note the icon ID.
. Make sure you have SVG code for the icon that you want to use. For example, if you are using icons from an external site, copy its SVG code.
. Create an icon sprite file and add the SVG code and icon ID. The following code snippet shows how to override the chart icon (`rd-icon-chart`) on the *Answers* page.
* Add the SVG hosting domain to the following allowlists on the *Develop* > *Security Settings* page:
** xref:security-settings.adoc#csp-connect-src[CSP connect-src domains allowlist]
** xref:security-settings.adoc#csp-trusted-domain[CSP img-src domains allowlist]
+
* xref:customize-icons.adoc#_try_it_out_in_the_embed_playground[Try out] the icon override code in the embed Playground. For ease of testing, the domain `cdn.jsdeliver.net` is already whitelisted on the ThoughtSpot link:https://try-everywhere.thoughtspot.cloud/v2/#/everywhere/playground/search[public Playground] and trial sites.

== Create an icon override
The basic structure of an icon override file is shown in the following snippet:

[source,svg]
----
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="width:0;height:0;visibility:hidden;">
<defs/>
<symbol id="rd-icon-name" viewBox="0 0 18 18">
<path />
</symbol>
</svg>
----

The `<path />` portion within the `<symbol>` tags is the definition of the actual drawing.

You are defining a small icon, so it should fit within a square boundary and have a single solid color.

There are many simple SVG icon examples available online, for example, the link:https://www.svgviewer.dev/[SVG viewer site, window=_blank].

You only need to copy the `<path>` tags from your example SVG within the `<symbol> </symbol>` tags.

=== viewBox property

The link:https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox[viewBox property^] is in the order `min-x`, `min-y`, `width`, and `height`.

The first two properties should be `0 0` while the second should match any `width` and `height` properties from the source of your SVG paths.

The `width` and `height` properties may be added directly in the `<svg>` tag, or as part of `viewBox` property in that tag, or perhaps in another tag above `<path>`. Use the values from your source SVG in the `viewBox` property of the `<symbol>` element within your override file.

=== fill property
You can add the `fill` property to the `<symbol>` tag to define a different fill color than the default:

[source,svg]
----
<symbol id="rd-icon-spotter" viewBox="0 0 222 225" fill="red">
----

== Override an icon
To override an icon:

. Create an icon sprite file with the SVG element, define the properties, and specify the icon ID.
+
The following code snippet shows how to override the chart icon (`rd-icon-chart`) on the *Answers* page.
+
[source,HTML]
----
Expand Down Expand Up @@ -44,75 +91,65 @@ To override multiple icons, use the following format:

+
. Save the icon sprite file on a Web server.
. Add the SVG hosting domain to the *CSP connect-src domains* allowlist on the *Develop* > *Security Settings* page. For more information, see xref:security-settings.adoc#csp-connect-src[Security Settings].
. To override the icons on the ThoughtSpot page, specify the icon sprite URL in the `iconSpriteURL` property of the `customizations` object in Visual Embed SDK.
+
The following code snippet uses the `icon-override1.svg` file hosted on the link:https://github.com/thoughtspot/custom-css-demo/blob/main/css-variables.css[Custom CSS demo GitHub Repo, window=_blank] to override the chart icon on the *Answers* page (`rd-icon-chart`):
For example, the following code snippets use the link:https://github.com/thoughtspot/custom-css-demo/blob/main/icon-override1.svg[icon-override1.svg] and link:https://github.com/thoughtspot/custom-css-demo/blob/main/alternate-spotter-icon.svg[alternate-spotter-icon.svg] files in the link:https://github.com/thoughtspot/custom-css-demo[Custom CSS demo GitHub Repo, window=_blank] to override the chart (`rd-icon-chart`) and Spotter (`rd-icon-spotter`) icons respectively:

+
[source,JavaScript]
----
customizations: {
iconSpriteUrl: "https://cdn.jsdelivr.net/gh/thoughtspot/custom-css-demo/icon-override1.svg"
}
init({
//...
customizations: {
// rd-icon-chart
iconSpriteUrl: "https://cdn.jsdelivr.net/gh/thoughtspot/custom-css-demo/icon-override1.svg"
}
});
----

+
[source,JavaScript]
----
init({
//...
customizations: {
// rd-icon-spotter
iconSpriteUrl: "https://cdn.jsdelivr.net/gh/thoughtspot/custom-css-demo/alternate-spotter-icon.svg"
}
});
----
. Load the application page and check the icon.
+
The following figures show the icons before and after the override.
+
[width="100%" cols="6,6"]
|======
a|**Before** +
||
2+|**Chart icon** on Answers
a|Before +

image::./images/pre-icon-override.png[Before icon override]
a|**After** +
a|After +

image::./images/post-icon-override.png[After icon override]
|======

== Creating an icon override
The basic structure of an icon override file is shown in the following snippet:

[source,svg]
----
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="width:0;height:0;visibility:hidden;">
<defs/>
<symbol id="rd-icon-name" viewBox="0 0 18 18">
<path />
</symbol>
</svg>
----

The `<path />` portion within the `<symbol>` tags is the definition of the actual drawing.

You are defining a small icon, so it should fit within a square boundary and have a single solid color.

There are many simple SVG icon examples available online, for example, the link:https://www.svgviewer.dev/[SVG viewer site, window=_blank].

You only need to copy the `<path>` tags from your example SVG within the `<symbol> </symbol>` tags.

=== viewBox property

The link:https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox[viewBox property^] is in the order `min-x`, `min-y`, `width`, and `height`.

The first two properties should be `0 0` while the second should match any `width` and `height` properties from the source of your SVG paths.
2+|**Spotter icon**
a|Before +
[.bordered]
image::./images/spotter-icon.png[Conversation embed]
a|After +
[.bordered]
image::./images/spotter-icon-customization.png[Spotter icon customization]

The `width` and `height` properties may be added directly in the `<svg>` tag, or as part of `viewBox` property in that tag, or perhaps in another tag above `<path>`. Use the values from your source SVG in the `viewBox` property of the `<symbol>` element within your override file.

=== fill property
You can add the `fill` property to the `<symbol>` tag to define a different fill color than the default:

[source,svg]
----
<symbol id="rd-icon-spotter" viewBox="0 0 222 225" fill="red">
----
|======

== Testing an icon override file
== Try it out in the Playground
The +++<a href="{{previewPrefix}}/playground/search" target="_blank">Visual Embed SDK Playground </a>+++ allows you to try out the icon customization framework.

To view the code for customization:

. Select the *Apply custom styles* checkbox in the Playground. +
The `customizations` code appears for CSS modifications appears in the code panel.
The `customizations` code for CSS modifications appears in the code panel.
. Replace the `customization` section with the following code and click *Run* to view the results:
+
[source,JavaScript]
Expand All @@ -121,9 +158,3 @@ The `customizations` code appears for CSS modifications appears in the code pane
iconSpriteUrl: "https://cdn.jsdelivr.net/gh/thoughtspot/custom-css-demo/icon-override1.svg"
}
----

[NOTE]
====
The `cdn.jsdeliver.net` domain is allowed on ThoughtSpot Embedded link:https://try-everywhere.thoughtspot.cloud/v2/#/everywhere/playground/search[public playground] and trial sites.
On your ThoughtSpot application instance, make sure to add the domain that will host the SVG file to xref:security-settings.adoc#csp-trusted-domain[the *CSP img-src domains* allowlist].
====
Loading
Loading