@antadesign/anta 0.2.0 → 0.2.2
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/README.md +40 -1
- package/dist/components/Button.js +6 -3
- package/dist/components/Progress.module.css +0 -5
- package/dist/components/Text.module.css +0 -6
- package/dist/components/Tooltip.d.ts +19 -9
- package/dist/components/Tooltip.js +2 -2
- package/dist/elements/a-button.css +1 -756
- package/dist/elements/a-icon.css +1 -43
- package/dist/elements/a-icon.shapes.css +1 -377
- package/dist/elements/a-icon.shapes.d.ts +2 -2
- package/dist/elements/a-icon.shapes.js +2 -2
- package/dist/elements/a-progress.css +1 -68
- package/dist/elements/a-tag.css +1 -196
- package/dist/elements/a-text.css +1 -90
- package/dist/elements/a-title.css +1 -64
- package/dist/elements/a-tooltip.css +1 -62
- package/dist/elements/a-tooltip.d.ts +25 -7
- package/dist/elements/a-tooltip.js +114 -69
- package/dist/general_types.d.ts +4 -4
- package/dist/index.d.ts +1 -0
- package/dist/jsx-runtime.d.ts +17 -15
- package/dist/reset.css +1 -209
- package/dist/tokens.css +1 -285
- package/package.json +6 -4
- package/dist/components/Button.module.css +0 -2
- package/dist/components/Menu.d.ts +0 -61
- package/dist/components/Menu.js +0 -34
- package/dist/components/MenuGroup.d.ts +0 -24
- package/dist/components/MenuGroup.js +0 -19
- package/dist/components/MenuItem.d.ts +0 -49
- package/dist/components/MenuItem.js +0 -40
- package/dist/components/MenuSeparator.d.ts +0 -14
- package/dist/components/MenuSeparator.js +0 -7
- package/dist/components/Sticker.d.ts +0 -31
- package/dist/components/Sticker.js +0 -17
- package/dist/components/StickerAnimated.d.ts +0 -23
- package/dist/components/StickerAnimated.js +0 -28
- package/dist/components/__generated__/stickers/angry-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/angry-animated.js +0 -7
- package/dist/components/__generated__/stickers/angry.d.ts +0 -3
- package/dist/components/__generated__/stickers/angry.js +0 -7
- package/dist/components/__generated__/stickers/ask-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/ask-animated.js +0 -7
- package/dist/components/__generated__/stickers/ask.d.ts +0 -3
- package/dist/components/__generated__/stickers/ask.js +0 -7
- package/dist/components/__generated__/stickers/balance-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/balance-animated.js +0 -7
- package/dist/components/__generated__/stickers/balance.d.ts +0 -3
- package/dist/components/__generated__/stickers/balance.js +0 -7
- package/dist/components/__generated__/stickers/butterfly-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/butterfly-animated.js +0 -7
- package/dist/components/__generated__/stickers/butterfly-snake-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/butterfly-snake-animated.js +0 -7
- package/dist/components/__generated__/stickers/butterfly-snake.d.ts +0 -3
- package/dist/components/__generated__/stickers/butterfly-snake.js +0 -7
- package/dist/components/__generated__/stickers/butterfly.d.ts +0 -3
- package/dist/components/__generated__/stickers/butterfly.js +0 -7
- package/dist/components/__generated__/stickers/catch-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/catch-animated.js +0 -7
- package/dist/components/__generated__/stickers/catch.d.ts +0 -3
- package/dist/components/__generated__/stickers/catch.js +0 -7
- package/dist/components/__generated__/stickers/clap-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/clap-animated.js +0 -7
- package/dist/components/__generated__/stickers/clap.d.ts +0 -3
- package/dist/components/__generated__/stickers/clap.js +0 -7
- package/dist/components/__generated__/stickers/coding-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/coding-animated.js +0 -7
- package/dist/components/__generated__/stickers/coding.d.ts +0 -3
- package/dist/components/__generated__/stickers/coding.js +0 -7
- package/dist/components/__generated__/stickers/cowboy-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/cowboy-animated.js +0 -7
- package/dist/components/__generated__/stickers/cowboy.d.ts +0 -3
- package/dist/components/__generated__/stickers/cowboy.js +0 -7
- package/dist/components/__generated__/stickers/dance-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/dance-animated.js +0 -7
- package/dist/components/__generated__/stickers/dance.d.ts +0 -3
- package/dist/components/__generated__/stickers/dance.js +0 -7
- package/dist/components/__generated__/stickers/detective-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/detective-animated.js +0 -7
- package/dist/components/__generated__/stickers/detective.d.ts +0 -3
- package/dist/components/__generated__/stickers/detective.js +0 -7
- package/dist/components/__generated__/stickers/disapprove-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/disapprove-animated.js +0 -7
- package/dist/components/__generated__/stickers/disapprove.d.ts +0 -3
- package/dist/components/__generated__/stickers/disapprove.js +0 -7
- package/dist/components/__generated__/stickers/distracted-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/distracted-animated.js +0 -7
- package/dist/components/__generated__/stickers/distracted.d.ts +0 -3
- package/dist/components/__generated__/stickers/distracted.js +0 -7
- package/dist/components/__generated__/stickers/dive-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/dive-animated.js +0 -7
- package/dist/components/__generated__/stickers/dive.d.ts +0 -3
- package/dist/components/__generated__/stickers/dive.js +0 -7
- package/dist/components/__generated__/stickers/eat-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/eat-animated.js +0 -7
- package/dist/components/__generated__/stickers/eat.d.ts +0 -3
- package/dist/components/__generated__/stickers/eat.js +0 -7
- package/dist/components/__generated__/stickers/facepalm-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/facepalm-animated.js +0 -7
- package/dist/components/__generated__/stickers/facepalm.d.ts +0 -3
- package/dist/components/__generated__/stickers/facepalm.js +0 -7
- package/dist/components/__generated__/stickers/failed-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/failed-animated.js +0 -7
- package/dist/components/__generated__/stickers/failed.d.ts +0 -3
- package/dist/components/__generated__/stickers/failed.js +0 -7
- package/dist/components/__generated__/stickers/found-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/found-animated.js +0 -7
- package/dist/components/__generated__/stickers/found.d.ts +0 -3
- package/dist/components/__generated__/stickers/found.js +0 -7
- package/dist/components/__generated__/stickers/grow-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/grow-animated.js +0 -7
- package/dist/components/__generated__/stickers/grow.d.ts +0 -3
- package/dist/components/__generated__/stickers/grow.js +0 -7
- package/dist/components/__generated__/stickers/handstand-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/handstand-animated.js +0 -7
- package/dist/components/__generated__/stickers/handstand.d.ts +0 -3
- package/dist/components/__generated__/stickers/handstand.js +0 -7
- package/dist/components/__generated__/stickers/heart-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/heart-animated.js +0 -7
- package/dist/components/__generated__/stickers/heart.d.ts +0 -3
- package/dist/components/__generated__/stickers/heart.js +0 -7
- package/dist/components/__generated__/stickers/hello-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/hello-animated.js +0 -7
- package/dist/components/__generated__/stickers/hello.d.ts +0 -3
- package/dist/components/__generated__/stickers/hello.js +0 -7
- package/dist/components/__generated__/stickers/idea-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/idea-animated.js +0 -7
- package/dist/components/__generated__/stickers/idea.d.ts +0 -3
- package/dist/components/__generated__/stickers/idea.js +0 -7
- package/dist/components/__generated__/stickers/index.d.ts +0 -99
- package/dist/components/__generated__/stickers/index.js +0 -198
- package/dist/components/__generated__/stickers/laugh-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/laugh-animated.js +0 -7
- package/dist/components/__generated__/stickers/laugh.d.ts +0 -3
- package/dist/components/__generated__/stickers/laugh.js +0 -7
- package/dist/components/__generated__/stickers/love-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/love-animated.js +0 -7
- package/dist/components/__generated__/stickers/love.d.ts +0 -3
- package/dist/components/__generated__/stickers/love.js +0 -7
- package/dist/components/__generated__/stickers/nap-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/nap-animated.js +0 -7
- package/dist/components/__generated__/stickers/nap.d.ts +0 -3
- package/dist/components/__generated__/stickers/nap.js +0 -7
- package/dist/components/__generated__/stickers/party-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/party-animated.js +0 -7
- package/dist/components/__generated__/stickers/party.d.ts +0 -3
- package/dist/components/__generated__/stickers/party.js +0 -7
- package/dist/components/__generated__/stickers/passed-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/passed-animated.js +0 -7
- package/dist/components/__generated__/stickers/passed.d.ts +0 -3
- package/dist/components/__generated__/stickers/passed.js +0 -7
- package/dist/components/__generated__/stickers/peekaboo-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/peekaboo-animated.js +0 -7
- package/dist/components/__generated__/stickers/peekaboo.d.ts +0 -3
- package/dist/components/__generated__/stickers/peekaboo.js +0 -7
- package/dist/components/__generated__/stickers/pizza-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/pizza-animated.js +0 -7
- package/dist/components/__generated__/stickers/pizza.d.ts +0 -3
- package/dist/components/__generated__/stickers/pizza.js +0 -7
- package/dist/components/__generated__/stickers/puzzle-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/puzzle-animated.js +0 -7
- package/dist/components/__generated__/stickers/puzzle.d.ts +0 -3
- package/dist/components/__generated__/stickers/puzzle.js +0 -7
- package/dist/components/__generated__/stickers/sad-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/sad-animated.js +0 -7
- package/dist/components/__generated__/stickers/sad.d.ts +0 -3
- package/dist/components/__generated__/stickers/sad.js +0 -7
- package/dist/components/__generated__/stickers/scared-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/scared-animated.js +0 -7
- package/dist/components/__generated__/stickers/scared.d.ts +0 -3
- package/dist/components/__generated__/stickers/scared.js +0 -7
- package/dist/components/__generated__/stickers/scroll-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/scroll-animated.js +0 -7
- package/dist/components/__generated__/stickers/scroll.d.ts +0 -3
- package/dist/components/__generated__/stickers/scroll.js +0 -7
- package/dist/components/__generated__/stickers/search-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/search-animated.js +0 -7
- package/dist/components/__generated__/stickers/search.d.ts +0 -3
- package/dist/components/__generated__/stickers/search.js +0 -7
- package/dist/components/__generated__/stickers/shield-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/shield-animated.js +0 -7
- package/dist/components/__generated__/stickers/shield.d.ts +0 -3
- package/dist/components/__generated__/stickers/shield.js +0 -7
- package/dist/components/__generated__/stickers/shocked-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/shocked-animated.js +0 -7
- package/dist/components/__generated__/stickers/shocked.d.ts +0 -3
- package/dist/components/__generated__/stickers/shocked.js +0 -7
- package/dist/components/__generated__/stickers/sleep-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/sleep-animated.js +0 -7
- package/dist/components/__generated__/stickers/sleep.d.ts +0 -3
- package/dist/components/__generated__/stickers/sleep.js +0 -7
- package/dist/components/__generated__/stickers/stressed-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/stressed-animated.js +0 -7
- package/dist/components/__generated__/stickers/stressed.d.ts +0 -3
- package/dist/components/__generated__/stickers/stressed.js +0 -7
- package/dist/components/__generated__/stickers/suspicious-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/suspicious-animated.js +0 -7
- package/dist/components/__generated__/stickers/suspicious.d.ts +0 -3
- package/dist/components/__generated__/stickers/suspicious.js +0 -7
- package/dist/components/__generated__/stickers/thanks-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/thanks-animated.js +0 -7
- package/dist/components/__generated__/stickers/thanks.d.ts +0 -3
- package/dist/components/__generated__/stickers/thanks.js +0 -7
- package/dist/components/__generated__/stickers/think-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/think-animated.js +0 -7
- package/dist/components/__generated__/stickers/think-of-you-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/think-of-you-animated.js +0 -7
- package/dist/components/__generated__/stickers/think-of-you.d.ts +0 -3
- package/dist/components/__generated__/stickers/think-of-you.js +0 -7
- package/dist/components/__generated__/stickers/think.d.ts +0 -3
- package/dist/components/__generated__/stickers/think.js +0 -7
- package/dist/components/__generated__/stickers/thumbs-up-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/thumbs-up-animated.js +0 -7
- package/dist/components/__generated__/stickers/thumbs-up.d.ts +0 -3
- package/dist/components/__generated__/stickers/thumbs-up.js +0 -7
- package/dist/components/__generated__/stickers/vacation-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/vacation-animated.js +0 -7
- package/dist/components/__generated__/stickers/vacation.d.ts +0 -3
- package/dist/components/__generated__/stickers/vacation.js +0 -7
- package/dist/components/__generated__/stickers/wait-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/wait-animated.js +0 -7
- package/dist/components/__generated__/stickers/wait.d.ts +0 -3
- package/dist/components/__generated__/stickers/wait.js +0 -7
- package/dist/components/__generated__/stickers/wink-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/wink-animated.js +0 -7
- package/dist/components/__generated__/stickers/wink.d.ts +0 -3
- package/dist/components/__generated__/stickers/wink.js +0 -7
- package/dist/components/__generated__/stickers/work-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/work-animated.js +0 -7
- package/dist/components/__generated__/stickers/work.d.ts +0 -3
- package/dist/components/__generated__/stickers/work.js +0 -7
- package/dist/components/__generated__/stickers/zen-animated.d.ts +0 -3
- package/dist/components/__generated__/stickers/zen-animated.js +0 -7
- package/dist/components/__generated__/stickers/zen.d.ts +0 -3
- package/dist/components/__generated__/stickers/zen.js +0 -7
- package/dist/elements/a-menu-group.css +0 -21
- package/dist/elements/a-menu-group.d.ts +0 -13
- package/dist/elements/a-menu-group.js +0 -15
- package/dist/elements/a-menu-item.css +0 -162
- package/dist/elements/a-menu-item.d.ts +0 -27
- package/dist/elements/a-menu-item.js +0 -29
- package/dist/elements/a-menu-separator.css +0 -15
- package/dist/elements/a-menu-separator.d.ts +0 -12
- package/dist/elements/a-menu-separator.js +0 -15
- package/dist/elements/a-menu.css +0 -34
- package/dist/elements/a-menu.d.ts +0 -120
- package/dist/elements/a-menu.js +0 -649
- package/dist/elements/a-sticker-animated.css +0 -9
- package/dist/elements/a-sticker-animated.d.ts +0 -39
- package/dist/elements/a-sticker-animated.js +0 -81
- package/dist/elements/a-sticker.css +0 -9
- package/dist/elements/a-sticker.d.ts +0 -19
- package/dist/elements/a-sticker.js +0 -32
- package/dist/generate-stickers.mjs +0 -293
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import lottie from "lottie-web";
|
|
2
|
-
import { HTMLElementBase } from "../anta_helpers";
|
|
3
|
-
import "./a-sticker-animated.css";
|
|
4
|
-
class AStickerAnimatedElement extends HTMLElementBase {
|
|
5
|
-
static observedAttributes = ["animation", "paused"];
|
|
6
|
-
container;
|
|
7
|
-
player = null;
|
|
8
|
-
_animation = null;
|
|
9
|
-
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
const shadow = this.attachShadow({ mode: "open" });
|
|
12
|
-
const style = document.createElement("style");
|
|
13
|
-
style.textContent = `
|
|
14
|
-
:host { display: inline-block; }
|
|
15
|
-
div { width: 100%; height: 100%; }
|
|
16
|
-
div > svg { display: block; width: 100%; height: 100%; }
|
|
17
|
-
`;
|
|
18
|
-
this.container = document.createElement("div");
|
|
19
|
-
shadow.append(style, this.container);
|
|
20
|
-
}
|
|
21
|
-
connectedCallback() {
|
|
22
|
-
if (this._animation != null && this.player == null) this.rebuild();
|
|
23
|
-
}
|
|
24
|
-
disconnectedCallback() {
|
|
25
|
-
this.teardown();
|
|
26
|
-
}
|
|
27
|
-
attributeChangedCallback(name) {
|
|
28
|
-
if (name === "animation") {
|
|
29
|
-
const value = this.getAttribute("animation");
|
|
30
|
-
this._animation = value ? JSON.parse(value) : null;
|
|
31
|
-
if (this.isConnected) this.rebuild();
|
|
32
|
-
} else if (name === "paused") {
|
|
33
|
-
this.applyPaused();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
rebuild() {
|
|
37
|
-
this.teardown();
|
|
38
|
-
if (this._animation == null) return;
|
|
39
|
-
this.player = lottie.loadAnimation({
|
|
40
|
-
container: this.container,
|
|
41
|
-
renderer: "svg",
|
|
42
|
-
loop: true,
|
|
43
|
-
autoplay: !this.hasAttribute("paused"),
|
|
44
|
-
animationData: this._animation
|
|
45
|
-
});
|
|
46
|
-
this.applyPaused();
|
|
47
|
-
}
|
|
48
|
-
applyPaused() {
|
|
49
|
-
if (!this.player) return;
|
|
50
|
-
const attr = this.getAttribute("paused");
|
|
51
|
-
if (attr === null) {
|
|
52
|
-
this.player.play();
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const seconds = Number(attr);
|
|
56
|
-
if (Number.isFinite(seconds) && seconds > 0) {
|
|
57
|
-
const frame = seconds * this.player.frameRate;
|
|
58
|
-
const clamped = Math.min(this.player.totalFrames - 1, Math.max(0, frame));
|
|
59
|
-
this.player.goToAndStop(clamped, true);
|
|
60
|
-
} else {
|
|
61
|
-
this.player.pause();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
teardown() {
|
|
65
|
-
if (this.player) {
|
|
66
|
-
this.player.destroy();
|
|
67
|
-
this.player = null;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function register_a_sticker_animated() {
|
|
72
|
-
if (typeof customElements === "undefined") return;
|
|
73
|
-
if (!customElements.get("a-sticker-animated")) {
|
|
74
|
-
customElements.define("a-sticker-animated", AStickerAnimatedElement);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
register_a_sticker_animated();
|
|
78
|
-
export {
|
|
79
|
-
AStickerAnimatedElement,
|
|
80
|
-
register_a_sticker_animated
|
|
81
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { HTMLElementBase } from '../anta_helpers';
|
|
2
|
-
import './a-sticker.css';
|
|
3
|
-
/**
|
|
4
|
-
* `<a-sticker>` — static sticker carrier.
|
|
5
|
-
*
|
|
6
|
-
* Receives SVG markup as the `svg` attribute. On change, drops it into
|
|
7
|
-
* a shadow-DOM container so the host's light DOM stays untouched.
|
|
8
|
-
* Sizing comes from external CSS reading `--sticker-size` (set by the
|
|
9
|
-
* JSX wrapper, or by the consumer directly).
|
|
10
|
-
*
|
|
11
|
-
* The animated counterpart is `<a-sticker-animated>`.
|
|
12
|
-
*/
|
|
13
|
-
export declare class AStickerElement extends HTMLElementBase {
|
|
14
|
-
static observedAttributes: string[];
|
|
15
|
-
container: HTMLDivElement;
|
|
16
|
-
constructor();
|
|
17
|
-
attributeChangedCallback(): void;
|
|
18
|
-
}
|
|
19
|
-
export declare function register_a_sticker(): void;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { HTMLElementBase } from "../anta_helpers";
|
|
2
|
-
import "./a-sticker.css";
|
|
3
|
-
class AStickerElement extends HTMLElementBase {
|
|
4
|
-
static observedAttributes = ["svg"];
|
|
5
|
-
container;
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
const shadow = this.attachShadow({ mode: "open" });
|
|
9
|
-
const style = document.createElement("style");
|
|
10
|
-
style.textContent = `
|
|
11
|
-
:host { display: inline-block; }
|
|
12
|
-
div { width: 100%; height: 100%; }
|
|
13
|
-
div > svg { display: block; width: 100%; height: 100%; }
|
|
14
|
-
`;
|
|
15
|
-
this.container = document.createElement("div");
|
|
16
|
-
shadow.append(style, this.container);
|
|
17
|
-
}
|
|
18
|
-
attributeChangedCallback() {
|
|
19
|
-
this.container.innerHTML = this.getAttribute("svg") ?? "";
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function register_a_sticker() {
|
|
23
|
-
if (typeof customElements === "undefined") return;
|
|
24
|
-
if (!customElements.get("a-sticker")) {
|
|
25
|
-
customElements.define("a-sticker", AStickerElement);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
register_a_sticker();
|
|
29
|
-
export {
|
|
30
|
-
AStickerElement,
|
|
31
|
-
register_a_sticker
|
|
32
|
-
};
|
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* generate-stickers.mjs — read a folder of per-sticker subfolders and emit
|
|
4
|
-
* one per-sticker TS module per mode (static + animated) under the chosen
|
|
5
|
-
* output folder, plus a barrel index that re-exports them.
|
|
6
|
-
*
|
|
7
|
-
* Expected source layout:
|
|
8
|
-
*
|
|
9
|
-
* stickers/
|
|
10
|
-
* coding/
|
|
11
|
-
* coding.json — Lottie animation (drives Sticker{Name}Animated)
|
|
12
|
-
* coding.svg — static pose (drives Sticker{Name})
|
|
13
|
-
* vacation/
|
|
14
|
-
* vacation.json
|
|
15
|
-
* vacation.svg
|
|
16
|
-
* …
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* Collision detection — when `--internal` is NOT passed (i.e. consumer
|
|
20
|
-
* run), the generator warns if a generated name collides with one of
|
|
21
|
-
* anta's built-in stickers. Anta's own build passes `--internal`.
|
|
22
|
-
*
|
|
23
|
-
* node scripts/generate-stickers.mjs --input ./stickers --output ./src/components/__generated__/stickers
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
import fs from "node:fs";
|
|
27
|
-
import path from "node:path";
|
|
28
|
-
|
|
29
|
-
// Anta's built-in sticker names. Consumers who generate a same-named
|
|
30
|
-
// sticker get a warning; their generated module will resolve to the same
|
|
31
|
-
// import path and shadow ours. Keep this list in sync with the canonical
|
|
32
|
-
// names under ./stickers/<name>/.
|
|
33
|
-
const DEFAULT_BUILT_IN = [
|
|
34
|
-
"angry",
|
|
35
|
-
"ask",
|
|
36
|
-
"balance",
|
|
37
|
-
"butterfly",
|
|
38
|
-
"butterfly-snake",
|
|
39
|
-
"catch",
|
|
40
|
-
"clap",
|
|
41
|
-
"coding",
|
|
42
|
-
"cowboy",
|
|
43
|
-
"dance",
|
|
44
|
-
"detective",
|
|
45
|
-
"disapprove",
|
|
46
|
-
"distracted",
|
|
47
|
-
"dive",
|
|
48
|
-
"eat",
|
|
49
|
-
"facepalm",
|
|
50
|
-
"failed",
|
|
51
|
-
"found",
|
|
52
|
-
"grow",
|
|
53
|
-
"handstand",
|
|
54
|
-
"heart",
|
|
55
|
-
"hello",
|
|
56
|
-
"idea",
|
|
57
|
-
"laugh",
|
|
58
|
-
"love",
|
|
59
|
-
"nap",
|
|
60
|
-
"party",
|
|
61
|
-
"passed",
|
|
62
|
-
"peekaboo",
|
|
63
|
-
"pizza",
|
|
64
|
-
"puzzle",
|
|
65
|
-
"sad",
|
|
66
|
-
"scared",
|
|
67
|
-
"scroll",
|
|
68
|
-
"search",
|
|
69
|
-
"shield",
|
|
70
|
-
"shocked",
|
|
71
|
-
"sleep",
|
|
72
|
-
"stressed",
|
|
73
|
-
"suspicious",
|
|
74
|
-
"thanks",
|
|
75
|
-
"think",
|
|
76
|
-
"think-of-you",
|
|
77
|
-
"thumbs-up",
|
|
78
|
-
"vacation",
|
|
79
|
-
"wait",
|
|
80
|
-
"wink",
|
|
81
|
-
"work",
|
|
82
|
-
"zen",
|
|
83
|
-
];
|
|
84
|
-
|
|
85
|
-
function pascalCase(name) {
|
|
86
|
-
return name
|
|
87
|
-
.split(/[-_\s]+/)
|
|
88
|
-
.filter(Boolean)
|
|
89
|
-
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
90
|
-
.join("");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function componentName(base) {
|
|
94
|
-
return `Sticker${pascalCase(base)}`;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export async function generate({ input, output, internal = false } = {}) {
|
|
98
|
-
if (!input) throw new Error("generate-stickers: --input is required");
|
|
99
|
-
if (!output) throw new Error("generate-stickers: --output is required");
|
|
100
|
-
|
|
101
|
-
const inDir = path.resolve(input);
|
|
102
|
-
const outDir = path.resolve(output);
|
|
103
|
-
if (!fs.existsSync(inDir)) {
|
|
104
|
-
throw new Error(`generate-stickers: input folder not found: ${inDir}`);
|
|
105
|
-
}
|
|
106
|
-
fs.mkdirSync(outDir, { recursive: true });
|
|
107
|
-
|
|
108
|
-
// Each immediate subfolder of inDir is one sticker. The folder name is
|
|
109
|
-
// the canonical sticker name.
|
|
110
|
-
const subdirs = fs
|
|
111
|
-
.readdirSync(inDir, { withFileTypes: true })
|
|
112
|
-
.filter((d) => d.isDirectory())
|
|
113
|
-
.map((d) => d.name)
|
|
114
|
-
.sort();
|
|
115
|
-
|
|
116
|
-
if (subdirs.length === 0) {
|
|
117
|
-
console.warn(`generate-stickers: no sticker subfolders in ${inDir}`);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
// Clear out previous generated files so renamed/removed stickers don't
|
|
121
|
-
// leave stale modules behind. Keep index.ts (about to be rewritten) and
|
|
122
|
-
// the per-sticker static + animated file names we're about to write.
|
|
123
|
-
// Naming convention: `<name>.ts` is the static (default) sticker;
|
|
124
|
-
// `<name>-animated.ts` is the Lottie-backed animated variant.
|
|
125
|
-
const keep = new Set([
|
|
126
|
-
"index.ts",
|
|
127
|
-
...subdirs.flatMap((n) => [`${n}.ts`, `${n}-animated.ts`]),
|
|
128
|
-
]);
|
|
129
|
-
for (const existing of fs.readdirSync(outDir)) {
|
|
130
|
-
if (!keep.has(existing) && /\.ts$/.test(existing)) {
|
|
131
|
-
fs.unlinkSync(path.join(outDir, existing));
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const exports = [];
|
|
136
|
-
const skipped = [];
|
|
137
|
-
const builtInSet = internal ? new Set() : new Set(DEFAULT_BUILT_IN);
|
|
138
|
-
const collisions = [];
|
|
139
|
-
|
|
140
|
-
for (const name of subdirs) {
|
|
141
|
-
const subdir = path.join(inDir, name);
|
|
142
|
-
const lottiePath = path.join(subdir, `${name}.json`);
|
|
143
|
-
const svgPath = path.join(subdir, `${name}.svg`);
|
|
144
|
-
const hasLottie = fs.existsSync(lottiePath);
|
|
145
|
-
const hasSvg = fs.existsSync(svgPath) && fs.statSync(svgPath).size > 0;
|
|
146
|
-
if (!hasLottie && !hasSvg) {
|
|
147
|
-
skipped.push(`${name} (no ${name}.json or ${name}.svg)`);
|
|
148
|
-
continue;
|
|
149
|
-
}
|
|
150
|
-
if (builtInSet.has(name)) collisions.push(name);
|
|
151
|
-
const cname = componentName(name);
|
|
152
|
-
const animatedName = `${cname}Animated`;
|
|
153
|
-
|
|
154
|
-
// Static module — the default. Emitted whenever a non-empty SVG
|
|
155
|
-
// exists. Imports the `Sticker` runtime wrapper from the package
|
|
156
|
-
// root `@antadesign/anta` (same root specifier the icon codegen
|
|
157
|
-
// uses — no bespoke runtime subpath). Lives at `<name>.ts` so the
|
|
158
|
-
// import path matches the bare sticker name.
|
|
159
|
-
//
|
|
160
|
-
// Two exports: the JSX `Sticker{Name}` component (React/Preact),
|
|
161
|
-
// and the raw `svg` string (vanilla JS / non-JSX consumers, who
|
|
162
|
-
// assign it to an `<a-sticker>` element's `svg` attribute).
|
|
163
|
-
// Bundlers tree-shake the unused one.
|
|
164
|
-
if (hasSvg) {
|
|
165
|
-
const svg = fs.readFileSync(svgPath, "utf8");
|
|
166
|
-
const lines = [
|
|
167
|
-
"/* Auto-generated by @antadesign/anta. Do not edit by hand. */",
|
|
168
|
-
"",
|
|
169
|
-
"import { Sticker, type StickerProps } from '@antadesign/anta'",
|
|
170
|
-
"",
|
|
171
|
-
`export const svg = ${JSON.stringify(svg)}`,
|
|
172
|
-
"",
|
|
173
|
-
`export const ${cname} = (props: StickerProps) => Sticker({ ...props, svg })`,
|
|
174
|
-
"",
|
|
175
|
-
];
|
|
176
|
-
fs.writeFileSync(path.join(outDir, `${name}.ts`), lines.join("\n"));
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
// Animated module — emitted whenever a Lottie JSON exists. Each
|
|
180
|
-
// module lives in `<name>-animated.ts` so importing only the static
|
|
181
|
-
// sticker (`<name>.ts`) never drags the Lottie payload. Bundlers
|
|
182
|
-
// tree-shake per-file when the barrel uses `export { … } from
|
|
183
|
-
// './foo'`. Imports the `StickerAnimated` runtime wrapper from the
|
|
184
|
-
// package root `@antadesign/anta`.
|
|
185
|
-
//
|
|
186
|
-
// The animation is exported as a JSON *string* (not the parsed
|
|
187
|
-
// object). `<a-sticker-animated>` receives it via its `animation`
|
|
188
|
-
// attribute and parses it once on set. Two exports: the JSX
|
|
189
|
-
// `Sticker{Name}Animated` component, and the raw `animationJson`
|
|
190
|
-
// string (vanilla JS / non-JSX consumers who call
|
|
191
|
-
// `el.setAttribute('animation', animationJson)`).
|
|
192
|
-
if (hasLottie) {
|
|
193
|
-
const lottieJson = fs.readFileSync(lottiePath, "utf8");
|
|
194
|
-
const lines = [
|
|
195
|
-
"/* Auto-generated by @antadesign/anta. Do not edit by hand. */",
|
|
196
|
-
"",
|
|
197
|
-
"import { StickerAnimated, type StickerAnimatedProps } from '@antadesign/anta'",
|
|
198
|
-
"",
|
|
199
|
-
`export const animationJson = ${JSON.stringify(lottieJson)}`,
|
|
200
|
-
"",
|
|
201
|
-
`export const ${animatedName} = (props: StickerAnimatedProps) => StickerAnimated({ ...props, animation: animationJson })`,
|
|
202
|
-
"",
|
|
203
|
-
];
|
|
204
|
-
fs.writeFileSync(
|
|
205
|
-
path.join(outDir, `${name}-animated.ts`),
|
|
206
|
-
lines.join("\n"),
|
|
207
|
-
);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
exports.push({
|
|
211
|
-
base: name,
|
|
212
|
-
componentName: cname,
|
|
213
|
-
hasLottie,
|
|
214
|
-
hasSvg,
|
|
215
|
-
animatedName,
|
|
216
|
-
});
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// Barrel — alphabetical for stable diffs, side-effect free so unused
|
|
220
|
-
// stickers tree-shake. Each export references the correct per-mode
|
|
221
|
-
// file so importing only the static variant doesn't pull the animated
|
|
222
|
-
// module (and vice versa).
|
|
223
|
-
const reExports = [];
|
|
224
|
-
for (const {
|
|
225
|
-
base,
|
|
226
|
-
componentName,
|
|
227
|
-
hasLottie,
|
|
228
|
-
hasSvg,
|
|
229
|
-
animatedName,
|
|
230
|
-
} of exports) {
|
|
231
|
-
if (hasSvg) reExports.push(`export { ${componentName} } from './${base}'`);
|
|
232
|
-
if (hasLottie)
|
|
233
|
-
reExports.push(`export { ${animatedName} } from './${base}-animated'`);
|
|
234
|
-
}
|
|
235
|
-
const indexLines = [
|
|
236
|
-
"/* Auto-generated by @antadesign/anta. Do not edit by hand. */",
|
|
237
|
-
"",
|
|
238
|
-
"export type { StickerProps, StickerAnimatedProps } from '@antadesign/anta'",
|
|
239
|
-
"",
|
|
240
|
-
...reExports,
|
|
241
|
-
"",
|
|
242
|
-
];
|
|
243
|
-
fs.writeFileSync(path.join(outDir, "index.ts"), indexLines.join("\n"));
|
|
244
|
-
|
|
245
|
-
if (collisions.length > 0) {
|
|
246
|
-
console.warn(
|
|
247
|
-
`generate-stickers: ${collisions.length} sticker name(s) collide with Anta's built-in stickers: ` +
|
|
248
|
-
`${collisions.join(", ")}. ` +
|
|
249
|
-
`Consumers importing from \`@antadesign/anta/stickers\` get Anta's; your generated barrel exposes yours under its own import path.`,
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
console.log(
|
|
254
|
-
`generate-stickers: wrote ${exports.length} sticker${exports.length === 1 ? "" : "s"} to ${outDir}`,
|
|
255
|
-
);
|
|
256
|
-
if (skipped.length) {
|
|
257
|
-
console.warn(
|
|
258
|
-
`generate-stickers: skipped ${skipped.length} (${skipped.join(", ")})`,
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
return { stickers: exports };
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
function parseArgs(argv) {
|
|
265
|
-
const out = {};
|
|
266
|
-
for (let i = 0; i < argv.length; i++) {
|
|
267
|
-
const arg = argv[i];
|
|
268
|
-
if (arg.startsWith("--")) {
|
|
269
|
-
const key = arg.slice(2);
|
|
270
|
-
const next = argv[i + 1];
|
|
271
|
-
if (next && !next.startsWith("--")) {
|
|
272
|
-
out[key] = next;
|
|
273
|
-
i++;
|
|
274
|
-
} else {
|
|
275
|
-
out[key] = true;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
return out;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const isMain = process.argv[1]?.endsWith("generate-stickers.mjs");
|
|
283
|
-
if (isMain) {
|
|
284
|
-
const args = parseArgs(process.argv.slice(2));
|
|
285
|
-
generate({
|
|
286
|
-
input: args.input,
|
|
287
|
-
output: args.output,
|
|
288
|
-
internal: args.internal === true,
|
|
289
|
-
}).catch((e) => {
|
|
290
|
-
console.error(e.message);
|
|
291
|
-
process.exit(1);
|
|
292
|
-
});
|
|
293
|
-
}
|