0.0.1 • Published 2 years ago

use-svg-maker v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

use-svg-maker

See a partial example

Install

npm i use-svg-maker

Use in React projects, I would recommend pulling in leva to make it trivial to parameterize drawings.

Import:

import { useSVG } from "use-svg-maker"

Use:

const { ref, download, name, setName, props, meta } = useSVG({
  height: 540,
  width: 960,
})
<svg className=" bg-white" {...props} ref={ref}>
  {/* draw things here with code */}
</svg>

Add something like this to allow local saving of files:

<div className="flex flex-row gap-4 items-center mt-8 print:hidden">
    <input
    type="text"
    value={name}
    onChange={(e) => setName(e.target.value)}
    className="p-4 rounded bg-slate-100 text-slate-700"
    />
    <p className="text-white text-lg">.svg</p>
</div>

<button
    className="bg-emerald-500 text-white p-4 rounded-lg mt-8 print:hidden"
    onClick={download}
>
    Download
</button>

Releases

  • 0.0.1 - Initial release