File size: 2,238 Bytes
48c7837
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import { ReactNode } from "react"
import Image from "next/image"

import { DeviceFrameset } from "react-device-frameset"
import "react-device-frameset/styles/marvel-devices.min.css"

import { useOrientation } from "@/lib/hooks"
import { cn } from "@/lib/utils"

import HFLogo from "../../app/hf-logo.svg"

export function DeviceFrame({ children, companion, showFrame = false }: {
  children?: ReactNode
  companion?: ReactNode
  showFrame?: boolean
}) {

  const { isLandscape, isPortrait } = useOrientation()

  if (!showFrame) {
    return children
  }

  return (
    <div className={cn(`
      -mt-8 md:mt-0
      transition-all duration-200 ease-in-out
    `,
    isLandscape
      ? `scale-[0.9] md:scale-[0.75] lg:scale-[0.9] xl:scale-[1.0] 2xl:scale-[1.1]`
      : `scale-[0.8] md:scale-[0.9] lg:scale-[1.1]`
      )}>
      <DeviceFrameset
        device="Nexus 5"
        // color="black"

        landscape={isLandscape}

        // note 1: videos are generated in 1024x576 or 576x1024
        // so we need to keep the same ratio here

        // note 2: width and height are fixed, if width always stays 512
        // that's because the landscape={} parameter will do the switch for us

        width={288}
        height={512}
      >
        <div className="
        flex flex-col items-center justify-center
        w-full h-full
        bg-black text-white
        ">
          {children}
        </div>

        <div className={cn(`
          fixed
          flex flex-row items-center justify-center
          bg-transparent
          font-sans
          -mb-0
          `,
          isLandscape ? 'h-4' : 'h-14'
        )}
          style={{ width: isPortrait ? 288 : 512 }}>
          <span className="text-stone-100/50 text-4xs"
            style={{ textShadow: "rgb(0 0 0 / 80%) 0px 0px 2px" }}>
            Powered by
          </span>
          <span className="ml-1 mr-0.5">
            <Image src={HFLogo} alt="Hugging Face" width={14} height={13} />
          </span>
          <span className="text-stone-100/80 text-3xs font-semibold"
            style={{ textShadow: "rgb(0 0 0 / 80%) 0px 0px 2px" }}>Hugging Face</span>
    
        </div>
      </DeviceFrameset>
      
      {companion}
    </div>
  )
}