UNPKG

adwaita-web

Version:

A GTK inspired toolkit designed to build awesome web apps

29 lines (28 loc) 680 B
import cx from "clsx"; import React from "react"; import { onlyText } from "react-children-utilities"; function Heading({ as = "h1", children, className, weight, anchor = true, ...rest }) { const Component = as; const id = anchor ? toID(onlyText(children)) : void 0; return /* @__PURE__ */ React.createElement(Component, { id, className: cx("Heading", className, weight ? `weight-${weight}` : void 0), ...rest }, anchor && /* @__PURE__ */ React.createElement("a", { className: "Heading__anchor link", href: `#${id}` }, "#"), children); } function toID(string) { return string.toLowerCase().replace(/\W+/g, "-"); } export { Heading };