Skip to content

Commit a64377d

Browse files
authored
open files
load load
2 parents f9d8d08 + ca0b3e5 commit a64377d

File tree

15 files changed

+586
-21
lines changed

15 files changed

+586
-21
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
[![npm version](https://img.shields.io/npm/v/@earthyscience/netcdf4-wasm.svg)](https://www.npmjs.com/package/@earthyscience/netcdf4-wasm)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/EarthyScience/netcdf4-wasm/blob/main/LICENSE)
5-
[![NetCDF4](https://img.shields.io/badge/NetCDF4-Compatible-4B8BBE)](https://www.unidata.ucar.edu/software/netcdf/)
5+
[![NetCDF4](https://img.shields.io/badge/NetCDF4-Compatible-008B8B)](https://www.unidata.ucar.edu/software/netcdf/)
66
[![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178c6)](https://www.typescriptlang.org/)
77
[![WebAssembly](https://img.shields.io/badge/WebAssembly-654FF0)](https://webassembly.org/)
8-
[![Emscripten](https://img.shields.io/badge/Emscripten-3.x-000000)](https://emscripten.org/)
8+
[![Emscripten](https://img.shields.io/badge/Emscripten-4.0.23-0000)](https://emscripten.org/)
99
[![Jest](https://img.shields.io/badge/Jest-29.x-C21325)](https://jestjs.io/)
1010
[![ts-jest](https://img.shields.io/badge/ts--jest-29.x-3178c6)](https://kulshekhar.github.io/ts-jest/)
1111

@@ -24,6 +24,10 @@
2424
- 🚀 High-performance WASM compilation
2525
- 📝 Complete TypeScript type definitions
2626

27+
28+
> [!TIP]
29+
> Want to do more? Plot, visualize, and explore your data at [browzarr.io](https://browzarr.io/)
30+
2731
## Installation
2832

2933
```bash

docs/next-js/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ yarn-error.log*
3939
# typescript
4040
*.tsbuildinfo
4141
next-env.d.ts
42+
*.wasm

docs/next-js/app/globals.css

Lines changed: 160 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,174 @@
11
@import "tailwindcss";
2+
@import "tw-animate-css";
23

34
:root {
4-
--background: #ffffff;
5-
--foreground: #171717;
5+
--radius: 0.625rem;
6+
7+
--background: oklch(1 0 0);
8+
--foreground: oklch(0.145 0 0);
9+
10+
--card: oklch(1 0 0);
11+
--card-foreground: oklch(0.145 0 0);
12+
13+
--popover: oklch(1 0 0);
14+
--popover-foreground: oklch(0.145 0 0);
15+
16+
--primary: oklch(0.205 0 0);
17+
--primary-foreground: oklch(0.985 0 0);
18+
19+
--secondary: oklch(0.97 0 0);
20+
--secondary-foreground: oklch(0.205 0 0);
21+
22+
--muted: oklch(0.97 0 0);
23+
--muted-foreground: oklch(0.556 0 0);
24+
25+
--accent: oklch(0.97 0 0);
26+
--accent-foreground: oklch(0.205 0 0);
27+
28+
--destructive: oklch(0.577 0.245 27.325);
29+
30+
--border: oklch(0.922 0 0);
31+
--input: oklch(0.922 0 0);
32+
--ring: oklch(0.708 0 0);
33+
34+
--chart-1: oklch(0.646 0.222 41.116);
35+
--chart-2: oklch(0.6 0.118 184.704);
36+
--chart-3: oklch(0.398 0.07 227.392);
37+
--chart-4: oklch(0.828 0.189 84.429);
38+
--chart-5: oklch(0.769 0.188 70.08);
39+
40+
--sidebar: oklch(0.985 0 0);
41+
--sidebar-foreground: oklch(0.145 0 0);
42+
--sidebar-primary: oklch(0.205 0 0);
43+
--sidebar-primary-foreground: oklch(0.985 0 0);
44+
--sidebar-accent: oklch(0.97 0 0);
45+
--sidebar-accent-foreground: oklch(0.205 0 0);
46+
--sidebar-border: oklch(0.922 0 0);
47+
--sidebar-ring: oklch(0.708 0 0);
48+
}
49+
50+
@media (prefers-color-scheme: dark) {
51+
:root {
52+
--background: rgb(29, 29, 29);
53+
--foreground: oklch(0.985 0 0);
54+
55+
--card: oklch(0.205 0 0);
56+
--card-foreground: oklch(0.985 0 0);
57+
58+
--popover: oklch(0.205 0 0);
59+
--popover-foreground: oklch(0.985 0 0);
60+
61+
--primary: oklch(0.922 0 0);
62+
--primary-foreground: oklch(0.205 0 0);
63+
64+
--secondary: oklch(0.269 0 0);
65+
--secondary-foreground: oklch(0.985 0 0);
66+
67+
--muted: oklch(0.269 0 0);
68+
--muted-foreground: oklch(0.708 0 0);
69+
70+
--accent: oklch(0.269 0 0);
71+
--accent-foreground: oklch(0.985 0 0);
72+
73+
--destructive: oklch(0.704 0.191 22.216);
74+
75+
--border: oklch(1 0 0 / 10%);
76+
--input: oklch(1 0 0 / 15%);
77+
--ring: oklch(0.556 0 0);
78+
79+
--chart-1: oklch(0.488 0.243 264.376);
80+
--chart-2: oklch(0.696 0.17 162.48);
81+
--chart-3: oklch(0.769 0.188 70.08);
82+
--chart-4: oklch(0.627 0.265 303.9);
83+
--chart-5: oklch(0.645 0.246 16.439);
84+
85+
--sidebar: oklch(0.205 0 0);
86+
--sidebar-foreground: oklch(0.985 0 0);
87+
--sidebar-primary: oklch(0.488 0.243 264.376);
88+
--sidebar-primary-foreground: oklch(0.985 0 0);
89+
--sidebar-accent: oklch(0.269 0 0);
90+
--sidebar-accent-foreground: oklch(0.985 0 0);
91+
--sidebar-border: oklch(1 0 0 / 10%);
92+
--sidebar-ring: oklch(0.556 0 0);
93+
}
94+
}
95+
96+
.dark {
97+
--background: rgb(29, 29, 29);
98+
--foreground: oklch(0.985 0 0);
99+
--card: oklch(0.205 0 0);
100+
--card-foreground: oklch(0.985 0 0);
101+
--popover: oklch(0.205 0 0);
102+
--popover-foreground: oklch(0.985 0 0);
103+
--primary: oklch(0.922 0 0);
104+
--primary-foreground: oklch(0.205 0 0);
105+
--secondary: oklch(0.269 0 0);
106+
--secondary-foreground: oklch(0.985 0 0);
107+
--muted: oklch(0.269 0 0);
108+
--muted-foreground: oklch(0.708 0 0);
109+
--accent: oklch(0.269 0 0);
110+
--accent-foreground: oklch(0.985 0 0);
111+
--destructive: oklch(0.704 0.191 22.216);
112+
--border: oklch(1 0 0 / 10%);
113+
--input: oklch(1 0 0 / 15%);
114+
--ring: oklch(0.556 0 0);
115+
--chart-1: oklch(0.488 0.243 264.376);
116+
--chart-2: oklch(0.696 0.17 162.48);
117+
--chart-3: oklch(0.769 0.188 70.08);
118+
--chart-4: oklch(0.627 0.265 303.9);
119+
--chart-5: oklch(0.645 0.246 16.439);
120+
--sidebar: oklch(0.205 0 0);
121+
--sidebar-foreground: oklch(0.985 0 0);
122+
--sidebar-primary: oklch(0.488 0.243 264.376);
123+
--sidebar-primary-foreground: oklch(0.985 0 0);
124+
--sidebar-accent: oklch(0.269 0 0);
125+
--sidebar-accent-foreground: oklch(0.985 0 0);
126+
--sidebar-border: oklch(1 0 0 / 10%);
127+
--sidebar-ring: oklch(0.556 0 0);
6128
}
7129

8130
@theme inline {
9131
--color-background: var(--background);
10132
--color-foreground: var(--foreground);
11133
--font-sans: var(--font-geist-sans);
12134
--font-mono: var(--font-geist-mono);
135+
--color-card: var(--card);
136+
--color-card-foreground: var(--card-foreground);
137+
--color-popover: var(--popover);
138+
--color-popover-foreground: var(--popover-foreground);
139+
--color-primary: var(--primary);
140+
--color-primary-foreground: var(--primary-foreground);
141+
--color-secondary: var(--secondary);
142+
--color-secondary-foreground: var(--secondary-foreground);
143+
--color-muted: var(--muted);
144+
--color-muted-foreground: var(--muted-foreground);
145+
--color-accent: var(--accent);
146+
--color-accent-foreground: var(--accent-foreground);
147+
--color-destructive: var(--destructive);
148+
--color-border: var(--border);
149+
--color-input: var(--input);
150+
--color-ring: var(--ring);
151+
--color-chart-1: var(--chart-1);
152+
--color-chart-2: var(--chart-2);
153+
--color-chart-3: var(--chart-3);
154+
--color-chart-4: var(--chart-4);
155+
--color-chart-5: var(--chart-5);
156+
--color-sidebar: var(--sidebar);
157+
--color-sidebar-foreground: var(--sidebar-foreground);
158+
--color-sidebar-primary: var(--sidebar-primary);
159+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
160+
--color-sidebar-accent: var(--sidebar-accent);
161+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
162+
--color-sidebar-border: var(--sidebar-border);
163+
--color-sidebar-ring: var(--sidebar-ring);
13164
}
14165

15-
@media (prefers-color-scheme: dark) {
16-
:root {
17-
--background: #0a0a0a;
18-
--foreground: #ededed;
166+
@layer base {
167+
* {
168+
@apply border-border outline-ring/50;
19169
}
20-
}
21170

22-
body {
23-
background: var(--background);
24-
color: var(--foreground);
25-
font-family: Arial, Helvetica, sans-serif;
26-
}
171+
body {
172+
@apply bg-background text-foreground font-sans;
173+
}
174+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import fs from 'fs';
2+
import path from 'path';
3+
4+
const src = 'node_modules/@earthyscience/netcdf4-wasm/dist';
5+
const dest = 'public/';
6+
7+
fs.mkdirSync(dest, { recursive: true });
8+
9+
fs.readdirSync(src)
10+
.filter(f => f.endsWith('.wasm'))
11+
.forEach(f => {
12+
fs.copyFileSync(path.join(src, f), path.join(dest, f));
13+
console.log(`✓ ${f}`);
14+
});

docs/next-js/app/page.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Image from "next/image";
2+
import LocalNetCDFMeta from "../components/loading/LocalNetCDFMeta";
23

34
export default function Home() {
45
return (
@@ -23,12 +24,7 @@ export default function Home() {
2324
priority
2425
/>
2526
</div>
26-
27-
<div className="flex flex-col items-center gap-6 text-center">
28-
<h1 className="max-w-full text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
29-
Let&apos;s get started!
30-
</h1>
31-
</div>
27+
<LocalNetCDFMeta />
3228
</main>
3329
</div>
3430
);

docs/next-js/components.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "new-york",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "",
8+
"css": "app/globals.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"iconLibrary": "lucide",
14+
"aliases": {
15+
"components": "@/components",
16+
"utils": "@/lib/utils",
17+
"ui": "@/components/ui",
18+
"lib": "@/lib",
19+
"hooks": "@/hooks"
20+
},
21+
"registries": {}
22+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react';
2+
import Link from 'next/link';
3+
import { Button } from '@/components/ui/button';
4+
5+
interface BrowzarrCTAProps {
6+
message?: string;
7+
buttonText?: string;
8+
className?: string;
9+
}
10+
11+
export default function BrowzarrCTA({
12+
message = "Reading is just the beginning. Explore your data!",
13+
buttonText = "Try browzarr.io",
14+
className = ""
15+
}: BrowzarrCTAProps) {
16+
return (
17+
<div className={`flex flex-col items-center gap-3 p-4 ${className}`}>
18+
<p className="text-center text-sm text-gray-600 dark:text-gray-400">
19+
{message}
20+
</p>
21+
<Link
22+
aria-label="browzarr.io"
23+
href="https://browzarr.io/"
24+
target="_blank"
25+
rel="noopener noreferrer"
26+
>
27+
<Button
28+
size="sm"
29+
className="bg-gradient-to-tr from-pink-500 to-yellow-500 text-white shadow-lg hover:shadow-xl transition-shadow cursor-pointer"
30+
>
31+
{buttonText}
32+
</Button>
33+
</Link>
34+
</div>
35+
);
36+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
'use client';
2+
3+
import React, { ChangeEvent, useState } from 'react';
4+
import { Input } from '@/components/ui/input';
5+
import { Label } from '@/components/ui/label';
6+
import { MetaNetCDFAccordion } from './MetaNetCDFAccordion';
7+
import { NetCDF4 } from '@earthyscience/netcdf4-wasm';
8+
import BrowzarrCTA from './BrowzarrCTA';
9+
const LocalNetCDFMeta = () => {
10+
const [variables, setVariables] = useState<Record<string, unknown> | null>(null);
11+
const [attributes, setAttributes] = useState<Record<string, unknown> | null>(null);
12+
const [metadata, setMetadata] = useState<Record<string, unknown>[] | null>(null);
13+
14+
const handleFileSelect = async (
15+
event: ChangeEvent<HTMLInputElement>
16+
) => {
17+
const files = event.target.files;
18+
if (!files || files.length === 0) return;
19+
20+
const file = files[0];
21+
22+
try {
23+
const data = await NetCDF4.fromBlobLazy(file);
24+
25+
const [variables, attrs, metadata] = await Promise.all([
26+
data.getVariables(),
27+
data.getGlobalAttributes(),
28+
data.getFullMetadata(),
29+
]);
30+
31+
setVariables(variables);
32+
setAttributes(attrs);
33+
setMetadata(metadata);
34+
35+
} catch (error) {
36+
console.error('Error loading NetCDF file:', error);
37+
alert('Failed to load NetCDF file. Check console for details.');
38+
}
39+
};
40+
41+
return (
42+
<div className="grid w-full max-w-sm items-center gap-3 p-4 py-0">
43+
<Label
44+
htmlFor="netcdf-file"
45+
className="justify-self-center font-semibold"
46+
>
47+
NetCDF file
48+
</Label>
49+
50+
<Input
51+
id="netcdf-file"
52+
type="file"
53+
accept=".nc,.netcdf,.nc3,.nc4"
54+
onChange={handleFileSelect}
55+
className="cursor-pointer"
56+
/>
57+
58+
{variables && attributes && metadata && (
59+
<MetaNetCDFAccordion
60+
variables={variables}
61+
attributes={attributes}
62+
metadata={metadata}
63+
/>
64+
)
65+
}
66+
<BrowzarrCTA />
67+
68+
</div>
69+
);
70+
};
71+
72+
export default LocalNetCDFMeta;

0 commit comments

Comments
 (0)