-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(molecule): setup image with article row molecule
- setup container for the atoms - include image atom - include text and title atom - write test for component [Finishes #167454777]
- Loading branch information
1 parent
769fe87
commit 73fe5db
Showing
18 changed files
with
414 additions
and
74 deletions.
There are no files selected for viewing
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
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
113 changes: 113 additions & 0 deletions
113
src/components/UI/molecules/ArticleContent/ArticleContent.jsx
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,113 @@ | ||
/* eslint-disable no-use-before-define */ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import FlexContainer from '<atoms>/layouts/FlexContainer/FlexContainer'; | ||
import Title from '<atoms>/Title/Title'; | ||
import Text from '<atoms>/Text/Text'; | ||
import { fontSizes, lineHeights } from '<variables>/fonts'; | ||
|
||
/** | ||
* @description - ArticleContent Component | ||
* | ||
* @prop {string} title - title | ||
* @prop {string} author - author | ||
* @prop {string} description - description | ||
* @prop {string} titleFontSize - titleFontSize | ||
* @prop {string} authorFontSize - authorFontSize | ||
* @prop {string} descriptionFontSize - descriptionFontSize | ||
* | ||
* @return {component} ArticleContent | ||
*/ | ||
const ArticleContent = ({ | ||
title, | ||
author, | ||
description, | ||
authorLineHeight, | ||
titleFontSize, | ||
authorFontSize, | ||
descriptionFontSize, | ||
}) => { | ||
return ( | ||
<FlexContainer | ||
containerWidth="articleWidth" | ||
backgroundColor="primary" | ||
padding="xxl" | ||
paddingLeft="xl" | ||
> | ||
<FlexContainer | ||
backgroundColor="primary" | ||
> | ||
{title && (renderTitle(titleFontSize))} | ||
{author && (renderAuthor(authorFontSize, authorLineHeight))} | ||
</FlexContainer> | ||
<FlexContainer | ||
backgroundColor="primary" | ||
> | ||
{description && (renderDescription(descriptionFontSize))} | ||
</FlexContainer> | ||
</FlexContainer> | ||
); | ||
|
||
function renderTitle(size) { | ||
return ( | ||
<Title | ||
fontSize={size} | ||
color="lightBrown" | ||
content="true" | ||
paddingBottom="zero" | ||
> | ||
{title} | ||
</Title> | ||
); | ||
} | ||
|
||
function renderAuthor(size, height) { | ||
return ( | ||
<div> | ||
<Text | ||
fontSize={size} | ||
color="lightBrown" | ||
content="true" | ||
lineHeight={height} | ||
> | ||
{author} | ||
</Text> | ||
</div> | ||
); | ||
} | ||
|
||
function renderDescription(size) { | ||
return ( | ||
<div> | ||
<Text | ||
fontSize={size} | ||
color="white001" | ||
content="true" | ||
> | ||
{description} | ||
</Text> | ||
</div> | ||
); | ||
} | ||
}; | ||
|
||
|
||
ArticleContent.defaultProps = { | ||
titleFontSize: 'xlarge', | ||
authorFontSize: 'medx', | ||
descriptionFontSize: 'medium', | ||
authorLineHeight: 'zero', | ||
}; | ||
|
||
ArticleContent.propTypes = { | ||
title: PropTypes.string, | ||
author: PropTypes.string, | ||
description: PropTypes.string, | ||
titleFontSize: PropTypes.oneOf(Object.keys(fontSizes)), | ||
authorFontSize: PropTypes.oneOf(Object.keys(fontSizes)), | ||
descriptionFontSize: PropTypes.oneOf(Object.keys(fontSizes)), | ||
authorLineHeight: PropTypes.oneOf(Object.keys(lineHeights)), | ||
}; | ||
|
||
export default ArticleContent; |
19 changes: 19 additions & 0 deletions
19
src/components/UI/molecules/ArticleContent/ArticleContent.md
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,19 @@ | ||
ArticleContent Default: | ||
|
||
```jsx | ||
<ArticleContent | ||
/> | ||
``` | ||
|
||
ArticleContent with all attributes: | ||
|
||
```jsx | ||
<ArticleContent | ||
title="City by the bay" | ||
author="By : Emmy Joans" | ||
description="This is a description of an article" | ||
titleFontSize="medx" | ||
authorFontSize="normal" | ||
descriptionFontSize="normal" | ||
/> | ||
``` |
55 changes: 55 additions & 0 deletions
55
src/components/UI/molecules/ArticleContent/ArticleContent.spec.js
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,55 @@ | ||
/* eslint-disable max-len */ | ||
import React from 'react'; | ||
import { render, cleanup } from '<src>/helpers/testUtils'; | ||
import ArticleContent from './ArticleContent'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
|
||
afterEach(cleanup); | ||
|
||
const setup = () => { | ||
const utils = render( | ||
<ArticleContent />, | ||
); | ||
|
||
return { ...utils }; | ||
}; | ||
|
||
describe('ArticleContent', () => { | ||
it('should render the ArticleContent component', () => { | ||
const { container } = setup(); | ||
|
||
expect(container).toBeTruthy(); | ||
}); | ||
|
||
it('should render the ArticleContent Component with titleFontSize', () => { | ||
const { container } = render(<ArticleContent titleFontSize="large" />); | ||
|
||
expect(container.lastChild).toHaveStyle(` | ||
titleFontSize: large | ||
`); | ||
}); | ||
|
||
it('should render the ArticleContent Component with authorFontSize', () => { | ||
const { container } = render(<ArticleContent authorFontSize="medium" />); | ||
|
||
expect(container.lastChild).toHaveStyle(` | ||
authorFontSize: medium, | ||
`); | ||
}); | ||
|
||
it('should render the ArticleContent Component with descriptionFontSize', () => { | ||
const { container } = render(<ArticleContent descriptionFontSize="medium" />); | ||
|
||
expect(container.lastChild).toHaveStyle(` | ||
descriptionFontSize: medium, | ||
`); | ||
}); | ||
|
||
it('should render the ArticleContent Component with authorLineHeight', () => { | ||
const { container } = render(<ArticleContent authorLineHeight="single" />); | ||
|
||
expect(container.lastChild).toHaveStyle(` | ||
authorLineHeight: single, | ||
`); | ||
}); | ||
}); |
Oops, something went wrong.