PluginProbe
Extendify / 3.0.6
Extendify v3.0.6
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Assist / pages / parts / Header.jsx

Header.jsx in Extendify 3.0.6, at src/Assist/pages/parts/Header.jsx

61 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { Logo } from '@assist/svg';
2 import { useLayoutEffect, useState } from '@wordpress/element';
3 import { __ } from '@wordpress/i18n';
4 import classNames from 'classnames';
5 import { colord } from 'colord';
6
7 export const Header = () => {
8 const [contrastBg, setContrastBg] = useState();
9 const [focusColor, setFocusColor] = useState();
10
11 useLayoutEffect(() => {
12 const documentStyles = window.getComputedStyle(document.body);
13 const bannerMain = documentStyles.getPropertyValue('--ext-banner-main');
14 const b = colord(bannerMain || '#000000');
15 const contrast = b.isDark() ? b.lighten(0.1) : b.darken(0.1);
16 setContrastBg(contrast.toHex());
17 const focus = b.isDark() ? b.lighten(0.3) : b.darken(0.3);
18 setFocusColor(focus.toHex());
19 }, []);
20
21 return (
22 <header className="flex w-full border-b border-gray-400 bg-banner-main">
23 <div className="mx-auto mt-auto flex w-full max-w-[996px] flex-col px-4">
24 <div className="my-6 flex flex-wrap items-center justify-between gap-x-4 gap-y-6">
25 {window.extSharedData?.partnerLogo && (
26 <div className="flex h-10 max-w-52 overflow-hidden md:max-w-72">
27 <img
28 className="max-h-full max-w-full object-contain"
29 src={window.extSharedData.partnerLogo}
30 alt={window.extSharedData.partnerName}
31 />
32 </div>
33 )}
34 {!window.extSharedData?.partnerLogo && (
35 <Logo className="logo max-h-9 w-32 text-banner-text sm:w-40" />
36 )}
37 <div
38 id="assist-menu-bar"
39 className={classNames(
40 'flex-wrap items-center gap-4 lg:flex lg:w-auto',
41 )}
42 >
43 <a
44 style={{
45 borderColor: contrastBg,
46 '--tw-ring-color': focusColor,
47 '--ext-override': focusColor,
48 }}
49 className="block cursor-pointer rounded-xs border border-gray-500 bg-white px-4 py-2 text-center text-sm text-gray-900 no-underline transition-colors duration-200 hover:bg-gray-100 focus:outline-hidden focus:ring focus:ring-gray-900 focus:ring-offset-1 lg:inline-block lg:rounded-xs"
50 href={window.extSharedData.homeUrl}
51 target="_blank"
52 >
53 {__('View site', 'extendify-local')}
54 </a>
55 </div>
56 </div>
57 </div>
58 </header>
59 );
60 };
61