-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathHeader.tsx
More file actions
64 lines (59 loc) · 1.84 KB
/
Header.tsx
File metadata and controls
64 lines (59 loc) · 1.84 KB
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
import { RefreshCcw, RefreshCwOffIcon } from 'lucide-react'
import { useTranslation } from 'react-i18next'
interface HeaderProps {
windowTitle?: string
windowIcon?: string
isLiveReloadEnabled: boolean
onLiveReloadToggle: (value: boolean) => void
}
export function Header({
windowTitle = 'index.html',
windowIcon = '',
isLiveReloadEnabled,
onLiveReloadToggle,
}: HeaderProps) {
const { t } = useTranslation()
const handleToggle = () => {
onLiveReloadToggle(!isLiveReloadEnabled)
}
return (
<header className="bg-zinc-100 w-full h-8 px-4 grid items-center relative">
<span className="text-sm text-zinc-400 justify-self-start flex items-center gap-2">
{windowIcon && (
<img
alt="window icon"
src={windowIcon}
className="w-[16px] h-[16px] object-cover object-center"
/>
)}
{windowTitle}
</span>
<label
title={t('preview.liveReloadTooltip')}
htmlFor="live-reload"
className={`hover:opacity-[1] flex gap-2 absolute right-3 top-2 items-center transition-opacity ${
isLiveReloadEnabled ? 'opacity-[0.4]' : 'opacity-[0.6]'
}`}
>
<span className={`text-xs flex-1 flex justify-end cursor-pointer ${
isLiveReloadEnabled ? 'text-zinc-500' : 'text-red-500'
}`}>
{t('preview.liveReload')}
</span>
{isLiveReloadEnabled ? (
<RefreshCcw className="size-3 text-zinc-600" />
) : (
<RefreshCwOffIcon className="size-3 text-red-500" />
)}
<input
type="checkbox"
id="live-reload"
aria-label={t('preview.liveReload')}
onChange={handleToggle}
checked={isLiveReloadEnabled}
className="absolute inset-0 opacity-0 cursor-pointer"
/>
</label>
</header>
)
}