Skip to content

Commit

Permalink
Merge branch 'release/v1.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
ja573 committed Sep 9, 2022
2 parents 7fc5c12 + be777ac commit a549af8
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 56 deletions.
38 changes: 17 additions & 21 deletions lib/geo-chart.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import React, { Component, Suspense } from 'react';
import React, { Component } from 'react';
import { Switch } from '@headlessui/react';
import urlPropType from 'url-prop-type';
import doiPropType from 'doi-prop-type';
import Spinner from './spinner';

const ContinentsChart = React.lazy(() => import('./continent-chart'));
const CountryChart = React.lazy(() => import('./country-chart'));
import ContinentsChart from './continent-chart';
import CountryChart from './country-chart';

export default class GeoChart extends Component {
constructor(props) {
Expand Down Expand Up @@ -64,22 +62,20 @@ export default class GeoChart extends Component {
</Switch>
</div>
<div className="h-5/6">
<Suspense fallback={Spinner}>
{tab === 'continent' && (
<ContinentsChart
apiEndpoint={apiEndpoint}
doi={doi}
showTitle={false}
/>
)}
{tab === 'country' && (
<CountryChart
apiEndpoint={apiEndpoint}
doi={doi}
showTitle={false}
/>
)}
</Suspense>
{tab === 'continent' && (
<ContinentsChart
apiEndpoint={apiEndpoint}
doi={doi}
showTitle={false}
/>
)}
{tab === 'country' && (
<CountryChart
apiEndpoint={apiEndpoint}
doi={doi}
showTitle={false}
/>
)}
</div>
</div>
);
Expand Down
62 changes: 29 additions & 33 deletions lib/widget.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Component, Suspense } from 'react';
import React, { Component } from 'react';
import urlPropType from 'url-prop-type';
import doiPropType from 'doi-prop-type';

Expand All @@ -9,12 +9,10 @@ import {
InformationCircleIcon,
ArrowTrendingUpIcon,
} from '@heroicons/react/24/outline';
import Spinner from './spinner';

const MeasuresGraph = React.lazy(() => import('./measures-graph'));
const TimelineChart = React.lazy(() => import('./timeline-chart'));
const GeoChart = React.lazy(() => import('./geo-chart'));
const Information = React.lazy(() => import('./information'));
import MeasuresGraph from './measures-graph';
import TimelineChart from './timeline-chart';
import GeoChart from './geo-chart';
import Information from './information';

export default class MetricsWidget extends Component {
constructor(props) {
Expand Down Expand Up @@ -73,32 +71,30 @@ export default class MetricsWidget extends Component {
</span>
</div>
<div className="p-2 h-96 w-full border-gray-200 dark:border-gray-400 border-t-2 border-b-2">
<Suspense fallback={Spinner}>
{tab === 'measures' && (
<MeasuresGraph
apiEndpoint={apiEndpoint}
doi={doi}
/>
)}
{tab === 'time' && (
<TimelineChart
apiEndpoint={apiEndpoint}
doi={doi}
/>
)}
{tab === 'geo' && (
<GeoChart
apiEndpoint={apiEndpoint}
doi={doi}
/>
)}
{tab === 'info' && (
<Information
apiEndpoint={apiEndpoint}
doi={doi}
/>
)}
</Suspense>
{tab === 'measures' && (
<MeasuresGraph
apiEndpoint={apiEndpoint}
doi={doi}
/>
)}
{tab === 'time' && (
<TimelineChart
apiEndpoint={apiEndpoint}
doi={doi}
/>
)}
{tab === 'geo' && (
<GeoChart
apiEndpoint={apiEndpoint}
doi={doi}
/>
)}
{tab === 'info' && (
<Information
apiEndpoint={apiEndpoint}
doi={doi}
/>
)}
</div>
<div className="flex bg-white dark:bg-gray-700">
<div className="flex-1 group">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metrics-widget",
"version": "1.8.2",
"version": "1.9.0",
"description": "Display book usage metrics",
"main": "./dist/index.js",
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = {
entry: './lib/index.js',
output: {
path: path.resolve('dist'),
publicPath: '/',
filename: 'index.js',
libraryTarget: 'umd',
globalObject: 'this'
Expand Down

0 comments on commit a549af8

Please sign in to comment.