@base-ui/react
Version:
Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.
41 lines (39 loc) • 1.12 kB
JavaScript
'use client';
import * as React from 'react';
import { useRenderElement } from "../../utils/useRenderElement.js";
import { useDrawerProviderContext } from "../provider/DrawerProviderContext.js";
const stateAttributesMapping = {
active(value) {
if (value) {
return {
'data-active': ''
};
}
return {
'data-inactive': ''
};
}
};
/**
* An element placed before <Drawer.Indent> to render a background layer
* that can be styled based on whether any drawer is open.
*/
export const DrawerIndentBackground = /*#__PURE__*/React.forwardRef(function DrawerIndentBackground(componentProps, forwardedRef) {
const {
render,
className,
...elementProps
} = componentProps;
const providerContext = useDrawerProviderContext(true);
const active = providerContext?.active ?? false;
const state = {
active
};
return useRenderElement('div', componentProps, {
ref: forwardedRef,
state,
props: elementProps,
stateAttributesMapping
});
});
if (process.env.NODE_ENV !== "production") DrawerIndentBackground.displayName = "DrawerIndentBackground";