Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CreateBloks utility to create nested bloks #69

Merged
merged 2 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 13 additions & 48 deletions src/components/page-types/oodSupportPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ import Footer from "../partials/footer"
import BelowContent from '../partials/belowContent'
import IconCardSection from '../partials/iconCardSection'
import SeoSocial from "../partials/seoSocial"
import CreateBloks from "../../utilities/createBloks"

const OodSupportPage = (props) => {
return (
<>
<SbEditable content={props.blok}>
<SeoSocial {...props}/>
{props.blok.localHeader && props.blok.localHeader.map((blok) => React.createElement(Components(blok.component), {
key: blok._uid,
blok: blok
}))}
<CreateBloks blokSection={props.blok.localHeader} />
<main id="main-content"
className="ood-interior-page--no-image ood-support-page"
>
Expand Down Expand Up @@ -53,50 +51,17 @@ const OodSupportPage = (props) => {
<input type="radio" id="teaching" name="areas-to-support"/>
<label htmlFor="teaching">Teaching + Learning</label>
<div className={`grid-3-column su-mt-6 su-mb-4`}>
{props.blok.undergraduate && props.blok.undergraduate.map((blok) => React.createElement(Components(blok.component), {
key: blok._uid,
blok: blok
}))}
{props.blok.graduate && props.blok.graduate.map((blok) => React.createElement(Components(blok.component), {
key: blok._uid,
blok: blok
}))}
{props.blok.arts && props.blok.arts.map((blok) => React.createElement(Components(blok.component), {
key: blok._uid,
blok: blok
}))}
{props.blok.athletics && props.blok.athletics.map((blok) => React.createElement(Components(blok.component), {
key: blok._uid,
blok: blok
}))}
{props.blok.business && props.blok.business.map((blok) => React.createElement(Components(blok.component), {
key: blok._uid,
blok: blok
}))}
{props.blok.culture && props.blok.culture.map((blok) => React.createElement(Components(blok.component), {
key: blok._uid,
blok: blok
}))}
{props.blok.law && props.blok.law.map((blok) => React.createElement(Components(blok.component), {
key: blok._uid,
blok: blok
}))}
{props.blok.medicine && props.blok.medicine.map((blok) => React.createElement(Components(blok.component), {
key: blok._uid,
blok: blok
}))}
{props.blok.science && props.blok.science.map((blok) => React.createElement(Components(blok.component), {
key: blok._uid,
blok: blok
}))}
{props.blok.sustainability && props.blok.sustainability.map((blok) => React.createElement(Components(blok.component), {
key: blok._uid,
blok: blok
}))}
{props.blok.teaching && props.blok.teaching.map((blok) => React.createElement(Components(blok.component), {
key: blok._uid,
blok: blok
}))}
<CreateBloks blokSection={props.blok.undergraduate} />
<CreateBloks blokSection={props.blok.graduate} />
<CreateBloks blokSection={props.blok.arts} />
<CreateBloks blokSection={props.blok.athletics} />
<CreateBloks blokSection={props.blok.business} />
<CreateBloks blokSection={props.blok.culture} />
<CreateBloks blokSection={props.blok.law} />
<CreateBloks blokSection={props.blok.medicine} />
<CreateBloks blokSection={props.blok.science} />
<CreateBloks blokSection={props.blok.sustainability} />
<CreateBloks blokSection={props.blok.teaching} />
</div>
</div>
</section>
Expand Down
19 changes: 19 additions & 0 deletions src/utilities/createBloks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Process image using the Storyblok image service
// See all the "param" options on the website
// https://www.storyblok.com/docs/image-service

import React from "react"
import Components from "../components/components"

const CreateBloks = (props) => {
if (props.blokSection) {
return (
props.blokSection.map((blok) => React.createElement(Components(blok.component), {
key: blok._uid,
blok: blok
}))
)
}
};

export default CreateBloks