Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:NMRium react wrapper info #142

Merged
merged 5 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
dist
node_modules
public
src/*.json
build
src/*.json
vite.config.*
lib
5 changes: 5 additions & 0 deletions .github/workflows/dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Update version number
run: |
VERSION=${GITHUB_REF//*\/}
echo "export default { version: '$VERSION' };" > src/versionInfo.ts

# Setup gcloud CLI
- name: Setup CLI
uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn.lock


.eslintcache

.vscode

/test-results
/playwright-report
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
9,178 changes: 5,488 additions & 3,690 deletions package-lock.json

Large diffs are not rendered by default.

21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
"dependencies": {
"@emotion/react": "^11.11.1",
"filelist-utils": "^1.10.2",
"nmr-load-save": "^0.17.3",
"nmr-load-save": "^0.18.0",
"nmrium": "^0.43.1-pre.1692874523",
"react-science": "^0.26.2",
"vite-plugin-pwa": "^0.16.4"
},
"scripts": {
Expand All @@ -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",
Expand All @@ -35,28 +36,28 @@
"test-e2e-server": "serve -l tcp://localhost:3000 build"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.22.5",
"@babel/plugin-transform-modules-commonjs": "^7.22.11",
"@babel/preset-react": "^7.22.5",
"@babel/preset-typescript": "^7.22.5",
"@babel/preset-typescript": "^7.22.11",
"@playwright/test": "^1.37.1",
"@simbathesailor/use-what-changed": "^2.0.0",
"@types/jest": "^29.5.4",
"@types/node": "^20.5.3",
"@types/node": "^20.5.8",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"@types/react-router-dom": "^5.3.3",
"@vitejs/plugin-react-swc": "^3.3.2",
"cross-env": "^7.0.3",
"eslint": "^8.47.0",
"eslint": "^8.48.0",
"eslint-config-cheminfo-react": "^10.0.0",
"eslint-config-cheminfo-typescript": "^12.0.4",
"jest": "^29.6.3",
"prettier": "3.0.2",
"jest": "^29.6.4",
"prettier": "3.0.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.15.0",
"serve": "^14.2.1",
"typescript": "^5.1.6",
"typescript": "^5.2.2",
"vite": "^4.4.9"
}
}
}
20 changes: 12 additions & 8 deletions src/NMRiumWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
import events from './events';
import { useLoadSpectra } from './hooks/useLoadSpectra';
import { usePreferences } from './hooks/usePreferences';
import { useWhiteList } from './hooks/useWhiteList';

Check warning on line 7 in src/NMRiumWrapper.tsx

View workflow job for this annotation

GitHub Actions / lint / nodejs

There should be at least one empty line between import groups
import { RootLayout } from 'react-science/ui';

Check warning on line 8 in src/NMRiumWrapper.tsx

View workflow job for this annotation

GitHub Actions / lint / nodejs

There should be at least one empty line between import groups

Check warning on line 8 in src/NMRiumWrapper.tsx

View workflow job for this annotation

GitHub Actions / lint / nodejs

`react-science/ui` import should occur before import of `./events`
import AboutUsModal from './modal/AboutUsModal';

const styles: Record<'container' | 'loadingContainer', CSSProperties> = {
container: {
height: '100%',
width: '100%',
position: 'relative',
},

loadingContainer: {
Expand Down Expand Up @@ -102,13 +105,13 @@
});

return (
<div style={styles.container}>
{isLoading ||
(isFetchAllowedOriginsPending && (
<div style={styles.loadingContainer}>
<span>Loading .... </span>
</div>
))}
<RootLayout style={styles.container}>
{' '}
{isFetchAllowedOriginsPending && (
<div style={styles.loadingContainer}>
<span>Loading .... </span>
</div>
)}
<NMRium
ref={nmriumRef}
data={data}
Expand All @@ -117,7 +120,8 @@
workspace={workspace}
emptyText={defaultEmptyMessage}
/>
</div>
<AboutUsModal />
</RootLayout>
);
}

Expand Down
145 changes: 145 additions & 0 deletions src/modal/AboutUsModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
/** @jsxImportSource @emotion/react */
import { css } from '@emotion/react';
import { Modal, useOnOff } from 'react-science/ui';

Check warning on line 3 in src/modal/AboutUsModal.tsx

View workflow job for this annotation

GitHub Actions / lint / nodejs

There should be at least one empty line between import groups
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 (
<>
<InfoButton onClick={openDialog} />
<Modal
hasCloseButton
isOpen={isOpenDialog}
onRequestClose={closeDialog}
maxWidth={1000}
>
<div css={styles}>
<Modal.Header>
<div className="header">
<span>About NMRium react wrapper</span>
</div>
</Modal.Header>
<div className="container">
<span className="title"> NMRium react wrapper</span>
<Separator />
Version <VersionInfo />
<Separator />
<a href="https://git.nmrium.org" target="_blank" rel="noreferrer">
GitHub ( https://git.nmrium.org )
</a>
</div>
</div>
</Modal>
</>
);
}

export default AboutUsModal;

function VersionInfo() {
const { version } = versionInfo;
if (version === 'HEAD') {
return <>HEAD</>;
} else if (version.startsWith('git-')) {
return (
<a
href={`https://github.com/NFDI4Chem/nmrium-react-wrapper/tree/${version.slice(
4,
)}`}
target="_blank"
rel="noreferrer"
>
git-{version.slice(4, 14)}
</a>
);
} else {
return (
<a
href={`https://github.com/NFDI4Chem/nmrium-react-wrapper/tree/${version}`}
target="_blank"
rel="noreferrer"
>
{version}
</a>
);
}
}

function InfoButton({ onClick }) {
return (
<button
onClick={onClick}
type="button"
style={{
fontSize: '13px',
textAlign: 'center',
width: '25px',
height: '25px',
borderRadius: '25px',
border: '0.55px solid #ea580c',
left: '5px',
bottom: '10px',
position: 'absolute',
}}
>
&#9432;
</button>
);
}

function Separator() {
return (
<span
style={{
borderBottom: '1px solid gray',
width: '15px',
height: '1px',
margin: '10px 0',
}}
/>
);
}
1 change: 1 addition & 0 deletions src/versionInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default { version: 'HEAD' };
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
"noImplicitAny": false,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "ESNext",
"moduleResolution": "Node",
"module": "node16",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"jsx": "react-jsx"
},
"include": [
"src",
Expand Down
Loading
Loading