forked from aduros/wasm4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(site): incorrect cart layout in iOS devices aduros#85
- Loading branch information
1 parent
8584e99
commit b7a7e81
Showing
4 changed files
with
50 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import styles from './AspectRatio.module.css'; | ||
|
||
function processAspectRatioValue(value) { | ||
return Number.isFinite(value) && value >= 0 ? value : 1; | ||
} | ||
|
||
/** | ||
* @see https://stackoverflow.com/a/53245657 | ||
*/ | ||
export function AspectRatio({ | ||
width: widthRatio, | ||
height: heightRatio, | ||
children, | ||
className, | ||
...otherProps | ||
}) { | ||
const width = processAspectRatioValue(widthRatio); | ||
const height = processAspectRatioValue(heightRatio); | ||
|
||
return ( | ||
<div {...otherProps} className={clsx(className, styles.ratio)}> | ||
<svg className={styles.innerSvg} viewBox={`0 0 ${width} ${height}`}></svg> | ||
{children} | ||
</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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.ratio { | ||
display: grid; | ||
padding: 0; | ||
} | ||
|
||
.ratio > * { | ||
grid-area: 1/1; | ||
} | ||
|
||
.innerSvg { | ||
visibility: hidden; | ||
} |
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