-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
26019b6
commit 11e8b36
Showing
16 changed files
with
301 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import {Grid, SimpleGrid, Stack} from "@mantine/core"; | ||
import React, {useRef} from "react"; | ||
import {Viz} from "@datawheel/canon-next"; | ||
|
||
/** | ||
* CMS custom section | ||
*/ | ||
export default function CustomSection({ | ||
slug, | ||
heading, | ||
hideOptions, | ||
title, | ||
paragraphs, | ||
configOverride, | ||
loading, | ||
filters, | ||
resetButton, | ||
stats, | ||
sources, | ||
visualizations, | ||
vizHeadingLevel, | ||
updateSource, | ||
onSetVariables | ||
}) { | ||
const section = useRef(null); | ||
|
||
return ( | ||
<Grid | ||
className={`cp-section-inner cp-default-section-inner cp-${slug}-section-inner ${loading ? "is-loading" : ""}`} | ||
ref={section} | ||
my="md" | ||
> | ||
{/* sidebar */} | ||
<Grid.Col | ||
md={3} | ||
span={12} | ||
className="cp-section-content cp-default-section-caption" | ||
> | ||
<Stack spacing="sm"> | ||
{heading} | ||
{filters} | ||
{stats} | ||
{paragraphs} | ||
{sources} | ||
{resetButton} | ||
</Stack> | ||
</Grid.Col> | ||
|
||
{/* caption */} | ||
{visualizations.length | ||
? <Grid.Col | ||
md={9} | ||
span={12} | ||
className={`cp-default-section-figure${ | ||
visualizations.length > 1 ? " cp-multicolumn-default-section-figure" : "" | ||
}${ | ||
visualizations.filter( | ||
viz => viz.logic_simple && viz.logic_simple.type === "Graphic" | ||
).length ? " cp-graphic-viz-grid" : "" | ||
}`} | ||
> | ||
<SimpleGrid | ||
breakpoints={[ | ||
{minWidth: "sm", cols: 1}, | ||
{minWidth: "md", cols: visualizations.length >= 2 ? 2 : 1} | ||
]} | ||
> | ||
{visualizations.map(visualization => | ||
<Viz | ||
section={section} | ||
config={visualization} | ||
headingLevel={vizHeadingLevel} | ||
sectionTitle={title} | ||
slug={slug} | ||
hideOptions={hideOptions} | ||
configOverride={configOverride} | ||
updateSource={updateSource} | ||
onSetVariables={onSetVariables} | ||
key={visualization.id} | ||
/> | ||
)} | ||
</SimpleGrid> | ||
</Grid.Col> | ||
: ""} | ||
</Grid> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import {Grid, SimpleGrid, Stack, Title} from "@mantine/core"; | ||
import React, {useRef} from "react"; | ||
import {Viz} from "@datawheel/canon-next"; | ||
|
||
/** | ||
* CMS custom section | ||
*/ | ||
export default function Default({ | ||
slug, | ||
heading, | ||
hideOptions, | ||
title, | ||
paragraphs, | ||
configOverride, | ||
loading, | ||
filters, | ||
resetButton, | ||
stats, | ||
sources, | ||
visualizations, | ||
vizHeadingLevel, | ||
updateSource, | ||
onSetVariables | ||
}) { | ||
const section = useRef(null); | ||
|
||
return ( | ||
<Grid | ||
className={`cp-section-inner cp-default-section-inner cp-${slug}-section-inner ${loading ? "is-loading" : ""}`} | ||
ref={section} | ||
my="md" | ||
> | ||
{/* sidebar */} | ||
<Grid.Col | ||
md={3} | ||
span={12} | ||
className="cp-section-content cp-default-section-caption" | ||
> | ||
<Stack spacing="sm"> | ||
{heading} | ||
{filters} | ||
{stats} | ||
{paragraphs} | ||
{sources} | ||
{resetButton} | ||
</Stack> | ||
</Grid.Col> | ||
|
||
{/* caption */} | ||
{visualizations.length | ||
? <Grid.Col | ||
md={9} | ||
span={12} | ||
className={`cp-default-section-figure${ | ||
visualizations.length > 1 ? " cp-multicolumn-default-section-figure" : "" | ||
}${ | ||
visualizations.filter( | ||
viz => viz.logic_simple && viz.logic_simple.type === "Graphic" | ||
).length ? " cp-graphic-viz-grid" : "" | ||
}`} | ||
> | ||
<SimpleGrid | ||
breakpoints={[ | ||
{minWidth: "sm", cols: 1}, | ||
{minWidth: "md", cols: visualizations.length >= 2 ? 2 : 1} | ||
]} | ||
> | ||
{visualizations.map(visualization => | ||
<Viz | ||
section={section} | ||
config={visualization} | ||
headingLevel={vizHeadingLevel} | ||
sectionTitle={title} | ||
slug={slug} | ||
hideOptions={hideOptions} | ||
configOverride={configOverride} | ||
updateSource={updateSource} | ||
onSetVariables={onSetVariables} | ||
key={visualization.id} | ||
/> | ||
)} | ||
</SimpleGrid> | ||
</Grid.Col> | ||
: ""} | ||
</Grid> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import CustomSection from "./CustomSection"; | ||
import Default from "./Default"; | ||
export default { | ||
CustomSection, | ||
Default | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": ["./*"] | ||
"@/*": ["./*"], | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
const {i18n} = require("./next-i18next.config"); | ||
const rootDir = process.cwd(); | ||
const path = require("path"); | ||
|
||
const nextConfig = { | ||
i18n, | ||
reactStrictMode: true | ||
reactStrictMode: true, | ||
webpack(config, options) { | ||
config.resolve.alias.CustomSections = path.join(__dirname, "cms/sections"); | ||
return config; | ||
} | ||
}; | ||
|
||
module.exports = nextConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {Viz} from "@datawheel/canon-next"; | ||
|
||
/** */ | ||
export default function Page() { | ||
console.log(Viz); | ||
return <div>Just testing</div>; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.