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

React component implementation #17

Merged
merged 53 commits into from
Sep 2, 2022

Conversation

Stukova
Copy link
Collaborator

@Stukova Stukova commented Jun 20, 2022

I would like to introduce the changes that add support to our project for building React components, as suggested in the issue #7. Further below I have described all the changes I have made.

The main change I've made is upgrading Webpack 4 to Webpack 5. Webpack 5 has better support for creating a library. Related changes:

I've also add new scripts for building React components library:

  • build-component / build-component:vosviewer script,
  • build-component:dimensions script,
  • build-component:zeta-alpha script,
  • build-component:rori script.

They build a component for each project in the lib folder and copy the package.json to the same place as well.
See copy-package-json.js Node script where package.json is created.

I've also add lib folder to a .gitignore list.

As for refactoring, I moved Helmet component from each App to the entry point for the Application. It creates a title for the page, that is no needed in the React component.
And added DATA_MAP, DATA_NETWORK and DATA_JSON string global variable. Papaparse, which is located inside Web Worker, will not upload local files. Local files will be downloaded from outside Web Worker using the require function. DATA_MAP, DATA_NETWORK and DATA_JSON are jsonConfig.parameters.map, jsonConfig.parameters.network and jsonConfig.parameters.json string values. I did this way, so require will get a global string variable. Require doesn't support an argument as a variable. (@rokotyan )
As a result of using require, I deleted from webpack.config.json copying of data files. Now all local data files are created as a separate module file.
Note! Because of require, config.json, config-zeta-alpha.json and config-dimensions.json does not support parameters.map, parameters.network and parameters.json as the URL value. @neesjanvaneck do you see a case where a file from a URL will be needed as an initial file for an Application or a React component?

I've updated, added or removed the following packages.
Updated:

  • "mobx": "^4.9.3" -> "^6.6.0"
  • "mobx-react-lite": "^1.4.1" -> "^3.4.0"
  • "@mui/material": "^5.2.6" -> "^5.8.4"
  • "@mui/icons-material": "^5.2.5" -> "^5.8.4"
  • "@babel/core": "^7.2.2" -> "^7.18.2"
  • "@babel/plugin-transform-regenerator": "^7.0.0" -> "^7.18.0"
  • "@babel/plugin-transform-runtime": "^7.2.0" -> "^7.18.2"
  • "@babel/preset-env": "^7.2.3" -> "^7.18.2"
  • "@mui/icons-material": "^5.2.5" -> "^5.8.4"
  • "babel-loader": "^8.0.5" -> "^8.2.5"
  • "webpack": "^4.28.4" -> "^5.73.0"
  • "webpack-cli": "^3.2.1" -> "^4.9.2"
  • "webpack-dev-server": "^3.1.14" -> "^4.9.2"

Added:

Removed:

  • Removed "@emotion/core". No needed: Global from "@emotion/core" -> injectGlobal from "@emotion/css".
  • Removed "@mui/styles" - legacy reason. Function withStyles that we are using from "@mui/styles" can be replaced with build-in Mui components sx property.
  • Removed "emotion". "Emotion" -> "@emotion/react", "@emotion/css", "@emotion/styled".
  • Removed "react-router-dom". Parameters from URL query string directly parsed from a window.location.search.
  • Removed "@babel/polyfill". Deprecated.
  • Removed "eslint-loader". Package has been deprecated.
  • Removed "file-loader", "raw-loader" and "url-loader". Webpack 5 has build-in asset modules.
  • Removed "worker-loader". Package has been deprecated.

I've also moved MobX, mobx-react-lite, React and ReactDOM to a peerDependencies. These packages must be in package.json for the React components as peerDependencies, but not sure if it is ok if they are in the main package.json as peerDependencies. (@rokotyan )

@rokotyan , could you please review the parts where I noticed you in the description.

@neesjanvaneck could you please review the React component library names.

Example of using the component:

import Dimensions from 'vosviewer-component-dimensions'

<Dimensions parameters={{ ... }} data={{ ... }} />

parameters prop include all parameters that was supported from a URL string query and data - an initial network data. parameters and data are optional props. data prop has the same type that has json data in the current state.

#7
- code refactoring,
- updating package dependencies,
- export and building React components.
@rokotyan
Copy link
Collaborator

@Stukova I think the main package.json shouldn't have peerDependencies so I would move them to dependencies there.

@Stukova
Copy link
Collaborator Author

Stukova commented Jun 24, 2022

@neesjanvaneck I have made some changes to the style of the React components so that they fit well into the page elements. I've fixed the placement of the control panel, interaction with the visualization and full screen mode.

Also added two new dependencies:

  • "react-full-screen" instead of our hard-coded version. This works well in the React component.
  • "react-resize-detector" instead of our hard-coded version. The package automatically detects changes in the size of React component element.

@Stukova
Copy link
Collaborator Author

Stukova commented Jun 24, 2022

I think the main package.json shouldn't have peerDependencies so I would move them to dependencies there.

@rokotyan @neesjanvaneck Done 85061b7.

@neesjanvaneck
Copy link
Owner

neesjanvaneck commented Jun 27, 2022

@neesjanvaneck I have made some changes to the style of the React components so that they fit well into the page elements. I've fixed the placement of the control panel, interaction with the visualization and full screen mode.

Thanks a lot for these fixes @Stukova! I found four other issues related to the style of the React components:

  1. The light/dark user interface setting is not limited to the part in which the VOSviewer Online component is loaded but applied to the entire window. See the first screenshot below.
  2. The cluster colors list and picker windows are not displayed correctly in the case of the component. See the second screenshot. (In the app it still looks fine. See the third screenshot.)
  3. The font in the component is different from the one in the app. It is desirable to use the same font in the component as the one used in the app.
  4. The VOSviewer logo doesn't look good in screenshots taken using the Screenshot icon button from the component. See the fourth image below. (In screenshots taken from the app this is not an issue.)

image

image

image

VOSviewer-screenshot (33)

@neesjanvaneck
Copy link
Owner

@Stukova Since the update of "mobx": "^4.9.3" -> "^6.6.0" (and "mobx-react-lite": "^1.4.1" -> "^3.4.0"), the following warnings appear in the console:

image

@Stukova Stukova force-pushed the feature/export-react-components branch from 9b8c688 to 7bc24e7 Compare July 15, 2022 10:17
@neesjanvaneck neesjanvaneck merged commit 4465905 into develop Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants