@imerss/inat-components 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -13
- package/dist/index.d.ts +87 -75
- package/dist/index.js +261 -173
- package/dist/standalone.min.js +1 -1
- package/package.json +10 -12
- package/PUBLISH.md +0 -13
- package/declaration.d.ts +0 -2
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -20
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/public/standalone.html +0 -55
- package/rollup.config.js +0 -47
- package/src/__shared/api/common-taxa.ts +0 -57
- package/src/__shared/api/favourites.ts +0 -57
- package/src/__shared/api/index.ts +0 -4
- package/src/__shared/api/recent-observations.ts +0 -44
- package/src/__shared/api/summary.ts +0 -86
- package/src/__shared/constants.ts +0 -6
- package/src/__shared/index.ts +0 -4
- package/src/__shared/typings.ts +0 -83
- package/src/__shared/utils/configUtils.ts +0 -25
- package/src/__shared/utils/dateUtils.ts +0 -14
- package/src/__shared/utils/index.ts +0 -3
- package/src/__shared/utils/numberUtils.ts +0 -1
- package/src/components/common-taxa/__tests__/common-taxa.test.tsx +0 -14
- package/src/components/common-taxa/common-taxa.tsx +0 -73
- package/src/components/error/__tests__/error.test.tsx +0 -9
- package/src/components/error/error.module.scss +0 -7
- package/src/components/error/error.tsx +0 -15
- package/src/components/favourites/__tests__/favourites.test.tsx +0 -13
- package/src/components/favourites/favourites.tsx +0 -73
- package/src/components/hooks/hooks.tsx +0 -34
- package/src/components/loader/__tests__/loader.test.tsx +0 -10
- package/src/components/loader/loader.tsx +0 -26
- package/src/components/no-results/__tests__/no-results.test.tsx +0 -9
- package/src/components/no-results/no-results.tsx +0 -9
- package/src/components/observation/__tests__/observation.test.tsx +0 -14
- package/src/components/observation/observation.module.scss +0 -20
- package/src/components/observation/observation.tsx +0 -30
- package/src/components/recent-observations/__tests__/recent-observations.test.tsx +0 -9
- package/src/components/recent-observations/recent-observations.tsx +0 -84
- package/src/components/seasonality-graph/__tests__/seasonality-graph.test.tsx +0 -9
- package/src/components/seasonality-graph/seasonality-graph.module.scss +0 -7
- package/src/components/seasonality-graph/seasonality-graph.tsx +0 -46
- package/src/components/shared/css/general.module.scss +0 -73
- package/src/components/summary/ObserverList.tsx +0 -24
- package/src/components/summary/__tests__/summary.test.tsx +0 -18
- package/src/components/summary/summary.module.scss +0 -88
- package/src/components/summary/summary.tsx +0 -91
- package/src/components/tabs/__tests__/tabs.test.tsx +0 -16
- package/src/components/tabs/tabs.module.scss +0 -28
- package/src/components/tabs/tabs.tsx +0 -65
- package/src/components/taxon-panel/__tests__/taxon-panel.test.tsx +0 -10
- package/src/components/taxon-panel/taxon-panel.module.scss +0 -7
- package/src/components/taxon-panel/taxon-panel.tsx +0 -110
- package/src/components/year-dropdown/__tests__/year-dropdown.test.tsx +0 -14
- package/src/components/year-dropdown/year-dropdown.module.scss +0 -3
- package/src/components/year-dropdown/year-dropdown.tsx +0 -37
- package/src/hooks/useLoadSourceData.ts +0 -81
- package/src/index.ts +0 -15
- package/src/types/index.d.ts +0 -17
- package/src/types/standalone.d.ts +0 -6
- package/tsconfig.json +0 -6
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { numberWithCommas, C, CommonTaxData, getCommonTaxa, BaseComponentProps, GeneralClasses } from "../../__shared";
|
|
3
|
-
import { Observation } from "../observation/observation";
|
|
4
|
-
import Loader from "../loader/loader";
|
|
5
|
-
import { NoResults } from "../no-results/no-results";
|
|
6
|
-
import { useLoadSourceData } from "../../hooks/useLoadSourceData";
|
|
7
|
-
import styles from "../shared/css/general.module.scss";
|
|
8
|
-
|
|
9
|
-
export type CommonTaxaProps = BaseComponentProps & {
|
|
10
|
-
year: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const CommonTaxaLabel = (data: CommonTaxData & { classes: GeneralClasses }) => (
|
|
14
|
-
<div className={styles.obsLabel}>
|
|
15
|
-
<h3 className={data.classes?.observationLabelTitle}>{data.taxonCommonName || data.taxonName}</h3>
|
|
16
|
-
<label className={`${data.classes?.observationCount || ''} ${styles.count}`}>{numberWithCommas(data.obsCount)}</label>
|
|
17
|
-
</div>
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
export const CommonTaxa = ({
|
|
21
|
-
year,
|
|
22
|
-
source,
|
|
23
|
-
taxonId,
|
|
24
|
-
placeId,
|
|
25
|
-
numResults = C.NUM_RESULTS,
|
|
26
|
-
itemWidth = C.DEFAULT_ITEM_WIDTH,
|
|
27
|
-
dataUrl,
|
|
28
|
-
components,
|
|
29
|
-
generalClasses,
|
|
30
|
-
className,
|
|
31
|
-
tabDesc
|
|
32
|
-
}: CommonTaxaProps) => {
|
|
33
|
-
const { loading, results: taxa } = useLoadSourceData({
|
|
34
|
-
taxonId,
|
|
35
|
-
placeId,
|
|
36
|
-
numResults,
|
|
37
|
-
dataUrl,
|
|
38
|
-
source,
|
|
39
|
-
year,
|
|
40
|
-
action: getCommonTaxa
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const Load = components?.loader ? components.loader as any : Loader;
|
|
44
|
-
const Label = components?.label ? components.label as any : CommonTaxaLabel;
|
|
45
|
-
|
|
46
|
-
let elClasses = styles.panel;
|
|
47
|
-
if (className) {
|
|
48
|
-
elClasses += ` ${className}`;
|
|
49
|
-
}
|
|
50
|
-
let descClasses = styles.tabDesc;
|
|
51
|
-
if (generalClasses?.tabDesc) {
|
|
52
|
-
descClasses += ` ${generalClasses.tabDesc}`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<div className={elClasses}>
|
|
57
|
-
{tabDesc && <p className={descClasses}>{tabDesc}</p>}
|
|
58
|
-
<Load loading={loading}/>
|
|
59
|
-
{!loading && taxa.length === 0 && <NoResults/>}
|
|
60
|
-
<div className={styles.grid} style={{ gridTemplateColumns: `repeat(auto-fit, minmax(${itemWidth}px, 1fr))` }}>
|
|
61
|
-
{taxa.map((data: CommonTaxData) => (
|
|
62
|
-
<Observation
|
|
63
|
-
key={data.id}
|
|
64
|
-
imageUrl={data.imageUrl.replace(/square/, "medium")}
|
|
65
|
-
itemWidth={itemWidth}
|
|
66
|
-
linkUrl={`${C.BASE_URL}/${data.id}`}>
|
|
67
|
-
<Label {...data} classes={generalClasses} />
|
|
68
|
-
</Observation>
|
|
69
|
-
))}
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
)
|
|
73
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import styles from './error.module.scss';
|
|
2
|
-
|
|
3
|
-
/* eslint-disable-next-line */
|
|
4
|
-
export interface ErrorProps {
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const Error = (props: ErrorProps) => {
|
|
8
|
-
return (
|
|
9
|
-
<div className={styles['container']}>
|
|
10
|
-
<h1>Error!</h1>
|
|
11
|
-
</div>
|
|
12
|
-
);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export default Error;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import {render} from '@testing-library/react';
|
|
2
|
-
import {Favourites} from '../favourites';
|
|
3
|
-
|
|
4
|
-
const defaultProps = {
|
|
5
|
-
year: 2022
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
describe('Favourites', () => {
|
|
9
|
-
it('should render successfully', () => {
|
|
10
|
-
const {baseElement} = render(<Favourites {...defaultProps} />);
|
|
11
|
-
expect(baseElement).toBeTruthy();
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { formatDate, C, getFavourites, FavouritesData, BaseComponentProps, GeneralClasses } from "../../__shared";
|
|
3
|
-
import { Observation } from "../observation/observation";
|
|
4
|
-
import Loader from "../loader/loader";
|
|
5
|
-
import { NoResults } from "../no-results/no-results";
|
|
6
|
-
import { useLoadSourceData } from "../../hooks/useLoadSourceData";
|
|
7
|
-
import generalStyles from "../shared/css/general.module.scss";
|
|
8
|
-
|
|
9
|
-
export type FavouritesProps = BaseComponentProps & {
|
|
10
|
-
year: number | string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const FavouritesLabel = (data: FavouritesData & { classes: GeneralClasses }) => (
|
|
14
|
-
<div className={generalStyles.obsLabel}>
|
|
15
|
-
<h3 className={data.classes?.observationLabelTitle}>{data.taxonCommonName || data.taxonName}</h3>
|
|
16
|
-
<div className={data.classes?.observationLabelTitle}>{data.observerUsername}</div>
|
|
17
|
-
<div className={data.classes?.observationLabelDate}>{formatDate(data.obsDate)}</div>
|
|
18
|
-
<label className={`${data.classes?.observationCount || ''} ${generalStyles.count}`}>{data.numFaves}</label>
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
export const Favourites = ({
|
|
23
|
-
year,
|
|
24
|
-
source,
|
|
25
|
-
taxonId,
|
|
26
|
-
placeId,
|
|
27
|
-
dataUrl,
|
|
28
|
-
components,
|
|
29
|
-
className,
|
|
30
|
-
tabDesc,
|
|
31
|
-
generalClasses,
|
|
32
|
-
itemWidth = C.DEFAULT_ITEM_WIDTH,
|
|
33
|
-
numResults = C.NUM_RESULTS
|
|
34
|
-
}: FavouritesProps) => {
|
|
35
|
-
const { loading, results: observations } = useLoadSourceData({
|
|
36
|
-
year,
|
|
37
|
-
taxonId,
|
|
38
|
-
placeId,
|
|
39
|
-
numResults,
|
|
40
|
-
dataUrl,
|
|
41
|
-
source,
|
|
42
|
-
action: getFavourites
|
|
43
|
-
});
|
|
44
|
-
const Load = components?.loader ? components.loader as any : Loader;
|
|
45
|
-
const Label = components?.label ? components.label as any : FavouritesLabel;
|
|
46
|
-
|
|
47
|
-
let elClasses = generalStyles.panel;
|
|
48
|
-
if (className) {
|
|
49
|
-
elClasses += ` ${className}`;
|
|
50
|
-
}
|
|
51
|
-
let descClasses = generalStyles.tabDesc;
|
|
52
|
-
if (generalClasses?.tabDesc) {
|
|
53
|
-
descClasses += ` ${generalClasses.tabDesc}`;
|
|
54
|
-
}
|
|
55
|
-
return (
|
|
56
|
-
<div className={elClasses}>
|
|
57
|
-
{tabDesc && <p className={descClasses}>{tabDesc}</p>}
|
|
58
|
-
<Load loading={loading}/>
|
|
59
|
-
{!loading && observations.length === 0 && <NoResults/>}
|
|
60
|
-
<div className={generalStyles.grid} style={{ gridTemplateColumns: `repeat(auto-fit, minmax(${itemWidth}px, 1fr))` }}>
|
|
61
|
-
{observations.map((obs: any) => (
|
|
62
|
-
<Observation
|
|
63
|
-
key={obs.id}
|
|
64
|
-
imageUrl={obs.imageUrl.replace(/square/, "medium")}
|
|
65
|
-
itemWidth={itemWidth}
|
|
66
|
-
linkUrl={obs.obsUrl}>
|
|
67
|
-
<Label {...obs} classes={generalClasses} />
|
|
68
|
-
</Observation>
|
|
69
|
-
))}
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { Feature, TaxonPanelFeatures } from "../../__shared";
|
|
3
|
-
|
|
4
|
-
const defaultTitles = {
|
|
5
|
-
[Feature.recentObservations]: "Recent",
|
|
6
|
-
[Feature.commonTaxa]: "Most common",
|
|
7
|
-
[Feature.favourites]: "Most favourited",
|
|
8
|
-
[Feature.stats]: "General stats"
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const useFeatureTitles = (features: any) => {
|
|
12
|
-
const [titles, setTitles] = useState(defaultTitles);
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
setTitles({
|
|
16
|
-
[Feature.recentObservations]: features.recentObservations?.title || defaultTitles[Feature.recentObservations],
|
|
17
|
-
[Feature.commonTaxa]: features.commonTaxa?.title || defaultTitles[Feature.commonTaxa],
|
|
18
|
-
[Feature.favourites]: features.favourites?.title || defaultTitles[Feature.favourites],
|
|
19
|
-
[Feature.stats]: features.stats?.title || defaultTitles[Feature.stats]
|
|
20
|
-
});
|
|
21
|
-
}, [features]);
|
|
22
|
-
|
|
23
|
-
return titles;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const convertFeaturesToObj = (features: TaxonPanelFeatures) => {
|
|
27
|
-
const featuresObj: any = {};
|
|
28
|
-
features.forEach((row) => {
|
|
29
|
-
const { feature, ...other } = row;
|
|
30
|
-
featuresObj[feature] = other;
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return featuresObj;
|
|
34
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import {render} from '@testing-library/react';
|
|
2
|
-
|
|
3
|
-
import Loader from '../loader';
|
|
4
|
-
|
|
5
|
-
describe('Loader', () => {
|
|
6
|
-
it('should render successfully', () => {
|
|
7
|
-
const {baseElement} = render(<Loader loading={true} />);
|
|
8
|
-
expect(baseElement).toBeTruthy();
|
|
9
|
-
});
|
|
10
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import LoadingSpinner from "react-spinners/MoonLoader.js";
|
|
3
|
-
import styles from "../shared/css/general.module.scss";
|
|
4
|
-
|
|
5
|
-
export type LoaderProps = {
|
|
6
|
-
loading: boolean;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const Loader = ({ loading }: LoaderProps) => {
|
|
10
|
-
let loaderClasses = styles.loader;
|
|
11
|
-
// if (loading) {
|
|
12
|
-
// loaderClasses += ` ${styles.loading}`;
|
|
13
|
-
// }
|
|
14
|
-
if (!loading) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<div className={loaderClasses}>
|
|
20
|
-
<div className={styles.loaderBg} />
|
|
21
|
-
<LoadingSpinner color="#000000" />
|
|
22
|
-
</div>
|
|
23
|
-
);
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export default Loader;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {render} from '@testing-library/react';
|
|
2
|
-
import {Observation} from '../observation';
|
|
3
|
-
|
|
4
|
-
const defaultProps = {
|
|
5
|
-
linkUrl: "",
|
|
6
|
-
imageUrl: "",
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
describe('Observation', () => {
|
|
10
|
-
it('should render successfully', () => {
|
|
11
|
-
const {baseElement} = render(<Observation {...defaultProps}>test</Observation>);
|
|
12
|
-
expect(baseElement).toBeTruthy();
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
.obs {
|
|
2
|
-
cursor: pointer;
|
|
3
|
-
border-radius: 8px;
|
|
4
|
-
background-color: #f9f9f9;
|
|
5
|
-
text-align: center;
|
|
6
|
-
transition: all 0.15s ease-in-out;
|
|
7
|
-
|
|
8
|
-
&:hover {
|
|
9
|
-
background-color: #e1e1e1;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.obs h3 {
|
|
14
|
-
margin: 0;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.image {
|
|
18
|
-
max-width: 100%;
|
|
19
|
-
max-height: 100%;
|
|
20
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React, { useCallback } from "react";
|
|
2
|
-
import styles from "./observation.module.scss";
|
|
3
|
-
|
|
4
|
-
export type ObservationProps = {
|
|
5
|
-
imageUrl: string;
|
|
6
|
-
linkUrl: string;
|
|
7
|
-
itemWidth: number;
|
|
8
|
-
children: any;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const Observation = ({imageUrl, linkUrl, itemWidth, children}: ObservationProps) => {
|
|
12
|
-
const gotoObservation = useCallback(() => {
|
|
13
|
-
window.open(linkUrl);
|
|
14
|
-
}, [linkUrl]);
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<article className={styles.obs} onClick={gotoObservation}>
|
|
18
|
-
<div style={{
|
|
19
|
-
width: itemWidth,
|
|
20
|
-
height: itemWidth,
|
|
21
|
-
overflow: "hidden",
|
|
22
|
-
borderRadius: 5,
|
|
23
|
-
background: `url(${imageUrl}) 50% 50% no-repeat`,
|
|
24
|
-
margin: "0 auto",
|
|
25
|
-
backgroundSize: "cover"
|
|
26
|
-
}}/>
|
|
27
|
-
{children}
|
|
28
|
-
</article>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import {render} from '@testing-library/react';
|
|
2
|
-
import {RecentObservations} from '../recent-observations';
|
|
3
|
-
|
|
4
|
-
describe('RecentObservations', () => {
|
|
5
|
-
it('should render successfully', () => {
|
|
6
|
-
const {baseElement} = render(<RecentObservations/>);
|
|
7
|
-
expect(baseElement).toBeTruthy();
|
|
8
|
-
});
|
|
9
|
-
});
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
formatDate,
|
|
4
|
-
C,
|
|
5
|
-
getRecentObservations,
|
|
6
|
-
RecentObservationData,
|
|
7
|
-
BaseComponentProps,
|
|
8
|
-
DataSourceEnum,
|
|
9
|
-
GeneralClasses
|
|
10
|
-
} from "../../__shared";
|
|
11
|
-
import { Observation } from "../observation/observation";
|
|
12
|
-
import Loader from "../loader/loader";
|
|
13
|
-
import { NoResults } from "../no-results/no-results";
|
|
14
|
-
import { useLoadSourceData } from "../../hooks/useLoadSourceData";
|
|
15
|
-
import styles from "../shared/css/general.module.scss";
|
|
16
|
-
|
|
17
|
-
export type RecentObservationsProps = BaseComponentProps;
|
|
18
|
-
|
|
19
|
-
export const RecentObservationLabel = (obs: RecentObservationData & { classes: GeneralClasses }) => (
|
|
20
|
-
<div className={styles.obsLabel}>
|
|
21
|
-
<h3 className={obs.classes?.observationLabelTitle}>{obs.taxonCommonName || obs.taxonName}</h3>
|
|
22
|
-
<div className={obs.classes?.observationLabelDate}>{formatDate(obs.obsDate)}</div>
|
|
23
|
-
<div className={obs.classes?.observationLabelName}>
|
|
24
|
-
<a href={`${C.BASE_URL}/people/${obs.observerUsername}`}
|
|
25
|
-
target="_blank"
|
|
26
|
-
rel="noreferrer"
|
|
27
|
-
onClick={(e) => e.stopPropagation()}>
|
|
28
|
-
{obs.observerUsername}
|
|
29
|
-
</a>
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
export const RecentObservations = ({
|
|
35
|
-
taxonId,
|
|
36
|
-
placeId,
|
|
37
|
-
dataUrl,
|
|
38
|
-
components,
|
|
39
|
-
className,
|
|
40
|
-
generalClasses,
|
|
41
|
-
tabDesc,
|
|
42
|
-
source = DataSourceEnum.autoLoad,
|
|
43
|
-
numResults = C.NUM_RESULTS,
|
|
44
|
-
itemWidth = C.DEFAULT_ITEM_WIDTH
|
|
45
|
-
}: RecentObservationsProps) => {
|
|
46
|
-
const { loading, results: observations } = useLoadSourceData({
|
|
47
|
-
taxonId,
|
|
48
|
-
placeId,
|
|
49
|
-
numResults,
|
|
50
|
-
dataUrl,
|
|
51
|
-
source,
|
|
52
|
-
action: getRecentObservations
|
|
53
|
-
});
|
|
54
|
-
const Load = components?.loader ? components.loader as any : Loader;
|
|
55
|
-
const Label = components?.label ? components.label as any : RecentObservationLabel;
|
|
56
|
-
|
|
57
|
-
let componentClasses = styles.panel;
|
|
58
|
-
if (className) {
|
|
59
|
-
componentClasses += ` ${className}`;
|
|
60
|
-
}
|
|
61
|
-
let descClasses = styles.tabDesc;
|
|
62
|
-
if (generalClasses?.tabDesc) {
|
|
63
|
-
descClasses += ` ${generalClasses.tabDesc}`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<div className={componentClasses}>
|
|
68
|
-
{tabDesc && <p className={descClasses}>{tabDesc}</p>}
|
|
69
|
-
<Load loading={loading}/>
|
|
70
|
-
<div className={styles.grid} style={{ gridTemplateColumns: `repeat(auto-fit, minmax(${itemWidth}px, 1fr))` }}>
|
|
71
|
-
{!loading && observations.length === 0 && <NoResults/>}
|
|
72
|
-
{observations.map((obs: RecentObservationData) => (
|
|
73
|
-
<Observation
|
|
74
|
-
key={obs.id}
|
|
75
|
-
imageUrl={obs.imageUrl.replace(/square/, "medium")}
|
|
76
|
-
itemWidth={itemWidth}
|
|
77
|
-
linkUrl={obs.obsUrl}>
|
|
78
|
-
<Label {...obs} classes={generalClasses} />
|
|
79
|
-
</Observation>
|
|
80
|
-
))}
|
|
81
|
-
</div>
|
|
82
|
-
</div>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import {render} from '@testing-library/react';
|
|
2
|
-
import {SeasonalityGraph} from '../seasonality-graph';
|
|
3
|
-
|
|
4
|
-
describe('SeasonalityGraph', () => {
|
|
5
|
-
it('should render successfully', () => {
|
|
6
|
-
const {baseElement} = render(<SeasonalityGraph/>);
|
|
7
|
-
expect(baseElement).toBeTruthy();
|
|
8
|
-
});
|
|
9
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { AxisOptions, Chart } from "react-charts";
|
|
3
|
-
import { format } from "date-fns";
|
|
4
|
-
|
|
5
|
-
export const SeasonalityGraph = ({ data }: any) => {
|
|
6
|
-
const primaryAxis = React.useMemo<
|
|
7
|
-
AxisOptions<typeof data[number]["data"][number]>
|
|
8
|
-
>(
|
|
9
|
-
() => ({
|
|
10
|
-
getValue: (datum: any) => datum.primary as any
|
|
11
|
-
}),
|
|
12
|
-
[]
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
const secondaryAxes = React.useMemo<
|
|
16
|
-
AxisOptions<typeof data[number]["data"][number]>[]
|
|
17
|
-
>(
|
|
18
|
-
() => [
|
|
19
|
-
{
|
|
20
|
-
getValue: (datum: any) => datum.secondary,
|
|
21
|
-
elementType: "area"
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
[]
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
const formattedData = [
|
|
28
|
-
{
|
|
29
|
-
label: "Observations",
|
|
30
|
-
data: Object.keys(data).map((monthNum) => ({
|
|
31
|
-
primary: format(new Date(2000, parseInt(monthNum, 10)-1, 1), 'MMMM'),
|
|
32
|
-
secondary: data[monthNum]
|
|
33
|
-
}))
|
|
34
|
-
}
|
|
35
|
-
];
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<Chart
|
|
39
|
-
options={{
|
|
40
|
-
data: formattedData,
|
|
41
|
-
primaryAxis,
|
|
42
|
-
secondaryAxes
|
|
43
|
-
}}
|
|
44
|
-
/>
|
|
45
|
-
);
|
|
46
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
.page {
|
|
2
|
-
padding: 80px 10px 10px;
|
|
3
|
-
margin: 0 auto;
|
|
4
|
-
max-width: 1100px;
|
|
5
|
-
|
|
6
|
-
h1 {
|
|
7
|
-
border-bottom: 1px solid #efefef;
|
|
8
|
-
padding-bottom: 2px;
|
|
9
|
-
margin-bottom: 25px;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
.panel {
|
|
14
|
-
position: relative;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.grid {
|
|
18
|
-
display: grid;
|
|
19
|
-
width: 100%;
|
|
20
|
-
grid-gap: 8px;
|
|
21
|
-
text-align: center;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.obsLabel {
|
|
25
|
-
padding: 10px 20px;
|
|
26
|
-
|
|
27
|
-
a {
|
|
28
|
-
text-decoration: none;
|
|
29
|
-
color: #336699;
|
|
30
|
-
|
|
31
|
-
&:hover {
|
|
32
|
-
text-decoration: underline;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.loader {
|
|
38
|
-
position: absolute;
|
|
39
|
-
top: 50px;
|
|
40
|
-
left: 0;
|
|
41
|
-
right: 0;
|
|
42
|
-
z-index: 1;
|
|
43
|
-
margin: 0;
|
|
44
|
-
display: flex;
|
|
45
|
-
align-items: center;
|
|
46
|
-
justify-content: center;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.loaderBg {
|
|
50
|
-
position: absolute;
|
|
51
|
-
background-color: #cccccc;
|
|
52
|
-
padding: 20px;
|
|
53
|
-
width: 100px;
|
|
54
|
-
border-radius: 10px;
|
|
55
|
-
height: 100%;
|
|
56
|
-
opacity: 0.8;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.count {
|
|
60
|
-
background-color: #efefef;
|
|
61
|
-
color: #666666;
|
|
62
|
-
padding: 2px 8px;
|
|
63
|
-
margin-top: 6px;
|
|
64
|
-
display: inline-block;
|
|
65
|
-
border-radius: 3px;
|
|
66
|
-
font-weight: bold;
|
|
67
|
-
font-size: 18px;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.tabDesc {
|
|
71
|
-
font-size: 14px;
|
|
72
|
-
margin-bottom: 20px;
|
|
73
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { numberWithCommas, Observer, C, GeneralClasses } from "../../__shared";
|
|
3
|
-
import styles from "./summary.module.scss";
|
|
4
|
-
|
|
5
|
-
export const ObserverList = ({ observers, generalClasses, className = '' }: { observers: Observer[], generalClasses?: GeneralClasses, className?: string }) => {
|
|
6
|
-
let classes = styles.top;
|
|
7
|
-
if (className) {
|
|
8
|
-
classes += ` ${className}`;
|
|
9
|
-
}
|
|
10
|
-
return (
|
|
11
|
-
<ul className={classes}>
|
|
12
|
-
{observers.map((obs) => (
|
|
13
|
-
<li key={obs.id}>
|
|
14
|
-
<a href={`${C.BASE_URL}/people/${obs.userName}`} target="_blank" rel="noreferrer">
|
|
15
|
-
{obs.iconUrl ? <img src={obs.iconUrl || ""} className={styles.avatar} alt="User icon"/> :
|
|
16
|
-
<div className={styles.noAvatar}/>}
|
|
17
|
-
<h3>{obs.userName}</h3>
|
|
18
|
-
<label className={generalClasses?.observationCount}>{numberWithCommas(obs.numObservations)}</label>
|
|
19
|
-
</a>
|
|
20
|
-
</li>
|
|
21
|
-
))}
|
|
22
|
-
</ul>
|
|
23
|
-
);
|
|
24
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {render} from "@testing-library/react";
|
|
2
|
-
import {DataSource} from "../../../index";
|
|
3
|
-
import {Summary} from "../summary";
|
|
4
|
-
|
|
5
|
-
describe("Summary", () => {
|
|
6
|
-
it("should render successfully", () => {
|
|
7
|
-
const {baseElement} = render(
|
|
8
|
-
<Summary
|
|
9
|
-
placeId={1}
|
|
10
|
-
taxonId={1}
|
|
11
|
-
source={DataSource.url}
|
|
12
|
-
year={2020}
|
|
13
|
-
dataUrl=""
|
|
14
|
-
/>
|
|
15
|
-
);
|
|
16
|
-
expect(baseElement).toBeTruthy();
|
|
17
|
-
});
|
|
18
|
-
});
|