signalk-tides 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ /*! tailwindcss v4.1.3 | MIT License | https://tailwindcss.com */@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:rotateX(0);--tw-rotate-y:rotateY(0);--tw-rotate-z:rotateZ(0);--tw-skew-x:skewX(0);--tw-skew-y:skewY(0);--tw-font-weight:initial;--tw-tracking:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-black:#000;--color-white:#fff;--spacing:.25rem;--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-2xl:1.5rem;--text-2xl--line-height:calc(2/1.5);--font-weight-semibold:600;--tracking-tight:-.025em;--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4,0,.6,1)infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){-webkit-appearance:button;-moz-appearance:button;appearance:button}::file-selector-button{-webkit-appearance:button;-moz-appearance:button;appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.sr-only{clip:rect(0,0,0,0);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.fixed{position:fixed}.relative{position:relative}.static{position:static}.container{width:100%}@media (min-width:40rem){.container{max-width:40rem}}@media (min-width:48rem){.container{max-width:48rem}}@media (min-width:64rem){.container{max-width:64rem}}@media (min-width:80rem){.container{max-width:80rem}}@media (min-width:96rem){.container{max-width:96rem}}.m-0{margin:calc(var(--spacing)*0)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.block{display:block}.contents{display:contents}.flex{display:flex}.inline{display:inline}.size-5{width:calc(var(--spacing)*5);height:calc(var(--spacing)*5)}.size-20{width:calc(var(--spacing)*20);height:calc(var(--spacing)*20)}.h-screen{height:100vh}.flex-1{flex:1}.transform{transform:var(--tw-rotate-x)var(--tw-rotate-y)var(--tw-rotate-z)var(--tw-skew-x)var(--tw-skew-y)}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-center{justify-content:center}.gap-6{gap:calc(var(--spacing)*6)}.gap-8{gap:calc(var(--spacing)*8)}.bg-black\/20{background-color:#0003}@supports (color:color-mix(in lab,red,red)){.bg-black\/20{background-color:color-mix(in oklab,var(--color-black)20%,transparent)}}.fill-white\/60{fill:#fff9}@supports (color:color-mix(in lab,red,red)){.fill-white\/60{fill:color-mix(in oklab,var(--color-white)60%,transparent)}}.stroke-white\/70{stroke:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.stroke-white\/70{stroke:color-mix(in oklab,var(--color-white)70%,transparent)}}.p-6{padding:calc(var(--spacing)*6)}.px-6{padding-inline:calc(var(--spacing)*6)}.py-4{padding-block:calc(var(--spacing)*4)}.text-center{text-align:center}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-tight{--tw-tracking:var(--tracking-tight);letter-spacing:var(--tracking-tight)}.text-white{color:var(--color-white)}.text-white\/50{color:#ffffff80}@supports (color:color-mix(in lab,red,red)){.text-white\/50{color:color-mix(in oklab,var(--color-white)50%,transparent)}}.text-white\/70{color:#ffffffb3}@supports (color:color-mix(in lab,red,red)){.text-white\/70{color:color-mix(in oklab,var(--color-white)70%,transparent)}}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}@media (hover:hover){.hover\:stroke-white:hover{stroke:var(--color-white)}}@media (prefers-color-scheme:dark){.dark\:text-white\/20{color:#fff3}@supports (color:color-mix(in lab,red,red)){.dark\:text-white\/20{color:color-mix(in oklab,var(--color-white)20%,transparent)}}}}:root{color-scheme:dark;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-weight:400}html{background:linear-gradient(#024b66,#00141e)}body{min-height:100vh;margin:0}.TideChart{flex:1;width:100vw;overflow:auto hidden}.TideChart__Gradient--stop1{stop-color:#388fca80}.TideChart__Gradient--stop2{stop-color:#388fca00}.TideChart__Line{fill:none;stroke:#50beff;stroke-width:3px}.TideChart__DataPoint{fill:#024b66;stroke:#fff;stroke-width:3px}.TideChart__Text{fill:#ffffffe6;text-anchor:middle;font-weight:700}.TideChart__Text--High{alignment-baseline:hanging}.TideChart__Text--Low{alignment-baseline:bottom}.TideChart__Depth{opacity:.8}.TideChart__XAxis{opacity:.3}.TideChart__XAxis .tick{font-size:1rem;font-weight:600}.TideChart__LowWater{stroke:#ffffff40;stroke-width:3px;stroke-dasharray:1 6;stroke-linecap:round}.TideChart__Now{stroke:#b43232cc;stroke-linecap:round;stroke-width:4px}.Position{text-align:right;font-variant-numeric:tabular-nums;flex-direction:column;font-size:.9rem;display:inline-flex}.Position__Coordinate{flex-direction:row;justify-content:end;gap:.2rem;display:inline-flex}.Position__Direction{text-align:left;width:1.5rem}@property --tw-rotate-x{syntax:"*";inherits:false;initial-value:rotateX(0)}@property --tw-rotate-y{syntax:"*";inherits:false;initial-value:rotateY(0)}@property --tw-rotate-z{syntax:"*";inherits:false;initial-value:rotateZ(0)}@property --tw-skew-x{syntax:"*";inherits:false;initial-value:skewX(0)}@property --tw-skew-y{syntax:"*";inherits:false;initial-value:skewY(0)}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}}
@@ -6,11 +6,12 @@
6
6
  <link rel="icon" type="image/svg+xml" href="./assets/icon.svg" />
7
7
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
8
  <title>Tides</title>
9
+ <script type="module" crossorigin src="./assets/index-DhK0dKq8.js"></script>
10
+ <link rel="stylesheet" crossorigin href="./assets/index-b9CEyV9Z.css">
9
11
  </head>
10
12
 
11
13
  <body>
12
14
  <div id="app" class="h-screen text-white flex flex-col"></div>
13
- <script type="module" src="/app/main.tsx"></script>
14
15
  </body>
15
16
 
16
17
  </html>
package/app/App.css DELETED
@@ -1,103 +0,0 @@
1
- @import "tailwindcss";
2
-
3
- :root {
4
- color-scheme: dark;
5
- font-weight: 400;
6
- text-rendering: optimizeLegibility;
7
- -webkit-font-smoothing: antialiased;
8
- -moz-osx-font-smoothing: grayscale;
9
- }
10
-
11
- html {
12
- background: linear-gradient(rgb(2, 75, 102), rgb(0, 20, 30));
13
- }
14
-
15
- body {
16
- margin: 0;
17
- min-height: 100vh;
18
- }
19
-
20
- .TideChart {
21
- width: 100vw;
22
- overflow-x: auto;
23
- overflow-y: hidden;
24
- flex: 1;
25
- }
26
-
27
- .TideChart__Gradient--stop1 {
28
- stop-color: rgba(56, 143, 202, 0.5);
29
- }
30
- .TideChart__Gradient--stop2 {
31
- stop-color: rgba(56, 143, 202, 0);
32
- }
33
-
34
- .TideChart__Line {
35
- fill: none;
36
- stroke: rgba(80, 190, 255, 1);
37
- stroke-width: 3;
38
- }
39
-
40
- .TideChart__DataPoint {
41
- fill: rgb(2, 75, 102);
42
- stroke: white;
43
- stroke-width: 3;
44
- }
45
-
46
- .TideChart__Text {
47
- fill: rgba(255, 255, 255, 0.9);
48
- font-weight: bold;
49
- text-anchor: middle;
50
- }
51
-
52
- .TideChart__Text--High {
53
- alignment-baseline: hanging;
54
- }
55
- .TideChart__Text--Low {
56
- alignment-baseline: bottom;
57
- }
58
-
59
- .TideChart__Depth {
60
- opacity: 0.8;
61
- }
62
-
63
- .TideChart__XAxis {
64
- opacity: 0.3;
65
- }
66
-
67
- .TideChart__XAxis .tick {
68
- font-size: 1rem;
69
- font-weight: 600;
70
- }
71
-
72
- .TideChart__LowWater {
73
- stroke: rgba(255, 255, 255, 0.25);
74
- stroke-width: 3;
75
- stroke-dasharray: 1, 6;
76
- stroke-linecap: round;
77
- }
78
-
79
- .TideChart__Now {
80
- stroke: rgba(180, 50, 50, 0.8);
81
- stroke-linecap: round;
82
- stroke-width: 4;
83
- }
84
-
85
- .Position {
86
- font-size: 0.9rem;
87
- text-align: right;
88
- font-variant-numeric: tabular-nums;
89
- display: inline-flex;
90
- flex-direction: column;
91
- }
92
-
93
- .Position__Coordinate {
94
- display: inline-flex;
95
- flex-direction: row;
96
- justify-content: end;
97
- gap: 0.2rem;
98
- }
99
-
100
- .Position__Direction {
101
- width: 1.5rem;
102
- text-align: left;
103
- }
package/app/App.tsx DELETED
@@ -1,15 +0,0 @@
1
- import { StrictMode } from 'react'
2
- import './App.css'
3
- import { TidesView } from './views/TidesView'
4
- import { Footer } from './components/Footer'
5
-
6
- function App() {
7
- return (
8
- <StrictMode>
9
- <TidesView />
10
- <Footer />
11
- </StrictMode>
12
- )
13
- }
14
-
15
- export default App
@@ -1,8 +0,0 @@
1
- export function Footer() {
2
- return (
3
- <footer className="px-6 py-4 text-center text-sm text-white/50 bg-black/20">
4
- Made by
5
- <a className="decoration-none text-white/70" href="https://github.com/sponsors/bkeepers"> @bkeepers</a>
6
- </footer>
7
- )
8
- }
@@ -1,18 +0,0 @@
1
- import { Coordinate } from "../coordinate";
2
-
3
- export function Position({ latitude, longitude }: { latitude: number, longitude: number }) {
4
- const lat = Coordinate.lat(latitude);
5
- const lon = Coordinate.lon(longitude);
6
- return (
7
- <div className="Position">
8
- <div className="Position__Coordinate">
9
- <span>{lat.format('DD mm')}</span>
10
- <span className="Position__Direction">{lat.format('X')}</span>
11
- </div>
12
- <div className="Position__Coordinate">
13
- <span>{lon.format('DD mm')}</span>
14
- <span className="Position__Direction">{lon.format('X')}</span>
15
- </div>
16
- </div>
17
- );
18
- }
@@ -1,149 +0,0 @@
1
- import { useEffect, useRef, useState } from "react";
2
- import * as d3 from "d3";
3
- import { TideExtreme } from "../hooks/useTideData";
4
- import moment from "moment";
5
- import { useContainerDimensions } from "../hooks/useContainerDimensions";
6
-
7
- type TideChartProps = {
8
- width?: number;
9
- height?: number;
10
- marginTop?: number;
11
- marginRight?: number;
12
- marginBottom?: number;
13
- marginLeft?: number;
14
- units?: "m" | "ft";
15
- timeFormat?: string;
16
- data: TideExtreme[];
17
- };
18
-
19
- export function TideChart({
20
- data,
21
- marginTop = 20,
22
- marginRight = 6,
23
- marginBottom = 30,
24
- marginLeft = 6,
25
- units = "m",
26
- timeFormat = "HH:mm",
27
- }: TideChartProps) {
28
- const container = useRef<HTMLDivElement>(null);
29
- const now = useRef<SVGLineElement>(null);
30
- const { height = 0 } = useContainerDimensions(container) || {};
31
- const [width, setWidth] = useState(0)
32
- const gx = useRef<SVGGElement>(null);
33
- const x = useRef<d3.ScaleTime<number, number, never>>(null);
34
- const y = useRef<d3.ScaleLinear<number, number, never>>(null);
35
- const area = useRef<d3.Area<TideExtreme>>(null);
36
- const line = useRef<d3.Line<TideExtreme>>(null);
37
- const textPadding = 25;
38
- const yPadding = 0.3; // meters
39
-
40
- // Adjust width relative to height and number of forecasts
41
- useEffect(() => {
42
- setWidth(height / 4 * data.length)
43
- }, [height, data])
44
-
45
- function displayDepth(value: number) {
46
- return units === "m" ? `${value.toFixed(2)} m` : `${(value * 3.28084).toFixed(1)} ft`;
47
- }
48
-
49
- function displayTime(value: string) {
50
- return moment(value).format(timeFormat);
51
- }
52
-
53
- useEffect(() => {
54
- const [min = 0, max = 0] = d3.extent(data, d => new Date(d.time));
55
-
56
- x.current = d3.scaleTime()
57
- .domain([min, max])
58
- .range([marginLeft, width - marginRight]);
59
-
60
- const [yMin = 0, yMax = 0] = d3.extent(data, d => d.value)
61
- const yPad = (yMax - yMin) * .3;
62
-
63
- // Declare the y (vertical position) scale.
64
- y.current = d3.scaleLinear()
65
- .domain([yMin - yPad, yMax + yPad])
66
- .range([height - marginBottom, marginTop]);
67
-
68
- // Declare the area generator.
69
- area.current = d3.area<TideExtreme>()
70
- .curve(d3.curveMonotoneX)
71
- .x(d => x.current!(new Date(d.time)))
72
- .y0(y.current!(d3.min(data, d => d.value - yPadding) ?? 0))
73
- .y1(d => y.current!(d.value));
74
-
75
- line.current = d3.line<TideExtreme>()
76
- .curve(d3.curveMonotoneX)
77
- .x(d => x.current!(new Date(d.time)))
78
- .y(d => y.current!(d.value))
79
-
80
- if (gx.current) d3.select(gx.current).call(d3.axisBottom(x.current));
81
- }, [data, height, width, marginBottom, marginLeft, marginRight, marginTop])
82
-
83
- useEffect(() => {
84
- now.current?.scrollIntoView({ block: 'center', inline: 'center' })
85
- }, [data, now, width])
86
-
87
- return (
88
- <div className="TideChart" ref={container}>
89
- <svg width={width} height={height}>
90
- <defs>
91
- <linearGradient id="gradient" gradientTransform="rotate(90)">
92
- <stop className="TideChart__Gradient--stop1" offset="0" />
93
- <stop className="TideChart__Gradient--stop2" offset="100%" />
94
- </linearGradient>
95
- </defs>
96
- <g className="TideChart__XAxis" ref={gx} transform={`translate(0,${height - marginBottom})`} />
97
-
98
- <line
99
- className="TideChart__LowWater"
100
- x1={marginLeft}
101
- x2={width - marginRight}
102
- y1={y.current?.(0)}
103
- y2={y.current?.(0)}
104
- />
105
-
106
- <path fill="url(#gradient)" d={area.current?.(data) || ''} />
107
- <path className="TideChart__Line" d={line.current?.(data) || ''} />
108
-
109
- <line
110
- ref={now}
111
- className="TideChart__Now"
112
- x1={x.current?.(new Date())}
113
- x2={x.current?.(new Date())}
114
- y1={marginTop}
115
- y2={height - marginTop}
116
- />
117
-
118
- <g>
119
- {
120
- data.map((d, i) => (
121
- <g key={i}>
122
- <circle
123
- className="TideChart__DataPoint"
124
- cx={x.current?.(new Date(d.time))}
125
- cy={y.current?.(d.value)}
126
- r={5}
127
- />
128
- {
129
- (i !== 0 && i !== data.length - 1) &&
130
- <text
131
- className={["TideChart__Text", `TideChart__Text--${d.type}`].join(" ")}
132
- y={d.type === "High" ? marginTop + textPadding : height - marginBottom - textPadding}
133
- >
134
- <tspan className="TideChart__Depth" x={x.current?.(new Date(d.time))} dy={d.type === "High" ? "1.5em" : "-1.5em"}>
135
- {displayDepth(d.value)}
136
- </tspan>
137
- <tspan className="TideChart__Time" x={x.current?.(new Date(d.time))} dy={d.type === "High" ? "-1.5em" : "1.5em"}>
138
- {displayTime(d.time)}
139
- </tspan>
140
- </text>
141
- }
142
- </g>
143
- ))
144
- }
145
- </g>
146
- </svg>
147
- </div>
148
- );
149
- }
package/app/coordinate.ts DELETED
@@ -1,62 +0,0 @@
1
- export type CoordinateFormatOptions = {
2
- precision: number,
3
- units: { degrees: string, minutes: string, seconds: string }
4
- }
5
-
6
- // Adapted from https://github.com/nerik/formatcoords
7
- export class Coordinate {
8
- static lat(value: number) {
9
- return new Coordinate(value, ['N', 'S']);
10
- }
11
-
12
- static lon(value: number) {
13
- return new Coordinate(value, ['E', 'W']);
14
- }
15
-
16
- constructor(public value: number, public directions: [string, string]) {
17
- }
18
-
19
- get degrees() {
20
- return Math.abs(this.value);
21
- }
22
-
23
- get minutes() {
24
- return (this.degrees % 1) * 60;
25
- }
26
-
27
- get seconds() {
28
- return (this.minutes % 1) * 60;
29
- }
30
-
31
- get direction() {
32
- return this.directions[this.value > 0 ? 0 : 1];
33
- }
34
-
35
- format(format: string, options?: CoordinateFormatOptions) {
36
- if (isNaN(this.value)) return;
37
-
38
- const {
39
- precision = 3,
40
- units = { degrees: '°', minutes: '′', seconds: '″' }
41
- } = options ?? {};
42
-
43
- const formats: [RegExp, () => string][] = [
44
- [/DD/g, () => [Math.floor(this.degrees), units.degrees].join('')],
45
- [/dd/g, () => [this.degrees.toFixed(precision), units.degrees].join('')],
46
- [/D/g, () => Math.floor(this.degrees).toString()],
47
- [/d/g, () => this.degrees.toFixed(precision)],
48
- [/MM/g, () => [Math.floor(this.minutes), units.minutes].join('')],
49
- [/mm/g, () => [this.minutes.toFixed(precision), units.minutes].join('')],
50
- [/M/g, () => Math.floor(this.minutes).toString()],
51
- [/m/g, () => this.minutes.toFixed(precision)],
52
- [/ss/g, () => [this.seconds.toFixed(precision), units.seconds].join('')],
53
- [/s/g, () => this.seconds.toFixed(precision)],
54
- [/-/g, () => this.value < 0 ? '-' : ''],
55
- [/X/g, () => this.direction],
56
- ]
57
-
58
- return formats.reduce((result, [regex, replacer]) => {
59
- return result.replace(regex, replacer);
60
- }, format);
61
- }
62
- }
@@ -1,13 +0,0 @@
1
- import { RefObject, useLayoutEffect, useState } from "react";
2
- import useResizeObserver from '@react-hook/resize-observer'
3
-
4
- export function useContainerDimensions<T extends HTMLElement | null>(ref: RefObject<T>) {
5
- const [size, setSize] = useState<DOMRect>()
6
-
7
- useLayoutEffect(() => {
8
- setSize(ref.current?.getBoundingClientRect())
9
- }, [ref])
10
-
11
- useResizeObserver(ref, (entry) => setSize(entry.contentRect))
12
- return size
13
- }
@@ -1,21 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- import { TideForecastResult, TideExtreme } from "../../src/types";
3
-
4
- const { VITE_SIGNALK_URL = window.location.toString() } = import.meta.env;
5
- export const API_URL = new URL("/signalk/v2/api/resources/tides", VITE_SIGNALK_URL).toString();
6
- export const SETTINGS_URL = new URL("/#/serverConfiguration/plugins/tides", VITE_SIGNALK_URL).toString();
7
-
8
- export type { TideForecastResult, TideExtreme }
9
-
10
- export function useTideData() {
11
- const [data, setData] = useState<TideForecastResult>()
12
-
13
- useEffect(() => {
14
- (async () => {
15
- const res = await fetch(API_URL)
16
- setData(await res.json())
17
- })()
18
- }, []);
19
-
20
- return data;
21
- }
package/app/main.tsx DELETED
@@ -1,9 +0,0 @@
1
- import { StrictMode } from 'react'
2
- import { createRoot } from 'react-dom/client'
3
- import App from './App.tsx'
4
-
5
- createRoot(document.getElementById('app')!).render(
6
- <StrictMode>
7
- <App />
8
- </StrictMode>,
9
- )
@@ -1,44 +0,0 @@
1
- import { SETTINGS_URL, useTideData } from "../hooks/useTideData";
2
- import { Position } from '../components/Position';
3
- import { TideChart } from '../components/TideChart'
4
-
5
- export function TidesView() {
6
- const data = useTideData();
7
-
8
- return (
9
- <>
10
- <header className="p-6 mb-8 flex gap-8">
11
- <div className="flex-1">
12
- <h1 className="text-2xl font-semibold tracking-tight m-0 flex-1">{data?.station?.name}</h1>
13
- {data?.station?.position && <Position {...data?.station?.position} />}
14
- </div>
15
- <div>
16
- <a href={SETTINGS_URL}>
17
- <svg className="size-5 stroke-white/70 hover:stroke-white transition-colors" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" strokeWidth={1.5}>
18
- <path strokeLinecap="round" strokeLinejoin="round" d="M10.343 3.94c.09-.542.56-.94 1.11-.94h1.093c.55 0 1.02.398 1.11.94l.149.894c.07.424.384.764.78.93.398.164.855.142 1.205-.108l.737-.527a1.125 1.125 0 0 1 1.45.12l.773.774c.39.389.44 1.002.12 1.45l-.527.737c-.25.35-.272.806-.107 1.204.165.397.505.71.93.78l.893.15c.543.09.94.559.94 1.109v1.094c0 .55-.397 1.02-.94 1.11l-.894.149c-.424.07-.764.383-.929.78-.165.398-.143.854.107 1.204l.527.738c.32.447.269 1.06-.12 1.45l-.774.773a1.125 1.125 0 0 1-1.449.12l-.738-.527c-.35-.25-.806-.272-1.203-.107-.398.165-.71.505-.781.929l-.149.894c-.09.542-.56.94-1.11.94h-1.094c-.55 0-1.019-.398-1.11-.94l-.148-.894c-.071-.424-.384-.764-.781-.93-.398-.164-.854-.142-1.204.108l-.738.527c-.447.32-1.06.269-1.45-.12l-.773-.774a1.125 1.125 0 0 1-.12-1.45l.527-.737c.25-.35.272-.806.108-1.204-.165-.397-.506-.71-.93-.78l-.894-.15c-.542-.09-.94-.56-.94-1.109v-1.094c0-.55.398-1.02.94-1.11l.894-.149c.424-.07.765-.383.93-.78.165-.398.143-.854-.108-1.204l-.526-.738a1.125 1.125 0 0 1 .12-1.45l.773-.773a1.125 1.125 0 0 1 1.45-.12l.737.527c.35.25.807.272 1.204.107.397-.165.71-.505.78-.929l.15-.894Z" />
19
- <path strokeLinecap="round" strokeLinejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
20
- </svg>
21
- </a>
22
- </div>
23
- </header >
24
- {
25
- data?.extremes ?
26
- <TideChart data={data?.extremes ?? []
27
- } units="ft" timeFormat="h:mm a" /> :
28
- <LoadingTidesView />
29
- }
30
- </>
31
- )
32
- }
33
-
34
- export function LoadingTidesView() {
35
- return (
36
- <div className="flex-1 flex flex-col gap-6 items-center justify-center animate-pulse">
37
- <svg aria-hidden="true" className="size-20 animate-spin dark:text-white/20 fill-white/60" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
38
- <path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor" />
39
- <path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill" />
40
- </svg>
41
- <span className="sr-only">Loading...</span>
42
- </div>
43
- )
44
- }
package/app/vite-env.d.ts DELETED
@@ -1 +0,0 @@
1
- /// <reference types="vite/client" />
package/docs/icon.sketch DELETED
Binary file
package/eslint.config.js DELETED
@@ -1,28 +0,0 @@
1
- const js = require("@eslint/js");
2
- const globals = require("globals");
3
- const reactHooks = require("eslint-plugin-react-hooks");
4
- const reactRefresh = require("eslint-plugin-react-refresh");
5
- const tseslint = require("typescript-eslint");
6
-
7
- module.exports = tseslint.config(
8
- { ignores: ["dist"] },
9
- {
10
- extends: [js.configs.recommended, ...tseslint.configs.recommended],
11
- files: ["**/*.{ts,tsx}"],
12
- languageOptions: {
13
- ecmaVersion: 2020,
14
- globals: globals.browser,
15
- },
16
- plugins: {
17
- "react-hooks": reactHooks,
18
- "react-refresh": reactRefresh,
19
- },
20
- rules: {
21
- ...reactHooks.configs.recommended.rules,
22
- "react-refresh/only-export-components": [
23
- "warn",
24
- { allowConstantExport: true },
25
- ],
26
- },
27
- }
28
- );