UNPKG

@intility/bifrost-react

Version:

React library for Intility's design system, Bifrost.

100 lines 2.14 kB
import { c as _c } from "react-compiler-runtime"; import { forwardRef } from "react"; import classNames from "classnames"; import { jsx as _jsx } from "react/jsx-runtime"; /** * Sticky is a box that will follow scroll position until it reaches top, then * stick there. * * @see https://bifrost.intility.com/react/sticky */ const Sticky = /*#__PURE__*/forwardRef((t0, ref) => { const $ = _c(22); let children; let className; let props; let style; let t1; let top; if ($[0] !== t0) { ({ top, unstyled: t1, className, children, style, ...props } = t0); $[0] = t0; $[1] = children; $[2] = className; $[3] = props; $[4] = style; $[5] = t1; $[6] = top; } else { children = $[1]; className = $[2]; props = $[3]; style = $[4]; t1 = $[5]; top = $[6]; } const unstyled = t1 === undefined ? false : t1; const t2 = typeof top === "number" ? top + "px" : top; let t3; if ($[7] !== style || $[8] !== t2) { t3 = { "--bf-sticky-top": t2, ...style }; $[7] = style; $[8] = t2; $[9] = t3; } else { t3 = $[9]; } const t4 = t3; const t5 = !unstyled; const t6 = !unstyled; const t7 = !unstyled; const t8 = !unstyled; let t9; if ($[10] !== className || $[11] !== t5 || $[12] !== t6 || $[13] !== t7 || $[14] !== t8) { t9 = classNames(className, "bf-sticky bf-scrollbar-small", { "bf-padding": t5, "bfc-base-3-bg": t6, "bf-radius-xs": t7, "bf-shadow": t8 }); $[10] = className; $[11] = t5; $[12] = t6; $[13] = t7; $[14] = t8; $[15] = t9; } else { t9 = $[15]; } let t10; if ($[16] !== children || $[17] !== props || $[18] !== ref || $[19] !== t4 || $[20] !== t9) { t10 = /*#__PURE__*/_jsx("div", { ...props, ref: ref, style: t4, className: t9, children: children }); $[16] = children; $[17] = props; $[18] = ref; $[19] = t4; $[20] = t9; $[21] = t10; } else { t10 = $[21]; } return t10; }); Sticky.displayName = "Sticky"; export default Sticky;