@rogieking/figui3 1.5.6 → 1.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +3 -0
- package/components.css +15 -5
- package/example.html +45 -2
- package/fig.js +41 -4
- package/package.json +1 -1
package/components.css
CHANGED
|
@@ -1967,17 +1967,27 @@ fig-tooltip {
|
|
|
1967
1967
|
}
|
|
1968
1968
|
.fig-tooltip {
|
|
1969
1969
|
inset: unset;
|
|
1970
|
-
display: block;
|
|
1970
|
+
display: inline-block;
|
|
1971
1971
|
color: var(--color-tooltip);
|
|
1972
1972
|
background-color: var(--bg-tooltip);
|
|
1973
1973
|
padding: var(--spacer-1) var(--spacer-2);
|
|
1974
1974
|
line-height: 1rem !important;
|
|
1975
|
-
display: inline-flex;
|
|
1976
1975
|
font-weight: inherit;
|
|
1977
1976
|
border-radius: var(--radius-medium, 0.3125rem);
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1977
|
+
max-width: 180px;
|
|
1978
|
+
width: max-content;
|
|
1979
|
+
|
|
1980
|
+
& > span {
|
|
1981
|
+
text-wrap: balance;
|
|
1982
|
+
max-height: 2.5rem;
|
|
1983
|
+
overflow-y: hidden;
|
|
1984
|
+
display: -webkit-box;
|
|
1985
|
+
-webkit-line-clamp: 2;
|
|
1986
|
+
-webkit-box-orient: vertical;
|
|
1987
|
+
line-clamp: 2;
|
|
1988
|
+
text-overflow: ellipsis;
|
|
1989
|
+
width: auto;
|
|
1990
|
+
}
|
|
1981
1991
|
|
|
1982
1992
|
&:after {
|
|
1983
1993
|
content: "";
|
package/example.html
CHANGED
|
@@ -26,7 +26,49 @@
|
|
|
26
26
|
<h2><label>Effects/</label>UI3 Components</h2>
|
|
27
27
|
</fig-header>
|
|
28
28
|
<fig-content>
|
|
29
|
-
|
|
29
|
+
|
|
30
|
+
<br /><br /><br /><br /><br /><br /><br /><br /><br />
|
|
31
|
+
<hstack>
|
|
32
|
+
<fig-tooltip text="Tooltip"
|
|
33
|
+
delay="0">
|
|
34
|
+
<fig-button>
|
|
35
|
+
Test
|
|
36
|
+
</fig-button>
|
|
37
|
+
</fig-tooltip>
|
|
38
|
+
<fig-tooltip text="Tooltip that is a bit longer"
|
|
39
|
+
delay="0">
|
|
40
|
+
<fig-button>
|
|
41
|
+
Test
|
|
42
|
+
</fig-button>
|
|
43
|
+
</fig-tooltip>
|
|
44
|
+
<fig-tooltip text="Tooltip that is a bit longer ish"
|
|
45
|
+
delay="0">
|
|
46
|
+
<fig-button>
|
|
47
|
+
Test
|
|
48
|
+
</fig-button>
|
|
49
|
+
</fig-tooltip>
|
|
50
|
+
<fig-tooltip text="Tooltip that is a bit longer ish yet"
|
|
51
|
+
delay="0">
|
|
52
|
+
<fig-button>
|
|
53
|
+
Test
|
|
54
|
+
</fig-button>
|
|
55
|
+
</fig-tooltip>
|
|
56
|
+
<fig-tooltip text="Tooltip that is a bit longer and has a lot of text and even more text"
|
|
57
|
+
delay="0">
|
|
58
|
+
<fig-button>
|
|
59
|
+
Test
|
|
60
|
+
</fig-button>
|
|
61
|
+
</fig-tooltip>
|
|
62
|
+
<fig-tooltip text="Super mega fuckin long ass tooltip that likely shouldn't even be possible to fit in the space"
|
|
63
|
+
delay="0">
|
|
64
|
+
<fig-button>
|
|
65
|
+
Test
|
|
66
|
+
</fig-button>
|
|
67
|
+
</fig-tooltip>
|
|
68
|
+
|
|
69
|
+
</hstack>
|
|
70
|
+
<br /><br /><br /><br /><br /><br /><br /><br /><br />
|
|
71
|
+
<fig-button type="link"
|
|
30
72
|
href="https://www.google.com">
|
|
31
73
|
<svg width="24"
|
|
32
74
|
height="24"
|
|
@@ -39,7 +81,8 @@
|
|
|
39
81
|
</svg>
|
|
40
82
|
|
|
41
83
|
Install</fig-button>
|
|
42
|
-
<fig-button type="
|
|
84
|
+
<fig-button type="link"
|
|
85
|
+
target="_blank"
|
|
43
86
|
size="large"
|
|
44
87
|
href="https://www.google.com">
|
|
45
88
|
<svg width="24"
|
package/fig.js
CHANGED
|
@@ -77,8 +77,13 @@ class FigButton extends HTMLElement {
|
|
|
77
77
|
}
|
|
78
78
|
if (this.type === "link") {
|
|
79
79
|
const href = this.getAttribute("href");
|
|
80
|
+
const target = this.getAttribute("target");
|
|
80
81
|
if (href) {
|
|
81
|
-
|
|
82
|
+
if (target) {
|
|
83
|
+
window.open(href, target);
|
|
84
|
+
} else {
|
|
85
|
+
window.location.href = href;
|
|
86
|
+
}
|
|
82
87
|
}
|
|
83
88
|
}
|
|
84
89
|
}
|
|
@@ -249,14 +254,24 @@ class FigTooltip extends HTMLElement {
|
|
|
249
254
|
|
|
250
255
|
render() {
|
|
251
256
|
this.destroy();
|
|
257
|
+
let content = document.createElement("span");
|
|
252
258
|
this.popup = document.createElement("span");
|
|
253
259
|
this.popup.setAttribute("class", "fig-tooltip");
|
|
254
260
|
this.popup.style.position = "fixed";
|
|
255
261
|
this.popup.style.visibility = "hidden";
|
|
256
262
|
this.popup.style.display = "inline-flex";
|
|
257
263
|
this.popup.style.pointerEvents = "none";
|
|
258
|
-
this.popup.
|
|
264
|
+
this.popup.append(content);
|
|
265
|
+
content.innerText = this.getAttribute("text");
|
|
259
266
|
document.body.append(this.popup);
|
|
267
|
+
const text = content.childNodes[0];
|
|
268
|
+
if (text) {
|
|
269
|
+
const range = document.createRange();
|
|
270
|
+
range.setStartBefore(text);
|
|
271
|
+
range.setEndAfter(text);
|
|
272
|
+
const clientRect = range.getBoundingClientRect();
|
|
273
|
+
content.style.width = `${clientRect.width}px`;
|
|
274
|
+
}
|
|
260
275
|
}
|
|
261
276
|
|
|
262
277
|
destroy() {
|
|
@@ -1910,8 +1925,30 @@ class FigImage extends HTMLElement {
|
|
|
1910
1925
|
}
|
|
1911
1926
|
});
|
|
1912
1927
|
}
|
|
1913
|
-
handleFileInput(e) {
|
|
1914
|
-
this.
|
|
1928
|
+
async handleFileInput(e) {
|
|
1929
|
+
this.blob = URL.createObjectURL(e.target.files[0]);
|
|
1930
|
+
//set base64 url
|
|
1931
|
+
const reader = new FileReader();
|
|
1932
|
+
reader.readAsDataURL(e.target.files[0]);
|
|
1933
|
+
//await this data url to be set
|
|
1934
|
+
await new Promise((resolve) => {
|
|
1935
|
+
reader.onload = (e) => {
|
|
1936
|
+
this.base64 = e.target.result;
|
|
1937
|
+
resolve();
|
|
1938
|
+
};
|
|
1939
|
+
});
|
|
1940
|
+
//emit event for loaded
|
|
1941
|
+
this.dispatchEvent(
|
|
1942
|
+
new CustomEvent("load", {
|
|
1943
|
+
bubbles: true,
|
|
1944
|
+
cancelable: true,
|
|
1945
|
+
detail: {
|
|
1946
|
+
blob: this.blob,
|
|
1947
|
+
base64: this.base64,
|
|
1948
|
+
},
|
|
1949
|
+
})
|
|
1950
|
+
);
|
|
1951
|
+
this.src = this.blob;
|
|
1915
1952
|
this.setAttribute("src", this.src);
|
|
1916
1953
|
this.chit.setAttribute("src", this.src);
|
|
1917
1954
|
}
|