@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
45 lines • 2.5 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import React, { forwardRef } from "react";
import { Slot } from "../../slot/Slot.js";
import { useRenameCSS, useThemeInternal } from "../../theme/Theme.js";
import { getResponsiveProps } from "../utilities/css.js";
/**
* Foundational Layout-primitive for generic encapsulation & styling.
*
* @see [📝 Documentation](https://aksel.nav.no/komponenter/primitives/Bleed)
* @see 🏷️ {@link BleedProps}
* @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
*
* @example
* <Box padding="4">
* <Bleed marginInline="4" marginBlock="4">
* <BodyLong>Some content</BodyLong>
* </Bleed>
* </Box>
*/
export const Bleed = forwardRef((_a, ref) => {
var { className, marginInline, marginBlock, reflectivePadding, style: _style, asChild } = _a, rest = __rest(_a, ["className", "marginInline", "marginBlock", "reflectivePadding", "style", "asChild"]);
const themeContext = useThemeInternal(false);
const { cn } = useRenameCSS();
const prefix = (themeContext === null || themeContext === void 0 ? void 0 : themeContext.isDarkside) ? "ax" : "a";
let style = Object.assign(Object.assign(Object.assign({}, _style), getResponsiveProps(prefix, "bleed", "margin-inline", "spacing", marginInline, true, ["0", "full", "px"])), getResponsiveProps(prefix, "bleed", "margin-block", "spacing", marginBlock, true, ["0", "px"]));
if (reflectivePadding) {
style = Object.assign(Object.assign(Object.assign({}, style), getResponsiveProps(prefix, "bleed", "padding-inline", "spacing", marginInline, false, ["0", "full", "px"])), getResponsiveProps(prefix, "bleed", "padding-block", "spacing", marginBlock, false, ["0", "px"]));
}
const Comp = asChild ? Slot : "div";
return (React.createElement(Comp, Object.assign({}, rest, { className: cn("navds-bleed", className, {
"navds-bleed--padding": reflectivePadding,
}), ref: ref, style: style })));
});
export default Bleed;
//# sourceMappingURL=Bleed.js.map