Skip to content

Commit

Permalink
🐛 Override textblock component #1880
Browse files Browse the repository at this point in the history
  • Loading branch information
millianapia committed Nov 2, 2023
1 parent 6943723 commit 8034fe3
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 5 deletions.
1 change: 0 additions & 1 deletion web/components/src/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const StyledList = styled(EdsList)<ListProps>`
margin-left: var(--space-medium);
margin-right: var(--space-medium);
padding-left: var(--space-medium);
padding-bottom: var(--space-small);
list-style-position: outside;
${({ unstyled }) =>
unstyled && {
Expand Down
54 changes: 50 additions & 4 deletions web/pageComponents/topicPages/TextBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Eyebrow, BackgroundContainer, Text, Heading } from '@components'
import { Eyebrow, BackgroundContainer, Text, Heading, List } from '@components'
import IngressText from '../shared/portableText/IngressText'
import RichText from '../shared/portableText/RichText'
import TitleText from '../shared/portableText/TitleText'
import Image, { Ratios } from '../shared/SanityImage'
import styled from 'styled-components'
import type { TextBlockData } from '../../types/types'
import CallToActions from './CallToActions'
import { BlockType } from '../shared/portableText/helpers/defaultSerializers'
import { BlockType, ListType } from '../shared/portableText/helpers/defaultSerializers'
import type { PortableTextBlock } from '@portabletext/types'

export const StyledTextBlockWrapper = styled(BackgroundContainer)<{ id: string | undefined }>`
${({ id }) =>
Expand Down Expand Up @@ -39,6 +40,9 @@ const StyledTextBlock = styled.section`
margin-bottom: 0;
}
`
const StyledList = styled(List)`
margin-bottom: var(--space-medium);
`

const TextContainer = styled.div`
margin-bottom: var(--space-medium);
Expand Down Expand Up @@ -93,12 +97,54 @@ const TextBlock = ({ data, anchor }: TextBlockProps) => {
)}
{overline && <Eyebrow>{overline}</Eyebrow>}
{title && <TitleText value={title} />}
{ingress && <IngressText value={ingress} />}
{ingress && (
<IngressText
value={ingress}
components={{
list: {
bullet: ({ children }) => {
return (
<StyledList>
<>{children}</>
</StyledList>
)
},
number: ({ children }) => {
return (
<StyledList>
<>{children}</>
</StyledList>
)
},
},
}}
/>
)}
</>
)}
{text && (
<TextContainer>
<RichText value={text} />
<RichText
value={text}
components={{
list: {
bullet: ({ children }) => {
return (
<StyledList>
<>{children}</>
</StyledList>
)
},
number: ({ children }) => {
return (
<StyledList>
<>{children}</>
</StyledList>
)
},
},
}}
></RichText>
</TextContainer>
)}
{callToActions && callToActions.length === 1 && !overrideButtonStyle && <Spacer />}
Expand Down

0 comments on commit 8034fe3

Please sign in to comment.