11import { Fragment , useEffect , useState } from 'react' ;
22import { Disclosure , Menu , Popover , Transition } from '@headlessui/react' ;
3+ import { Dialog } from '@headlessui/react'
4+
35import {
46 Bars3Icon ,
57 XMarkIcon ,
@@ -18,11 +20,13 @@ import { faEllipsis, faSearch } from '@fortawesome/free-solid-svg-icons';
1820import { faBug , faLock , faUserSecret , faNetworkWired , faBrain , faTerminal } from '@fortawesome/free-solid-svg-icons' ;
1921
2022import 'reactjs-popup/dist/index.css' ;
23+ import Upgrade from './nav/Upgrade' ;
24+
2125import { useRouter } from 'next/router' ;
2226import { LogoAdmin } from './LogoAdmin' ;
2327import { CSSTransition } from 'react-transition-group' ;
24-
25-
28+ import SearchModal from './nav/SearchModal' ;
29+ import SpawnTerminal from './nav/SpawnTerminal' ;
2630function classNames ( ...classes ) {
2731 return classes . filter ( Boolean ) . join ( ' ' ) ;
2832}
@@ -39,13 +43,20 @@ const DEFAULT_NOTIFICATION = {
3943} ;
4044
4145export function StandardNav ( { guestAllowed, alignCenter = true } ) {
46+ const [ terminaIsOpen , setTerminalIsOpen ] = useState ( false ) ;
47+ const [ upgradeModalOpen , setUpgradeModalOpen ] = useState ( false ) ;
48+
49+
4250 const [ isAdmin , setIsAdmin ] = useState ( false ) ;
4351 const [ points , setPoints ] = useState ( '0' ) ;
4452 const [ notifications , setNotifications ] = useState ( [ ] ) ;
4553 const [ showBanner , setShowBanner ] = useState ( false ) ;
4654 const [ showSearchModal , setShowSearchModal ] = useState ( false ) ;
4755 const [ isPopoverOpen , setIsPopoverOpen ] = useState ( false ) ;
4856
57+ const [ open , setOpen ] = useState ( true )
58+
59+
4960 const router = useRouter ( ) ;
5061
5162 function logout ( ) {
@@ -213,7 +224,11 @@ export function StandardNav({ guestAllowed, alignCenter = true }) {
213224 < br > </ br >
214225 </ div >
215226 ) }
216- < Disclosure as = "nav" className = " shadow border-b border-white/10" >
227+
228+
229+
230+
231+ < Disclosure as = "nav" className = " shadow border-b border-neutral-800" >
217232 { ( { open } ) => (
218233 < >
219234 < div className = { `px-2 ${ alignCenter ? 'mx-auto' : '' } ` } >
@@ -257,12 +272,26 @@ export function StandardNav({ guestAllowed, alignCenter = true }) {
257272 </ Link >
258273 < Link
259274 href = '/leaderboards'
260- className = { linkClass ( '/leaderboards' ) }
275+ className = { linkClass ( '/leaderboards' ) + " hidden lg:inline-flex" }
261276 >
262277 Leaderboards
263278 </ Link >
279+ < Link
280+ href = '/create'
281+ className = { linkClass ( '/create' ) + " hidden md:hidden lg:hidden xl:hidden 2xl:inline-flex" }
282+ >
283+ Create
284+ </ Link >
285+
286+ < Link
287+ href = '/groups'
288+ className = { linkClass ( '/groups' ) + " hidden md:hidden lg:hidden xl:hidden 2xl:inline-flex" }
289+ >
290+ Classrooms
291+ </ Link >
292+
264293 { /* Ellipsis dropdown */ }
265- < Popover className = "relative" >
294+ < Popover className = "relative md:block lg:block xl:block 2xl:hidden " >
266295 { ( { open } ) => (
267296 < >
268297 < Popover . Button className = "inline-flex items-center p-2 text-gray-400 hover:text-white ring-none outline-none " >
@@ -305,17 +334,16 @@ export function StandardNav({ guestAllowed, alignCenter = true }) {
305334 </ Popover >
306335
307336 { /*search bar*/ }
308- < div className = "mt-3 ml-4 flex-grow " >
309-
310- < div
311- type = "text"
312- className = "w-full px-16 vertical-align flex py-2 text-sm font-semibold text-neutral-500 hover:text-neutral-50 placeholder-gray-300 bg-neutral-800 hover:cursor-pointer border border-transparent rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
313- onClick = { ( ) => setShowSearchModal ( true ) }
314- >
315- < FontAwesomeIcon icon = { faSearch } className = "w-3 h-3 mt-1.5 mr-1" /> Search for anything
316- </ div >
317-
318- </ div >
337+ < div className = "mt-3 ml-4 flex-grow" >
338+ < div
339+ type = "text"
340+ className = "w-full px-16 py-2 text-sm font-semibold text-neutral-500 hover:text-neutral-50 placeholder-gray-300 bg-neutral-800 hover:cursor-pointer border border-transparent rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent flex items-center"
341+ onClick = { ( ) => setShowSearchModal ( true ) }
342+ >
343+ < FontAwesomeIcon icon = { faSearch } className = "w-3 h-3 md:mt-1.5 mr-1" />
344+ < span className = "hidden md:inline" > Search for anything</ span >
345+ </ div >
346+ </ div >
319347 { /* <Link */ }
320348 { /* href={`${baseUrl}/live` } */ }
321349 { /* className="inline-flex items-center border-b-2 border-transparent px-4 pt-1 text-sm font-semibold text-gray-300 hover:text-gray-50 transition-all" */ }
@@ -341,8 +369,18 @@ export function StandardNav({ guestAllowed, alignCenter = true }) {
341369 </ div >
342370 { ! guestAllowed &&
343371 < div className = "flex items-center " >
344-
345- < div className = "mb-0 flex items-center space-x-2 rounded-lg px-4 py-1"
372+ < button className = 'bg-blue-600 hover:bg-blue-500 text-white px-2 py-1 text-sm rounded-md'
373+ onClick = { ( ) => setTerminalIsOpen ( true ) }
374+ > < i className = "fas fa-terminal" > </ i > Launch a machine</ button >
375+
376+ < button
377+ className = 'ml-4 bg-orange-600 hover:bg-orange-500 text-white px-2 py-1 text-sm rounded-md'
378+ onClick = { ( ) => setUpgradeModalOpen ( true ) }
379+ >
380+ < i className = "fas fa-crown" > </ i > Upgrade to Pro
381+ </ button >
382+
383+ < div className = "ml-2 mb-0 flex items-center space-x-2 rounded-lg px-4 py-1"
346384 style = { { backgroundColor : '#212121' , borderWidth : '0px' } }
347385 >
348386 < h1 className = "mx-auto mb-0 mt-0 text-center font-semibold text-blue-500" >
@@ -524,61 +562,11 @@ export function StandardNav({ guestAllowed, alignCenter = true }) {
524562 ) }
525563 </ Disclosure >
526564
527- { showSearchModal && (
528- < div
529- onEnter = { ( ) => setShowSearchModal ( true ) }
530-
531- >
532- < div
533- className = "fastanimate fixed inset-0 z-50 flex items-center justify-center bg-black bg-opacity-70 animate__animated animate__faster animate__fadeIn"
534- style = { {
535- backdropFilter : 'blur(2px)' ,
536- } }
537- onClick = { ( ) => setShowSearchModal ( false ) }
538- >
539- < div
540- className = "relative transform overflow-hidden rounded-lg bg-neutral-800 px-4 pb-4 pt-5 text-left shadow-xl transition-all sm:my-8 sm:w-full sm:p-6 sm:max-w-3xl sm:mx-auto sm:rounded-xl sm:shadow-2xl sm:ring-1 sm:ring-white/10"
541- onClick = { ( e ) => e . stopPropagation ( ) }
542- >
543- < div className = "px-4 py-5 sm:px-6 mx-auto" >
544- < div className = 'flex items-center mx-auto' >
545- < FontAwesomeIcon icon = { faSearch } className = "w-5 h-5 mr-1 text-white" />
546- < input placeholder = "Search for challenges, users, or competitions" className = 'w-full border-0 text-xl focus:ring-0 bg-transparent text-white' autoFocus > </ input >
547- </ div >
548- < h1 className = 'mt-10 text-xl text-white font-semibold mb-4' > Search by Category</ h1 >
549- < div className = "flex flex-wrap gap-2" >
550- < button className = "px-4 py-2 rounded bg-blue-500 bg-opacity-50 border border-blue-800 hover:brightness-110 text-white flex items-center gap-2" >
551- < FontAwesomeIcon icon = { faBug } className = 'w-4 h-4' />
552- < span > Web Exploitation</ span >
553- </ button >
554- < button className = "px-4 py-2 rounded bg-green-500 bg-opacity-50 border border-green-800 hover:brightness-110 text-white flex items-center gap-2" >
555- < FontAwesomeIcon icon = { faLock } className = 'w-4 h-4' />
556- < span > Cryptography</ span >
557- </ button >
558- < button className = "px-4 py-2 rounded bg-red-500 bg-opacity-50 border border-red-800 hover:brightness-110 text-white flex items-center gap-2" >
559- < FontAwesomeIcon icon = { faUserSecret } className = 'w-4 h-4' />
560- < span > Reverse Engineering</ span >
561- </ button >
562- < button className = "px-4 py-2 rounded bg-yellow-500 bg-opacity-50 border border-yellow-800 hover:brightness-110 text-white flex items-center gap-2" >
563- < FontAwesomeIcon icon = { faNetworkWired } className = 'w-4 h-4' />
564- < span > Networking</ span >
565- </ button >
566- < button className = "px-4 py-2 rounded bg-purple-500 bg-opacity-50 border border-purple-800 hover:brightness-110 text-white flex items-center gap-2" >
567- < FontAwesomeIcon icon = { faBrain } className = 'w-4 h-4' />
568- < span > Forensics</ span >
569- </ button >
570- < button className = "px-4 py-2 rounded bg-pink-500 bg-opacity-50 border border-pink-800 hover:brightness-110 text-white flex items-center gap-2" >
571- < FontAwesomeIcon icon = { faTerminal } className = 'w-4 h-4' />
572- < span > Binary Exploitation</ span >
573- </ button >
574- </ div >
575- </ div >
576- < div className = "px-4 py-5 sm:p-6" > { /* Content goes here */ } </ div >
577- </ div >
578- </ div >
579- </ div >
580- ) }
581565
566+ < SearchModal showSearchModal = { showSearchModal } setShowSearchModal = { setShowSearchModal } />
567+ < Upgrade open = { upgradeModalOpen } setOpen = { setUpgradeModalOpen } />
568+
569+
582570 { isAdmin && (
583571 < div className = "bg-neutral-800 py-1 text-center text-sm text-white " >
584572 < h1 > CTFGuide is running in development mode. </ h1 >
@@ -593,6 +581,9 @@ export function StandardNav({ guestAllowed, alignCenter = true }) {
593581 </ div >
594582 )
595583 }
584+
585+
586+ < SpawnTerminal open = { terminaIsOpen } setOpen = { setTerminalIsOpen } />
596587 </ >
597588 ) ;
598589}
0 commit comments