@openneuro/app 4.33.4 → 4.34.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 +4 -3
- 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,335 @@
|
|
|
1
|
+
@import '../scss/variables';
|
|
2
|
+
.custom-radio {
|
|
3
|
+
margin: 10px 0 20px;
|
|
4
|
+
[type='radio']:checked,
|
|
5
|
+
[type='radio']:not(:checked) {
|
|
6
|
+
position: absolute;
|
|
7
|
+
left: -9999px;
|
|
8
|
+
}
|
|
9
|
+
[type='radio']:checked + label,
|
|
10
|
+
[type='radio']:not(:checked) + label {
|
|
11
|
+
font-size: 14px;
|
|
12
|
+
position: relative;
|
|
13
|
+
padding-left: 25px;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
line-height: 20px;
|
|
16
|
+
display: inline-block;
|
|
17
|
+
color: #666;
|
|
18
|
+
}
|
|
19
|
+
[type='radio']:checked + label:before,
|
|
20
|
+
[type='radio']:not(:checked) + label:before {
|
|
21
|
+
content: '';
|
|
22
|
+
position: absolute;
|
|
23
|
+
left: 0;
|
|
24
|
+
top: 0;
|
|
25
|
+
width: 18px;
|
|
26
|
+
height: 18px;
|
|
27
|
+
border: 1px solid $newspaper;
|
|
28
|
+
border-radius: 100%;
|
|
29
|
+
background: #fff;
|
|
30
|
+
}
|
|
31
|
+
[type='radio']:checked + label:after,
|
|
32
|
+
[type='radio']:not(:checked) + label:after {
|
|
33
|
+
content: '';
|
|
34
|
+
width: 12px;
|
|
35
|
+
height: 12px;
|
|
36
|
+
background: var(--current-theme-primary);
|
|
37
|
+
position: absolute;
|
|
38
|
+
top: 4px;
|
|
39
|
+
left: 4px;
|
|
40
|
+
border-radius: 100%;
|
|
41
|
+
-webkit-transition: all 0.2s ease;
|
|
42
|
+
transition: all 0.2s ease;
|
|
43
|
+
}
|
|
44
|
+
[type='radio']:not(:checked) + label:after {
|
|
45
|
+
opacity: 0;
|
|
46
|
+
-webkit-transform: scale(0);
|
|
47
|
+
transform: scale(0);
|
|
48
|
+
}
|
|
49
|
+
[type='radio']:checked + label:after {
|
|
50
|
+
opacity: 1;
|
|
51
|
+
-webkit-transform: scale(1);
|
|
52
|
+
transform: scale(1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.custom-checkbox {
|
|
57
|
+
margin: 10px 0 20px;
|
|
58
|
+
[type='checkbox']:checked,
|
|
59
|
+
[type='checkbox']:not(:checked) {
|
|
60
|
+
position: absolute;
|
|
61
|
+
left: -9999px;
|
|
62
|
+
}
|
|
63
|
+
[type='checkbox']:checked + label,
|
|
64
|
+
[type='checkbox']:not(:checked) + label {
|
|
65
|
+
font-size: 14px;
|
|
66
|
+
position: relative;
|
|
67
|
+
padding-left: 25px;
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
line-height: 20px;
|
|
70
|
+
display: inline-block;
|
|
71
|
+
color: #666;
|
|
72
|
+
}
|
|
73
|
+
[type='checkbox']:checked + label:before,
|
|
74
|
+
[type='checkbox']:not(:checked) + label:before {
|
|
75
|
+
content: '';
|
|
76
|
+
position: absolute;
|
|
77
|
+
left: 0;
|
|
78
|
+
top: 0;
|
|
79
|
+
width: 18px;
|
|
80
|
+
height: 18px;
|
|
81
|
+
border: 1px solid $newspaper;
|
|
82
|
+
border-radius: 0;
|
|
83
|
+
background: #fff;
|
|
84
|
+
}
|
|
85
|
+
[type='checkbox']:checked + label:after,
|
|
86
|
+
[type='checkbox']:not(:checked) + label:after {
|
|
87
|
+
content: '';
|
|
88
|
+
width: 12px;
|
|
89
|
+
height: 12px;
|
|
90
|
+
background: var(--current-theme-primary);
|
|
91
|
+
position: absolute;
|
|
92
|
+
top: 4px;
|
|
93
|
+
left: 4px;
|
|
94
|
+
border-radius: 0;
|
|
95
|
+
-webkit-transition: all 0.2s ease;
|
|
96
|
+
transition: all 0.2s ease;
|
|
97
|
+
}
|
|
98
|
+
[type='checkbox']:not(:checked) + label:after {
|
|
99
|
+
opacity: 0;
|
|
100
|
+
-webkit-transform: scale(0);
|
|
101
|
+
transform: scale(0);
|
|
102
|
+
}
|
|
103
|
+
[type='checkbox']:checked + label:after {
|
|
104
|
+
opacity: 1;
|
|
105
|
+
-webkit-transform: scale(1);
|
|
106
|
+
transform: scale(1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.on-radio-wrapper {
|
|
111
|
+
&.row {
|
|
112
|
+
display: flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
flex-wrap: wrap;
|
|
115
|
+
.custom-radio {
|
|
116
|
+
margin-right: 20px;
|
|
117
|
+
&:last-child {
|
|
118
|
+
margin-right: 0;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
&.column {
|
|
123
|
+
display: flex;
|
|
124
|
+
flex-direction: column;
|
|
125
|
+
justify-content: space-between;
|
|
126
|
+
align-items: flex-start;
|
|
127
|
+
.custom-radio {
|
|
128
|
+
margin-bottom: 20px;
|
|
129
|
+
&:last-child {
|
|
130
|
+
margin-bottom: 0;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.on-radio-wrapper.chiclet {
|
|
137
|
+
display: flex;
|
|
138
|
+
justify-content: space-between;
|
|
139
|
+
.custom-radio {
|
|
140
|
+
margin: 0 0 10px;
|
|
141
|
+
|
|
142
|
+
> label {
|
|
143
|
+
margin: 0 10px 0 0;
|
|
144
|
+
}
|
|
145
|
+
&:last-child {
|
|
146
|
+
> label {
|
|
147
|
+
margin-right: 0;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
[type='radio']:checked + label:before,
|
|
151
|
+
[type='radio']:not(:checked) + label:before,
|
|
152
|
+
[type='radio']:not(:checked) + label:after,
|
|
153
|
+
[type='radio']:checked + label:after {
|
|
154
|
+
content: '';
|
|
155
|
+
width: auto;
|
|
156
|
+
height: auto;
|
|
157
|
+
background: none;
|
|
158
|
+
position: relative;
|
|
159
|
+
top: 0;
|
|
160
|
+
left: 0;
|
|
161
|
+
border-radius: 0;
|
|
162
|
+
transition: none;
|
|
163
|
+
font-size: 20px;
|
|
164
|
+
|
|
165
|
+
line-height: 0;
|
|
166
|
+
border: 0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
[type='radio']:checked + label:after {
|
|
170
|
+
content: '\d7';
|
|
171
|
+
margin: 0 0 0 10px;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
[type='radio']:not(:checked) + label {
|
|
175
|
+
border-radius: 4px;
|
|
176
|
+
border: 1px solid $chiclet-color;
|
|
177
|
+
color: $chiclet-color;
|
|
178
|
+
transition: background-color 0.3s;
|
|
179
|
+
cursor: pointer;
|
|
180
|
+
font-size: 13px;
|
|
181
|
+
line-height: 1.7em;
|
|
182
|
+
position: relative;
|
|
183
|
+
padding: 6px 10px;
|
|
184
|
+
display: flex;
|
|
185
|
+
align-items: center;
|
|
186
|
+
&:nth-child(1) {
|
|
187
|
+
margin: 0 10px 0 0;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
[type='radio']:checked + label {
|
|
191
|
+
color: #fff;
|
|
192
|
+
border-radius: 4px;
|
|
193
|
+
background-color: $chiclet-color;
|
|
194
|
+
transition: background-color 0.3s;
|
|
195
|
+
cursor: pointer;
|
|
196
|
+
font-size: 13px;
|
|
197
|
+
line-height: 1.7em;
|
|
198
|
+
position: relative;
|
|
199
|
+
padding: 6px 10px;
|
|
200
|
+
display: flex;
|
|
201
|
+
align-items: center;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.facet-radio.btn-group-wrapper {
|
|
207
|
+
position: relative;
|
|
208
|
+
margin: 0 0 10px;
|
|
209
|
+
background-color: #f6f6f6;
|
|
210
|
+
border: 1px solid #eee;
|
|
211
|
+
border-radius: 4px;
|
|
212
|
+
@media (max-width: 450px) {
|
|
213
|
+
.on-radio-wrapper.btn-group {
|
|
214
|
+
flex-direction: column;
|
|
215
|
+
button,
|
|
216
|
+
.custom-radio {
|
|
217
|
+
height: 50px;
|
|
218
|
+
padding: 0;
|
|
219
|
+
display: flex;
|
|
220
|
+
align-items: center;
|
|
221
|
+
justify-content: center;
|
|
222
|
+
min-width: 100%;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
&:after {
|
|
228
|
+
content: '';
|
|
229
|
+
min-width: 25%;
|
|
230
|
+
height: 100%;
|
|
231
|
+
background-color: var(--current-theme-primary);
|
|
232
|
+
position: absolute;
|
|
233
|
+
display: block;
|
|
234
|
+
top: 0;
|
|
235
|
+
transition: margin 0.3s;
|
|
236
|
+
border-radius: 4px 0 0 4px;
|
|
237
|
+
@media (max-width: 450px) {
|
|
238
|
+
min-width: 100%;
|
|
239
|
+
height: 50px;
|
|
240
|
+
border-radius: 0;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
&.Following {
|
|
244
|
+
&:after {
|
|
245
|
+
margin-left: 25%;
|
|
246
|
+
border-radius: 0;
|
|
247
|
+
@media (max-width: 450px) {
|
|
248
|
+
margin-left: 0;
|
|
249
|
+
margin-top: 50px;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
&.MyDatasets {
|
|
254
|
+
&:after {
|
|
255
|
+
margin-left: 50%;
|
|
256
|
+
border-radius: 0;
|
|
257
|
+
@media (max-width: 450px) {
|
|
258
|
+
margin-left: 0;
|
|
259
|
+
margin-top: 100px;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
&.MyBookmarks {
|
|
264
|
+
&:after {
|
|
265
|
+
margin-left: 75%;
|
|
266
|
+
border-radius: 0 4px 4px 0;
|
|
267
|
+
@media (max-width: 450px) {
|
|
268
|
+
margin-left: 0;
|
|
269
|
+
border-radius: 0;
|
|
270
|
+
margin-top: 150px;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
.on-radio-wrapper.btn-group {
|
|
276
|
+
display: flex;
|
|
277
|
+
justify-content: space-between;
|
|
278
|
+
z-index: 1;
|
|
279
|
+
position: relative;
|
|
280
|
+
.custom-radio {
|
|
281
|
+
min-width: 25%;
|
|
282
|
+
margin: 0;
|
|
283
|
+
|
|
284
|
+
> label {
|
|
285
|
+
margin: 0;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
[type='radio']:checked + label:before,
|
|
289
|
+
[type='radio']:not(:checked) + label:before,
|
|
290
|
+
[type='radio']:not(:checked) + label:after,
|
|
291
|
+
[type='radio']:checked + label:after {
|
|
292
|
+
display: none;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
[type='radio']:checked + label,
|
|
296
|
+
[type='radio']:not(:checked) + label {
|
|
297
|
+
border-radius: 0;
|
|
298
|
+
border: none;
|
|
299
|
+
color: var(--current-theme-primary);
|
|
300
|
+
cursor: pointer;
|
|
301
|
+
font-size: 13px;
|
|
302
|
+
line-height: 1.7em;
|
|
303
|
+
position: relative;
|
|
304
|
+
padding: 6px 2px;
|
|
305
|
+
display: block;
|
|
306
|
+
text-align: center;
|
|
307
|
+
transition: color 0s;
|
|
308
|
+
transition-delay: 0s;
|
|
309
|
+
border-right: 1px solid var(--current-theme-primary);
|
|
310
|
+
@media (max-width: 450px) {
|
|
311
|
+
border-right: 0;
|
|
312
|
+
border-bottom: 1px solid var(--current-theme-primary);
|
|
313
|
+
height: 50px;
|
|
314
|
+
padding: 0;
|
|
315
|
+
display: flex;
|
|
316
|
+
align-items: center;
|
|
317
|
+
justify-content: center;
|
|
318
|
+
min-width: 100%;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
[type='radio']:not(:checked) + label:hover {
|
|
322
|
+
background-color: var(--current-theme-primary-light);
|
|
323
|
+
}
|
|
324
|
+
[type='radio']:checked + label {
|
|
325
|
+
color: #fff;
|
|
326
|
+
transition-delay: 0.15s;
|
|
327
|
+
}
|
|
328
|
+
&:last-child {
|
|
329
|
+
[type='radio']:checked + label,
|
|
330
|
+
[type='radio']:not(:checked) + label {
|
|
331
|
+
border: 0;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
@import '../scss/variables';
|
|
2
|
+
$rangeWidth: 90%;
|
|
3
|
+
|
|
4
|
+
.formRange-inner {
|
|
5
|
+
max-width: 80%;
|
|
6
|
+
margin: 0 auto;
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
align-items: center;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
min-width: $rangeWidth;
|
|
12
|
+
position: relative;
|
|
13
|
+
padding: 0 0 30px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.slider {
|
|
17
|
+
position: relative;
|
|
18
|
+
width: $rangeWidth;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.slider__track,
|
|
22
|
+
.slider__range,
|
|
23
|
+
.slider__left-value,
|
|
24
|
+
.slider__right-value {
|
|
25
|
+
position: absolute;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.slider__track,
|
|
29
|
+
.slider__range {
|
|
30
|
+
border-radius: 3px;
|
|
31
|
+
height: 5px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.slider__track {
|
|
35
|
+
background-color: #ced4da;
|
|
36
|
+
width: 100%;
|
|
37
|
+
z-index: 1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.slider__range {
|
|
41
|
+
background-color: var(--current-theme-primary);
|
|
42
|
+
z-index: 2;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.slider__left-value,
|
|
46
|
+
.slider__right-value {
|
|
47
|
+
color: #333;
|
|
48
|
+
font-size: 12px;
|
|
49
|
+
margin-top: 20px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.slider__left-value {
|
|
53
|
+
left: 6px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.slider__right-value {
|
|
57
|
+
right: -4px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Removing the default appearance */
|
|
61
|
+
.thumb,
|
|
62
|
+
.thumb::-webkit-slider-thumb {
|
|
63
|
+
-webkit-appearance: none;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.thumb {
|
|
67
|
+
pointer-events: none;
|
|
68
|
+
position: absolute;
|
|
69
|
+
height: 0;
|
|
70
|
+
width: $rangeWidth;
|
|
71
|
+
outline: none;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.thumb--left {
|
|
75
|
+
z-index: 3;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.thumb--right {
|
|
79
|
+
z-index: 4;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* For Chrome browsers */
|
|
83
|
+
.thumb::-webkit-slider-thumb {
|
|
84
|
+
background-color: #fff;
|
|
85
|
+
border: 1px solid var(--current-theme-primary-light);
|
|
86
|
+
border-radius: 50%;
|
|
87
|
+
box-shadow: 0 0 5px -1px var(--current-theme-primary);
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
height: 18px;
|
|
90
|
+
width: 18px;
|
|
91
|
+
margin-top: 4px;
|
|
92
|
+
pointer-events: all;
|
|
93
|
+
position: relative;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* For Firefox browsers */
|
|
97
|
+
.thumb::-moz-range-thumb {
|
|
98
|
+
background-color: #fff;
|
|
99
|
+
border: 1px solid var(--current-theme-primary-light);
|
|
100
|
+
border-radius: 50%;
|
|
101
|
+
box-shadow: 0 0 5px -1px var(--current-theme-primary);
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
height: 18px;
|
|
104
|
+
width: 18px;
|
|
105
|
+
margin-top: 4px;
|
|
106
|
+
pointer-events: all;
|
|
107
|
+
position: relative;
|
|
108
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef } from "react"
|
|
2
|
+
import "./TwoHandleRange.scss"
|
|
3
|
+
|
|
4
|
+
export function stepping(value, step) {
|
|
5
|
+
return Math.round(value / step) * step
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface TwoHandleRangeProps {
|
|
9
|
+
// Minimum value for range
|
|
10
|
+
min: number
|
|
11
|
+
// Maximum value for range
|
|
12
|
+
max: number
|
|
13
|
+
// Integer step for range values
|
|
14
|
+
step: number
|
|
15
|
+
// [min, max] starting values
|
|
16
|
+
value: [number, number]
|
|
17
|
+
// Change event handler for either value changing, returns [minVal, maxVal]
|
|
18
|
+
onChange: (value: [number, number]) => void
|
|
19
|
+
// At max value interpret this as any value greater than min
|
|
20
|
+
uncappedMax?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const TwoHandleRange: React.FC<TwoHandleRangeProps> = ({
|
|
24
|
+
min,
|
|
25
|
+
max,
|
|
26
|
+
step,
|
|
27
|
+
value,
|
|
28
|
+
onChange,
|
|
29
|
+
uncappedMax = false,
|
|
30
|
+
}) => {
|
|
31
|
+
const range = useRef<HTMLDivElement>(null)
|
|
32
|
+
|
|
33
|
+
// Convert to percentage
|
|
34
|
+
const getPercent = useCallback(
|
|
35
|
+
(value: number) => Math.round(((value - min) / (max - min)) * 100),
|
|
36
|
+
[min, max],
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
// Set width of the range to decrease from the left side
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
const minPercent = getPercent(value[0])
|
|
42
|
+
const maxPercent = getPercent(value[1])
|
|
43
|
+
|
|
44
|
+
if (range.current) {
|
|
45
|
+
range.current.style.left = `${minPercent}%`
|
|
46
|
+
range.current.style.width = `${maxPercent - minPercent}%`
|
|
47
|
+
}
|
|
48
|
+
}, [value[0], getPercent])
|
|
49
|
+
|
|
50
|
+
// Set width of the range to decrease from the right side
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const minPercent = getPercent(value[0])
|
|
53
|
+
const maxPercent = getPercent(value[1])
|
|
54
|
+
|
|
55
|
+
if (range.current) {
|
|
56
|
+
range.current.style.width = `${maxPercent - minPercent}%`
|
|
57
|
+
}
|
|
58
|
+
}, [value[1], getPercent])
|
|
59
|
+
|
|
60
|
+
const minChangeHandler = (
|
|
61
|
+
event:
|
|
62
|
+
| React.ChangeEvent<HTMLInputElement>
|
|
63
|
+
| React.KeyboardEvent<HTMLInputElement>,
|
|
64
|
+
) => {
|
|
65
|
+
const changeEvent = event as React.ChangeEvent<HTMLInputElement>
|
|
66
|
+
const discreteValue = stepping(
|
|
67
|
+
Math.min(Number(changeEvent.target.value), value[1] - 1),
|
|
68
|
+
step,
|
|
69
|
+
)
|
|
70
|
+
onChange([discreteValue, value[1]])
|
|
71
|
+
}
|
|
72
|
+
const maxChangeHandler = (
|
|
73
|
+
event:
|
|
74
|
+
| React.ChangeEvent<HTMLInputElement>
|
|
75
|
+
| React.KeyboardEvent<HTMLInputElement>,
|
|
76
|
+
) => {
|
|
77
|
+
const changeEvent = event as React.ChangeEvent<HTMLInputElement>
|
|
78
|
+
const discreteValue = stepping(
|
|
79
|
+
Math.max(Number(changeEvent.target.value), value[0] + 1),
|
|
80
|
+
step,
|
|
81
|
+
)
|
|
82
|
+
onChange([value[0], discreteValue])
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const leftValue = value[0]
|
|
86
|
+
const rightValue = uncappedMax
|
|
87
|
+
? (value[1] === max && `${value[1]}+`) || value[1]
|
|
88
|
+
: value[1]
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div className="formRange-inner">
|
|
92
|
+
<input
|
|
93
|
+
type="range"
|
|
94
|
+
min={min}
|
|
95
|
+
max={max}
|
|
96
|
+
value={value[0]}
|
|
97
|
+
step={step}
|
|
98
|
+
onChange={minChangeHandler}
|
|
99
|
+
onKeyDown={minChangeHandler}
|
|
100
|
+
aria-valuemin={min}
|
|
101
|
+
aria-valuemax={max}
|
|
102
|
+
aria-valuenow={value[0]}
|
|
103
|
+
className="thumb thumb--left"
|
|
104
|
+
style={{ zIndex: value[0] > max - 100 && 5 }}
|
|
105
|
+
/>
|
|
106
|
+
<input
|
|
107
|
+
type="range"
|
|
108
|
+
min={min}
|
|
109
|
+
max={max}
|
|
110
|
+
value={value[1]}
|
|
111
|
+
step={step}
|
|
112
|
+
onChange={maxChangeHandler}
|
|
113
|
+
onKeyDown={maxChangeHandler}
|
|
114
|
+
aria-valuemin={min}
|
|
115
|
+
aria-valuemax={max}
|
|
116
|
+
aria-valuenow={value[1]}
|
|
117
|
+
className="thumb thumb--right"
|
|
118
|
+
/>
|
|
119
|
+
|
|
120
|
+
<div className="slider">
|
|
121
|
+
<div className="slider__track"></div>
|
|
122
|
+
<div ref={range} className="slider__range"></div>
|
|
123
|
+
<div className="slider__left-value">{leftValue}</div>
|
|
124
|
+
<div className="slider__right-value">{rightValue}</div>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { vi } from "vitest"
|
|
2
|
+
import React from "react"
|
|
3
|
+
import { fireEvent, render, screen } from "@testing-library/react"
|
|
4
|
+
import { TwoHandleRange } from "../TwoHandleRange"
|
|
5
|
+
|
|
6
|
+
import { stepping } from "../TwoHandleRange"
|
|
7
|
+
|
|
8
|
+
describe("TwoHandleRange component", () => {
|
|
9
|
+
describe("stepping()", () => {
|
|
10
|
+
it("rounds to ten based steps", () => {
|
|
11
|
+
expect(stepping(4, 10)).toBe(0)
|
|
12
|
+
expect(stepping(15, 10)).toBe(20)
|
|
13
|
+
expect(stepping(99, 10)).toBe(100)
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
it("fires event when changed", () => {
|
|
17
|
+
const onChange = vi.fn()
|
|
18
|
+
render(
|
|
19
|
+
<TwoHandleRange
|
|
20
|
+
min={0}
|
|
21
|
+
max={100}
|
|
22
|
+
step={10}
|
|
23
|
+
value={[0, 20]}
|
|
24
|
+
onChange={onChange}
|
|
25
|
+
/>,
|
|
26
|
+
)
|
|
27
|
+
const ranges = screen.queryAllByRole("slider")
|
|
28
|
+
fireEvent.focus(ranges[0])
|
|
29
|
+
fireEvent.keyDown(ranges[0], { key: "ArrowRight", code: "ArrowRight" })
|
|
30
|
+
fireEvent.focus(ranges[1])
|
|
31
|
+
fireEvent.keyDown(ranges[1], { key: "ArrowRight", code: "ArrowRight" })
|
|
32
|
+
expect(onChange).toHaveBeenCalledTimes(2)
|
|
33
|
+
})
|
|
34
|
+
})
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from "react"
|
|
2
|
+
import "./read-more.scss"
|
|
3
|
+
|
|
4
|
+
export interface ReadMoreProps {
|
|
5
|
+
children: React.ReactNode
|
|
6
|
+
id: string
|
|
7
|
+
collapseLabel: string
|
|
8
|
+
expandLabel: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const ReadMore = ({
|
|
12
|
+
children,
|
|
13
|
+
id,
|
|
14
|
+
expandLabel,
|
|
15
|
+
collapseLabel,
|
|
16
|
+
}: ReadMoreProps) => {
|
|
17
|
+
const readmoreRef = useRef<HTMLDivElement>()
|
|
18
|
+
const [dimensions, setDimensions] = useState({ height: 0 })
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (readmoreRef.current) {
|
|
21
|
+
setDimensions({
|
|
22
|
+
height: readmoreRef.current.offsetHeight,
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
}, [])
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<div ref={readmoreRef}>
|
|
29
|
+
{dimensions.height > 400
|
|
30
|
+
? (
|
|
31
|
+
<article className="has-read-more file-tree">
|
|
32
|
+
<input type="checkbox" className="show-more" id={id} />
|
|
33
|
+
|
|
34
|
+
<section>
|
|
35
|
+
{children}
|
|
36
|
+
<label htmlFor={id} className="expand-collapse">
|
|
37
|
+
<span>{expandLabel}</span>
|
|
38
|
+
<span>{collapseLabel}</span>
|
|
39
|
+
</label>
|
|
40
|
+
</section>
|
|
41
|
+
</article>
|
|
42
|
+
)
|
|
43
|
+
: (
|
|
44
|
+
<article>
|
|
45
|
+
<section>{children}</section>
|
|
46
|
+
</article>
|
|
47
|
+
)}
|
|
48
|
+
</div>
|
|
49
|
+
)
|
|
50
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import { render, screen } from "@testing-library/react"
|
|
3
|
+
import { ReadMore } from "../ReadMore"
|
|
4
|
+
|
|
5
|
+
describe("ReadMore component", () => {
|
|
6
|
+
it("renders children", async () => {
|
|
7
|
+
render(
|
|
8
|
+
<ReadMore id="readmoretest" expandLabel="expand" collapseLabel="hide">
|
|
9
|
+
Hidden children
|
|
10
|
+
</ReadMore>,
|
|
11
|
+
)
|
|
12
|
+
expect(await screen.getByText(/Hidden children/)).toBeInTheDocument()
|
|
13
|
+
})
|
|
14
|
+
})
|