Skip to content

Commit 4d995ea

Browse files
Merge pull request #241 from thoughtspot/svg-instruction-update
Svg instruction update
2 parents b42f015 + 9090a96 commit 4d995ea

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

modules/ROOT/pages/customize-icons.adoc

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You can customize the icons on a ThoughtSpot page using an icon sprite SVG file
1010

1111
To override an icon:
1212

13-
. Open the ThoughtSpot application page and locate the icon that you want to replace.
13+
. Open the ThoughtSpot application page and locate the icon you want to replace.
1414
.. Right-click on the icon and select *Inspect*.
1515
.. Inspect the `<svg>` element.
1616
.. Note the icon ID.
@@ -69,3 +69,61 @@ a|**After** +
6969
image::./images/post-icon-override.png[After icon override]
7070
|======
7171
72+
== Creating an icon override
73+
The basic structure of an icon override file is shown in the following snippet:
74+
75+
[source,svg]
76+
----
77+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="width:0;height:0;visibility:hidden;">
78+
<defs/>
79+
<symbol id="rd-icon-name" viewBox="0 0 18 18">
80+
<path />
81+
</symbol>
82+
</svg>
83+
----
84+
85+
The `<path />` portion within the `<symbol>` tags is the definition of the actual drawing.
86+
87+
You are defining a small icon, so it should fit within a square boundary and have a single solid color.
88+
89+
There are many simple SVG icon examples available online, for example, the link:https://www.svgviewer.dev/[SVG viewer site, window=_blank].
90+
91+
You only need to copy the `<path>` tags from your example SVG within the `<symbol> </symbol>` tags.
92+
93+
=== viewBox property
94+
95+
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`.
96+
97+
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.
98+
99+
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.
100+
101+
=== fill property
102+
You can add the `fill` property to the `<symbol>` tag to define a different fill color than the default:
103+
104+
[source,svg]
105+
----
106+
<symbol id="rd-icon-spotter" viewBox="0 0 222 225" fill="red">
107+
----
108+
109+
== Testing an icon override file
110+
The +++<a href="{{navprefix}}/dev-playground">Visual Embed SDK Playground </a>+++ allows you to try out the icon customization framework.
111+
112+
To view the code for customization:
113+
114+
. Select the *Apply custom styles* checkbox in the Playground. +
115+
The `customizations` code appears for CSS modifications appears in the code panel.
116+
. Replace the `customization` section with the following code and click *Run* to view the results:
117+
+
118+
[source,JavaScript]
119+
----
120+
customizations: {
121+
iconSpriteUrl: "https://cdn.jsdelivr.net/gh/thoughtspot/custom-css-demo/icon-override1.svg"
122+
}
123+
----
124+
125+
[NOTE]
126+
====
127+
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.
128+
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].
129+
====

0 commit comments

Comments
 (0)