Skip to content

Commit

Permalink
Accordion title changed to text and h3 styling applied
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorreem committed Jul 18, 2023
1 parent 47facb0 commit 14bf912
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions components/storyblok/StoryblokAccordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import AccordionSummary from '@mui/material/AccordionSummary';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import Image from 'next/image';
import { render } from 'storyblok-rich-text-react-renderer';
import { ReactNode } from 'react';
import { NODE_PARAGRAPH, render } from 'storyblok-rich-text-react-renderer';
import { ACCORDION_OPENED } from '../../constants/events';
import logEvent from '../../utils/logEvent';
import { RichTextOptions } from '../../utils/richText';
Expand Down Expand Up @@ -39,7 +40,6 @@ interface StoryblokAccordionProps {
accordion_items: Array<StoryblokAccordionItemProps>;
theme: 'primary' | 'secondary';
}

const StoryblokAccordion = (props: StoryblokAccordionProps) => {
const { accordion_items, theme } = props;

Expand All @@ -62,18 +62,25 @@ const StoryblokAccordion = (props: StoryblokAccordionProps) => {
<Icon
sx={{
position: 'relative',
fontSize: 24,
fontSize: 32,
marginBottom: 0,
marginRight: 1,
marginRight: 2,
}}
>
<Image alt={ai.icon.alt} src={ai.icon.filename} layout="fill" objectFit="contain" />
</Icon>
)}

<Typography component="h3" textAlign="left">
{render(ai.title, RichTextOptions)}
</Typography>
{render(ai.title, {
nodeResolvers: {
// Overriding default rendering of the text paragraph component
[NODE_PARAGRAPH]: (children: ReactNode | null) => (
<Typography sx={{ marginBottom: 0 }} component="h3" variant="h3" textAlign="left">
{children}
</Typography>
),
},
})}
</AccordionSummary>
<AccordionDetails sx={accordionDetail}>
{render(ai.body, RichTextOptions)}
Expand Down

0 comments on commit 14bf912

Please sign in to comment.