From 57e9934f37fec697f2a1f973f653587466798e64 Mon Sep 17 00:00:00 2001 From: hamed musallam Date: Fri, 1 Sep 2023 13:31:36 +0200 Subject: [PATCH] feat: about 'NMRium wrapper' modal --- .vscode/settings.json | 1 + package-lock.json | 1 + package.json | 5 +- src/NMRiumWrapper.tsx | 20 +++-- src/modal/AboutUsModal.tsx | 145 +++++++++++++++++++++++++++++++++++++ src/versionInfo.ts | 1 + 6 files changed, 163 insertions(+), 10 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 src/modal/AboutUsModal.tsx create mode 100644 src/versionInfo.ts diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 86defa8..a2fcd1e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "filelist-utils": "^1.10.2", "nmr-load-save": "^0.17.3", "nmrium": "^0.43.1-pre.1692874523", + "react-science": "^0.26.2", "vite-plugin-pwa": "^0.16.4" }, "devDependencies": { diff --git a/package.json b/package.json index d790f9e..76a6cbe 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "filelist-utils": "^1.10.2", "nmr-load-save": "^0.17.3", "nmrium": "^0.43.1-pre.1692874523", + "react-science": "^0.26.2", "vite-plugin-pwa": "^0.16.4" }, "scripts": { @@ -25,7 +26,7 @@ "build": "cross-env NODE_OPTIONS=--max_old_space_size=4096 vite build --outDir build", "build-no-minify": "cross-env NO_MINIFY=true npm run build", "test": "jest --coverage", - "eslint": "eslint src/* ", + "eslint": "eslint . --cache", "eslint-fix": "npm run eslint -- --fix", "compile": "tsc --project tsconfig.esm.json && tsc --project tsconfig.cjs.json", "check-types": "tsc --project tsconfig.esm.json", @@ -59,4 +60,4 @@ "typescript": "^5.1.6", "vite": "^4.4.9" } -} +} \ No newline at end of file diff --git a/src/NMRiumWrapper.tsx b/src/NMRiumWrapper.tsx index 6e839c6..1a3706c 100644 --- a/src/NMRiumWrapper.tsx +++ b/src/NMRiumWrapper.tsx @@ -5,11 +5,14 @@ import events from './events'; import { useLoadSpectra } from './hooks/useLoadSpectra'; import { usePreferences } from './hooks/usePreferences'; import { useWhiteList } from './hooks/useWhiteList'; +import { RootLayout } from 'react-science/ui'; +import AboutUsModal from './modal/AboutUsModal'; const styles: Record<'container' | 'loadingContainer', CSSProperties> = { container: { height: '100%', width: '100%', + position: 'relative', }, loadingContainer: { @@ -102,13 +105,13 @@ export default function NMRiumWrapper() { }); return ( -
- {isLoading || - (isFetchAllowedOriginsPending && ( -
- Loading .... -
- ))} + + {' '} + {isFetchAllowedOriginsPending && ( +
+ Loading .... +
+ )} -
+ + ); } diff --git a/src/modal/AboutUsModal.tsx b/src/modal/AboutUsModal.tsx new file mode 100644 index 0000000..9515f1a --- /dev/null +++ b/src/modal/AboutUsModal.tsx @@ -0,0 +1,145 @@ +/** @jsxImportSource @emotion/react */ +import { css } from '@emotion/react'; +import { Modal, useOnOff } from 'react-science/ui'; +import versionInfo from '../versionInfo'; + +const styles = css` + width: 30vw; + min-width: 400px; + display: flex; + flex-direction: column; + user-select: none; + + button:focus { + outline: none; + } + + .container { + padding: 20px; + display: flex; + flex-direction: column; + align-items: center; + } + + span.title { + font-weight: bold; + color: #ea580c; + font-size: 2em; + } + + a { + color: #969696; + } + + a:hover, + a:focus { + color: #00bcd4; + } + + .header { + span { + color: #464646; + font-size: 15px; + flex: 1; + user-select: none; + } + } +`; + +function AboutUsModal() { + const [isOpenDialog, openDialog, closeDialog] = useOnOff(false); + return ( + <> + + +
+ +
+ About NMRium react wrapper +
+
+
+ NMRium react wrapper + + Version + + + GitHub ( https://git.nmrium.org ) + +
+
+
+ + ); +} + +export default AboutUsModal; + +function VersionInfo() { + const { version } = versionInfo; + if (version === 'HEAD') { + return <>HEAD; + } else if (version.startsWith('git-')) { + return ( + + git-{version.slice(4, 14)} + + ); + } else { + return ( + + {version} + + ); + } +} + +function InfoButton({ onClick }) { + return ( + + ); +} + +function Separator() { + return ( + + ); +} diff --git a/src/versionInfo.ts b/src/versionInfo.ts new file mode 100644 index 0000000..25b88ba --- /dev/null +++ b/src/versionInfo.ts @@ -0,0 +1 @@ +export default { version: 'HEAD' };