;
+}
diff --git a/package-lock.json b/package-lock.json
index 2882e0c36..f66d245af 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -7824,7 +7824,7 @@
},
"packages/next": {
"name": "@datawheel/canon-next",
- "version": "0.1.3",
+ "version": "0.1.4",
"license": "GPL-3.0-or-later",
"dependencies": {
"@mantine/core": "^5.6.3",
diff --git a/packages/next/cms/components/Viz/Viz.js b/packages/next/cms/components/Viz/Viz.js
index 0d039fd47..d2a88665d 100644
--- a/packages/next/cms/components/Viz/Viz.js
+++ b/packages/next/cms/components/Viz/Viz.js
@@ -10,7 +10,8 @@ import {useRouter} from "next/router.js";
import {Title} from "@mantine/core";
import {useViewportSize} from "@mantine/hooks";
import * as d3plus from "d3plus-react";
-import {Options, ProfileContext} from "../../../index";
+import Options from "./Options"
+import ProfileContext from "../ProfileContext";
import propify from "../../utils/d3plusPropify";
import HTML from "./HTML";
// User must define custom sections in app/cms/sections, and export them from an index.js in that folder.
@@ -120,7 +121,7 @@ function Viz(props) {
{title && showTitle
- ? setFilterProfiles(profileIds.join(","))}
@@ -385,13 +388,13 @@ function ProfileSearch({
>
{ d.levels
? onFilterLevels(false)}
dangerouslySetInnerHTML={{__html: d.title}}
/>
: onFilterLevels(false)}
dangerouslySetInnerHTML={{__html: d.title}}
/>
@@ -400,7 +403,7 @@ function ProfileSearch({
? d.sortedLevels.map(l =>
onFilterLevels(l)}
dangerouslySetInnerHTML={{__html: filterHierarchyTitle(l, activeProfile[0])}}
/>
diff --git a/packages/next/cms/components/sections/Hero.js b/packages/next/cms/components/sections/Hero.js
index 4e327919f..59c3fcae9 100644
--- a/packages/next/cms/components/sections/Hero.js
+++ b/packages/next/cms/components/sections/Hero.js
@@ -7,10 +7,10 @@ import {
import {
IconChevronDown, IconChevronUp
} from "@tabler/icons-react";
-// eslint-disable-next-line import/no-cycle
-import {
- ProfileContext, SourceGroup, StatGroup, Viz
-} from "../../../index";
+import ProfileContext from "../ProfileContext";
+import SourceGroup from "../Viz/SourceGroup";
+import StatGroup from "../Viz/StatGroup";
+import Viz from "../Viz/Viz";
import stripP from "../../utils/formatters/stripP";
// import {strip} from "d3plus-text";
@@ -181,7 +181,7 @@ function Hero({
{/* display image credits, and images */}
- {profile.images.length &&
+ {profile.images.length ?
<>
{/* credits */}
{type !== "story" && hasAuthor &&
@@ -268,6 +268,14 @@ function Hero({
zIndex={1}
/>
>
+ :
+
+
+
}
{
+ Object.keys(newVariables).forEach(key => {
changedVariables[key] = initialVariables[key];
});
setChangedVariables(changedVariables);
@@ -99,7 +101,8 @@ function Section({
if (screenTop !== containerTop) {
if (containerTop < screenTop && !isStickyIE) {
setIsStickyIE(true);
- } else if (containerTop > screenTop && isStickyIE) {
+ }
+ else if (containerTop > screenTop && isStickyIE) {
setIsStickyIE(false);
}
}
@@ -108,15 +111,18 @@ function Section({
useWindowEvent("scroll", scrollHandler);
- const updateSource = (newSources) => {
- if (!newSources) { setSources([]); } else {
- setSources((oldSources) => {
+ const updateSource = newSources => {
+ if (!newSources) {
+ setSources([]);
+ }
+ else {
+ setSources(oldSources => {
const addSources = newSources
- .map((s) => s.annotations)
+ .map(s => s.annotations)
// filter out new sources that already are on the sources state variable.
- .filter((source) => (
- source && source.source_name && !oldSources.find((s) => s.source_name === source.source_name)
- ));
+ .filter(source =>
+ source && source.source_name && !oldSources.find(s => s.source_name === source.source_name)
+ );
return [...oldSources, ...addSources];
});
}
@@ -124,16 +130,17 @@ function Section({
const layout = contents.type;
const layoutClass = `cp-${toKebabCase(layout)}-section`;
+
const Layout = contents.position === "sticky" ? Default : sectionTypes[layout] || Default;
const showAnchor = !(isModal || hideAnchor);
const {
- slug, title, descriptions, subtitles, visualizations,
+ slug, title, descriptions, subtitles, visualizations
} = contents;
const selectors = contents.selectors || [];
- const filters = selectors.map((selector) => (
+ const filters = selectors.map(selector =>
- ));
-
- const mainTitle = (
- title
- && (
-
-
- {title}
-
- {showAnchor
- && (
-
-
+
+ {title}
+
+ {showAnchor &&
+
+
+
#
- permalink to section
-
-
- )}
-
- )
+ permalink to section
+
+
+ }
+
+
- );
+ ;
- const subTitle = (
- contents.position !== "sticky" && subtitles.map((content, i) => (
+ const subTitle =
+ contents.position !== "sticky" && subtitles.map((content, i) =>
{content.subtitle}
- ))
- );
- const heading = (
+ )
+ ;
+ const heading =
<>
{mainTitle}
{subTitle}
>
- );
+ ;
let statContent;
const {stats} = contents;
if (contents.position !== "sticky") {
- const statGroups = nest().key((d) => d.title).entries(stats);
+ const statGroups = nest().key(d => d.title).entries(stats);
if (stats.length > 0) {
- statContent = (
+ statContent =
*": {
- flex: "1 0 50%",
- },
+ flex: "1 0 50%"
+ }
}}
className={`cp-stat-group-wrapper${stats.length === 1 ? " single-stat" : ""}`}
wrap="wrap"
>
{statGroups.map(({key, values}) => )}
- );
+ ;
}
}
let paragraphs;
if (descriptions.length && contents.position !== "sticky") {
- paragraphs = descriptions.map((content, i) => (
+ paragraphs = descriptions.map((content, i) =>
{content.description}
- ));
+ );
}
const sourceContent = ;
- const resetButton = showReset
- && (
+ const resetButton = showReset &&
+
- );
+ ;
const componentProps = {
slug,
@@ -265,7 +272,7 @@ function Section({
contents,
// these were set as context child props. Not possible with new Context API
updateSource,
- onSetVariables,
+ onSetVariables
};
return (
@@ -285,12 +292,12 @@ function Section({
{/* in IE, create empty div set to the height of the stuck element */}
- {isStickyIE && (
+ {isStickyIE &&
<>
>
- )}
+ }
);
}
diff --git a/packages/next/index.ts b/packages/next/index.ts
index b8ab28fca..08c5df2ec 100644
--- a/packages/next/index.ts
+++ b/packages/next/index.ts
@@ -8,11 +8,13 @@ export {default as ProfileSearch} from "./cms/components/fields/ProfileSearch.js
export {default as ProfileTile} from "./cms/components/fields/ProfileTile.js";
export {default as Hero} from "./cms/components/sections/Hero.js";
-export {default as Stat} from "./cms/components/sections/components/Stat.js";
+
+// Elements to be used by Custom Sections
+// export {default as PDFButton} from "./components/sections/components/PDFButton.jsx";
+export {default as Selector} from "./cms/components/sections/components/Selector.js";
+export {default as Stat} from "./cms/components/sections/components/Stat.js";
export {default as Viz} from "./cms/components/Viz/Viz.js";
-export {default as Options} from "./cms/components/Viz/Options.js";
-export {default as SourceGroup} from "./cms/components/Viz/SourceGroup.js";
export {default as StatGroup} from "./cms/components/Viz/StatGroup.js";
export {default as cmsDefaultProps} from "./ssg/cmsDefaultProps.js";
diff --git a/packages/next/package.json b/packages/next/package.json
index 702b8c22c..ff98686d9 100644
--- a/packages/next/package.json
+++ b/packages/next/package.json
@@ -1,6 +1,6 @@
{
"name": "@datawheel/canon-next",
- "version": "0.1.3",
+ "version": "0.1.4",
"description": "Nextjs components for sites migrating away from canon-core.",
"main": "./dist/index.js",
"exports": {
diff --git a/packages/next/tsup.config.js b/packages/next/tsup.config.js
index 5d493d5bb..d950e7b14 100644
--- a/packages/next/tsup.config.js
+++ b/packages/next/tsup.config.js
@@ -13,4 +13,5 @@ export default defineConfig(options => ({
shims: true,
splitting: false,
treeshake: true,
+ external: ["CustomSections"],
}));