3.0.1 • Published 2 years ago

w3ts-jsx v3.0.1

Weekly downloads
13
License
ISC
Repository
github
Last release
2 years ago

w3ts-jsx

Add JSX to your WC3 maps!

Features

FeatureStatus
Box model
Base frame types✔️
Lifecycle methods❌ (possible with hooks)
JSX✔️
Class components✔️
Functional components✔️
Hooks✔️
Fragments✔️

Usage

  1. Install dependencies
npm install -D w3ts-jsx basic-pragma
  1. Configure tsconfig.json
{
  "compilerOptions": {
    "jsx": "react",
    "jsxFactory": "createElement",
    "jsxFragmentFactory": "Fragment"
  }
}
  1. Implement a JSX component
import { createElement, useEffect, useState } from "w3ts-jsx";
import { Timer } from "@voces/w3ts";

export const App = () => {
  const [count, setCount] = useState(0);

  useEffect(() => {
    const timer = new Timer();
    timer.start(1, true, () => setCount((c) => c + 1));

    return () => timer.destroy();
  }, []);

  return (
    <button
      inherits="ScoreScreenTabButtonTemplate"
      absPosition={{ point: FRAMEPOINT_CENTER, x: 0.4, y: 0.3 }}
      size={{ width: 0.1, height: 0.04 }}
      onClick={() => print("Button Clicked")}
    >
      <backdrop
        position="parent"
        texture="ReplaceableTextures\\CommandButtons\\BTNSelectHeroOn"
      />
      <text text={`Waited ${count} seconds`} position="parent" />
    </button>
  );
};
  1. Render it
import { adapter, createElement, render, setAdapter } from "w3ts-jsx";
import { App } from "./App";

setAdapter(adapter);

render(<App />, BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0));

Examples

3.0.1

2 years ago

3.0.0

2 years ago

2.5.2

3 years ago

2.5.1

3 years ago

2.5.0

3 years ago

2.3.0

3 years ago

2.4.0

3 years ago

2.2.0

4 years ago

2.0.1

4 years ago

1.1.0

4 years ago

2.0.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago