File size: 609 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import clsx from 'clsx'
import { ReactNode } from 'react'
import { assignInlineVars } from '@vanilla-extract/dynamic'

import { container, heightVar, widthVar } from './AspectRatio.css'

interface AspectRatioProps {
  children: ReactNode
  className?: string
  width?: number
  height?: number
}

export const AspectRatio = ({
  children,
  width = 1,
  height = 1,
  className,
}: AspectRatioProps) => (
  <div
    className={clsx(container, className)}
    style={{
      ...assignInlineVars({
        [widthVar]: `${width}`,
        [heightVar]: `${height}`,
      }),
    }}
  >
    {children}
  </div>
)