UNPKG

@wordpress/components

Version:
32 lines (31 loc) • 1.05 kB
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); let ___context_index_ts = require("../context/index.cjs"); let ___text_index_ts = require("../text/index.cjs"); let ___utils_font_size_ts = require("../utils/font-size.cjs"); // packages/components/src/heading/hook.ts function useHeading(props) { const { as: asProp, level = 2, color, isBlock = true, weight = "var(--wpds-typography-font-weight-emphasis, 600)", ...otherProps } = (0, ___context_index_ts.useContextSystem)(props, "Heading"); const as = asProp || `h${level}`; const a11yProps = {}; if (typeof as === "string" && as[0] !== "h") { a11yProps.role = "heading"; a11yProps["aria-level"] = typeof level === "string" ? parseInt(level) : level; } return { ...(0, ___text_index_ts.useText)({ color, isBlock, weight, size: (0, ___utils_font_size_ts.getHeadingFontSize)(level), ...otherProps }), ...a11yProps, as }; } exports.useHeading = useHeading; //# sourceMappingURL=hook.cjs.map