This repository has been archived by the owner on Mar 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ecmwf-projects/COPDS-1308
Copds 1308
- Loading branch information
Showing
9 changed files
with
17,017 additions
and
1,712 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react' | ||
import { render, screen } from '@testing-library/react' | ||
|
||
import { HtmlBlock } from '../../../src/components' | ||
|
||
describe('type html', () => { | ||
it('it renders correctly', () => { | ||
render( | ||
<HtmlBlock | ||
block={{ | ||
type: 'html', | ||
id: 'test-id-1', | ||
content: | ||
'<div>This is a raw HTML</div><p>With more HTML</p>', | ||
}} | ||
/>, | ||
) | ||
|
||
screen.getByText('This is a raw HTML') | ||
screen.getByText('With more HTML') | ||
}) | ||
it('it renders correctly without content', () => { | ||
render( | ||
<HtmlBlock | ||
block={{ | ||
type: 'html', | ||
id: 'test-id-1', | ||
content: null as unknown as string, | ||
}} | ||
/>, | ||
) | ||
}) | ||
}) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react' | ||
import { HtmlBlock } from './HtmlBlock'; | ||
|
||
export const HtmlBlockStory = () => (<div style={ | ||
{ | ||
width: '100%', | ||
height: '100%', | ||
} | ||
}> | ||
<HtmlBlock | ||
block={{ | ||
'id': 'html', | ||
'type': 'html', | ||
'content': `<div>This is an HTML</div> <b>inside</b> <p>an HTML block</p>` | ||
}} | ||
/> | ||
</div>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react' | ||
|
||
import styled from 'styled-components' | ||
|
||
import { HtmlBlockInteface, } from '../../models' | ||
|
||
export const HtmlBlock = ({ | ||
block, | ||
}: { | ||
block: HtmlBlockInteface | ||
}) => ( | ||
<Content data-stylizable="block html-content"> | ||
{block?.content && ( | ||
<ContentWrapper dangerouslySetInnerHTML={{ __html: block.content }} /> | ||
)} | ||
</Content> | ||
) | ||
|
||
const Content = styled.div` | ||
display: flex; | ||
margin: 0; | ||
flex-direction: column; | ||
justify-content: flex-start; | ||
` | ||
|
||
const ContentWrapper = styled.div` | ||
width: 100%; | ||
height: 100%; | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.