Skip to content

Commit

Permalink
Add global props to layout children
Browse files Browse the repository at this point in the history
  • Loading branch information
markdoeswork committed Dec 4, 2024
1 parent bcc10b3 commit af79551
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions playbook/app/pb_kits/playbook/pb_layout/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,37 @@ type LayoutPropTypes = {
type LayoutSideProps = {
children: React.ReactNode[] | React.ReactNode,
className?: string,
}
} & GlobalProps

type LayoutBodyProps = {
children: React.ReactNode[] | React.ReactNode,
className?: string,
}
} & GlobalProps

type LayoutItemProps = {
children: React.ReactNode[] | React.ReactNode,
className?: string,
size?: "sm" | "md" | "lg"
}
} & GlobalProps

type LayoutHeaderProps = {
children: React.ReactNode[] | React.ReactNode,
className?: string,
}
} & GlobalProps

type LayoutFooterProps = {
children: React.ReactNode[] | React.ReactNode,
className?: string,
}
} & GlobalProps

// Side component
const Side = (props: LayoutSideProps) => {
const { children, className } = props
const dynamicInlineProps = globalInlineProps(props)
return (
<div className={classnames('layout_sidebar', globalProps(props), className)}>
<div
className={classnames('layout_sidebar', globalProps(props), className)}
style={dynamicInlineProps}
>
{children}
</div>
)
Expand All @@ -60,8 +63,12 @@ const Side = (props: LayoutSideProps) => {
// Body component
const Body = (props: LayoutBodyProps) => {
const { children, className } = props
const dynamicInlineProps = globalInlineProps(props)
return (
<div className={classnames('layout_body', globalProps(props), className)}>
<div
className={classnames('layout_body', globalProps(props), className)}
style={dynamicInlineProps}
>
{children}
</div>
)
Expand All @@ -71,8 +78,12 @@ const Body = (props: LayoutBodyProps) => {
const Item = (props: LayoutItemProps) => {
const { children, className, size = 'sm' } = props
const sizeClass = `size_${size}`
const dynamicInlineProps = globalInlineProps(props)
return (
<div className={classnames('layout_item', sizeClass, globalProps(props), className)}>
<div
className={classnames('layout_item', sizeClass, globalProps(props), className)}
style={dynamicInlineProps}
>
{children}
</div>
)
Expand All @@ -81,8 +92,12 @@ const Item = (props: LayoutItemProps) => {
// Header component
const Header = (props: LayoutHeaderProps) => {
const { children, className } = props
const dynamicInlineProps = globalInlineProps(props)
return (
<div className={classnames('layout_header', globalProps(props), className)}>
<div
className={classnames('layout_header', globalProps(props), className)}
style={dynamicInlineProps}
>
{children}
</div>
)
Expand All @@ -91,8 +106,12 @@ const Header = (props: LayoutHeaderProps) => {
// Footer component
const Footer = (props: LayoutFooterProps) => {
const { children, className } = props
const dynamicInlineProps = globalInlineProps(props)
return (
<div className={classnames('layout_footer', globalProps(props), className)}>
<div
className={classnames('layout_footer', globalProps(props), className)}
style={dynamicInlineProps}
>
{children}
</div>
)
Expand Down

0 comments on commit af79551

Please sign in to comment.