@buildcanada/charts 0.1.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/LICENSE.md +8 -0
- package/README.md +113 -0
- package/package.json +137 -0
- package/src/components/BodyPortal/BodyPortal.tsx +40 -0
- package/src/components/Button/Button.scss +110 -0
- package/src/components/Button/Button.tsx +101 -0
- package/src/components/Checkbox.scss +93 -0
- package/src/components/Checkbox.tsx +47 -0
- package/src/components/ExpandableToggle/ExpandableToggle.scss +123 -0
- package/src/components/ExpandableToggle/ExpandableToggle.tsx +60 -0
- package/src/components/GrapherTabIcon.tsx +156 -0
- package/src/components/GrapherTrendArrow.scss +16 -0
- package/src/components/GrapherTrendArrow.tsx +30 -0
- package/src/components/Halo/Halo.tsx +44 -0
- package/src/components/LabeledSwitch/LabeledSwitch.scss +109 -0
- package/src/components/LabeledSwitch/LabeledSwitch.tsx +62 -0
- package/src/components/MarkdownTextWrap/MarkdownTextWrap.tsx +1173 -0
- package/src/components/OverlayHeader.scss +18 -0
- package/src/components/OverlayHeader.tsx +29 -0
- package/src/components/RadioButton.scss +69 -0
- package/src/components/RadioButton.tsx +42 -0
- package/src/components/SimpleMarkdownText.tsx +89 -0
- package/src/components/TextInput.scss +17 -0
- package/src/components/TextInput.tsx +19 -0
- package/src/components/TextWrap/TextWrap.tsx +361 -0
- package/src/components/TextWrap/TextWrapUtils.ts +32 -0
- package/src/components/closeButton/CloseButton.scss +40 -0
- package/src/components/closeButton/CloseButton.tsx +27 -0
- package/src/components/index.ts +70 -0
- package/src/components/loadingIndicator/LoadingIndicator.scss +40 -0
- package/src/components/loadingIndicator/LoadingIndicator.tsx +28 -0
- package/src/components/markdown/remarkPlainLinks.ts +36 -0
- package/src/components/reactUtil.ts +20 -0
- package/src/components/stubs/CodeSnippet.tsx +19 -0
- package/src/components/stubs/DataCitation.tsx +16 -0
- package/src/components/stubs/IndicatorKeyData.tsx +45 -0
- package/src/components/stubs/IndicatorProcessing.tsx +15 -0
- package/src/components/stubs/IndicatorSources.tsx +15 -0
- package/src/components/styles/colors.scss +113 -0
- package/src/components/styles/mixins.scss +630 -0
- package/src/components/styles/typography.scss +579 -0
- package/src/components/styles/util.scss +89 -0
- package/src/components/styles/variables.scss +208 -0
- package/src/config/ChartsConfig.ts +163 -0
- package/src/config/ChartsProvider.tsx +157 -0
- package/src/config/index.ts +20 -0
- package/src/core-table/CoreTable.ts +1355 -0
- package/src/core-table/CoreTableColumns.ts +973 -0
- package/src/core-table/CoreTableUtils.ts +793 -0
- package/src/core-table/ErrorValues.ts +73 -0
- package/src/core-table/OwidTable.ts +1175 -0
- package/src/core-table/OwidTableSynthesizers.ts +272 -0
- package/src/core-table/OwidTableUtil.ts +76 -0
- package/src/core-table/Transforms.ts +484 -0
- package/src/core-table/index.ts +82 -0
- package/src/explorer/ColumnGrammar.ts +217 -0
- package/src/explorer/Explorer.sample.ts +212 -0
- package/src/explorer/Explorer.scss +148 -0
- package/src/explorer/Explorer.tsx +1283 -0
- package/src/explorer/ExplorerConstants.ts +85 -0
- package/src/explorer/ExplorerControls.scss +156 -0
- package/src/explorer/ExplorerControls.tsx +210 -0
- package/src/explorer/ExplorerDecisionMatrix.ts +471 -0
- package/src/explorer/ExplorerGrammar.ts +161 -0
- package/src/explorer/ExplorerProgram.ts +568 -0
- package/src/explorer/ExplorerUtils.ts +59 -0
- package/src/explorer/GrapherGrammar.ts +387 -0
- package/src/explorer/gridLang/GrammarUtils.ts +121 -0
- package/src/explorer/gridLang/GridCell.ts +298 -0
- package/src/explorer/gridLang/GridLangConstants.ts +255 -0
- package/src/explorer/gridLang/GridProgram.ts +311 -0
- package/src/explorer/gridLang/readme.md +17 -0
- package/src/explorer/index.ts +69 -0
- package/src/explorer/readme.md +19 -0
- package/src/explorer/urlMigrations/CO2UrlMigration.ts +46 -0
- package/src/explorer/urlMigrations/CovidUrlMigration.ts +37 -0
- package/src/explorer/urlMigrations/EnergyUrlMigration.ts +41 -0
- package/src/explorer/urlMigrations/ExplorerPageUrlMigrationSpec.ts +12 -0
- package/src/explorer/urlMigrations/ExplorerUrlMigrationUtils.ts +45 -0
- package/src/explorer/urlMigrations/ExplorerUrlMigrations.ts +33 -0
- package/src/explorer/urlMigrations/LegacyCovidUrlMigration.ts +144 -0
- package/src/explorer/urlMigrations/readme.md +39 -0
- package/src/grapher/axis/Axis.ts +973 -0
- package/src/grapher/axis/AxisConfig.ts +179 -0
- package/src/grapher/axis/AxisViews.tsx +597 -0
- package/src/grapher/barCharts/DiscreteBarChart.tsx +728 -0
- package/src/grapher/barCharts/DiscreteBarChartConstants.ts +60 -0
- package/src/grapher/barCharts/DiscreteBarChartHelpers.ts +338 -0
- package/src/grapher/barCharts/DiscreteBarChartState.ts +354 -0
- package/src/grapher/barCharts/DiscreteBarChartThumbnail.tsx +34 -0
- package/src/grapher/captionedChart/CaptionedChart.scss +61 -0
- package/src/grapher/captionedChart/CaptionedChart.tsx +523 -0
- package/src/grapher/captionedChart/Logos.tsx +141 -0
- package/src/grapher/captionedChart/LogosSVG.tsx +16 -0
- package/src/grapher/captionedChart/StaticChartRasterizer.tsx +178 -0
- package/src/grapher/captionedChart/assets/buildcanada-logo-square.svg +15 -0
- package/src/grapher/captionedChart/assets/buildcanada-logo.svg +15 -0
- package/src/grapher/captionedChart/assets/canadaspends.svg +7 -0
- package/src/grapher/captionedChart/readme.md +14 -0
- package/src/grapher/chart/Chart.tsx +62 -0
- package/src/grapher/chart/ChartAreaContent.tsx +172 -0
- package/src/grapher/chart/ChartDimension.ts +121 -0
- package/src/grapher/chart/ChartInterface.ts +83 -0
- package/src/grapher/chart/ChartManager.ts +113 -0
- package/src/grapher/chart/ChartTabs.ts +178 -0
- package/src/grapher/chart/ChartTypeMap.tsx +158 -0
- package/src/grapher/chart/ChartTypeSwitcher.tsx +26 -0
- package/src/grapher/chart/ChartUtils.tsx +364 -0
- package/src/grapher/chart/DimensionSlot.ts +45 -0
- package/src/grapher/chart/StaticChartWrapper.tsx +94 -0
- package/src/grapher/chart/guidedChartUtils.ts +82 -0
- package/src/grapher/color/BinningStrategies.ts +484 -0
- package/src/grapher/color/BinningStrategyEqualSizeBins.ts +132 -0
- package/src/grapher/color/BinningStrategyLogarithmic.ts +121 -0
- package/src/grapher/color/CategoricalColorAssigner.ts +97 -0
- package/src/grapher/color/ColorBrewerSchemes.ts +80 -0
- package/src/grapher/color/ColorConstants.ts +20 -0
- package/src/grapher/color/ColorScale.ts +339 -0
- package/src/grapher/color/ColorScaleBin.ts +147 -0
- package/src/grapher/color/ColorScaleConfig.ts +204 -0
- package/src/grapher/color/ColorScheme.ts +137 -0
- package/src/grapher/color/ColorSchemes.ts +149 -0
- package/src/grapher/color/ColorUtils.ts +86 -0
- package/src/grapher/color/CustomSchemes.ts +1772 -0
- package/src/grapher/color/readme.md +84 -0
- package/src/grapher/comparisonLine/ComparisonLine.tsx +31 -0
- package/src/grapher/comparisonLine/ComparisonLineConstants.ts +11 -0
- package/src/grapher/comparisonLine/ComparisonLineGenerator.ts +60 -0
- package/src/grapher/comparisonLine/ComparisonLineHelpers.ts +10 -0
- package/src/grapher/comparisonLine/CustomComparisonLine.tsx +159 -0
- package/src/grapher/comparisonLine/VerticalComparisonLine.tsx +208 -0
- package/src/grapher/controls/ActionButtons.scss +97 -0
- package/src/grapher/controls/ActionButtons.tsx +453 -0
- package/src/grapher/controls/CommandPalette.scss +50 -0
- package/src/grapher/controls/CommandPalette.tsx +74 -0
- package/src/grapher/controls/ContentSwitchers.scss +93 -0
- package/src/grapher/controls/ContentSwitchers.tsx +238 -0
- package/src/grapher/controls/Controls.scss +158 -0
- package/src/grapher/controls/DataTableFilterDropdown.scss +7 -0
- package/src/grapher/controls/DataTableFilterDropdown.tsx +168 -0
- package/src/grapher/controls/DataTableSearchField.scss +3 -0
- package/src/grapher/controls/DataTableSearchField.tsx +76 -0
- package/src/grapher/controls/Dropdown.scss +252 -0
- package/src/grapher/controls/Dropdown.tsx +235 -0
- package/src/grapher/controls/EntitySelectionToggle.tsx +135 -0
- package/src/grapher/controls/MapRegionDropdown.scss +3 -0
- package/src/grapher/controls/MapRegionDropdown.tsx +104 -0
- package/src/grapher/controls/MapResetButton.tsx +115 -0
- package/src/grapher/controls/MapZoomDropdown.scss +9 -0
- package/src/grapher/controls/MapZoomDropdown.tsx +270 -0
- package/src/grapher/controls/MapZoomToSelectionButton.tsx +87 -0
- package/src/grapher/controls/SearchField.scss +78 -0
- package/src/grapher/controls/SearchField.tsx +63 -0
- package/src/grapher/controls/SettingsMenu.scss +191 -0
- package/src/grapher/controls/SettingsMenu.tsx +399 -0
- package/src/grapher/controls/ShareMenu.scss +58 -0
- package/src/grapher/controls/ShareMenu.tsx +304 -0
- package/src/grapher/controls/SortIcon.tsx +39 -0
- package/src/grapher/controls/VerticalScrollContainer.tsx +263 -0
- package/src/grapher/controls/controlsRow/ControlsRow.tsx +168 -0
- package/src/grapher/controls/dropdown-icons.scss +4 -0
- package/src/grapher/controls/entityPicker/EntityPicker.scss +255 -0
- package/src/grapher/controls/entityPicker/EntityPicker.tsx +816 -0
- package/src/grapher/controls/entityPicker/EntityPickerConstants.ts +23 -0
- package/src/grapher/controls/globalEntitySelector/GlobalEntitySelector.scss +129 -0
- package/src/grapher/controls/globalEntitySelector/GlobalEntitySelector.tsx +463 -0
- package/src/grapher/controls/globalEntitySelector/GlobalEntitySelectorConstants.ts +3 -0
- package/src/grapher/controls/globalEntitySelector/readme.md +17 -0
- package/src/grapher/controls/settings/AbsRelToggle.tsx +64 -0
- package/src/grapher/controls/settings/AxisScaleToggle.tsx +53 -0
- package/src/grapher/controls/settings/FacetStrategySelector.tsx +110 -0
- package/src/grapher/controls/settings/FacetYDomainToggle.tsx +51 -0
- package/src/grapher/controls/settings/NoDataAreaToggle.tsx +38 -0
- package/src/grapher/controls/settings/ZoomToggle.tsx +36 -0
- package/src/grapher/core/EntitiesByRegionType.ts +174 -0
- package/src/grapher/core/EntityCodes.ts +19 -0
- package/src/grapher/core/EntityUrlBuilder.ts +200 -0
- package/src/grapher/core/FetchingGrapher.tsx +156 -0
- package/src/grapher/core/Grapher.tsx +760 -0
- package/src/grapher/core/GrapherAnalytics.ts +229 -0
- package/src/grapher/core/GrapherConstants.ts +173 -0
- package/src/grapher/core/GrapherState.tsx +3659 -0
- package/src/grapher/core/GrapherUrl.ts +184 -0
- package/src/grapher/core/GrapherUrlMigrations.ts +29 -0
- package/src/grapher/core/GrapherUseHelpers.tsx +147 -0
- package/src/grapher/core/LegacyToOwidTable.ts +841 -0
- package/src/grapher/core/grapher.entry.ts +5 -0
- package/src/grapher/core/grapher.scss +257 -0
- package/src/grapher/core/loadGrapherTableHelpers.ts +116 -0
- package/src/grapher/core/loadVariable.ts +104 -0
- package/src/grapher/core/relatedQuestion.ts +12 -0
- package/src/grapher/core/typography.scss +206 -0
- package/src/grapher/dataTable/DataTable.sample.ts +206 -0
- package/src/grapher/dataTable/DataTable.scss +249 -0
- package/src/grapher/dataTable/DataTable.tsx +1332 -0
- package/src/grapher/dataTable/DataTableConstants.ts +186 -0
- package/src/grapher/entitySelector/EntitySelector.scss +255 -0
- package/src/grapher/entitySelector/EntitySelector.tsx +1838 -0
- package/src/grapher/facet/FacetChart.tsx +943 -0
- package/src/grapher/facet/FacetChartConstants.ts +24 -0
- package/src/grapher/facet/FacetChartUtils.ts +51 -0
- package/src/grapher/facet/FacetMap.tsx +604 -0
- package/src/grapher/facet/FacetMapConstants.ts +23 -0
- package/src/grapher/facet/readme.md +13 -0
- package/src/grapher/focus/FocusArray.ts +79 -0
- package/src/grapher/footer/Footer.scss +63 -0
- package/src/grapher/footer/Footer.tsx +809 -0
- package/src/grapher/footer/FooterManager.ts +44 -0
- package/src/grapher/fullScreen/FullScreen.scss +11 -0
- package/src/grapher/fullScreen/FullScreen.tsx +61 -0
- package/src/grapher/header/Header.scss +35 -0
- package/src/grapher/header/Header.tsx +372 -0
- package/src/grapher/header/HeaderManager.ts +28 -0
- package/src/grapher/index.ts +157 -0
- package/src/grapher/interaction/InteractionState.ts +60 -0
- package/src/grapher/legend/HorizontalColorLegends.tsx +923 -0
- package/src/grapher/legend/LegendInteractionState.ts +40 -0
- package/src/grapher/legend/VerticalColorLegend.tsx +295 -0
- package/src/grapher/lineCharts/LineChart.tsx +968 -0
- package/src/grapher/lineCharts/LineChartConstants.ts +89 -0
- package/src/grapher/lineCharts/LineChartHelpers.ts +184 -0
- package/src/grapher/lineCharts/LineChartState.ts +394 -0
- package/src/grapher/lineCharts/LineChartThumbnail.tsx +437 -0
- package/src/grapher/lineCharts/Lines.tsx +258 -0
- package/src/grapher/lineLegend/LineLegend.tsx +723 -0
- package/src/grapher/lineLegend/LineLegendConstants.ts +9 -0
- package/src/grapher/lineLegend/LineLegendFilterAlgorithms.ts +143 -0
- package/src/grapher/lineLegend/LineLegendHelpers.ts +253 -0
- package/src/grapher/lineLegend/LineLegendTypes.ts +32 -0
- package/src/grapher/mapCharts/CanadaTopology.ts +17922 -0
- package/src/grapher/mapCharts/ChoroplethGlobe.tsx +949 -0
- package/src/grapher/mapCharts/ChoroplethMap.tsx +662 -0
- package/src/grapher/mapCharts/GeoFeatures.ts +184 -0
- package/src/grapher/mapCharts/GlobeController.ts +496 -0
- package/src/grapher/mapCharts/MapAnnotationPlacements.json +1040 -0
- package/src/grapher/mapCharts/MapAnnotationPlacements.ts +31 -0
- package/src/grapher/mapCharts/MapAnnotations.ts +723 -0
- package/src/grapher/mapCharts/MapChart.sample.ts +59 -0
- package/src/grapher/mapCharts/MapChart.scss +5 -0
- package/src/grapher/mapCharts/MapChart.tsx +720 -0
- package/src/grapher/mapCharts/MapChartConstants.ts +260 -0
- package/src/grapher/mapCharts/MapChartState.ts +416 -0
- package/src/grapher/mapCharts/MapChartThumbnail.tsx +25 -0
- package/src/grapher/mapCharts/MapComponents.tsx +338 -0
- package/src/grapher/mapCharts/MapConfig.ts +156 -0
- package/src/grapher/mapCharts/MapHelpers.ts +181 -0
- package/src/grapher/mapCharts/MapProjections.ts +49 -0
- package/src/grapher/mapCharts/MapSparkline.tsx +257 -0
- package/src/grapher/mapCharts/MapTooltip.scss +49 -0
- package/src/grapher/mapCharts/MapTooltip.tsx +409 -0
- package/src/grapher/mapCharts/MapTopology.ts +1766 -0
- package/src/grapher/mapCharts/d3-bboxCollide.js +204 -0
- package/src/grapher/mapCharts/d3-geo-projection.ts +198 -0
- package/src/grapher/modal/DownloadIcons.tsx +39 -0
- package/src/grapher/modal/DownloadModal.scss +300 -0
- package/src/grapher/modal/DownloadModal.tsx +1226 -0
- package/src/grapher/modal/EmbedModal.scss +40 -0
- package/src/grapher/modal/EmbedModal.tsx +160 -0
- package/src/grapher/modal/EntitySelectorModal.tsx +59 -0
- package/src/grapher/modal/Modal.scss +31 -0
- package/src/grapher/modal/Modal.tsx +90 -0
- package/src/grapher/modal/ModalHeader.scss +12 -0
- package/src/grapher/modal/ModalHeader.tsx +16 -0
- package/src/grapher/modal/SourcesDescriptions.scss +87 -0
- package/src/grapher/modal/SourcesDescriptions.tsx +89 -0
- package/src/grapher/modal/SourcesKeyDataTable.scss +49 -0
- package/src/grapher/modal/SourcesKeyDataTable.tsx +87 -0
- package/src/grapher/modal/SourcesModal.scss +301 -0
- package/src/grapher/modal/SourcesModal.tsx +568 -0
- package/src/grapher/noDataModal/NoDataModal.tsx +125 -0
- package/src/grapher/scatterCharts/ConnectedScatterLegend.tsx +143 -0
- package/src/grapher/scatterCharts/MultiColorPolyline.tsx +129 -0
- package/src/grapher/scatterCharts/NoDataSection.scss +14 -0
- package/src/grapher/scatterCharts/NoDataSection.tsx +56 -0
- package/src/grapher/scatterCharts/ScatterPlotChart.tsx +792 -0
- package/src/grapher/scatterCharts/ScatterPlotChartConstants.ts +157 -0
- package/src/grapher/scatterCharts/ScatterPlotChartState.ts +678 -0
- package/src/grapher/scatterCharts/ScatterPlotChartThumbnail.tsx +155 -0
- package/src/grapher/scatterCharts/ScatterPlotTooltip.tsx +560 -0
- package/src/grapher/scatterCharts/ScatterPoints.tsx +153 -0
- package/src/grapher/scatterCharts/ScatterPointsWithLabels.tsx +708 -0
- package/src/grapher/scatterCharts/ScatterSizeLegend.tsx +327 -0
- package/src/grapher/scatterCharts/ScatterUtils.ts +265 -0
- package/src/grapher/scatterCharts/Triangle.tsx +41 -0
- package/src/grapher/schema/README.md +33 -0
- package/src/grapher/schema/defaultGrapherConfig.ts +100 -0
- package/src/grapher/schema/grapher-schema.009.yaml +781 -0
- package/src/grapher/schema/migrations/helpers.ts +58 -0
- package/src/grapher/schema/migrations/migrate.ts +75 -0
- package/src/grapher/schema/migrations/migrations.ts +158 -0
- package/src/grapher/selection/MapSelectionArray.ts +99 -0
- package/src/grapher/selection/SelectionArray.ts +71 -0
- package/src/grapher/selection/readme.md +16 -0
- package/src/grapher/sidePanel/SidePanel.scss +10 -0
- package/src/grapher/sidePanel/SidePanel.tsx +23 -0
- package/src/grapher/slideInDrawer/SlideInDrawer.scss +57 -0
- package/src/grapher/slideInDrawer/SlideInDrawer.tsx +125 -0
- package/src/grapher/slideshowController/SlideShowController.tsx +43 -0
- package/src/grapher/slideshowController/readme.md +7 -0
- package/src/grapher/slopeCharts/MarkX.tsx +45 -0
- package/src/grapher/slopeCharts/Slope.tsx +102 -0
- package/src/grapher/slopeCharts/SlopeChart.tsx +1152 -0
- package/src/grapher/slopeCharts/SlopeChartConstants.ts +33 -0
- package/src/grapher/slopeCharts/SlopeChartHelpers.ts +73 -0
- package/src/grapher/slopeCharts/SlopeChartState.ts +392 -0
- package/src/grapher/slopeCharts/SlopeChartThumbnail.tsx +368 -0
- package/src/grapher/stackedCharts/AbstractStackedChartState.ts +370 -0
- package/src/grapher/stackedCharts/MarimekkoBars.tsx +190 -0
- package/src/grapher/stackedCharts/MarimekkoBarsForOneEntity.tsx +168 -0
- package/src/grapher/stackedCharts/MarimekkoChart.tsx +1144 -0
- package/src/grapher/stackedCharts/MarimekkoChartConstants.ts +112 -0
- package/src/grapher/stackedCharts/MarimekkoChartHelpers.ts +21 -0
- package/src/grapher/stackedCharts/MarimekkoChartState.ts +465 -0
- package/src/grapher/stackedCharts/MarimekkoChartThumbnail.tsx +168 -0
- package/src/grapher/stackedCharts/MarimekkoInternalLabels.tsx +124 -0
- package/src/grapher/stackedCharts/StackedAreaChart.tsx +678 -0
- package/src/grapher/stackedCharts/StackedAreaChartState.ts +34 -0
- package/src/grapher/stackedCharts/StackedAreaChartThumbnail.tsx +215 -0
- package/src/grapher/stackedCharts/StackedAreas.tsx +223 -0
- package/src/grapher/stackedCharts/StackedBarChart.tsx +619 -0
- package/src/grapher/stackedCharts/StackedBarChartState.ts +80 -0
- package/src/grapher/stackedCharts/StackedBarChartThumbnail.tsx +220 -0
- package/src/grapher/stackedCharts/StackedBarSegment.tsx +87 -0
- package/src/grapher/stackedCharts/StackedBars.tsx +102 -0
- package/src/grapher/stackedCharts/StackedConstants.ts +109 -0
- package/src/grapher/stackedCharts/StackedDiscreteBarChart.tsx +270 -0
- package/src/grapher/stackedCharts/StackedDiscreteBarChartState.ts +296 -0
- package/src/grapher/stackedCharts/StackedDiscreteBarChartThumbnail.tsx +27 -0
- package/src/grapher/stackedCharts/StackedDiscreteBars.tsx +648 -0
- package/src/grapher/stackedCharts/StackedUtils.ts +142 -0
- package/src/grapher/tabs/Tabs.scss +169 -0
- package/src/grapher/tabs/Tabs.tsx +54 -0
- package/src/grapher/tabs/TabsWithDropdown.scss +62 -0
- package/src/grapher/tabs/TabsWithDropdown.tsx +114 -0
- package/src/grapher/testData/OwidTestData.sample.ts +273 -0
- package/src/grapher/testData/OwidTestData.ts +64 -0
- package/src/grapher/timeline/TimelineComponent.scss +139 -0
- package/src/grapher/timeline/TimelineComponent.tsx +658 -0
- package/src/grapher/timeline/TimelineController.ts +368 -0
- package/src/grapher/timeline/readme.md +7 -0
- package/src/grapher/tooltip/Tooltip.scss +510 -0
- package/src/grapher/tooltip/Tooltip.tsx +294 -0
- package/src/grapher/tooltip/TooltipContents.tsx +383 -0
- package/src/grapher/tooltip/TooltipProps.ts +123 -0
- package/src/grapher/tooltip/TooltipState.ts +81 -0
- package/src/grapher/verticalLabels/VerticalLabels.tsx +31 -0
- package/src/grapher/verticalLabels/VerticalLabelsState.ts +154 -0
- package/src/index.ts +226 -0
- package/src/styles/charts.scss +15 -0
- package/src/types/NominalType.ts +30 -0
- package/src/types/OwidOrigin.ts +18 -0
- package/src/types/OwidSource.ts +9 -0
- package/src/types/OwidVariable.ts +133 -0
- package/src/types/OwidVariableDisplayConfigInterface.ts +49 -0
- package/src/types/analyticsTypes.ts +54 -0
- package/src/types/dbTypes/Tags.ts +11 -0
- package/src/types/domainTypes/Archive.ts +139 -0
- package/src/types/domainTypes/Author.ts +28 -0
- package/src/types/domainTypes/ContentGraph.ts +76 -0
- package/src/types/domainTypes/CoreTableTypes.ts +305 -0
- package/src/types/domainTypes/DeployStatus.ts +23 -0
- package/src/types/domainTypes/Layout.ts +34 -0
- package/src/types/domainTypes/Posts.ts +34 -0
- package/src/types/domainTypes/Search.ts +299 -0
- package/src/types/domainTypes/Site.ts +8 -0
- package/src/types/domainTypes/StaticViz.ts +64 -0
- package/src/types/domainTypes/Toc.ts +11 -0
- package/src/types/domainTypes/Tombstone.ts +19 -0
- package/src/types/domainTypes/Various.ts +79 -0
- package/src/types/gdocTypes/Gdoc.ts +280 -0
- package/src/types/grapherTypes/BinningStrategyTypes.ts +46 -0
- package/src/types/grapherTypes/GrapherConstants.ts +53 -0
- package/src/types/grapherTypes/GrapherTypes.ts +743 -0
- package/src/types/index.ts +316 -0
- package/src/types/wordpressTypes/WordpressTypes.ts +9 -0
- package/src/utils/Bounds.ts +439 -0
- package/src/utils/BrowserUtils.ts +12 -0
- package/src/utils/FuzzySearch.ts +74 -0
- package/src/utils/MultiDimDataPageConfig.ts +31 -0
- package/src/utils/OwidVariable.ts +82 -0
- package/src/utils/PointVector.ts +97 -0
- package/src/utils/PromiseCache.ts +36 -0
- package/src/utils/PromiseSwitcher.ts +52 -0
- package/src/utils/TimeBounds.ts +130 -0
- package/src/utils/Tippy.tsx +57 -0
- package/src/utils/Util.ts +2369 -0
- package/src/utils/archival/archivalDate.ts +48 -0
- package/src/utils/dayjs.ts +32 -0
- package/src/utils/formatValue.ts +242 -0
- package/src/utils/grapherConfigUtils.ts +81 -0
- package/src/utils/image.ts +225 -0
- package/src/utils/index.ts +318 -0
- package/src/utils/isPresent.ts +5 -0
- package/src/utils/metadataHelpers.ts +329 -0
- package/src/utils/persistable/Persistable.ts +82 -0
- package/src/utils/persistable/readme.md +50 -0
- package/src/utils/regions.json +5635 -0
- package/src/utils/regions.ts +463 -0
- package/src/utils/serializers.ts +16 -0
- package/src/utils/string.ts +42 -0
- package/src/utils/urls/Url.ts +195 -0
- package/src/utils/urls/UrlMigration.ts +10 -0
- package/src/utils/urls/UrlUtils.ts +54 -0
- package/src/utils/urls/readme.md +90 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
.embed-modal-content {
|
|
2
|
+
color: $dark-text;
|
|
3
|
+
|
|
4
|
+
// necessary for scrolling
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
height: 100%;
|
|
8
|
+
> * {
|
|
9
|
+
flex-shrink: 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.scrollable {
|
|
13
|
+
flex: 1 1 auto;
|
|
14
|
+
overflow-y: auto;
|
|
15
|
+
padding: 0 var(--modal-padding) var(--modal-padding);
|
|
16
|
+
width: 100%;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
p {
|
|
20
|
+
margin-bottom: 16px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.embed-modal--options {
|
|
24
|
+
display: flex;
|
|
25
|
+
gap: 32px;
|
|
26
|
+
flex-direction: column;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.embed-modal--option-title {
|
|
30
|
+
color: $gray-80;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.embed-modal--option-description {
|
|
34
|
+
color: $gray-70;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.embed-modal-hide-controls {
|
|
39
|
+
margin-top: 16px;
|
|
40
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { observer } from "mobx-react"
|
|
2
|
+
import * as React from "react"
|
|
3
|
+
import { computed, action, makeObservable } from "mobx"
|
|
4
|
+
import { Bounds, Url } from "../../utils/index.js"
|
|
5
|
+
import { Modal } from "./Modal"
|
|
6
|
+
import {
|
|
7
|
+
Checkbox,
|
|
8
|
+
CodeSnippet,
|
|
9
|
+
OverlayHeader,
|
|
10
|
+
} from "../../components/index.js"
|
|
11
|
+
import { DEFAULT_GRAPHER_BOUNDS, GrapherModal } from "../core/GrapherConstants"
|
|
12
|
+
|
|
13
|
+
export interface EmbedModalManager {
|
|
14
|
+
embedUrl?: string
|
|
15
|
+
embedArchivedUrl?: string
|
|
16
|
+
activeModal?: GrapherModal
|
|
17
|
+
canHideExternalControlsInEmbed: boolean
|
|
18
|
+
hideExternalControlsInEmbedUrl: boolean
|
|
19
|
+
setHideExternalControlsInEmbedUrl: (value: boolean) => void
|
|
20
|
+
frameBounds?: Bounds
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface EmbedModalProps {
|
|
24
|
+
manager: EmbedModalManager
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface EmbedOptions {
|
|
28
|
+
title: string
|
|
29
|
+
description: React.ReactElement
|
|
30
|
+
url: string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@observer
|
|
34
|
+
export class EmbedModal extends React.Component<EmbedModalProps> {
|
|
35
|
+
constructor(props: EmbedModalProps) {
|
|
36
|
+
super(props)
|
|
37
|
+
makeObservable(this)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@computed get manager(): EmbedModalManager {
|
|
41
|
+
return this.props.manager
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@computed private get frameBounds(): Bounds {
|
|
45
|
+
return this.manager.frameBounds ?? DEFAULT_GRAPHER_BOUNDS
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@computed private get modalBounds(): Bounds {
|
|
49
|
+
const maxWidth = 940
|
|
50
|
+
const padWidth = Math.max(16, (this.frameBounds.width - maxWidth) / 2)
|
|
51
|
+
return this.frameBounds.padHeight(16).padWidth(padWidth)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@computed private get embedOptions(): EmbedOptions[] {
|
|
55
|
+
const { embedUrl, embedArchivedUrl } = this.manager
|
|
56
|
+
|
|
57
|
+
const opts: EmbedOptions[] = []
|
|
58
|
+
|
|
59
|
+
// We only check origins (domain + port) because:
|
|
60
|
+
// - Query params are not relevant
|
|
61
|
+
// - We use the /latest/ path prefix as an alias for the latest version
|
|
62
|
+
// of the chart, which is not the same as the canonical URL
|
|
63
|
+
// - Archive and live versions live on a different domain
|
|
64
|
+
const areEmbedAndArchivedOriginsSame =
|
|
65
|
+
Url.fromURL(this.manager.embedUrl ?? "").origin ===
|
|
66
|
+
Url.fromURL(this.manager.embedArchivedUrl ?? "").origin
|
|
67
|
+
|
|
68
|
+
if (embedUrl && !areEmbedAndArchivedOriginsSame) {
|
|
69
|
+
opts.push({
|
|
70
|
+
title: "Chart with data updates",
|
|
71
|
+
description: (
|
|
72
|
+
<span>
|
|
73
|
+
To embed a version of this chart that will{" "}
|
|
74
|
+
<strong>update</strong> when we update the data on our
|
|
75
|
+
site, paste this code into an HTML page:
|
|
76
|
+
</span>
|
|
77
|
+
),
|
|
78
|
+
url: embedUrl,
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
if (embedArchivedUrl) {
|
|
82
|
+
opts.push({
|
|
83
|
+
title: "Archived chart without data updates",
|
|
84
|
+
description: (
|
|
85
|
+
<span>
|
|
86
|
+
To embed this specific version of the chart that will{" "}
|
|
87
|
+
<strong>not update</strong> when we update the data on
|
|
88
|
+
our site, paste this code into an HTML page:
|
|
89
|
+
</span>
|
|
90
|
+
),
|
|
91
|
+
url: embedArchivedUrl,
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
return opts
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private codeSnippetForUrl(url: string): string {
|
|
98
|
+
return `<iframe src="${url}" loading="lazy" style="width: 100%; height: 600px; border: 0px none;" allow="web-share; clipboard-write"></iframe>`
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
@action.bound private onDismiss(): void {
|
|
102
|
+
this.manager.activeModal = undefined
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
override render() {
|
|
106
|
+
const { embedOptions } = this
|
|
107
|
+
|
|
108
|
+
if (!embedOptions.length) return null
|
|
109
|
+
return (
|
|
110
|
+
<Modal
|
|
111
|
+
bounds={this.modalBounds}
|
|
112
|
+
alignVertical="bottom"
|
|
113
|
+
onDismiss={this.onDismiss}
|
|
114
|
+
>
|
|
115
|
+
<div
|
|
116
|
+
className="embed-modal-content"
|
|
117
|
+
style={{ maxHeight: this.modalBounds.height }}
|
|
118
|
+
>
|
|
119
|
+
<OverlayHeader title="Embed" onDismiss={this.onDismiss} />
|
|
120
|
+
<div className="scrollable">
|
|
121
|
+
<div className="embed-modal--options">
|
|
122
|
+
{embedOptions.map((option) => (
|
|
123
|
+
<div
|
|
124
|
+
key={option.title}
|
|
125
|
+
className="embed-modal--option"
|
|
126
|
+
>
|
|
127
|
+
<h3 className="grapher_body-2-semibold embed-modal--option-title">
|
|
128
|
+
{option.title}
|
|
129
|
+
</h3>
|
|
130
|
+
<p className="grapher_label-1-medium embed-modal--option-description">
|
|
131
|
+
{option.description}
|
|
132
|
+
</p>
|
|
133
|
+
<CodeSnippet
|
|
134
|
+
code={this.codeSnippetForUrl(
|
|
135
|
+
option.url
|
|
136
|
+
)}
|
|
137
|
+
/>
|
|
138
|
+
</div>
|
|
139
|
+
))}
|
|
140
|
+
</div>
|
|
141
|
+
{this.manager.canHideExternalControlsInEmbed && (
|
|
142
|
+
<Checkbox
|
|
143
|
+
className="embed-modal-hide-controls"
|
|
144
|
+
label="Hide controls"
|
|
145
|
+
checked={
|
|
146
|
+
this.manager.hideExternalControlsInEmbedUrl
|
|
147
|
+
}
|
|
148
|
+
onChange={(event) =>
|
|
149
|
+
this.manager.setHideExternalControlsInEmbedUrl(
|
|
150
|
+
event.target.checked
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
/>
|
|
154
|
+
)}
|
|
155
|
+
</div>
|
|
156
|
+
</div>
|
|
157
|
+
</Modal>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { observer } from "mobx-react"
|
|
3
|
+
import { computed, action, makeObservable } from "mobx"
|
|
4
|
+
import { Bounds } from "../../utils/index.js"
|
|
5
|
+
import { Modal } from "./Modal"
|
|
6
|
+
import {
|
|
7
|
+
EntitySelector,
|
|
8
|
+
EntitySelectorManager,
|
|
9
|
+
} from "../entitySelector/EntitySelector"
|
|
10
|
+
import { DEFAULT_GRAPHER_BOUNDS } from "../core/GrapherConstants"
|
|
11
|
+
|
|
12
|
+
export interface EntitySelectorModalManager extends EntitySelectorManager {
|
|
13
|
+
isEntitySelectorModalOrDrawerOpen?: boolean
|
|
14
|
+
frameBounds?: Bounds
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@observer
|
|
18
|
+
export class EntitySelectorModal extends React.Component<{
|
|
19
|
+
manager: EntitySelectorModalManager
|
|
20
|
+
}> {
|
|
21
|
+
constructor(props: { manager: EntitySelectorModalManager }) {
|
|
22
|
+
super(props)
|
|
23
|
+
makeObservable(this)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@computed private get manager(): EntitySelectorModalManager {
|
|
27
|
+
return this.props.manager
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@computed private get frameBounds(): Bounds {
|
|
31
|
+
return this.manager.frameBounds ?? DEFAULT_GRAPHER_BOUNDS
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@computed private get modalBounds(): Bounds {
|
|
35
|
+
const maxWidth = 366
|
|
36
|
+
const padWidth = Math.max(16, (this.frameBounds.width - maxWidth) / 2)
|
|
37
|
+
return this.frameBounds.padHeight(16).padWidth(padWidth)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@action.bound onDismiss(): void {
|
|
41
|
+
this.manager.isEntitySelectorModalOrDrawerOpen = false
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
override render(): React.ReactElement {
|
|
45
|
+
return (
|
|
46
|
+
<Modal
|
|
47
|
+
onDismiss={this.onDismiss}
|
|
48
|
+
bounds={this.modalBounds}
|
|
49
|
+
isHeightFixed={true}
|
|
50
|
+
>
|
|
51
|
+
<EntitySelector
|
|
52
|
+
manager={this.manager}
|
|
53
|
+
onDismiss={this.onDismiss}
|
|
54
|
+
autoFocus={true}
|
|
55
|
+
/>
|
|
56
|
+
</Modal>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.modal-overlay {
|
|
2
|
+
--modal-padding: 24px;
|
|
3
|
+
|
|
4
|
+
position: absolute;
|
|
5
|
+
|
|
6
|
+
// -1px to hide the frame border
|
|
7
|
+
top: -1px;
|
|
8
|
+
right: -1px;
|
|
9
|
+
bottom: -1px;
|
|
10
|
+
left: -1px;
|
|
11
|
+
|
|
12
|
+
background-color: rgba(0, 0, 0, 0.4);
|
|
13
|
+
z-index: $zindex-modal;
|
|
14
|
+
|
|
15
|
+
.modal-wrapper {
|
|
16
|
+
position: relative;
|
|
17
|
+
height: 100%;
|
|
18
|
+
|
|
19
|
+
.modal-content {
|
|
20
|
+
position: absolute;
|
|
21
|
+
border-radius: 4px;
|
|
22
|
+
background: #fff;
|
|
23
|
+
box-shadow: 0px 4px 30px 0px rgba(0, 0, 0, 0.15);
|
|
24
|
+
min-height: 150px;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&.GrapherComponentNarrow .modal-overlay {
|
|
30
|
+
--modal-padding: 16px;
|
|
31
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Bounds, bind } from "../../utils/index.js"
|
|
3
|
+
import {
|
|
4
|
+
isElementInteractive,
|
|
5
|
+
isTargetOutsideElement,
|
|
6
|
+
} from "../chart/ChartUtils"
|
|
7
|
+
|
|
8
|
+
export class Modal extends React.Component<{
|
|
9
|
+
bounds: Bounds
|
|
10
|
+
onDismiss: () => void
|
|
11
|
+
children?: React.ReactNode
|
|
12
|
+
isHeightFixed?: boolean // by default, the modal height is not fixed but fits to the content
|
|
13
|
+
alignVertical?: "top" | "center" | "bottom"
|
|
14
|
+
}> {
|
|
15
|
+
contentRef = React.createRef<HTMLDivElement>()
|
|
16
|
+
|
|
17
|
+
private get bounds(): Bounds {
|
|
18
|
+
return this.props.bounds
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private get isHeightFixed(): boolean {
|
|
22
|
+
return this.props.isHeightFixed ?? false
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private get alignVertical(): "top" | "center" | "bottom" {
|
|
26
|
+
return this.props.alignVertical ?? "center"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@bind onDocumentClick(e: MouseEvent): void {
|
|
30
|
+
if (
|
|
31
|
+
this.contentRef?.current &&
|
|
32
|
+
isTargetOutsideElement(e.target!, this.contentRef.current) &&
|
|
33
|
+
// clicking on an interactive element should not dismiss the modal
|
|
34
|
+
// (this is especially important for the suggested chart review tool)
|
|
35
|
+
!isElementInteractive(e.target as HTMLElement)
|
|
36
|
+
)
|
|
37
|
+
this.props.onDismiss()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@bind onDocumentKeyDown(e: KeyboardEvent): void {
|
|
41
|
+
if (e.key === "Escape") this.props.onDismiss()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
override componentDidMount(): void {
|
|
45
|
+
document.addEventListener("click", this.onDocumentClick)
|
|
46
|
+
document.addEventListener("keydown", this.onDocumentKeyDown)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
override componentWillUnmount(): void {
|
|
50
|
+
document.removeEventListener("click", this.onDocumentClick)
|
|
51
|
+
document.removeEventListener("keydown", this.onDocumentKeyDown)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
override render(): React.ReactElement {
|
|
55
|
+
const { bounds } = this
|
|
56
|
+
|
|
57
|
+
const contentStyle: React.CSSProperties = {
|
|
58
|
+
left: bounds.left,
|
|
59
|
+
width: bounds.width,
|
|
60
|
+
maxHeight: bounds.height,
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (this.isHeightFixed) {
|
|
64
|
+
contentStyle.height = bounds.height
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (this.alignVertical === "bottom") {
|
|
68
|
+
contentStyle.bottom = bounds.y
|
|
69
|
+
} else if (this.alignVertical === "top") {
|
|
70
|
+
contentStyle.top = bounds.y
|
|
71
|
+
} else {
|
|
72
|
+
contentStyle.top = "50%"
|
|
73
|
+
contentStyle.transform = "translateY(-50%)"
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<div className="modal-overlay">
|
|
78
|
+
<div className="modal-wrapper">
|
|
79
|
+
<div
|
|
80
|
+
className="modal-content"
|
|
81
|
+
style={contentStyle}
|
|
82
|
+
ref={this.contentRef}
|
|
83
|
+
>
|
|
84
|
+
{this.props.children}
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CloseButton } from "../../components/index.js"
|
|
2
|
+
|
|
3
|
+
export function ModalHeader({
|
|
4
|
+
title,
|
|
5
|
+
onDismiss,
|
|
6
|
+
}: {
|
|
7
|
+
title: string
|
|
8
|
+
onDismiss?: () => void
|
|
9
|
+
}) {
|
|
10
|
+
return (
|
|
11
|
+
<div className="modal-header">
|
|
12
|
+
<h2 className="grapher_h5-black-caps grapher_light">{title}</h2>
|
|
13
|
+
{onDismiss && <CloseButton onClick={onDismiss} />}
|
|
14
|
+
</div>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
.sources-descriptions {
|
|
2
|
+
margin-top: 24px;
|
|
3
|
+
|
|
4
|
+
.sources-description-key {
|
|
5
|
+
background-color: $gray-10;
|
|
6
|
+
margin: 24px 0;
|
|
7
|
+
padding: 24px;
|
|
8
|
+
|
|
9
|
+
&__title {
|
|
10
|
+
@include h2-semibold;
|
|
11
|
+
font-size: 20px;
|
|
12
|
+
color: $dark-text;
|
|
13
|
+
margin-top: 0;
|
|
14
|
+
margin-bottom: 16px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&__content,
|
|
18
|
+
&__content ul {
|
|
19
|
+
@include body-2-regular;
|
|
20
|
+
font-size: 14px;
|
|
21
|
+
font-weight: 500;
|
|
22
|
+
color: $dark-text;
|
|
23
|
+
margin: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&__content ul {
|
|
27
|
+
margin-left: 1em;
|
|
28
|
+
li {
|
|
29
|
+
margin-bottom: 1em;
|
|
30
|
+
|
|
31
|
+
&:last-child {
|
|
32
|
+
margin-bottom: 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&__learn-more {
|
|
38
|
+
@include body-3-medium;
|
|
39
|
+
display: inline-block;
|
|
40
|
+
margin-top: 16px;
|
|
41
|
+
text-decoration: underline;
|
|
42
|
+
text-underline-offset: 4px;
|
|
43
|
+
color: $dark-text;
|
|
44
|
+
|
|
45
|
+
&:hover {
|
|
46
|
+
text-decoration: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&:visited {
|
|
50
|
+
color: $dark-text;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
svg {
|
|
54
|
+
font-size: 0.75em;
|
|
55
|
+
margin-left: 12px;
|
|
56
|
+
display: inline-block;
|
|
57
|
+
transform: rotate(-90deg);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.expandable-info-blocks {
|
|
63
|
+
p {
|
|
64
|
+
margin: 0;
|
|
65
|
+
|
|
66
|
+
+ p {
|
|
67
|
+
margin-top: 8px;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
ol,
|
|
71
|
+
ul {
|
|
72
|
+
padding: 0;
|
|
73
|
+
margin-left: 1em;
|
|
74
|
+
|
|
75
|
+
li {
|
|
76
|
+
margin-top: 0.5em;
|
|
77
|
+
margin-bottom: 0.5em;
|
|
78
|
+
margin-left: 1em;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
a {
|
|
84
|
+
@include owid-link-60;
|
|
85
|
+
color: inherit;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { faArrowDown } from "@fortawesome/free-solid-svg-icons"
|
|
2
|
+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
|
|
3
|
+
import {
|
|
4
|
+
ExpandableToggle,
|
|
5
|
+
HtmlOrSimpleMarkdownText,
|
|
6
|
+
SimpleMarkdownText,
|
|
7
|
+
} from "../../components/index.js"
|
|
8
|
+
|
|
9
|
+
interface SourcesDescriptionsProps {
|
|
10
|
+
descriptionShort?: string
|
|
11
|
+
descriptionKey?: string[]
|
|
12
|
+
descriptionFromProducer?: string
|
|
13
|
+
attributionShort?: string
|
|
14
|
+
additionalInfo?: string
|
|
15
|
+
hasFaqEntries: boolean
|
|
16
|
+
isEmbeddedInADataPage?: boolean // true by default
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const SourcesDescriptions = (props: SourcesDescriptionsProps) => {
|
|
20
|
+
const isEmbeddedInADataPage = props.isEmbeddedInADataPage ?? true
|
|
21
|
+
return (
|
|
22
|
+
<div className="sources-descriptions">
|
|
23
|
+
{props.descriptionKey && props.descriptionKey.length > 0 && (
|
|
24
|
+
<div className="sources-description-key">
|
|
25
|
+
<h3 className="sources-description-key__title">
|
|
26
|
+
What you should know about this data
|
|
27
|
+
</h3>
|
|
28
|
+
<div className="sources-description-key__content">
|
|
29
|
+
{props.descriptionKey.length === 1 ? (
|
|
30
|
+
<SimpleMarkdownText
|
|
31
|
+
text={props.descriptionKey[0].trim()}
|
|
32
|
+
/>
|
|
33
|
+
) : (
|
|
34
|
+
<ul>
|
|
35
|
+
{props.descriptionKey.map((text, i) => (
|
|
36
|
+
<li key={i}>
|
|
37
|
+
<SimpleMarkdownText
|
|
38
|
+
text={text.trim()}
|
|
39
|
+
useParagraphs={false}
|
|
40
|
+
/>{" "}
|
|
41
|
+
</li>
|
|
42
|
+
))}
|
|
43
|
+
</ul>
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
{isEmbeddedInADataPage && props.hasFaqEntries && (
|
|
47
|
+
<a
|
|
48
|
+
className="sources-description-key__learn-more"
|
|
49
|
+
href="#faqs"
|
|
50
|
+
>
|
|
51
|
+
Learn more in the FAQs
|
|
52
|
+
<FontAwesomeIcon icon={faArrowDown} />
|
|
53
|
+
</a>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
)}
|
|
57
|
+
<div className="expandable-info-blocks">
|
|
58
|
+
{props.descriptionFromProducer && (
|
|
59
|
+
<ExpandableToggle
|
|
60
|
+
label={
|
|
61
|
+
props.attributionShort
|
|
62
|
+
? `How is this data described by its producer - ${props.attributionShort}?`
|
|
63
|
+
: "How is this data described by its producer?"
|
|
64
|
+
}
|
|
65
|
+
content={
|
|
66
|
+
<SimpleMarkdownText
|
|
67
|
+
text={props.descriptionFromProducer.trim()}
|
|
68
|
+
/>
|
|
69
|
+
}
|
|
70
|
+
isExpandedDefault={
|
|
71
|
+
!(props.descriptionShort || props.descriptionKey)
|
|
72
|
+
}
|
|
73
|
+
isStacked={!!props.additionalInfo}
|
|
74
|
+
/>
|
|
75
|
+
)}
|
|
76
|
+
{props.additionalInfo && (
|
|
77
|
+
<ExpandableToggle
|
|
78
|
+
label="Additional information about this data"
|
|
79
|
+
content={
|
|
80
|
+
<HtmlOrSimpleMarkdownText
|
|
81
|
+
text={props.additionalInfo.trim()}
|
|
82
|
+
/>
|
|
83
|
+
}
|
|
84
|
+
/>
|
|
85
|
+
)}
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
.sources-key-data-table {
|
|
2
|
+
margin-top: 16px;
|
|
3
|
+
|
|
4
|
+
display: grid;
|
|
5
|
+
grid-template-columns: repeat(2, 1fr);
|
|
6
|
+
gap: 16px;
|
|
7
|
+
|
|
8
|
+
.key-data {
|
|
9
|
+
@include label-2-medium;
|
|
10
|
+
font-size: 13px;
|
|
11
|
+
|
|
12
|
+
&__title {
|
|
13
|
+
margin-bottom: 4px;
|
|
14
|
+
color: $light-text;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&__content {
|
|
18
|
+
color: $dark-text;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&--span {
|
|
22
|
+
grid-column: 1 / -1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
a {
|
|
26
|
+
text-underline-offset: 2px;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
a {
|
|
31
|
+
color: inherit;
|
|
32
|
+
text-decoration: underline;
|
|
33
|
+
|
|
34
|
+
&:hover {
|
|
35
|
+
text-decoration: none;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&.GrapherComponentSemiNarrow .sources-key-data-table {
|
|
41
|
+
.key-data {
|
|
42
|
+
grid-column: 1 / -1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.key-data__title {
|
|
46
|
+
margin-right: 0;
|
|
47
|
+
margin-bottom: 4px;
|
|
48
|
+
}
|
|
49
|
+
}
|