@openneuro/app 4.33.3 → 4.34.0-alpha.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/package.json +5 -4
- package/src/client.jsx +2 -1
- package/src/scripts/authentication/signOut.ts +1 -1
- package/src/scripts/common/containers/footer.tsx +1 -1
- package/src/scripts/common/containers/header.tsx +3 -2
- package/src/scripts/common/content/affiliate-content.jsx +72 -0
- package/src/scripts/common/content/assets/affiliates/bids.jpg +0 -0
- package/src/scripts/common/content/assets/affiliates/datalad.jpg +0 -0
- package/src/scripts/common/content/assets/affiliates/nih-bi-logo.png +0 -0
- package/src/scripts/common/content/assets/front-page/brand_mark.png +0 -0
- package/src/scripts/common/content/assets/front-page/cube-get.png +0 -0
- package/src/scripts/common/content/assets/front-page/cube-share.png +0 -0
- package/src/scripts/common/content/assets/front-page/cube-use.png +0 -0
- package/src/scripts/common/content/assets/front-page/ljaf.png +0 -0
- package/src/scripts/common/content/assets/front-page/logo_app.png +0 -0
- package/src/scripts/common/content/assets/front-page/logo_cube.png +0 -0
- package/src/scripts/common/content/assets/front-page/logo_data.png +0 -0
- package/src/scripts/common/content/assets/front-page/logo_users.png +0 -0
- package/src/scripts/common/content/assets/front-page/novo-logo.png +0 -0
- package/src/scripts/common/content/assets/front-page/nru-logo.png +0 -0
- package/src/scripts/common/content/assets/front-page/nsf.png +0 -0
- package/src/scripts/common/content/assets/front-page/sqm-logo.png +0 -0
- package/src/scripts/common/content/assets/front-page/squishymedia.png +0 -0
- package/src/scripts/common/content/assets/front-page/stanford.png +0 -0
- package/src/scripts/common/content/assets/modality-cubes/brain-initiative.jpg +0 -0
- package/src/scripts/common/content/assets/modality-cubes/eeg.jpg +0 -0
- package/src/scripts/common/content/assets/modality-cubes/ieeg.jpg +0 -0
- package/src/scripts/common/content/assets/modality-cubes/meg.jpg +0 -0
- package/src/scripts/common/content/assets/modality-cubes/mri.jpg +0 -0
- package/src/scripts/common/content/assets/modality-cubes/nih_cube.jpg +0 -0
- package/src/scripts/common/content/assets/modality-cubes/nirs.jpg +0 -0
- package/src/scripts/common/content/assets/modality-cubes/pet-scan.jpg +0 -0
- package/src/scripts/common/content/assets/portal-content/nih-bi-brand.png +0 -0
- package/src/scripts/common/content/facet-content.jsx +186 -0
- package/src/scripts/common/content/front-page-content.jsx +177 -0
- package/src/scripts/common/content/image-attribution.tsx +3 -3
- package/src/scripts/common/content/modality-cube-content.jsx +92 -0
- package/src/scripts/common/content/portal-content.jsx +149 -0
- package/src/scripts/common/content/portal-grant-content.jsx +30 -0
- package/src/scripts/common/content/sortby-list.jsx +18 -0
- package/src/scripts/common/forms/warn-button.jsx +1 -1
- package/src/scripts/components/accordion/AccordionTab.tsx +68 -0
- package/src/scripts/components/accordion/AccordionWrap.tsx +22 -0
- package/src/scripts/components/accordion/__tests__/AccordionTab.spec.tsx +35 -0
- package/src/scripts/components/accordion/accordion.scss +68 -0
- package/src/scripts/components/activity-slider/ActivitySlider.tsx +121 -0
- package/src/scripts/components/activity-slider/slider.scss +130 -0
- package/src/scripts/components/affiliate-article/AffiliateArticle.tsx +26 -0
- package/src/scripts/components/affiliate-article/affiliate.scss +32 -0
- package/src/scripts/components/aggregate-count/AggregateCount.tsx +20 -0
- package/src/scripts/components/assets/activity-icon.png +0 -0
- package/src/scripts/components/assets/close-button.png +0 -0
- package/src/scripts/components/assets/favicon copy.ico +0 -0
- package/src/scripts/components/assets/favicon.ico +0 -0
- package/src/scripts/components/assets/get_data_browse.png +0 -0
- package/src/scripts/components/assets/get_data_download.png +0 -0
- package/src/scripts/components/assets/ljaf copy.png +0 -0
- package/src/scripts/components/assets/logo_app copy.png +0 -0
- package/src/scripts/components/assets/logo_cube copy.png +0 -0
- package/src/scripts/components/assets/logo_data copy.png +0 -0
- package/src/scripts/components/assets/logo_users copy.png +0 -0
- package/src/scripts/components/assets/mri-scan.jpg +0 -0
- package/src/scripts/components/assets/nih copy.png +0 -0
- package/src/scripts/components/assets/nih-bi-brand.jpg +0 -0
- package/src/scripts/components/assets/nih-stanford.jpg +0 -0
- package/src/scripts/components/assets/nih.png +0 -0
- package/src/scripts/components/assets/nimh.png +0 -0
- package/src/scripts/components/assets/nsf copy.png +0 -0
- package/src/scripts/components/assets/on-dark-horz.svg +1 -0
- package/src/scripts/components/assets/on-dark.svg +1 -0
- package/src/scripts/components/assets/on-light-horz.svg +1 -0
- package/src/scripts/components/assets/on-light.svg +1 -0
- package/src/scripts/components/assets/orcid_24x24 copy.png +0 -0
- package/src/scripts/components/assets/orcid_24x24.png +0 -0
- package/src/scripts/components/assets/share_data_collaborate.png +0 -0
- package/src/scripts/components/assets/share_data_publish.png +0 -0
- package/src/scripts/components/assets/share_data_validate.png +0 -0
- package/src/scripts/components/assets/squishymedia copy.png +0 -0
- package/src/scripts/components/assets/stanford copy.png +0 -0
- package/src/scripts/components/assets/tab-get_data.png +0 -0
- package/src/scripts/components/assets/tab-share_data.png +0 -0
- package/src/scripts/components/assets/tab-use_data.png +0 -0
- package/src/scripts/components/assets/use_data_analyze.png +0 -0
- package/src/scripts/components/assets/use_data_snapshot.png +0 -0
- package/src/scripts/components/button/Button.tsx +113 -0
- package/src/scripts/components/button/__tests__/Button.spec.tsx +21 -0
- package/src/scripts/components/button/button.scss +140 -0
- package/src/scripts/components/count-toggle/CountToggle.tsx +65 -0
- package/src/scripts/components/count-toggle/__tests__/CountToggle.spec.tsx +31 -0
- package/src/scripts/components/count-toggle/count-toggle.scss +34 -0
- package/src/scripts/components/dropdown/Dropdown.tsx +38 -0
- package/src/scripts/components/dropdown/dropdown.scss +29 -0
- package/src/scripts/components/facets/FacetRadio.tsx +43 -0
- package/src/scripts/components/facets/FacetRange.tsx +35 -0
- package/src/scripts/components/facets/FacetSearch.tsx +66 -0
- package/src/scripts/components/facets/FacetSelect.tsx +87 -0
- package/src/scripts/components/facets/SingleSelect.tsx +39 -0
- package/src/scripts/components/facets/__tests__/FacetSelect.spec.tsx +14 -0
- package/src/scripts/components/facets/__tests__/SingleSelect.spec.tsx +58 -0
- package/src/scripts/components/facets/facet.scss +244 -0
- package/src/scripts/components/footer/Footer.tsx +52 -0
- package/src/scripts/components/footer/footer.scss +20 -0
- package/src/scripts/components/formatting/__tests__/modality-label.spec.tsx +34 -0
- package/src/scripts/components/formatting/modality-label.tsx +34 -0
- package/src/scripts/components/front-page/ActivityHeader.tsx +12 -0
- package/src/scripts/components/front-page/AffiliateBlock.tsx +22 -0
- package/src/scripts/components/front-page/Contributors.tsx +28 -0
- package/src/scripts/components/front-page/GetUpdates.tsx +99 -0
- package/src/scripts/components/front-page/Infographic.tsx +36 -0
- package/src/scripts/components/front-page/front-page.scss +295 -0
- package/src/scripts/components/header/Header.tsx +151 -0
- package/src/scripts/components/header/LandingExpandedHeader.tsx +110 -0
- package/src/scripts/components/header/header.scss +409 -0
- package/src/scripts/components/icon/Icon.tsx +55 -0
- package/src/scripts/components/icon/__tests__/Icon.spec.tsx +10 -0
- package/src/scripts/components/icon/icon.scss +8 -0
- package/src/scripts/components/input/Input.tsx +137 -0
- package/src/scripts/components/input/TermSearch.tsx +101 -0
- package/src/scripts/components/input/input.scss +147 -0
- package/src/scripts/components/input/term-search.scss +68 -0
- package/src/scripts/components/json-tree/ExpandableProperty.tsx +35 -0
- package/src/scripts/components/json-tree/RecursiveProperty.tsx +67 -0
- package/src/scripts/components/json-tree/json-tree.scss +19 -0
- package/src/scripts/components/loading/Loading.tsx +19 -0
- package/src/scripts/components/loading/__tests__/Loading.spec.tsx +12 -0
- package/src/scripts/components/loading/loading.scss +141 -0
- package/src/scripts/components/logo/Logo.tsx +44 -0
- package/src/scripts/components/logo/__tests__/Logo.spec.tsx +22 -0
- package/src/scripts/components/modal/Modal.tsx +51 -0
- package/src/scripts/components/modal/ModalExample.tsx +25 -0
- package/src/scripts/components/modal/UserLoginModal.tsx +74 -0
- package/src/scripts/components/modal/__tests__/UserLoginModal.spec.tsx +37 -0
- package/src/scripts/components/modal/modal.scss +60 -0
- package/src/scripts/components/modality-cube/ModalityCube.tsx +60 -0
- package/src/scripts/components/modality-cube/modality-cube.scss +303 -0
- package/src/scripts/components/page/Page.tsx +61 -0
- package/src/scripts/components/page/page.scss +408 -0
- package/src/scripts/components/progress-bar/ProgressBar.tsx +16 -0
- package/src/scripts/components/progress-bar/progress-bar.scss +34 -0
- package/src/scripts/components/radio/Radio.tsx +33 -0
- package/src/scripts/components/radio/RadioGroup.tsx +45 -0
- package/src/scripts/components/radio/__tests__/RadioGroup.spec.tsx +31 -0
- package/src/scripts/components/radio/radio.scss +335 -0
- package/src/scripts/components/range/TwoHandleRange.scss +108 -0
- package/src/scripts/components/range/TwoHandleRange.tsx +128 -0
- package/src/scripts/components/range/__tests__/TwoHandleRange.spec.tsx +34 -0
- package/src/scripts/components/read-more/ReadMore.tsx +50 -0
- package/src/scripts/components/read-more/__tests__/ReadMore.spec.tsx +14 -0
- package/src/scripts/components/read-more/read-more.scss +79 -0
- package/src/scripts/components/scss/_flex-grid.scss +216 -0
- package/src/scripts/components/scss/_helper-classes.scss +162 -0
- package/src/scripts/components/scss/_normalize.scss +614 -0
- package/src/scripts/components/scss/_variables.scss +245 -0
- package/src/scripts/components/scss/global.scss +124 -0
- package/src/scripts/components/scss/toasts.scss +33 -0
- package/src/scripts/components/scss/upload-modal.scss +479 -0
- package/src/scripts/components/search-page/CommunityHeader.tsx +27 -0
- package/src/scripts/components/search-page/FacetBlockContainerExample.tsx +6 -0
- package/src/scripts/components/search-page/FilterDateItem.tsx +44 -0
- package/src/scripts/components/search-page/FilterListItem.tsx +62 -0
- package/src/scripts/components/search-page/FiltersBlock.tsx +277 -0
- package/src/scripts/components/search-page/ModalityHeader.tsx +64 -0
- package/src/scripts/components/search-page/NeurobagelSearch.tsx +59 -0
- package/src/scripts/components/search-page/SearchPage.tsx +114 -0
- package/src/scripts/components/search-page/SearchResultItem.tsx +417 -0
- package/src/scripts/components/search-page/SearchResultsList.tsx +48 -0
- package/src/scripts/components/search-page/SearchSort.tsx +52 -0
- package/src/scripts/components/search-page/SearchSortContainerExample.tsx +9 -0
- package/src/scripts/components/search-page/TermListItem.tsx +41 -0
- package/src/scripts/components/search-page/__tests__/NuerobagelSearch.spec.tsx +17 -0
- package/src/scripts/components/search-page/filters-block.scss +99 -0
- package/src/scripts/components/search-page/neurobagel_logo.svg +75 -0
- package/src/scripts/components/search-page/search-page.scss +505 -0
- package/src/scripts/components/search-page/search-result.scss +117 -0
- package/src/scripts/components/search-page/search-sort.scss +56 -0
- package/src/scripts/components/select/SelectGroup.tsx +41 -0
- package/src/scripts/components/select/__tests__/SelectGroup.spec.tsx +43 -0
- package/src/scripts/components/select/select.scss +40 -0
- package/src/scripts/components/textarea/Textarea.tsx +68 -0
- package/src/scripts/components/textarea/__tests__/Textarea.spec.tsx +53 -0
- package/src/scripts/components/tooltip/Tooltip.tsx +30 -0
- package/src/scripts/components/tooltip/__tests__/Tooltip.spec.tsx +14 -0
- package/src/scripts/components/tooltip/tooltip.scss +159 -0
- package/src/scripts/components/user/UserMenu.tsx +72 -0
- package/src/scripts/components/user/user-menu.scss +88 -0
- package/src/scripts/components/warn-button/WarnButton.tsx +97 -0
- package/src/scripts/components/warn-button/warn-button.scss +39 -0
- package/src/scripts/datalad/dataset/dataset-query-context.js +2 -0
- package/src/scripts/dataset/comments/comment.jsx +1 -1
- package/src/scripts/dataset/components/AnalyzeDropdown.tsx +2 -2
- package/src/scripts/dataset/components/CloneDropdown.tsx +2 -2
- package/src/scripts/dataset/components/DatasetEventItem.tsx +105 -0
- package/src/scripts/dataset/components/DatasetGitAccess.tsx +2 -2
- package/src/scripts/dataset/components/DatasetToolButton.tsx +2 -2
- package/src/scripts/dataset/components/ModalitiesMetaDataBlock.tsx +2 -10
- package/src/scripts/dataset/components/ValidationBlock.tsx +37 -2
- package/src/scripts/dataset/components/VersionList.tsx +1 -1
- package/src/scripts/dataset/components/scss/dataset-events.module.scss +41 -0
- package/src/scripts/dataset/dataset-query.jsx +12 -11
- package/src/scripts/dataset/download/__tests__/__snapshots__/download-command-line.spec.jsx.snap +7 -1
- package/src/scripts/dataset/download/__tests__/download-command-line.spec.jsx +2 -2
- package/src/scripts/dataset/download/download-command-line.jsx +17 -13
- package/src/scripts/dataset/download/download-datalad.jsx +6 -3
- package/src/scripts/dataset/download/download-link.jsx +1 -1
- package/src/scripts/dataset/download/download-s3.jsx +0 -4
- package/src/scripts/dataset/files/file-display.jsx +1 -1
- package/src/scripts/dataset/files/file-tree-unloaded-directory.jsx +1 -1
- package/src/scripts/dataset/files/file-tree.tsx +1 -1
- package/src/scripts/dataset/files/file-view.jsx +1 -1
- package/src/scripts/dataset/files/file-viewer-type.jsx +5 -1
- package/src/scripts/dataset/files/file.tsx +2 -2
- package/src/scripts/dataset/files/files.tsx +3 -3
- package/src/scripts/dataset/files/viewers/file-viewer-json.jsx +1 -1
- package/src/scripts/dataset/files/viewers/file-viewer-markdown.tsx +13 -0
- package/src/scripts/dataset/fragments/cancel-button.tsx +1 -1
- package/src/scripts/dataset/fragments/dataset-citation.jsx +2 -2
- package/src/scripts/dataset/fragments/edit-button.tsx +1 -1
- package/src/scripts/dataset/fragments/edit-list.jsx +1 -1
- package/src/scripts/dataset/fragments/save-button.tsx +1 -1
- package/src/scripts/dataset/mutations/admin-exports.jsx +1 -1
- package/src/scripts/dataset/mutations/cache-clear.jsx +1 -1
- package/src/scripts/dataset/mutations/create-anonymous-reviewer.tsx +2 -2
- package/src/scripts/dataset/mutations/dataset-events.tsx +187 -0
- package/src/scripts/dataset/mutations/dataset-relations.tsx +1 -1
- package/src/scripts/dataset/mutations/delete-anonymous-reviewer.tsx +1 -1
- package/src/scripts/dataset/mutations/delete-comment.jsx +1 -1
- package/src/scripts/dataset/mutations/delete-file.jsx +1 -1
- package/src/scripts/dataset/mutations/deprecate-version.tsx +1 -1
- package/src/scripts/dataset/mutations/flag-annex-object.jsx +2 -2
- package/src/scripts/dataset/mutations/follow.tsx +1 -1
- package/src/scripts/dataset/mutations/import-dataset.tsx +1 -1
- package/src/scripts/dataset/mutations/publish.jsx +1 -1
- package/src/scripts/dataset/mutations/remove-annex-object.jsx +2 -2
- package/src/scripts/dataset/mutations/remove-permissions.tsx +1 -1
- package/src/scripts/dataset/mutations/revalidate.jsx +2 -2
- package/src/scripts/dataset/mutations/snapshot.tsx +1 -1
- package/src/scripts/dataset/mutations/star.tsx +1 -1
- package/src/scripts/dataset/mutations/submit-metadata.jsx +1 -1
- package/src/scripts/dataset/mutations/undo-deprecate-version.tsx +2 -2
- package/src/scripts/dataset/mutations/update-permissions.tsx +1 -1
- package/src/scripts/dataset/routes/admin-datalad.jsx +4 -0
- package/src/scripts/dataset/routes/dataset-default.tsx +1 -1
- package/src/scripts/dataset/routes/delete-page.tsx +7 -3
- package/src/scripts/dataset/routes/deprecate-snapshot-page.tsx +1 -1
- package/src/scripts/dataset/routes/manage-permissions.jsx +1 -1
- package/src/scripts/dataset/routes/snapshot-default.tsx +1 -1
- package/src/scripts/dataset/routes/snapshot.tsx +1 -1
- package/src/scripts/dataset/snapshot-container.tsx +14 -8
- package/src/scripts/pages/admin/flagged-files.jsx +1 -1
- package/src/scripts/pages/admin/user-tools.tsx +1 -1
- package/src/scripts/pages/admin/users.tsx +2 -2
- package/src/scripts/pages/api.jsx +2 -2
- package/src/scripts/pages/front-page/aggregate-queries/aggregate-counts-container.tsx +6 -7
- package/src/scripts/pages/front-page/front-page.tsx +7 -9
- package/src/scripts/pages/metadata/dataset-metadata.tsx +1 -1
- package/src/scripts/search/__tests__/search-container.spec.tsx +7 -7
- package/src/scripts/search/filters-block-container.tsx +66 -9
- package/src/scripts/search/initial-search-params.tsx +7 -7
- package/src/scripts/search/inputs/__tests__/sort-by-select.spec.tsx +1 -1
- package/src/scripts/search/inputs/admin-allDatasets-toggle.tsx +1 -1
- package/src/scripts/search/inputs/age-range-input.tsx +3 -2
- package/src/scripts/search/inputs/author-input.tsx +3 -2
- package/src/scripts/search/inputs/dataset-type-select.tsx +3 -2
- package/src/scripts/search/inputs/date-radios.tsx +3 -2
- package/src/scripts/search/inputs/diagnosis-select.tsx +3 -2
- package/src/scripts/search/inputs/initiative-select.tsx +12 -6
- package/src/scripts/search/inputs/keyword-input.tsx +2 -2
- package/src/scripts/search/inputs/modality-select.tsx +28 -26
- package/src/scripts/search/inputs/pet/bodyParts_input.tsx +4 -3
- package/src/scripts/search/inputs/pet/scannerManufacturersModelNames_input.tsx +4 -3
- package/src/scripts/search/inputs/pet/scannerManufacturers_input.tsx +4 -3
- package/src/scripts/search/inputs/pet/tracerNames_input.tsx +4 -3
- package/src/scripts/search/inputs/pet/tracerRadionuclides_input.tsx +4 -3
- package/src/scripts/search/inputs/section-select.tsx +3 -2
- package/src/scripts/search/inputs/sex-radios.tsx +3 -2
- package/src/scripts/search/inputs/show-datasets-radios.tsx +4 -3
- package/src/scripts/search/inputs/sort-by-select.tsx +1 -1
- package/src/scripts/search/inputs/species-select.tsx +3 -2
- package/src/scripts/search/inputs/study-domain-input.tsx +4 -3
- package/src/scripts/search/inputs/subject-count-range-input.tsx +3 -2
- package/src/scripts/search/inputs/task-input.tsx +4 -3
- package/src/scripts/search/search-container.tsx +14 -17
- package/src/scripts/search/search-params-ctx.tsx +28 -5
- package/src/scripts/search/search-routes.tsx +2 -4
- package/src/scripts/search/use-search-results.tsx +14 -13
- package/src/scripts/uploader/upload-issues.tsx +1 -1
- package/src/scripts/uploader/upload-progress.jsx +1 -1
- package/src/scripts/uploader/uploader-modal.jsx +1 -1
- package/src/scripts/users/components/close-button.tsx +1 -1
- package/src/scripts/users/components/edit-button.tsx +1 -1
- package/src/scripts/users/components/edit-list.tsx +1 -1
- package/src/scripts/users/components/edit-string.tsx +1 -1
- package/src/scripts/users/dataset-card.tsx +2 -2
- package/src/scripts/users/user-notification-accordion.tsx +1 -1
- package/src/scripts/utils/user-login-modal-ctx.tsx +1 -1
- package/src/scripts/validation/validation-issues.tsx +2 -1
- package/src/scripts/validation/validation-panel.tsx +2 -1
- package/src/scripts/validation/validation-results.tsx +4 -3
- package/src/scripts/validation-legacy/validation-panel.jsx +2 -1
- package/src/scripts/validation-legacy/validation-results.issues.jsx +2 -3
- package/src/scripts/validation-legacy/validation-results.tsx +3 -4
- package/tsconfig.json +1 -4
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
@import '../scss/variables';
|
|
2
|
+
|
|
3
|
+
.on-button {
|
|
4
|
+
font-family: $font-sans;
|
|
5
|
+
font-weight: 600;
|
|
6
|
+
border: 0;
|
|
7
|
+
border-radius: $border-radius-default;
|
|
8
|
+
cursor: pointer;
|
|
9
|
+
display: inline-block;
|
|
10
|
+
line-height: 1.4em;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.on-button--primary {
|
|
14
|
+
color: #fff;
|
|
15
|
+
background-color: var(--current-theme-primary);
|
|
16
|
+
transition: background-color 0.3s;
|
|
17
|
+
border: 2px solid transparent;
|
|
18
|
+
&:hover {
|
|
19
|
+
background-color: var(--current-theme-primary-hover);
|
|
20
|
+
}
|
|
21
|
+
&.active {
|
|
22
|
+
background-color: transparent;
|
|
23
|
+
color: var(--current-theme-primary);
|
|
24
|
+
border-color: var(--current-theme-primary-hover);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.on-button--secondary {
|
|
29
|
+
color: $on-dark-aqua;
|
|
30
|
+
background-color: $on-light-green;
|
|
31
|
+
transition: background-color 0.3s;
|
|
32
|
+
box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px;
|
|
33
|
+
border: 2px solid transparent;
|
|
34
|
+
&:hover {
|
|
35
|
+
background-color: darken($on-light-green, 5%);
|
|
36
|
+
}
|
|
37
|
+
&.active {
|
|
38
|
+
background-color: transparent;
|
|
39
|
+
color: $on-dark-aqua;
|
|
40
|
+
border-color: $on-light-green;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.icon-text {
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
i {
|
|
48
|
+
margin-right: 10px;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.img-icon-text {
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
|
|
56
|
+
img {
|
|
57
|
+
margin-right: 10px;
|
|
58
|
+
height: auto;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.on-no-background {
|
|
63
|
+
background-color: transparent;
|
|
64
|
+
&:hover {
|
|
65
|
+
text-decoration: underline;
|
|
66
|
+
}
|
|
67
|
+
&.icon-text,
|
|
68
|
+
&.img-icon-text {
|
|
69
|
+
padding: 0 0 5px;
|
|
70
|
+
border-radius: 0;
|
|
71
|
+
border-bottom: 1px solid transparent;
|
|
72
|
+
&:hover {
|
|
73
|
+
text-decoration: none;
|
|
74
|
+
border-bottom: 1px solid;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
.on-button--default {
|
|
79
|
+
background-color: transparent;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.on-button--navbar {
|
|
83
|
+
background-color: #f4f4f4;
|
|
84
|
+
color: #204e5a;
|
|
85
|
+
box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px;
|
|
86
|
+
&:hover {
|
|
87
|
+
background-color: darken(#f4f4f4, 5%);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.on-button[disabled] {
|
|
92
|
+
cursor: default;
|
|
93
|
+
background-color: #aaa;
|
|
94
|
+
color: #777;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.on-button--xsmall {
|
|
98
|
+
font-size: 10px;
|
|
99
|
+
padding: 5px 8px;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.on-button--small {
|
|
103
|
+
font-size: 12px;
|
|
104
|
+
padding: 11px 14px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.on-button--medium {
|
|
108
|
+
font-size: 14px;
|
|
109
|
+
padding: 14px 20px;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.on-button--large {
|
|
113
|
+
font-size: 18px;
|
|
114
|
+
padding: 15px 24px;
|
|
115
|
+
|
|
116
|
+
&.on-button--navbar {
|
|
117
|
+
font-size: 14px;
|
|
118
|
+
padding: 18px 24px;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.login-button {
|
|
123
|
+
display: flex;
|
|
124
|
+
justify-content: center;
|
|
125
|
+
width: 100%;
|
|
126
|
+
margin: 0 20px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.button-group-wrapper {
|
|
130
|
+
position: relative;
|
|
131
|
+
.btn-group {
|
|
132
|
+
justify-content: flex-start;
|
|
133
|
+
button {
|
|
134
|
+
margin: 0 10px 0 0;
|
|
135
|
+
}
|
|
136
|
+
.tooltip {
|
|
137
|
+
display: inline-block;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { Tooltip } from "../tooltip/Tooltip"
|
|
3
|
+
import { Button } from "../button/Button"
|
|
4
|
+
import "./count-toggle.scss"
|
|
5
|
+
|
|
6
|
+
export interface CountToggleProps {
|
|
7
|
+
label?: string
|
|
8
|
+
icon?: string
|
|
9
|
+
disabled?: boolean
|
|
10
|
+
tooltip?: string
|
|
11
|
+
toggleClick?: () => void
|
|
12
|
+
lock?: boolean
|
|
13
|
+
clicked: boolean
|
|
14
|
+
count: number
|
|
15
|
+
}
|
|
16
|
+
export const CountToggle = ({
|
|
17
|
+
label,
|
|
18
|
+
icon,
|
|
19
|
+
disabled,
|
|
20
|
+
tooltip,
|
|
21
|
+
toggleClick,
|
|
22
|
+
clicked,
|
|
23
|
+
count,
|
|
24
|
+
}: CountToggleProps) => {
|
|
25
|
+
const toggleButton = (
|
|
26
|
+
<span className="toggle-counter">
|
|
27
|
+
<Button
|
|
28
|
+
className={clicked ? "toggle-btn active" : "toggle-btn"}
|
|
29
|
+
iconSize="12px"
|
|
30
|
+
icon={"fa " + icon}
|
|
31
|
+
onClick={toggleClick}
|
|
32
|
+
label={label}
|
|
33
|
+
>
|
|
34
|
+
<span className="count-span">{count}</span>
|
|
35
|
+
</Button>
|
|
36
|
+
</span>
|
|
37
|
+
)
|
|
38
|
+
const disabledToggleButton = (
|
|
39
|
+
<span className="toggle-counter disabled">
|
|
40
|
+
<Button
|
|
41
|
+
className={clicked ? "toggle-btn active" : "toggle-btn"}
|
|
42
|
+
iconSize="12px"
|
|
43
|
+
icon={"fa " + icon}
|
|
44
|
+
onClick={toggleClick}
|
|
45
|
+
label={label}
|
|
46
|
+
>
|
|
47
|
+
<span className="count-span">{count}</span>
|
|
48
|
+
</Button>
|
|
49
|
+
</span>
|
|
50
|
+
)
|
|
51
|
+
const button = disabled ? disabledToggleButton : toggleButton
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
<div className="toggle-counter-wrap">
|
|
55
|
+
{tooltip
|
|
56
|
+
? (
|
|
57
|
+
<Tooltip flow="up" tooltip={tooltip}>
|
|
58
|
+
{button}
|
|
59
|
+
</Tooltip>
|
|
60
|
+
)
|
|
61
|
+
: button}
|
|
62
|
+
</div>
|
|
63
|
+
</>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { vi } from "vitest"
|
|
2
|
+
import React from "react"
|
|
3
|
+
import { fireEvent, render, screen } from "@testing-library/react"
|
|
4
|
+
import { CountToggle } from "../CountToggle"
|
|
5
|
+
|
|
6
|
+
export const datasetType_available = [
|
|
7
|
+
{ label: "All Public", value: "All Public" },
|
|
8
|
+
{ label: "Following", value: "Following" },
|
|
9
|
+
{ label: "My Datasets", value: "My Datasets" },
|
|
10
|
+
{ label: "My Bookmarks", value: "My Bookmarks" },
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
describe("CountToggle component", () => {
|
|
14
|
+
it("calls toggleClick on toggle", () => {
|
|
15
|
+
const toggleClick = vi.fn()
|
|
16
|
+
const clicked = false
|
|
17
|
+
const count = 3
|
|
18
|
+
render(
|
|
19
|
+
<CountToggle
|
|
20
|
+
label="count toggle test"
|
|
21
|
+
icon="fa-thumbtack"
|
|
22
|
+
toggleClick={toggleClick}
|
|
23
|
+
tooltip="test tip"
|
|
24
|
+
clicked={clicked}
|
|
25
|
+
count={count}
|
|
26
|
+
/>,
|
|
27
|
+
)
|
|
28
|
+
fireEvent.click(screen.getByText("count toggle test"))
|
|
29
|
+
expect(toggleClick).toHaveBeenCalledTimes(1)
|
|
30
|
+
})
|
|
31
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@import '../scss/variables';
|
|
2
|
+
|
|
3
|
+
.toggle-btn {
|
|
4
|
+
border: 1px solid #aaa;
|
|
5
|
+
padding: 0 7px;
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
align-items: center;
|
|
9
|
+
background: #eee;
|
|
10
|
+
&:hover {
|
|
11
|
+
text-decoration: none;
|
|
12
|
+
background-color: white;
|
|
13
|
+
}
|
|
14
|
+
i {
|
|
15
|
+
margin: 2px 13px 0 5px;
|
|
16
|
+
color: #999;
|
|
17
|
+
}
|
|
18
|
+
> span {
|
|
19
|
+
display: block;
|
|
20
|
+
position: relative;
|
|
21
|
+
|
|
22
|
+
&.count-span {
|
|
23
|
+
border-left: 1px solid #aaa;
|
|
24
|
+
margin-left: 14px;
|
|
25
|
+
padding: 3px 3px 3px 10px;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&.active {
|
|
30
|
+
i {
|
|
31
|
+
color: var(--current-theme-primary);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from "react"
|
|
2
|
+
import "./dropdown.scss"
|
|
3
|
+
|
|
4
|
+
export interface DropdownProps {
|
|
5
|
+
label: React.ReactNode
|
|
6
|
+
children: React.ReactNode
|
|
7
|
+
className?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const Dropdown = ({ children, label, className }: DropdownProps) => {
|
|
11
|
+
const [isOpen, setIsOpen] = React.useState(false)
|
|
12
|
+
const wrapperRef = useRef(null)
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
function handleClickOutside(event) {
|
|
15
|
+
if (wrapperRef.current && !wrapperRef.current.contains(event.target)) {
|
|
16
|
+
setIsOpen((_prevIsOpen) => false)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
document.addEventListener("mousedown", handleClickOutside)
|
|
20
|
+
return () => {
|
|
21
|
+
document.removeEventListener("mousedown", handleClickOutside)
|
|
22
|
+
}
|
|
23
|
+
}, [wrapperRef])
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className={className + " dropdown-wrapper"} ref={wrapperRef}>
|
|
27
|
+
<div
|
|
28
|
+
className={`toggle ${isOpen ? "active" : ""}`}
|
|
29
|
+
onClick={() => setIsOpen((prevIsOpen) => !prevIsOpen)}
|
|
30
|
+
>
|
|
31
|
+
<span>{label}</span>
|
|
32
|
+
</div>
|
|
33
|
+
<div className={`menu ${isOpen ? "expanded" : "collapsed"}`} role="menu">
|
|
34
|
+
{children}
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@import '../scss/variables';
|
|
2
|
+
|
|
3
|
+
.dropdown-wrapper {
|
|
4
|
+
display: inline-block;
|
|
5
|
+
.toggle {
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
}
|
|
8
|
+
.menu {
|
|
9
|
+
position: absolute;
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
height: 0;
|
|
12
|
+
z-index: 9999;
|
|
13
|
+
right: 0;
|
|
14
|
+
background-color: #fff;
|
|
15
|
+
border-radius: $border-radius-default;
|
|
16
|
+
@media (max-width: 800px) {
|
|
17
|
+
width: 290px;
|
|
18
|
+
right: 0;
|
|
19
|
+
}
|
|
20
|
+
@media (max-width: 435px) {
|
|
21
|
+
right: 0;
|
|
22
|
+
left: 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&.expanded {
|
|
26
|
+
height: auto;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { RadioGroup } from "../radio/RadioGroup"
|
|
3
|
+
import "./facet.scss"
|
|
4
|
+
|
|
5
|
+
export interface FacetRadioProps {
|
|
6
|
+
// if radioArr is string[]
|
|
7
|
+
// then the string items are both the label and value for the radio buttons
|
|
8
|
+
radioArr: (
|
|
9
|
+
| string
|
|
10
|
+
| {
|
|
11
|
+
label: string
|
|
12
|
+
onChange?: React.MouseEventHandler<HTMLInputElement>
|
|
13
|
+
value: string
|
|
14
|
+
}
|
|
15
|
+
)[]
|
|
16
|
+
layout: string
|
|
17
|
+
name: string
|
|
18
|
+
selected: string
|
|
19
|
+
setSelected: (value) => void
|
|
20
|
+
className?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const FacetRadio = ({
|
|
24
|
+
radioArr,
|
|
25
|
+
layout,
|
|
26
|
+
name,
|
|
27
|
+
selected,
|
|
28
|
+
setSelected,
|
|
29
|
+
className,
|
|
30
|
+
}: FacetRadioProps) => {
|
|
31
|
+
const divClass = className ? `facet-radio ${className}` : "facet-radio"
|
|
32
|
+
return (
|
|
33
|
+
<div className={divClass}>
|
|
34
|
+
<RadioGroup
|
|
35
|
+
setSelected={setSelected}
|
|
36
|
+
selected={selected}
|
|
37
|
+
name={name}
|
|
38
|
+
radioArr={radioArr}
|
|
39
|
+
layout={layout}
|
|
40
|
+
/>
|
|
41
|
+
</div>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
|
|
3
|
+
import { TwoHandleRange } from "../range/TwoHandleRange"
|
|
4
|
+
import "./facet.scss"
|
|
5
|
+
|
|
6
|
+
export interface FacetRangeProps {
|
|
7
|
+
min: number
|
|
8
|
+
max: number
|
|
9
|
+
step: number
|
|
10
|
+
value: [number | null, number | null]
|
|
11
|
+
onChange: (newvalue) => void
|
|
12
|
+
uncappedMax?: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const FacetRange = ({
|
|
16
|
+
min,
|
|
17
|
+
max,
|
|
18
|
+
step,
|
|
19
|
+
value,
|
|
20
|
+
onChange,
|
|
21
|
+
uncappedMax,
|
|
22
|
+
}: FacetRangeProps) => {
|
|
23
|
+
return (
|
|
24
|
+
<div className="facet-range">
|
|
25
|
+
<TwoHandleRange
|
|
26
|
+
min={min}
|
|
27
|
+
max={max}
|
|
28
|
+
step={step}
|
|
29
|
+
value={value}
|
|
30
|
+
onChange={onChange}
|
|
31
|
+
uncappedMax={uncappedMax}
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { TermSearch } from "../input/TermSearch"
|
|
3
|
+
import type { ButtonPropsSize } from "../button/Button"
|
|
4
|
+
import type { InputPropsStyle } from "../input/Input"
|
|
5
|
+
import "./facet.scss"
|
|
6
|
+
|
|
7
|
+
export interface FacetSearchProps {
|
|
8
|
+
setTermValue: (string) => void
|
|
9
|
+
pushTerm: React.Dispatch<React.SetStateAction<object[]>>
|
|
10
|
+
allTerms: string[]
|
|
11
|
+
className?: string
|
|
12
|
+
type?: string
|
|
13
|
+
placeholder?: string
|
|
14
|
+
labelStyle?: InputPropsStyle
|
|
15
|
+
name?: string
|
|
16
|
+
termValue: string
|
|
17
|
+
primary?: boolean
|
|
18
|
+
color?: string
|
|
19
|
+
icon?: string
|
|
20
|
+
iconSize?: string
|
|
21
|
+
size?: ButtonPropsSize
|
|
22
|
+
helpText?: React.ReactNode
|
|
23
|
+
removeFilterItem?(param, value): void
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const FacetSearch = ({
|
|
27
|
+
className,
|
|
28
|
+
termValue,
|
|
29
|
+
setTermValue,
|
|
30
|
+
pushTerm,
|
|
31
|
+
allTerms,
|
|
32
|
+
type,
|
|
33
|
+
placeholder,
|
|
34
|
+
labelStyle,
|
|
35
|
+
name,
|
|
36
|
+
color,
|
|
37
|
+
icon,
|
|
38
|
+
size,
|
|
39
|
+
iconSize,
|
|
40
|
+
helpText,
|
|
41
|
+
removeFilterItem,
|
|
42
|
+
}: FacetSearchProps) => {
|
|
43
|
+
return (
|
|
44
|
+
<div className="facet-search">
|
|
45
|
+
{helpText ? <div className="help-text">{helpText}</div> : null}
|
|
46
|
+
<TermSearch
|
|
47
|
+
className={className}
|
|
48
|
+
primary={true}
|
|
49
|
+
color={color}
|
|
50
|
+
icon={icon}
|
|
51
|
+
iconSize={iconSize}
|
|
52
|
+
size={size}
|
|
53
|
+
pushTerm={pushTerm}
|
|
54
|
+
type={type}
|
|
55
|
+
label={null}
|
|
56
|
+
placeholder={placeholder}
|
|
57
|
+
labelStyle={labelStyle}
|
|
58
|
+
name={name}
|
|
59
|
+
termValue={termValue}
|
|
60
|
+
setTermValue={setTermValue}
|
|
61
|
+
allTerms={allTerms}
|
|
62
|
+
removeFilterItem={removeFilterItem}
|
|
63
|
+
/>
|
|
64
|
+
</div>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import "./facet.scss"
|
|
3
|
+
|
|
4
|
+
export type FacetSelectValueType =
|
|
5
|
+
| { label: string; value: string }
|
|
6
|
+
| string
|
|
7
|
+
| null
|
|
8
|
+
|
|
9
|
+
export interface FacetSelectProps {
|
|
10
|
+
// items may be a list of objects with labels and values
|
|
11
|
+
// or a simple array of strings, where the string is used for both their labels and values
|
|
12
|
+
items: (
|
|
13
|
+
| string
|
|
14
|
+
| {
|
|
15
|
+
label: string
|
|
16
|
+
value: string
|
|
17
|
+
count?: number
|
|
18
|
+
children?: null | { label: string; value: string; count: number }[]
|
|
19
|
+
}
|
|
20
|
+
)[]
|
|
21
|
+
className?: string
|
|
22
|
+
label?: string
|
|
23
|
+
selected: FacetSelectValueType
|
|
24
|
+
setSelected: (selected: FacetSelectValueType) => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const get = (obj, property) => (typeof obj === "object" ? obj[property] : obj)
|
|
28
|
+
export const check = (obj, property) =>
|
|
29
|
+
typeof obj === "object" && typeof obj[property] === "number"
|
|
30
|
+
? obj[property].toLocaleString()
|
|
31
|
+
: typeof obj === "object"
|
|
32
|
+
? obj[property]
|
|
33
|
+
: false
|
|
34
|
+
|
|
35
|
+
export const FacetSelect = ({
|
|
36
|
+
items,
|
|
37
|
+
className,
|
|
38
|
+
selected,
|
|
39
|
+
label,
|
|
40
|
+
setSelected,
|
|
41
|
+
}: FacetSelectProps) => {
|
|
42
|
+
const setSelectorNoPropagation = (e, value) => {
|
|
43
|
+
e.stopPropagation()
|
|
44
|
+
setSelected(value)
|
|
45
|
+
}
|
|
46
|
+
return (
|
|
47
|
+
<div className={className}>
|
|
48
|
+
{label && <h2>{label}</h2>}
|
|
49
|
+
<div className="facet-list">
|
|
50
|
+
<ul className="level-1">
|
|
51
|
+
{items.map((item, index) => (
|
|
52
|
+
<li
|
|
53
|
+
key={index}
|
|
54
|
+
onClick={(e) => setSelectorNoPropagation(e, get(item, "value"))}
|
|
55
|
+
className={selected && selected == get(item, "value")
|
|
56
|
+
? "selected-facet facet"
|
|
57
|
+
: "facet"}
|
|
58
|
+
>
|
|
59
|
+
<span className="label">
|
|
60
|
+
{get(item, "label")}
|
|
61
|
+
{check(item, "count") && <span>({check(item, "count")})</span>}
|
|
62
|
+
</span>
|
|
63
|
+
{check(item, "children") && (
|
|
64
|
+
<ul className="level-2">
|
|
65
|
+
{get(item, "children").map((item, index) => (
|
|
66
|
+
<li
|
|
67
|
+
key={index}
|
|
68
|
+
onClick={(e) => setSelectorNoPropagation(e, item.value)}
|
|
69
|
+
className={selected && selected == item.value
|
|
70
|
+
? "selected-facet facet"
|
|
71
|
+
: "facet"}
|
|
72
|
+
>
|
|
73
|
+
<span className="label">
|
|
74
|
+
{item.label}
|
|
75
|
+
{item.count && <span>({item.count})</span>}
|
|
76
|
+
</span>
|
|
77
|
+
</li>
|
|
78
|
+
))}
|
|
79
|
+
</ul>
|
|
80
|
+
)}
|
|
81
|
+
</li>
|
|
82
|
+
))}
|
|
83
|
+
</ul>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import "./facet.scss"
|
|
3
|
+
|
|
4
|
+
export interface SingleSelectProps {
|
|
5
|
+
items: string[]
|
|
6
|
+
label?: string
|
|
7
|
+
className?: string
|
|
8
|
+
selected: string | null
|
|
9
|
+
setSelected: (selected: string | null) => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const SingleSelect = ({
|
|
13
|
+
items,
|
|
14
|
+
label,
|
|
15
|
+
className,
|
|
16
|
+
selected,
|
|
17
|
+
setSelected,
|
|
18
|
+
}: SingleSelectProps) => {
|
|
19
|
+
const handleSelect = (e: React.MouseEvent, value: string) => {
|
|
20
|
+
e.stopPropagation()
|
|
21
|
+
setSelected(value)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className={className}>
|
|
26
|
+
<ul className="single-select-list">
|
|
27
|
+
{items.map((item, index) => (
|
|
28
|
+
<li
|
|
29
|
+
key={index}
|
|
30
|
+
onClick={(e) => handleSelect(e, item)}
|
|
31
|
+
className={selected === item ? "selected-item" : "item"}
|
|
32
|
+
>
|
|
33
|
+
{label ? label : item}
|
|
34
|
+
</li>
|
|
35
|
+
))}
|
|
36
|
+
</ul>
|
|
37
|
+
</div>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { check } from "../FacetSelect"
|
|
2
|
+
|
|
3
|
+
describe("FacetSelect component", () => {
|
|
4
|
+
describe("check()", () => {
|
|
5
|
+
it("adds commas to numeric properties", () => {
|
|
6
|
+
expect(check({ data: 1934810581 }, "data")).toEqual("1,934,810,581")
|
|
7
|
+
})
|
|
8
|
+
it("nested objects to return child object", () => {
|
|
9
|
+
expect(check({ num: 18485, obj: { num: 810591 } }, "obj")).toEqual({
|
|
10
|
+
num: 810591,
|
|
11
|
+
})
|
|
12
|
+
})
|
|
13
|
+
})
|
|
14
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { fireEvent, render, screen } from "@testing-library/react"
|
|
3
|
+
import { SingleSelect } from "../SingleSelect"
|
|
4
|
+
|
|
5
|
+
describe("SingleSelect Component", () => {
|
|
6
|
+
it("renders the provided label", () => {
|
|
7
|
+
const items = ["Option"]
|
|
8
|
+
let selectedValue: string | null = null
|
|
9
|
+
|
|
10
|
+
const mockSetSelected = (selected: string | null) => {
|
|
11
|
+
selectedValue = selected
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Test with label
|
|
15
|
+
render(
|
|
16
|
+
<SingleSelect
|
|
17
|
+
items={items}
|
|
18
|
+
selected={selectedValue}
|
|
19
|
+
setSelected={mockSetSelected}
|
|
20
|
+
label="Label"
|
|
21
|
+
/>,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
// Debug to check the rendered HTML
|
|
25
|
+
screen.debug()
|
|
26
|
+
|
|
27
|
+
// The label "Label" should be rendered outside the list
|
|
28
|
+
expect(screen.getByText("Label")).toBeInTheDocument()
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it("renders the provided item", () => {
|
|
32
|
+
const items = ["Option"]
|
|
33
|
+
let selectedValue: string | null = null
|
|
34
|
+
|
|
35
|
+
const mockSetSelected = (selected: string | null) => {
|
|
36
|
+
selectedValue = selected
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Test without label
|
|
40
|
+
render(
|
|
41
|
+
<SingleSelect
|
|
42
|
+
items={items}
|
|
43
|
+
selected={selectedValue}
|
|
44
|
+
setSelected={mockSetSelected}
|
|
45
|
+
/>,
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
// Debug to check the rendered HTML
|
|
49
|
+
screen.debug()
|
|
50
|
+
|
|
51
|
+
// Simulate selecting "Option"
|
|
52
|
+
const optionToSelect = screen.getByText("Option")
|
|
53
|
+
fireEvent.click(optionToSelect)
|
|
54
|
+
|
|
55
|
+
// Expect the selected value to be the clicked item ("Option")
|
|
56
|
+
expect(selectedValue).toBe("Option")
|
|
57
|
+
})
|
|
58
|
+
})
|