UNPKG

react-circular-text-writer

Version:

A JavaScript utility to arrange text in a circular shape using HTML and CSS. Supports monospaced fonts for better alignment.

68 lines (67 loc) 1.8 kB
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); // index.tsx import React from "react"; var CircularTextWriter = /* @__PURE__ */ __name(({ text, radius, id, options = {} }) => { const monospacedFonts = [ "Menlo", "Courier New", "Consolas", "Lucida Console", "Monaco", "monospace" ]; let fontFamily = "Menlo, monospace"; if (options.fontFamily === "customFont" && options.customFont) { fontFamily = options.customFont; } else if (monospacedFonts.includes(options.fontFamily || "")) { fontFamily = options.fontFamily || "Menlo"; } const letters = text?.split(""); const rotationBetweenLetters = 360 / letters.length; return /* @__PURE__ */ React.createElement( "div", { id, "aria-label": text, style: { height: `${radius * 2}px`, width: `${radius * 2}px`, position: "relative", display: "flex", justifyContent: "center" } }, letters?.map((letter, index) => { const rotation = index * rotationBetweenLetters; return /* @__PURE__ */ React.createElement( "p", { key: index, style: { height: `${radius}px`, position: "absolute", transform: `rotate(${rotation}deg)`, transformOrigin: "0 100%", color: options.color || "#000000", fontFamily, fontWeight: options.fontWeight || 400, lineHeight: "normal", fontSize: options.fontSize || 16 } }, letter ); }) ); }, "CircularTextWriter"); var index_default = CircularTextWriter; export { index_default as default }; //# sourceMappingURL=index.mjs.map