Merge pull request 'Aspect ratio component' (#121) from feature/aspect-ratio-component into develop
Reviewed-on: http://85.143.176.51:3000/free-land/front-end/pulls/121
This commit is contained in:
commit
8a64b5f0f7
38
src/components/AspectRatio.tsx
Normal file
38
src/components/AspectRatio.tsx
Normal file
@ -0,0 +1,38 @@
|
||||
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;
|
Loading…
x
Reference in New Issue
Block a user