@getflip/swirl-components 0.34.2 → 0.34.3
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/components.json +1 -1
- package/dist/cjs/swirl-text.cjs.entry.js +181 -10
- package/dist/collection/assets/pdfjs/pdf.worker.min.js +22 -0
- package/dist/collection/components/swirl-text/swirl-text.js +19 -10
- package/dist/components/assets/pdfjs/pdf.worker.min.js +22 -0
- package/dist/components/swirl-text2.js +181 -10
- package/dist/esm/swirl-text.entry.js +181 -10
- package/dist/swirl-components/p-5f05c203.entry.js +8 -0
- package/dist/swirl-components/swirl-components.esm.js +1 -1
- package/dist/types/components/swirl-text/swirl-text.d.ts +1 -0
- package/package.json +2 -1
- package/dist/swirl-components/p-0f186daa.entry.js +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { h, Host } from "@stencil/core";
|
|
2
2
|
import classnames from "classnames";
|
|
3
3
|
import balanceText from "balance-text";
|
|
4
|
+
import shave from "shave";
|
|
4
5
|
export class SwirlText {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.align = "start";
|
|
@@ -15,9 +16,23 @@ export class SwirlText {
|
|
|
15
16
|
}
|
|
16
17
|
componentDidRender() {
|
|
17
18
|
this.rebalance();
|
|
19
|
+
this.handleTruncation();
|
|
18
20
|
}
|
|
19
21
|
onWindowResize() {
|
|
20
22
|
this.rebalance();
|
|
23
|
+
this.handleTruncation();
|
|
24
|
+
}
|
|
25
|
+
handleTruncation() {
|
|
26
|
+
if (!this.truncate || !Boolean(this.lines) || this.lines === 1) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const lineHeight = +window
|
|
30
|
+
.getComputedStyle(this.textEl, null)
|
|
31
|
+
.getPropertyValue("line-height")
|
|
32
|
+
.replace("px", "");
|
|
33
|
+
if (lineHeight > 0) {
|
|
34
|
+
shave(this.textEl, lineHeight * this.lines);
|
|
35
|
+
}
|
|
21
36
|
}
|
|
22
37
|
rebalance() {
|
|
23
38
|
if (!this.balance || !Boolean(this.textEl)) {
|
|
@@ -27,16 +42,10 @@ export class SwirlText {
|
|
|
27
42
|
}
|
|
28
43
|
render() {
|
|
29
44
|
const Tag = this.as;
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"-webkit-box-orient": "vertical",
|
|
35
|
-
whiteSpace: "normal",
|
|
36
|
-
}
|
|
37
|
-
: undefined;
|
|
38
|
-
const className = classnames("text", `text--align-${this.align}`, `text--color-${this.color}`, `text--font-style-${this.fontStyle}`, `text--size-${this.size}`, `text--weight-${this.weight}`, { "text--truncate": this.truncate });
|
|
39
|
-
return (h(Host, null, h(Tag, { class: className, ref: (el) => (this.textEl = el), style: styles }, h("slot", null))));
|
|
45
|
+
const className = classnames("text", `text--align-${this.align}`, `text--color-${this.color}`, `text--font-style-${this.fontStyle}`, `text--size-${this.size}`, `text--weight-${this.weight}`, {
|
|
46
|
+
"text--truncate": this.truncate && (!Boolean(this.lines) || this.lines === 1),
|
|
47
|
+
});
|
|
48
|
+
return (h(Host, null, h(Tag, { class: className, ref: (el) => (this.textEl = el) }, h("slot", null))));
|
|
40
49
|
}
|
|
41
50
|
static get is() { return "swirl-text"; }
|
|
42
51
|
static get encapsulation() { return "scoped"; }
|