Skip to content

Commit

Permalink
[MIM-1976] Mim-1976 fix formatting errors in rich text part (#2807)
Browse files Browse the repository at this point in the history
* fix formatting

* fixed styling

---------

Co-authored-by: Johnnadel Salita Uy <johnnadel.salita@gmail.com>
  • Loading branch information
annesiri and johnnadeluy authored Jun 25, 2024
1 parent ad7ffea commit bf343ef
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/main/resources/assets/styles/_richText.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
.xp-part.rich-text {
.rich-text-lead-paragraph {
@include open-sans;
color: $ssb-dark-6;
font-size: 20px;
line-height: 32px;
}

.rich-text-paragraph {
@include open-sans;
color: $ssb-dark-6;
font-size: 16px;
line-height: 28px;
}

&.max-width > * {
max-width: $max-readable-width;
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/site/parts/richText/richText.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import { LeadParagraph, Text, Paragraph } from '@statisticsnorway/ssb-component-library'
import { sanitize } from '../../../lib/ssb/utils/htmlUtils'
import { Text } from '@statisticsnorway/ssb-component-library'

interface RichTextProps {
text: string
Expand All @@ -10,12 +9,13 @@ interface RichTextProps {

const RichText = ({ text, textType, inLayout }: RichTextProps) => {
const renderText = () => {
const textComponent = <span dangerouslySetInnerHTML={{ __html: sanitize(text) }} />
// Text is sanitized in ts file
const textComponent = <span dangerouslySetInnerHTML={{ __html: text }} />
switch (textType) {
case 'ingress':
return <LeadParagraph>{textComponent}</LeadParagraph>
return <div className='rich-text-lead-paragraph'>{textComponent}</div>
case 'brodtekst':
return <Paragraph>{textComponent}</Paragraph>
return <div className='rich-text-paragraph'>{textComponent}</div>
case 'mikrotekst':
return <Text small>{textComponent}</Text>
default:
Expand Down

0 comments on commit bf343ef

Please sign in to comment.