Map Targeting Reticle
terrae/targeting-reticleFreeComponent
Military-style targeting brackets with tracking and lock-on capabilities.
Install it
npx shadcn@latest add https://www.terrae.dev/targeting-reticle.jsonSource
1"use client"23import { useEffect, useRef, useCallback, useState, type CSSProperties } from "react"4import { useMap } from "./hooks"5import type { MapCoordinates } from "./types"67const DEFAULT_SIZE = 1208const DEFAULT_BRACKET_LENGTH = 249const DEFAULT_BRACKET_THICKNESS = 210const DEFAULT_GAP = 811const DEFAULT_COLOR = "rgba(59, 130, 246, 0.9)"12const DEFAULT_LOCKED_COLOR = "rgba(34, 197, 94, 0.9)"13const DEFAULT_TRACKING_SPEED = 0.0214const DEFAULT_LOCKED_THICKNESS_MULTIPLIER = 2.515const DEFAULT_CROSSHAIR_LENGTH = 121617type MapTargetingReticleProps = {18 coordinates: MapCoordinates19 target?: MapCoordinates20 size?: number21 bracketLength?: number22 bracketThickness?: number23 gap?: number24 color?: string25 lockedColor?: string26 locked?: boolean27 trackingSpeed?: number28 showCrosshair?: boolean29 showCoordinates?: boolean30 onLocked?: () => void31}3233type Corner = "topLeft" | "topRight" | "bottomLeft" | "bottomRight"3435type CornerBracketProps = {36 corner: Corner37 bracketLength: number38 bracketThickness: number39 gap: number40 color: string41}4243const CornerBracket = ({ corner, bracketLength, bracketThickness, gap, color }: CornerBracketProps) => {44 const getPosition = (): CSSProperties => {45 switch (corner) {46 case "topLeft":47 return { top: gap, left: gap }48 case "topRight":49 return { top: gap, right: gap }50 case "bottomLeft":51 return { bottom: gap, left: gap }52 case "bottomRight":53 return { bottom: gap, right: gap }54 }55 }5657 const getTransform = (): string => {58 switch (corner) {59 case "topLeft":60 return "rotate(0deg)"61 case "topRight":62 return "rotate(90deg)"63 case "bottomLeft":64 return "rotate(-90deg)"65 case "bottomRight":66 return "rotate(180deg)"67 }68 }6970 const style: CSSProperties = {71 position: "absolute",72 width: bracketLength,73 height: bracketLength,74 ...getPosition(),75 }7677 return (78 <div style={style}>79 <svg80 width={bracketLength}81 height={bracketLength}82 viewBox={`0 0 ${bracketLength} ${bracketLength}`}83 style={{ transform: getTransform() }}84 >85 <path86 d={`M 0 ${bracketLength} L 0 0 L ${bracketLength} 0`}87 fill="none"88 stroke={color}89 strokeWidth={bracketThickness}90 strokeLinecap="square"91 />92 </svg>93 </div>94 )95}9697type CrosshairProps = {98 size: number99 color: string100 thickness: number101}102103// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from terrae
All 40 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Map Animated Circleanimated-circle | terrae | Components | Free | 1 dep | |
| Map Animated Footprintanimated-footprint | terrae | Components | Free | 2 deps | |
| Map Animated Polygonanimated-polygon | terrae | Components | Free | 1 dep | |
| Map Animated Pulseanimated-pulse | terrae | Components | Free | 1 dep | |
| Map Arc Animatedarc-animated | terrae | Components | Free | 1 dep | |
| Map Blur Areablur-area | terrae | Components | Free | 1 dep | |
| Map Camera Followcamera-follow | terrae | Components | Free | 1 dep | |
| Map Choroplethchoropleth | terrae | Components | Free | 1 dep |
