Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 1x | import { PropsWithChildren, ReactElement } from "react"; interface IGridProps { minWidthItem?: string; maxWidthItem?: string; marginTop?: string; marginBottom?: string; } export default function Grid({ children, minWidthItem = "190px", maxWidthItem = "1fr", marginTop = "20px", marginBottom = "0px", }: PropsWithChildren<IGridProps>): ReactElement { return ( <div> {children} <style jsx>{` div { display: grid; grid-template-columns: repeat( auto-fill, minmax(${minWidthItem}, ${maxWidthItem}) ); gap: 24px; justify-content: space-between; margin-top: ${marginTop}; margin-bottom: ${marginBottom}; grid-template-rows: auto; transition: 400ms ease-in; } div > :global(*) { width: 100%; } @media screen and (max-width: 768px) { div { column-gap: 8px; row-gap: 16px; } } @media (max-width: 420px) { div { grid-template-columns: repeat( auto-fill, minmax(calc(${minWidthItem} - 20px), 1fr) ); } } `}</style> </div> ); } |