@genomicx/ui 0.1.0 → 0.2.0
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.
- package/README.md +285 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# @genomicx/ui
|
|
2
|
+
|
|
3
|
+
Shared UI components, design tokens, WASM loader, and utilities for [GenomicX](https://genomicx.org) browser-based bioinformatics tools.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @genomicx/ui
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies (install separately):
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install react react-dom react-router-dom react-hot-toast
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Setup
|
|
18
|
+
|
|
19
|
+
Import the CSS in your app's global stylesheet, **after** your Tailwind directives:
|
|
20
|
+
|
|
21
|
+
```css
|
|
22
|
+
@import "tailwindcss";
|
|
23
|
+
@import '@genomicx/ui/styles/tokens.css';
|
|
24
|
+
@import '@genomicx/ui/styles/components.css';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Init the theme on load (prevents flash of wrong theme):
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const saved = (localStorage.getItem('gx-theme') as 'light' | 'dark') || 'dark'
|
|
32
|
+
document.documentElement.setAttribute('data-theme', saved)
|
|
33
|
+
}, [])
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Components
|
|
37
|
+
|
|
38
|
+
### `NavBar`
|
|
39
|
+
|
|
40
|
+
Sticky top navigation with the GenomicX rings logo, theme toggle, and an About link.
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { NavBar } from '@genomicx/ui'
|
|
44
|
+
|
|
45
|
+
<NavBar
|
|
46
|
+
appName="MYAPP"
|
|
47
|
+
appSubtitle="What it does"
|
|
48
|
+
version="1.2.0"
|
|
49
|
+
/>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Props**
|
|
53
|
+
|
|
54
|
+
| Prop | Type | Default | Description |
|
|
55
|
+
|------|------|---------|-------------|
|
|
56
|
+
| `appName` | `string` | — | App name shown in header (uppercase recommended) |
|
|
57
|
+
| `appSubtitle` | `string` | — | Subtitle shown below app name |
|
|
58
|
+
| `version` | `string` | — | Version shown as `v1.0.0` badge |
|
|
59
|
+
| `actions` | `ReactNode` | — | Extra items in the desktop nav (right side) |
|
|
60
|
+
| `mobileActions` | `ReactNode` | — | Extra items in the mobile dropdown |
|
|
61
|
+
|
|
62
|
+
Tool-specific nav buttons (e.g. Save/Load Session) go in `actions`:
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
<NavBar
|
|
66
|
+
appName="BRIGX"
|
|
67
|
+
appSubtitle="Browser-based Ring Image Generator"
|
|
68
|
+
version={APP_VERSION}
|
|
69
|
+
actions={
|
|
70
|
+
<>
|
|
71
|
+
<button onClick={handleSave}>Save Session</button>
|
|
72
|
+
<label>Load Session<input type="file" onChange={handleLoad} /></label>
|
|
73
|
+
</>
|
|
74
|
+
}
|
|
75
|
+
/>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
### `AppFooter`
|
|
81
|
+
|
|
82
|
+
Standard footer with GenomicX branding and an optional bug report link.
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import { AppFooter } from '@genomicx/ui'
|
|
86
|
+
|
|
87
|
+
<AppFooter appName="MYAPP" />
|
|
88
|
+
<AppFooter appName="MYAPP" onReportBug={() => setShowBugReport(true)} />
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### `LogConsole`
|
|
94
|
+
|
|
95
|
+
Collapsible debug console for displaying WASM stderr/stdout.
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { LogConsole } from '@genomicx/ui'
|
|
99
|
+
|
|
100
|
+
<LogConsole logs={logLines} />
|
|
101
|
+
<LogConsole logs={logLines} progress="Running BLAST..." title="Debug Console" />
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
**Props**
|
|
105
|
+
|
|
106
|
+
| Prop | Type | Description |
|
|
107
|
+
|------|------|-------------|
|
|
108
|
+
| `logs` | `string[]` | Log lines to display |
|
|
109
|
+
| `progress` | `string` | Optional current progress message shown at top |
|
|
110
|
+
| `title` | `string` | Console title (default: `"Console"`) |
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
### `ThemeToggle`
|
|
115
|
+
|
|
116
|
+
Pill-style dark/light theme switcher. Already included in `NavBar` — use standalone only if building a custom nav.
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import { ThemeToggle } from '@genomicx/ui'
|
|
120
|
+
|
|
121
|
+
<ThemeToggle />
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### `AppShell`
|
|
127
|
+
|
|
128
|
+
Full-page layout wrapper (nav + main + footer).
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
import { AppShell } from '@genomicx/ui'
|
|
132
|
+
|
|
133
|
+
<AppShell appName="MYAPP" appSubtitle="What it does" version="0.1.0">
|
|
134
|
+
<YourContent />
|
|
135
|
+
</AppShell>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## WASM Loader
|
|
141
|
+
|
|
142
|
+
Canonical Emscripten loader for GenomicX WASM binaries hosted on `static.genomicx.org`.
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
import { createModuleInstance } from '@genomicx/ui'
|
|
146
|
+
|
|
147
|
+
// Loads mash.js + mash.wasm from static.genomicx.org/wasm/
|
|
148
|
+
const mod = await createModuleInstance('mash')
|
|
149
|
+
|
|
150
|
+
mod.FS.writeFile('/query.fa', fastaBytes)
|
|
151
|
+
mod.callMain(['dist', '/db.msh', '/query.fa'])
|
|
152
|
+
const output = mod._stdout.join('\n')
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Available binaries: `mash`, `blastall`, `formatdb`
|
|
156
|
+
|
|
157
|
+
**Low-level API** (custom base URL or caching control):
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
import { loadWasmModule } from '@genomicx/ui'
|
|
161
|
+
|
|
162
|
+
const { factory, wasmBinary } = await loadWasmModule('blastall', 'https://my-cdn.example.com/wasm')
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## Utilities
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
import { downloadBlob, downloadText, downloadBuffer } from '@genomicx/ui'
|
|
171
|
+
|
|
172
|
+
downloadText('results.tsv', tsvString)
|
|
173
|
+
downloadBuffer('output.fa', uint8Array, 'text/plain')
|
|
174
|
+
downloadBlob('report.json', new Blob([json], { type: 'application/json' }))
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## Design Tokens
|
|
180
|
+
|
|
181
|
+
All tokens are CSS custom properties on `:root` / `[data-theme]`. Key tokens:
|
|
182
|
+
|
|
183
|
+
| Token | Light | Dark | Usage |
|
|
184
|
+
|-------|-------|------|-------|
|
|
185
|
+
| `--gx-accent` | `#0d9488` | `#2dd4bf` | Primary accent (teal) |
|
|
186
|
+
| `--gx-bg` | `#f8fafc` | `#0d1117` | Page background |
|
|
187
|
+
| `--gx-bg-alt` | `#fff` | `#161b22` | Card/panel background |
|
|
188
|
+
| `--gx-text` | `#0f172a` | `#e6edf3` | Body text |
|
|
189
|
+
| `--gx-text-muted` | `#64748b` | `#8b949e` | Secondary text |
|
|
190
|
+
| `--gx-border` | `#e2e8f0` | `#30363d` | Borders |
|
|
191
|
+
| `--gx-gradient` | — | — | Accent gradient (button backgrounds) |
|
|
192
|
+
| `--gx-font-sans` | — | — | `Inter, system-ui, sans-serif` |
|
|
193
|
+
| `--gx-font-mono` | — | — | `JetBrains Mono, monospace` |
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Typical app scaffold
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
src/
|
|
201
|
+
main.tsx ← BrowserRouter + Toaster
|
|
202
|
+
App.tsx ← NavBar + Routes + AppFooter
|
|
203
|
+
index.css ← Tailwind + @genomicx/ui tokens + components
|
|
204
|
+
lib/version.ts ← export const APP_VERSION = '0.1.0'
|
|
205
|
+
pages/About.tsx
|
|
206
|
+
components/
|
|
207
|
+
[tool]/
|
|
208
|
+
pipeline.ts
|
|
209
|
+
types.ts
|
|
210
|
+
databases.ts
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
`index.css`:
|
|
214
|
+
```css
|
|
215
|
+
@import '@genomicx/ui/styles/tokens.css';
|
|
216
|
+
@import '@genomicx/ui/styles/components.css';
|
|
217
|
+
@import "tailwindcss";
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
`App.tsx`:
|
|
221
|
+
```tsx
|
|
222
|
+
import { NavBar, AppFooter, LogConsole } from '@genomicx/ui'
|
|
223
|
+
import { APP_VERSION } from './lib/version'
|
|
224
|
+
|
|
225
|
+
function App() {
|
|
226
|
+
useEffect(() => {
|
|
227
|
+
const theme = localStorage.getItem('gx-theme') as 'light' | 'dark' || 'dark'
|
|
228
|
+
document.documentElement.setAttribute('data-theme', theme)
|
|
229
|
+
}, [])
|
|
230
|
+
|
|
231
|
+
return (
|
|
232
|
+
<div className="app">
|
|
233
|
+
<NavBar appName="MYAPP" appSubtitle="What it does" version={APP_VERSION} />
|
|
234
|
+
<main className="app-main">
|
|
235
|
+
<Routes>
|
|
236
|
+
<Route path="/" element={<AnalysisPage />} />
|
|
237
|
+
<Route path="/about" element={<About />} />
|
|
238
|
+
</Routes>
|
|
239
|
+
</main>
|
|
240
|
+
<AppFooter appName="MYAPP" />
|
|
241
|
+
</div>
|
|
242
|
+
)
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
248
|
+
## Tools using this package
|
|
249
|
+
|
|
250
|
+
| Tool | Repo |
|
|
251
|
+
|------|------|
|
|
252
|
+
| BRIGx | [happykhan/brigx](https://github.com/happykhan/brigx) |
|
|
253
|
+
| MashX | [genomicx/mashx](https://github.com/genomicx/mashx) |
|
|
254
|
+
| Genetrax | [genomicx/genetrax](https://github.com/genomicx/genetrax) |
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## Development
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
git clone https://github.com/genomicx/ui
|
|
262
|
+
cd ui
|
|
263
|
+
npm install
|
|
264
|
+
npm run build # compile to dist/
|
|
265
|
+
npm run dev # watch mode
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
To test changes locally in a consuming app before publishing:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
# In this repo
|
|
272
|
+
npm link
|
|
273
|
+
|
|
274
|
+
# In the consuming app
|
|
275
|
+
npm link @genomicx/ui
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Publishing
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
npm run build
|
|
282
|
+
npm publish --access public
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Requires membership in the `@genomicx` npm org and an Automation token in `~/.npmrc`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genomicx/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Shared UI components, styles, and WASM loader for GenomicX tools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dev": "vite build --watch"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"react": "^18.0.0",
|
|
27
|
-
"react-dom": "^18.0.0",
|
|
26
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
27
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
28
28
|
"react-router-dom": "^6.0.0 || ^7.0.0",
|
|
29
29
|
"react-hot-toast": "^2.0.0"
|
|
30
30
|
},
|