ocearo-ui
Version:
Ocean Robot UI: 3D visualization dashboard for signalk
1 lines • 2.02 kB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,4875,e=>{"use strict";var t=e.i(43476),a=e.i(67561),s=e.i(46991),i=e.i(71645),l=e.i(85709);e.i(85269);var n=e.i(22831);let r={SOG:"navigation.speedOverGround",VMG:"performance.velocityMadeGood",STW:"navigation.speedThroughWater",POL:"performance.polarSpeedRatio"};e.s(["default",0,()=>{let{t:e}=(0,n.useTranslation)(),{nightMode:c}=(0,a.useOcearoContext)(),[o,d]=(0,i.useState)("SOG"),u=(0,i.useMemo)(()=>Object.values(r),[]),x=(0,l.useSignalKPaths)(u),h=(0,i.useMemo)(()=>{let e={};for(let[t,a]of Object.entries(r)){let i=x[a];null!=i&&(e[t]="POL"===t?100*i:(0,s.convertSpeedUnit)(i))}return e},[x]),m=Object.keys(h),p=void 0!==h[o]?o:m[0],g=h[p],v=(0,i.useCallback)(()=>{if(0===m.length)return;let e=(m.indexOf(p)+1)%m.length;d(m[e])},[m,p]);return 0===m.length?(0,t.jsxs)("div",{className:"mt-6 ml-2",children:[(0,t.jsx)("div",{className:"text-7xl font-black text-hud-dim tracking-tighter",children:"--"}),(0,t.jsx)("div",{className:"text-xs font-black uppercase tracking-[0.2em] text-hud-muted ml-1",children:e("common.na")})]}):(0,t.jsxs)("div",{className:"mt-6 ml-2 select-none group",children:[(0,t.jsx)("div",{className:`text-7xl font-black cursor-pointer tracking-tighter drop-shadow-2xl transition-all duration-300 group-hover:scale-105 active:scale-95 ${c?"text-oNight":"text-hud-main"}`,onClick:v,role:"button",tabIndex:0,"aria-label":`Current speed: ${g} ${p}. Click to change speed type.`,children:g?.toFixed(1)||"--"}),(0,t.jsxs)("div",{className:"flex items-center space-x-2 ml-1",children:[(0,t.jsx)("div",{className:`text-xs font-black uppercase tracking-[0.3em] ${c?"text-oNight":"text-hud-secondary"}`,children:p}),(0,t.jsx)("div",{className:"h-[2px] w-4 bg-oBlue/40 rounded-full"}),(0,t.jsx)("div",{className:`text-xs font-bold uppercase tracking-widest ${c?"text-oNight/60":"text-hud-muted"}`,children:"POL"===p?"%":(0,s.getSpeedUnitLabel)()})]})]})}])},56665,e=>{e.n(e.i(4875))}]);