@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
65 lines • 2.93 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 { useRenameCSS, useThemeInternal } from "../../theme/Theme.js";
import { PageBlock } from "./parts/PageBlock.js";
export const PageComponent = forwardRef((_a, ref) => {
var { as: Component = "div", className, style: _style, footer, children, footerPosition, background, contentBlockPadding = "end" } = _a, rest = __rest(_a, ["as", "className", "style", "footer", "children", "footerPosition", "background", "contentBlockPadding"]);
const themeContext = useThemeInternal(false);
const { cn } = useRenameCSS();
if (process.env.NODE_ENV !== "production" &&
(themeContext === null || themeContext === void 0 ? void 0 : themeContext.isDarkside) &&
background) {
console.warn(`Prop \`background\` is deprecated and cannot be used with theme-support. Instead wrap component with \`<Box asChild background>\``);
}
const style = Object.assign(Object.assign({}, _style), { "--__ac-page-background": `var(--a-${background !== null && background !== void 0 ? background : "bg-default"})` });
const belowFold = footerPosition === "belowFold";
return (React.createElement(Component, Object.assign({}, rest, { className: cn("navds-page", className), ref: ref, style: style }),
React.createElement("div", { className: cn({
"navds-page__content--fullheight": belowFold,
"navds-page__content--grow": !belowFold,
"navds-page__content--padding": contentBlockPadding === "end",
}) }, children),
footer));
});
/**
* Page helps with establishing a top-level layout for your page
*
* @see [📝 Documentation](https://aksel.nav.no/komponenter/primitives/page)
* @see 🏷️ {@link PageProps}
* @see [🤖 OverridableComponent](https://aksel.nav.no/grunnleggende/kode/overridablecomponent) support
*
* @example
* ```jsx
* <Page
* footer={<Page.Block width="xl" gutters />}
* >
* <Page.Block width="xl" gutters />// Header
* <Page.Block width="xl" gutters />// Content
* </Page>
* ```
* @example
* Footer placed below page-fold
* ```jsx
* <Page
* footer={<Page.Block width="xl" gutters />}
* footerPosition="belowFold"
* >
* <Page.Block width="xl" gutters />// Header
* <Page.Block width="xl" gutters />// Content
* </Page>
* ```
*/
const Page = PageComponent;
Page.Block = PageBlock;
export default Page;
//# sourceMappingURL=Page.js.map