MCPcopy
hub / github.com/primer/react / Root

Function Root

packages/react/src/PageLayout/PageLayout.tsx:70–122  ·  view source on GitHub ↗
({
  containerWidth = 'xlarge',
  padding = 'normal',
  rowGap = 'normal',
  columnGap = 'normal',
  children,
  sx = {},
  _slotsConfig: slotsConfig,
})

Source from the content-addressed store, hash-verified

68
69// TODO: refs
70const Root: React.FC<React.PropsWithChildren<PageLayoutProps>> = ({
71 containerWidth = 'xlarge',
72 padding = 'normal',
73 rowGap = 'normal',
74 columnGap = 'normal',
75 children,
76 sx = {},
77 _slotsConfig: slotsConfig,
78}) => {
79 const {rootRef, enableStickyPane, disableStickyPane, contentTopRef, contentBottomRef, stickyPaneHeight} =
80 useStickyPaneHeight()
81
82 const paneRef = useRef<HTMLDivElement>(null)
83
84 const [slots, rest] = useSlots(children, slotsConfig ?? {header: Header, footer: Footer})
85
86 return (
87 <PageLayoutContext.Provider
88 value={{
89 padding,
90 rowGap,
91 columnGap,
92 enableStickyPane,
93 disableStickyPane,
94 contentTopRef,
95 contentBottomRef,
96 paneRef,
97 }}
98 >
99 <Box
100 ref={rootRef}
101 style={{
102 // @ts-ignore TypeScript doesn't know about CSS custom properties
103 '--sticky-pane-height': stickyPaneHeight,
104 }}
105 sx={merge<BetterSystemStyleObject>({padding: SPACING_MAP[padding]}, sx)}
106 >
107 <Box
108 sx={{
109 maxWidth: containerWidths[containerWidth],
110 marginX: 'auto',
111 display: 'flex',
112 flexWrap: 'wrap',
113 }}
114 >
115 {slots.header}
116 <Box sx={{display: 'flex', flex: '1 1 100%', flexWrap: 'wrap', maxWidth: '100%'}}>{rest}</Box>
117 {slots.footer}
118 </Box>
119 </Box>
120 </PageLayoutContext.Provider>
121 )
122}
123
124Root.displayName = 'PageLayout'
125

Callers

nothing calls this directly

Calls 2

useStickyPaneHeightFunction · 0.90
useSlotsFunction · 0.90

Tested by

no test coverage detected