-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zaydek Michels-Gualtieri
committed
Nov 3, 2020
1 parent
e55e932
commit f88e6ef
Showing
5 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from "react" | ||
|
||
interface AspectRatioProps extends React.ComponentProps<"div"> { | ||
aspectRatio: number | ||
children?: React.ReactNode | ||
} | ||
|
||
// Ex: | ||
// | ||
// <AspectRatio aspectRatio={16 / 9}> | ||
// {children} | ||
// </AspectRatio> | ||
// | ||
export default function AspectRatio({ aspectRatio, children, ...props }: AspectRatioProps) { | ||
return ( | ||
// prettier-ignore | ||
<div className="relative" style={{ paddingBottom: (1 / aspectRatio) * 100 + "%" }} {...props}> | ||
<div className="absolute y-0 x-0"> | ||
{children} | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from "./utils" | ||
export { default as AspectRatio } from "./AspectRatio" | ||
export { default as Sorcery } from "./Sorcery" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters