xshape
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

xshape

npm version npm download

Install

NPM

npm install xshape

Usage

import { useXShape, XShapeStage, URLImage, createRootMachine } from 'xshape';

// url is optional
// data format see: https://github.com/tony40508/xshape/blob/main/public/mockData.json
const rootMachine = createRootMachine('initial-shape-data-url');

function App() {
  const {
    componentProps,
    // other props see: https://github.com/tony40508/xshape/blob/main/src/App.tsx
  } = useXShape(rootMachine);

  return (
    <XShapeStage
      {...componentProps}
      // enable to configure finish condition in limited options
      // see: https://github.com/tony40508/xshape/blob/main/src/utils/types.d.ts
      handleMouseDown={(e) => {
        componentProps.handleMouseDown(e, 'ctrl+click');
      }}
    >
      {/* URLImage is optional */}
      <URLImage url="background-image-url" />
    </XShapeStage>
  );
}

Run the example locally

npm install
npm run dev

Package Sidebar

Install

npm i xshape

Weekly Downloads

1

Version

0.0.5

License

MIT

Unpacked Size

1.44 MB

Total Files

20

Last publish

Collaborators

  • tony40508