1
1
mirror of https://github.com/theoludwig/theoludwig.git synced 2024-11-10 06:18:07 +01:00
.profile/components/design/Section/index.tsx

63 lines
1.5 KiB
TypeScript
Raw Normal View History

2021-04-18 01:56:23 +02:00
import { ShadowContainer } from '../ShadowContainer'
import { SectionHeading } from './SectionHeading'
type SectionProps = React.ComponentPropsWithRef<'section'> & {
heading?: string
description?: string
isMain?: boolean
withoutShadowContainer?: boolean
}
2021-06-15 20:35:52 +02:00
export const Section: React.FC<SectionProps> = (props) => {
2021-04-18 01:56:23 +02:00
const {
children,
heading,
description,
isMain = false,
withoutShadowContainer = false,
...rest
} = props
if (isMain) {
return (
<div className='px-3 w-full'>
<ShadowContainer style={{ marginTop: 50 }}>
2021-06-15 20:35:52 +02:00
<section {...rest}>
{heading != null && <SectionHeading>{heading}</SectionHeading>}
<div className='px-3 w-full'>{children}</div>
</section>
</ShadowContainer>
</div>
2021-04-18 01:56:23 +02:00
)
}
if (withoutShadowContainer) {
return (
2021-06-15 20:35:52 +02:00
<section {...rest}>
2021-04-18 01:56:23 +02:00
{heading != null && <SectionHeading>{heading}</SectionHeading>}
<div className='px-3 w-full'>{children}</div>
2021-04-18 01:56:23 +02:00
</section>
)
}
return (
2021-06-15 20:35:52 +02:00
<section {...rest}>
2021-04-18 01:56:23 +02:00
{heading != null && (
<SectionHeading style={{ ...(description != null && { margin: 0 }) }}>
{heading}
</SectionHeading>
)}
{description != null && (
<p style={{ marginTop: 7 }} className='text-center'>
{description}
</p>
)}
<div className='px-3 w-full'>
<ShadowContainer>
<div className='px-16 py-4 leading-8 w-full'>{children}</div>
</ShadowContainer>
</div>
2021-04-18 01:56:23 +02:00
</section>
)
2021-06-15 20:35:52 +02:00
}