From bb5cc1c934881c178bf1dabf382f6463438e71b6 Mon Sep 17 00:00:00 2001 From: Kenny Daniel Date: Tue, 10 Dec 2024 20:50:49 -0800 Subject: [PATCH] Error bar close button --- apps/hyparquet-demo/package.json | 4 +- apps/hyparquet-demo/src/Layout.tsx | 26 +++++++++++- apps/hyparquet-demo/src/index.css | 41 +++++++++++++++++-- packages/cli/public/styles.css | 38 ++++++++++++++++- packages/components/package.json | 18 ++++---- packages/components/src/components/Layout.tsx | 26 +++++++++++- 6 files changed, 134 insertions(+), 19 deletions(-) diff --git a/apps/hyparquet-demo/package.json b/apps/hyparquet-demo/package.json index f3c2633..106f835 100644 --- a/apps/hyparquet-demo/package.json +++ b/apps/hyparquet-demo/package.json @@ -15,8 +15,8 @@ "dependencies": { "@hyparam/components": "0.1.10", "hightable": "0.7.2", - "hyparquet": "1.6.3", - "hyparquet-compressors": "0.1.4", + "hyparquet": "1.6.4", + "hyparquet-compressors": "1.0.0", "react": "18.3.1", "react-dom": "18.3.1" }, diff --git a/apps/hyparquet-demo/src/Layout.tsx b/apps/hyparquet-demo/src/Layout.tsx index 4bdc7e0..40b2bd9 100644 --- a/apps/hyparquet-demo/src/Layout.tsx +++ b/apps/hyparquet-demo/src/Layout.tsx @@ -1,5 +1,5 @@ import { cn } from '@hyparam/components' -import { ReactNode, useEffect } from 'react' +import { ReactNode, useEffect, useState } from 'react' interface LayoutProps { children: ReactNode @@ -20,9 +20,21 @@ interface LayoutProps { * @returns {ReactNode} */ export default function Layout({ children, className, progress, error }: LayoutProps): ReactNode { + const [showError, setShowError] = useState(false) const errorMessage = error?.toString() if (error) console.error(error) + // Reset error visibility when error prop changes + useEffect(() => { + if (error) { + setShowError(true) + console.error(error) + } else { + setShowError(false) + } + }, [error]) + + // Update title useEffect(() => { document.title = 'hyparquet demo - apache parquet file viewer online' }, []) @@ -32,7 +44,17 @@ export default function Layout({ children, className, progress, error }: LayoutP
{children}
-
{errorMessage}
+
+
+ {errorMessage} + +
+
{progress !== undefined && progress < 1 &&
diff --git a/apps/hyparquet-demo/src/index.css b/apps/hyparquet-demo/src/index.css index 04a8505..475b856 100644 --- a/apps/hyparquet-demo/src/index.css +++ b/apps/hyparquet-demo/src/index.css @@ -1,12 +1,11 @@ * { box-sizing: border-box; - font-family: 'Mulish', 'Helvetica Neue', Helvetica, Arial, sans-serif; margin: 0; padding: 0; } body { display: flex; - font-family: sans-serif; + font-family: 'Mulish', 'Helvetica Neue', Helvetica, Arial, sans-serif; height: 100vh; width: 100vw; } @@ -156,15 +155,51 @@ main, padding: 0; background-color: #dd111199; font-family: monospace; - overflow-y: auto; + overflow: hidden; transition: max-height 0.3s; white-space: pre-wrap; } .show-error { max-height: 30%; +} +.error-content { + display: flex; + align-items: center; + justify-content: space-between; + min-height: 100%; + overflow-y: auto; padding: 10px; } +/* error bar close button */ +.close-button, +.close-button:active, +.close-button:focus, +.close-button:focus-visible, +.close-button:hover { + background: none; + border: none; + border-radius: 4px; + padding: 0 8px; + cursor: pointer; + color: #333; + font-size: 30px; + display: flex; + align-items: center; + justify-content: center; + transition: background-color 0.2s; +} +button.close-button:active { + background-color: rgba(0, 0, 0, 0.2); +} +button.close-button:focus { + background-color: rgba(0, 0, 0, 0.1); + outline: 2px solid #a44; +} +button.close-button:hover { + background-color: rgba(0, 0, 0, 0.1); +} + .top-header { align-items: center; background: linear-gradient(to right, #353540, #24202b); diff --git a/packages/cli/public/styles.css b/packages/cli/public/styles.css index d50861f..40f1d9c 100644 --- a/packages/cli/public/styles.css +++ b/packages/cli/public/styles.css @@ -176,15 +176,51 @@ main { padding: 0; background-color: #dd111199; font-family: monospace; - overflow-y: auto; + overflow: hidden; transition: max-height 0.3s; white-space: pre-wrap; } .show-error { max-height: 30%; +} +.error-content { + display: flex; + align-items: center; + justify-content: space-between; + min-height: 100%; + overflow-y: auto; padding: 10px; } +/* error bar close button */ +.close-button, +.close-button:active, +.close-button:focus, +.close-button:focus-visible, +.close-button:hover { + background: none; + border: none; + border-radius: 4px; + padding: 0 8px; + cursor: pointer; + color: #333; + font-size: 30px; + display: flex; + align-items: center; + justify-content: center; + transition: background-color 0.2s; +} +button.close-button:active { + background-color: rgba(0, 0, 0, 0.2); +} +button.close-button:focus { + background-color: rgba(0, 0, 0, 0.1); + outline: 2px solid #a44; +} +button.close-button:hover { + background-color: rgba(0, 0, 0, 0.1); +} + /* file list */ .file-list { flex: 1; diff --git a/packages/components/package.json b/packages/components/package.json index 578f8a6..f898b71 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -40,8 +40,8 @@ }, "dependencies": { "hightable": "0.7.2", - "hyparquet": "1.6.3", - "hyparquet-compressors": "0.1.4" + "hyparquet": "1.6.4", + "hyparquet-compressors": "1.0.0" }, "peerDependencies": { "react": "^18.3.1", @@ -49,21 +49,21 @@ }, "devDependencies": { "@eslint/js": "9.16.0", - "@testing-library/react": "16.0.1", - "@types/node": "22.10.1", - "@types/react": "18.3.12", - "@types/react-dom": "18.3.1", + "@testing-library/react": "16.1.0", + "@types/node": "22.10.2", + "@types/react": "19.0.1", + "@types/react-dom": "19.0.2", "@vitejs/plugin-react": "4.3.4", "@vitest/coverage-v8": "2.1.8", "eslint": "9.16.0", "eslint-plugin-react": "7.37.2", - "eslint-plugin-react-hooks": "5.0.0", + "eslint-plugin-react-hooks": "5.1.0", "eslint-plugin-react-refresh": "0.4.16", "globals": "15.13.0", "jsdom": "25.0.1", "typescript": "5.7.2", - "typescript-eslint": "8.17.0", - "vite": "5.4.11", + "typescript-eslint": "8.18.0", + "vite": "6.0.3", "vitest": "2.1.8" } } diff --git a/packages/components/src/components/Layout.tsx b/packages/components/src/components/Layout.tsx index f9533c9..4c4dfc2 100644 --- a/packages/components/src/components/Layout.tsx +++ b/packages/components/src/components/Layout.tsx @@ -1,4 +1,4 @@ -import { ReactNode, useEffect } from 'react' +import { ReactNode, useEffect, useState } from 'react' import { cn } from '../lib/utils.js' interface LayoutProps { @@ -21,9 +21,21 @@ interface LayoutProps { * @param props.title - page title */ export default function Layout({ children, className, progress, error, title }: LayoutProps) { + const [showError, setShowError] = useState(false) const errorMessage = error?.toString() if (error) console.error(error) + // Reset error visibility when error prop changes + useEffect(() => { + if (error) { + setShowError(true) + console.error(error) + } else { + setShowError(false) + } + }, [error]) + + // Update title useEffect(() => { document.title = title ? `${title} - hyperparam` : 'hyperparam' }, [title]) @@ -34,7 +46,17 @@ export default function Layout({ children, className, progress, error, title }:
{children}
-
{errorMessage}
+
+
+ {errorMessage} + +
+
{progress !== undefined && progress < 1 &&