-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
940 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function KickAllIcon({style}: {style?: React.CSSProperties}) { | ||
return <svg style={style} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18.97 18.35a3.076 3.076 0 0 1-3.42 3.4h-7.1a4.075 4.075 0 0 1-1.529-.25.75.75 0 1 1 .558-1.4 2.679 2.679 0 0 0 .971.146h7.1c1.363 0 1.92-.55 1.92-1.9a3.42 3.42 0 0 0-3.4-3.7.748.748 0 0 1-.714-.783.768.768 0 0 1 .783-.715 4.872 4.872 0 0 1 4.831 5.202zm-12.67.407L2.53 22.53a.75.75 0 0 1-1.06-1.06l3.579-3.579a4.81 4.81 0 0 1 4.721-4.722l1.486-1.485a3.755 3.755 0 1 1 4.428-4.428l2.95-2.95a1.407 1.407 0 0 0-1.124-.556 1.345 1.345 0 0 0-.947.367.75.75 0 1 1-1.046-1.074 2.832 2.832 0 0 1 1.993-.793 2.9 2.9 0 0 1 2.184 1l1.776-1.78a.75.75 0 0 1 1.06 1.06L6.3 18.756zm6.55-8.667 1.24-1.24a2.29 2.29 0 0 0 .17-.84 2.255 2.255 0 1 0-2.25 2.25 2.29 2.29 0 0 0 .84-.17zm5.94-1.41h-.22a.75.75 0 0 0 0 1.5h.22a2.261 2.261 0 0 1 2.46 2.47c0 .864-.309 1.17-1.18 1.17h-.36a.75.75 0 0 0 0 1.5h.36a2.435 2.435 0 0 0 2.68-2.67 3.76 3.76 0 0 0-3.96-3.97zM5.922 8.035a.75.75 0 1 0 .3-1.471A1.421 1.421 0 0 1 6.51 3.75a1.386 1.386 0 0 1 .956.375.749.749 0 0 0 1.029-1.09A2.875 2.875 0 0 0 6.51 2.25a2.922 2.922 0 0 0-.588 5.785zM3.93 15.32h.35a.75.75 0 1 0 0-1.5h-.35c-.871 0-1.18-.306-1.18-1.17a2.261 2.261 0 0 1 2.46-2.47h.99a.75.75 0 0 0 0-1.5h-.99a3.726 3.726 0 0 0-3.96 3.97 2.435 2.435 0 0 0 2.68 2.67z"/></svg>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as React from "react" | ||
import * as TooltipPrimitive from "@radix-ui/react-tooltip" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const TooltipProvider = TooltipPrimitive.Provider | ||
|
||
const Tooltip = TooltipPrimitive.Root | ||
|
||
const TooltipTrigger = TooltipPrimitive.Trigger | ||
|
||
const TooltipContent = React.forwardRef< | ||
React.ElementRef<typeof TooltipPrimitive.Content>, | ||
React.ComponentPropsWithoutRef<typeof TooltipPrimitive.Content> | ||
>(({ className, sideOffset = 4, ...props }, ref) => ( | ||
<TooltipPrimitive.Content | ||
ref={ref} | ||
sideOffset={sideOffset} | ||
className={cn( | ||
"z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
TooltipContent.displayName = TooltipPrimitive.Content.displayName | ||
|
||
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import KickAllIcon from '@/components/KickAllIcon'; | ||
import { processInstantiatedAtom } from '@/hooks/socketio'; | ||
import { cn } from '@/lib/utils'; | ||
import { cva } from 'class-variance-authority'; | ||
import { useAtomValue } from 'jotai'; | ||
import { MegaphoneIcon, PowerIcon, PowerOffIcon, RotateCcwIcon } from 'lucide-react'; | ||
import { | ||
Tooltip, | ||
TooltipContent, | ||
TooltipProvider, | ||
TooltipTrigger, | ||
} from "@/components/ui/tooltip"; | ||
|
||
|
||
const tooltipDelay = 300; | ||
|
||
const controlButtonsVariants = cva( | ||
`h-10 sm:h-8 rounded-md transition-colors | ||
flex flex-grow items-center justify-center flex-shrink-0 | ||
border bg-muted shadow-md | ||
focus:outline-none disabled:pointer-events-none disabled:opacity-50 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`, | ||
{ | ||
variants: { | ||
type: { | ||
default: "hover:bg-primary hover:text-primary-foreground hover:border-primary", | ||
destructive: "hover:bg-destructive hover:text-destructive-foreground hover:border-destructive", | ||
warning: "hover:bg-warning hover:text-warning-foreground hover:border-warning", | ||
success: "hover:bg-success hover:text-success-foreground hover:border-success", | ||
info: "hover:bg-info hover:text-info-foreground hover:border-info", | ||
}, | ||
}, | ||
defaultVariants: { | ||
type: "default", | ||
}, | ||
} | ||
); | ||
|
||
export default function ServerControls({ isSheet }: { isSheet?: boolean }) { | ||
const processInstantiated = useAtomValue(processInstantiatedAtom); | ||
|
||
const handleStartStop = () => { | ||
alert('FIXME: Start/stop'); | ||
} | ||
const handleRestart = () => { | ||
if (!processInstantiated) return; | ||
alert('FIXME: Restart'); | ||
} | ||
const handleAnnounce = () => { | ||
if (!processInstantiated) return; | ||
alert('FIXME: Announce'); | ||
} | ||
const handleKickAll = () => { | ||
if (!processInstantiated) return; | ||
alert('FIXME: KickAll'); | ||
} | ||
|
||
return ( | ||
<TooltipProvider delayDuration={tooltipDelay} disableHoverableContent={true} > | ||
<div className="flex flex-row justify-between gap-2"> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
{processInstantiated | ||
? <button | ||
onClick={handleStartStop} | ||
className={cn(controlButtonsVariants({ type: 'destructive' }))} | ||
> | ||
<PowerOffIcon className='h-5' /> | ||
</button> | ||
: <div className="relative flex flex-grow h-8"> | ||
<div className='absolute inset-0 bg-success animate-pulse rounded blur-sm'></div> | ||
<button | ||
onClick={handleStartStop} | ||
className={cn(controlButtonsVariants({ type: 'success' }), 'relative')} | ||
> | ||
<PowerIcon className='h-5' /> | ||
</button> | ||
</div> | ||
} | ||
</TooltipTrigger> | ||
<TooltipContent className='max-w-md flex-wrap'> | ||
<p>{processInstantiated ? 'Stop the server' : 'Start the server! 🚀'}</p> | ||
</TooltipContent> | ||
</Tooltip> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<button | ||
onClick={handleRestart} | ||
className={cn(controlButtonsVariants({ type: 'warning' }))} | ||
disabled={!processInstantiated} | ||
> | ||
<RotateCcwIcon className='h-5' /> | ||
</button> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
<p>Restart Server</p> | ||
</TooltipContent> | ||
</Tooltip> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<button | ||
onClick={handleAnnounce} | ||
className={cn(controlButtonsVariants())} | ||
disabled={!processInstantiated} | ||
> | ||
<MegaphoneIcon className='h-5' /> | ||
</button> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
<p>Send Announcement</p> | ||
</TooltipContent> | ||
</Tooltip> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<button | ||
onClick={handleKickAll} | ||
className={controlButtonsVariants()} | ||
disabled={!processInstantiated} | ||
> | ||
<KickAllIcon style={{ height: '1.25rem', width: '1.5rem', fill: 'currentcolor' }} /> | ||
</button> | ||
</TooltipTrigger> | ||
<TooltipContent> | ||
<p>Kick All Players</p> | ||
</TooltipContent> | ||
</Tooltip> | ||
</div> | ||
</TooltipProvider> | ||
); | ||
} |
Oops, something went wrong.