1
1
mirror of https://github.com/theoludwig/theoludwig.git synced 2024-09-19 22:15:53 +02:00
.profile/components/design/Section/index.tsx

67 lines
1.7 KiB
TypeScript
Raw Normal View History

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