UNPKG

@wordpress/components

Version:
27 lines (26 loc) • 826 B
import { useContextSystem } from "../context/index.mjs"; import { useText } from "../text/index.mjs"; import { getHeadingFontSize } from "../utils/font-size.mjs"; // 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 } = 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 { ...useText({ color, isBlock, weight, size: getHeadingFontSize(level), ...otherProps }), ...a11yProps, as }; } export { useHeading }; //# sourceMappingURL=hook.mjs.map