Skip to content

Commit 3d6baeb

Browse files
committed
refactor(styles): add white-scape css variables for more control
1 parent be47d33 commit 3d6baeb

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ You can customize tooltips theme using several methods:
7676
Tooltip CSS variables:
7777

7878
```css
79+
--tooltip-arrow-size: 10px;
7980
--tooltip-background-color: rgba(0, 0, 0, 0.9);
8081
--tooltip-border-radius: 4px;
8182
--tooltip-box-shadow: 0 1px 20px rgba(0, 0, 0, 0.25);
@@ -88,8 +89,9 @@ Tooltip CSS variables:
8889
--tooltip-offset-x: 12px;
8990
--tooltip-offset-y: 12px;
9091
--tooltip-padding: 12px;
92+
--tooltip-white-space-hidden: nowrap;
93+
--tooltip-white-space-shown: normal;
9194
--tooltip-z-index: 100;
92-
--tooltip-arrow-size: 10px;
9395
```
9496

9597
### Using the theme property

docs/src/App.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
</div>
8484

8585
<div class="example">
86-
This tooltip should appear on the <Tooltip content="<b>Tooltip Top</b><p>This is an example of using HTML and content wrapping.</p>" action="click" position="top" animation="slide" arrow={false}><i>top</i></Tooltip> when clicked.
86+
This tooltip should appear on the <Tooltip content="<b>Tooltip Top</b><p>This is an example of using HTML and content wrapping.</p>" position="top" animation="slide" arrow={false}><i>top</i></Tooltip> when I hover.
8787
</div>
8888

8989
<div class="example">
@@ -94,7 +94,7 @@
9494
position="right"
9595
action="click"
9696
theme="tooltip-theme">
97-
<b>right</b>.
97+
<b>right</b> when clicked.
9898
</Tooltip>
9999
</p>
100100
<Prism showLineNumbers={true} code={`

src/action-tooltip.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
*--------------------------*/
8080
8181
:root {
82+
--tooltip-arrow-size: 10px;
8283
--tooltip-background-color: rgba(0, 0, 0, 0.9);
8384
--tooltip-border-radius: 4px;
8485
--tooltip-box-shadow: 0 1px 20px rgba(0, 0, 0, 0.25);
@@ -91,8 +92,9 @@
9192
--tooltip-offset-x: 12px;
9293
--tooltip-offset-y: 12px;
9394
--tooltip-padding: 12px;
95+
--tooltip-white-space-hidden: nowrap;
96+
--tooltip-white-space-shown: normal;
9497
--tooltip-z-index: 100;
95-
--tooltip-arrow-size: 10px;
9698
}
9799
98100
/*--------------------------*
@@ -114,14 +116,14 @@
114116
position: absolute;
115117
text-align: left;
116118
visibility: hidden;
117-
white-space: nowrap;
119+
white-space: var(--tooltip-white-space-hidden);
118120
z-index: var(--tooltip-z-index);
119121
}
120122
121123
.tooltip.show {
122124
opacity: 1;
123125
visibility: visible;
124-
white-space: normal;
126+
white-space: var(--tooltip-white-space-shown);
125127
}
126128
127129
.tooltip.bottom:after,

src/tooltip.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@
164164
*--------------------------*/
165165
166166
:root {
167+
--tooltip-arrow-size: 10px;
167168
--tooltip-background-color: rgba(0, 0, 0, 0.9);
168169
--tooltip-border-radius: 4px;
169170
--tooltip-box-shadow: 0 1px 20px rgba(0, 0, 0, 0.25);
@@ -176,8 +177,9 @@
176177
--tooltip-offset-x: 0px;
177178
--tooltip-offset-y: 0px;
178179
--tooltip-padding: 12px;
180+
--tooltip-white-space-hidden: nowrap;
181+
--tooltip-white-space-shown: normal;
179182
--tooltip-z-index: 100;
180-
--tooltip-arrow-size: 10px;
181183
}
182184
183185
/*--------------------------*
@@ -203,14 +205,14 @@
203205
position: absolute;
204206
text-align: left;
205207
visibility: hidden;
206-
white-space: nowrap;
208+
white-space: var(--tooltip-white-space-hidden);
207209
z-index: var(--tooltip-z-index);
208210
}
209211
210212
.tooltip.show {
211213
opacity: 1;
212214
visibility: visible;
213-
white-space: normal;
215+
white-space: var(--tooltip-white-space-shown);
214216
}
215217
216218
.tooltip.bottom:after,

0 commit comments

Comments
 (0)