Frontend/src/components/AspectRatio.tsx
2022-08-30 15:31:23 +03:00

39 lines
698 B
TypeScript

import classNames from "classnames";
import React from "react";
export type Props = {
/**
* The style of component
*/
className?: string;
/**
* The optional child
*/
children?: React.ReactNode;
};
const AspectRatio = ({ className, children }: Props) => {
return (
<div
className={classNames(
"relative overflow-hidden pt-[55%] rounded w-full",
className
)}
>
{children}
</div>
);
};
AspectRatio.Content = function AspectRatioContent({
className,
children,
}: Props) {
return (
<div className={classNames([className, "absolute top-0 w-full h-full"])}>
{children}
</div>
);
};
export default AspectRatio;