|
1 |
| -import { useState, useEffect } from "react"; |
| 1 | +import { ReactNode, useEffect, useState } from 'react'; |
2 | 2 |
|
3 |
| -// next.js components |
4 |
| -import Image from "next/image"; |
5 |
| -import Link from "next/link"; |
| 3 | +type Props = { |
| 4 | + children: ReactNode; |
| 5 | + img: string; |
| 6 | +}; |
6 | 7 |
|
7 |
| -// react-copy-to-clipboard components |
8 |
| -import { CopyToClipboard } from "react-copy-to-clipboard"; |
9 |
| - |
10 |
| -// @material-tailwind/react components |
11 |
| -import { |
12 |
| - Tabs, |
13 |
| - TabsHeader, |
14 |
| - Tab, |
15 |
| - Typography, |
16 |
| - Button, |
17 |
| - Tooltip, |
18 |
| -} from "@material-tailwind/react"; |
19 |
| - |
20 |
| -export default function Header() { |
21 |
| - const [version, setVersion] = useState("npm i @material-tailwind/react"); |
22 |
| - const [copied, setCopied] = useState(false); |
| 8 | +const Header: React.FC<Props> = ({ children, img }) => { |
| 9 | + const [image, setImage] = useState(''); |
23 | 10 |
|
24 | 11 | useEffect(() => {
|
25 |
| - setTimeout(() => { |
26 |
| - setCopied(false); |
27 |
| - }, 3000); |
28 |
| - }, [copied]); |
| 12 | + setImage(img); |
| 13 | + }, [img]); |
29 | 14 |
|
30 | 15 | return (
|
31 |
| - <div className="h-screen min-h-screen bg-[url('/img/bg-header.jpg')] bg-cover bg-center bg-no-repeat"> |
32 |
| - <div className="relative z-50 h-fit py-20 lg:py-32"> |
| 16 | + <div className={`h-screen min-h-screen bg-cover bg-center bg-no-repeat`} style={{backgroundImage: `url(${image})`}}> |
| 17 | + <div className="relative z-50 h-fit pt-32"> |
33 | 18 | <div className="container mx-auto px-4">
|
34 |
| - <div className="flex flex-wrap items-center justify-between"> |
35 |
| - <div className="mt-48 w-full px-4 md:w-8/12 lg:mt-4 lg:w-5/12"> |
36 |
| - <div className="w-full max-w-full sm:my-auto md:w-5/6 md:flex-none lg:w-1/2"> |
37 |
| - <Tabs value="react" className="mb-6"> |
38 |
| - <TabsHeader |
39 |
| - className="h-10 w-auto rounded-full border border-white/80 bg-white/80 shadow-2xl shadow-blue-gray-500/40 backdrop-blur-2xl backdrop-saturate-200" |
40 |
| - indicatorProps={{ |
41 |
| - className: "rounded-full", |
42 |
| - }} |
43 |
| - > |
44 |
| - <Tab |
45 |
| - value="react" |
46 |
| - className="p-0 font-normal text-[#1A237E]" |
47 |
| - onClick={() => |
48 |
| - setVersion("npm i @material-tailwind/react") |
49 |
| - } |
50 |
| - > |
51 |
| - <i className="fab fa-react" /> |
52 |
| - React |
53 |
| - </Tab> |
54 |
| - <Tab |
55 |
| - value="html" |
56 |
| - className="p-0 font-normal text-[#1A237E]" |
57 |
| - onClick={() => |
58 |
| - setVersion("npm i @material-tailwind/html") |
59 |
| - } |
60 |
| - > |
61 |
| - <i className="fab fa-html5" /> |
62 |
| - HTML |
63 |
| - </Tab> |
64 |
| - </TabsHeader> |
65 |
| - </Tabs> |
66 |
| - </div> |
67 |
| - <Typography |
68 |
| - variant="h1" |
69 |
| - className="mb-2 font-black tracking-normal text-[#1A237E]" |
70 |
| - > |
71 |
| - Material Tailwind |
72 |
| - </Typography> |
73 |
| - <Typography className="mb-6 text-lg font-light text-[#1A237E] lg:pr-12"> |
74 |
| - Material Tailwind is an easy to use components library for |
75 |
| - Tailwind CSS and Material Design. |
76 |
| - </Typography> |
77 |
| - <div className="flex flex-col-reverse gap-2 lg:flex-row"> |
78 |
| - <Link |
79 |
| - href={ |
80 |
| - version === "npm i @material-tailwind/react" |
81 |
| - ? "/docs/react/installation" |
82 |
| - : "/docs/html/installation" |
83 |
| - } |
84 |
| - > |
85 |
| - <Button variant="gradient" className="h-full w-full"> |
86 |
| - Get Started |
87 |
| - </Button> |
88 |
| - </Link> |
89 |
| - <div className="flex rounded-lg border border-white/80 bg-white/80 py-2.5 px-5 text-[#1A237E] shadow-2xl shadow-blue-gray-500/20 backdrop-blur-2xl backdrop-saturate-200"> |
90 |
| - <CopyToClipboard |
91 |
| - text={version} |
92 |
| - onCopy={() => setCopied(true)} |
93 |
| - > |
94 |
| - <p className="mb-0 flex w-full items-center justify-between font-normal"> |
95 |
| - {version} |
96 |
| - <Tooltip |
97 |
| - content={copied ? "Copied" : "Copy"} |
98 |
| - interactive={false} |
99 |
| - > |
100 |
| - <i |
101 |
| - className={`${ |
102 |
| - copied ? "fas" : "far" |
103 |
| - } fa-copy ml-4 cursor-pointer text-sm`} |
104 |
| - /> |
105 |
| - </Tooltip> |
106 |
| - </p> |
107 |
| - </CopyToClipboard> |
108 |
| - </div> |
109 |
| - </div> |
110 |
| - </div> |
111 |
| - <div className="hidden w-full max-w-full px-4 pt-24 md:w-7/12 md:pt-0 lg:block"> |
112 |
| - <Image |
113 |
| - src="/img/components-header.png" |
114 |
| - alt="components" |
115 |
| - width={1000} |
116 |
| - height={700} |
117 |
| - quality={100} |
118 |
| - className="aspect-auto" |
119 |
| - /> |
120 |
| - </div> |
121 |
| - </div> |
| 19 | + {children} |
122 | 20 | </div>
|
123 | 21 | </div>
|
124 | 22 | </div>
|
125 | 23 | );
|
126 |
| -} |
| 24 | +}; |
| 25 | + |
| 26 | +export default Header; |
0 commit comments