Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
6f1026d
test(MarkdownBlockGroup): add story for MarkdownBlockGroup component
RobH0 Aug 6, 2024
9438f47
test(MarkdownBlockGroup): add cols arg to story
RobH0 Aug 6, 2024
33f0b71
feat(MarkdownBlockGroup): add skeleton code for MarkdownBlockGroup co…
RobH0 Aug 7, 2024
20420c8
feat(MarkdownBlockGroup): display blocks in columns determined by col…
RobH0 Aug 8, 2024
a6eece8
test(MarkdownBlockGroup): add light/dark mode arg to ColumnsTest story
RobH0 Aug 8, 2024
08eb087
style(MarkdownBlockGroup): display blocks in single column when viewp…
RobH0 Aug 8, 2024
d0c7af8
style(MarkdownBlockGroup): make light/dark mode change styling for al…
RobH0 Aug 8, 2024
8b7addb
test(MarkdownBlockGroup): add title arg to ColumnsTest story
RobH0 Aug 8, 2024
385cd66
feat(MarkdownBlockGroup): render header when title prop contains non-…
RobH0 Aug 9, 2024
bc05777
test: add MarkdownBlockGroup example to home.stories.js
RobH0 Aug 9, 2024
9a4325c
test: add second MarkdownBlockGroup example to home.stories.js
RobH0 Aug 9, 2024
fd4b7c6
Merge branch 'main' of https://github.com/EnCiv/enciv-home into markd…
RobH0 Aug 10, 2024
c64e250
test: add header icons to MarkdownBlockGroup example 2
RobH0 Aug 10, 2024
6c856ef
Merge branch 'main' of https://github.com/EnCiv/enciv-home into markd…
RobH0 Feb 11, 2025
6c63785
Merge branch 'main' of https://github.com/EnCiv/enciv-home into markd…
RobH0 Mar 11, 2025
5951e9e
test: add MarkdownBlockGroup example that uses MarkdownBlock with an …
RobH0 Mar 11, 2025
f8c268b
fix: fix lineWidth not correctly being rendered after merging #45
RobH0 Mar 11, 2025
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
82 changes: 82 additions & 0 deletions app/components/markdown-block-group.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
//https://github.com/EnCiv/enciv-home/issues/48
import React from 'react'
import MarkdownBlock from './markdown-block'
import { createUseStyles } from 'react-jss'

const Blocks = {
MarkdownBlock: MarkdownBlock
}

const MarkdownBlockGroup = props => {
const {
title = '',
blocks = [],
cols = 4,
mode = 'light',
} = props
const classes = useStylesFromThemeFunction({ cols, mode })

// contains blocks component generation to prevent code reuse within component.
const blocksGridDiv = <div className={classes.BlockGridLayout}>
{blocks.map((block, i) => {
const { key, ...otherProps } = block
if (!Blocks[key]) return null
const Component = Blocks[key]
return <Component key={block + '-' + i} {...otherProps} mode={props.mode} />
})}
</div>

if (title === ''){
return (
<div className={classes.container}>
<div className={`${classes.markdownBlockGroup} ${classes[mode]}`}>
{blocksGridDiv}
</div>
</div>
)
} else {
return (
<div className={classes.container}>
<div className={`${classes.markdownBlockGroup} ${classes[mode]}`}>
<h3>{props.title}</h3>
{blocksGridDiv}
</div>
</div>
)
}
}

export default MarkdownBlockGroup

const useStylesFromThemeFunction = createUseStyles( theme => ({
container: props => ({
backgroundColor: props.mode === 'light' ? '#F2F2F2' : theme.colors.darkModeGray,
color: props.mode === 'light' ? theme.colors.darkModeGray : 'white',
}),

BlockGridLayout: props => ({
display: 'grid',
gridTemplateColumns: `repeat(${props.cols}, 1fr)`,
textAlign: 'center',
margin: 'auto',
[`@media (max-width: ${theme.condensedWidthBreakPoint})`]: {
display: 'flex',
flexDirection: 'column',
},
}),
markdownBlockGroup: props => ({
maxWidth: theme.maxPanelWidth,
margin: 'auto',
display: 'flex',
justifyContent: 'center',
flexDirection: 'column',
fontFamily: 'Montserrat',
'& > h3': {
marginBottom: '0',
fontSize: '2rem',
fontWeight: 600,
marginBlockEnd: 0,
marginLeft: '2rem',
},
}),
}))
1 change: 1 addition & 0 deletions app/components/markdown-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const MarkdownBlock = props => {
imgUrl={imgUrl}
imgSide={imgSide}
children={children}
lineWidth={lineWidth}
{...otherProps}
/>
</div>
Expand Down
2 changes: 2 additions & 0 deletions app/web-components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import BrevoCommunity from '../components/brevo-community'
import { BrevoHelmet } from '../components/brevo-join'
import MarkdownBlock from '../components/markdown-block'
import VideoBlock from '../components/video-block'
import MarkdownBlockGroup from '../components/markdown-block-group'

const Blocks = {
HeroBlock: HeroBlock,
TextBlock: TextBlock,
VideoBlock: VideoBlock,
MarkdownBlock: MarkdownBlock,
Faq: Faq,
MarkdownBlockGroup: MarkdownBlockGroup,
}
export default function Home(props) {
const { subject, description, location, blocks } = props
Expand Down
66 changes: 66 additions & 0 deletions stories/home.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,72 @@ Together, we can fix it.\n\nTo overcome the forces polarizing us, we must have n
imgUrl:
'https://res.cloudinary.com/hf6mryjpf/image/upload/v1721882509/assets%20enciv-home%202024/0a73bf0c-dcd6-4ec9-a0e8-68034c4494cb.png',
},
{
key: 'MarkdownBlockGroup',
mode: 'light',
cols: 3,
blocks: [
{
key: 'MarkdownBlock',
mode: 'light',
iconName: 'NoPartisanship',
children: `###No partisanship.\n\n---\n\nWe're non-partisan\n\nWe never endorse a particular party, policy, or, candidate
`,
lineWidth: 'full',
},
{
key: 'MarkdownBlock',
mode: 'light',
iconName: 'NoSponsorship',
children: `###No sponsorship.\n\n---\n\nWe're cross-partisan\n\nWe actively seek out and give voice to multiple perspectives`,
lineWidth: 'full',
},
{
key: 'MarkdownBlock',
mode: 'light',
iconName: 'ProductiveDialogueHead',
children: `###Productive dialogue.\n\n---\n\nWe're community-led and community built\n\nWe never endorse a particular party, policy, or candidate`,
lineWidth: 'full',
},
],
title: '',
},
{
key: 'MarkdownBlockGroup',
mode: 'dark',
cols: 4,
title: 'When we speak as One',
blocks: [
{
key: 'MarkdownBlock',
lineWidth: 'partial',
children: `\n\n---\n\nWe're fed up with (and frankly scared of) the current political system`,
imgUrl: 'https://images.unsplash.com/photo-1641945511537-359c4f7510fe?q=80&w=1280&h=1280&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
imgSide: 'top'
},
{
key: 'MarkdownBlock',
lineWidth: 'partial',
children: `\n\n---\n\nSick of partisan gridlock that stops real policy and productive discussion`,
imgUrl: 'https://images.unsplash.com/photo-1641945511537-359c4f7510fe?q=80&w=1280&h=1280&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
imgSide: 'top'
},
{
key: 'MarkdownBlock',
lineWidth: 'partial',
children: `\n\n---\n\nDone with the media that only presents the most viral candidate moments and polarized takes`,
imgUrl: 'https://images.unsplash.com/photo-1641945511537-359c4f7510fe?q=80&w=1280&h=1280&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
imgSide: 'top'
},
{
key: 'MarkdownBlock',
lineWidth: 'partial',
children: `\n\n---\n\nThere is currently no cross-partisan discourse to address the biggest problems facing our country`,
imgUrl: 'https://images.unsplash.com/photo-1641945511537-359c4f7510fe?q=80&w=1280&h=1280&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
imgSide: 'top'
},
],
},
{
key: 'Faq',
faqs: [
Expand Down
49 changes: 49 additions & 0 deletions stories/markdown-block-group.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react'
import MarkdownBlockGroup from '../app/components/markdown-block-group'

export default {
component: MarkdownBlockGroup,
parameters: {
layout: 'fullscreen',
},
}

const blocks = [
{
key: 'MarkdownBlock',
mode: 'light',
children: `###No partisanship.\n\n---\n\nWe're non-partisan\n\nWe never endorse a particular party, policy, or, candidate
`,
lineWidth: 'full',
},
{
key: 'MarkdownBlock',
mode: 'light',
children: `###No partisanship.\n\n---\n\nWe're non-partisan\n\nWe never endorse a particular party, policy, or, candidate
`,
lineWidth: 'full',
},
{
key: 'MarkdownBlock',
mode: 'light',
children: `###No partisanship.\n\n---\n\nWe're non-partisan\n\nWe never endorse a particular party, policy, or, candidate
`,
lineWidth: 'full',
},
{
key: 'MarkdownBlock',
mode: 'light',
children: `###No partisanship.\n\n---\n\nWe're non-partisan\n\nWe never endorse a particular party, policy, or, candidate
`,
lineWidth: 'full',
},
]

export const ColumnsTest = {
args: {
blocks: blocks,
cols: 4,
mode: 'light',
title: '',
},
}