-
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
- Loading branch information
1 parent
769fe87
commit 270f156
Showing
14 changed files
with
294 additions
and
70 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
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,132 @@ | ||
/* eslint-disable no-use-before-define */ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
|
||
import FlexContainer from '<atoms>/layouts/FlexContainer/FlexContainer'; | ||
import Image from '<atoms>/Image/Image'; | ||
import Title from '<atoms>/Title/Title'; | ||
import Text from '<atoms>/Text/Text'; | ||
import { fontSizes } from '<variables>/fonts'; | ||
|
||
/** | ||
* @description - ImageText Component | ||
* | ||
* @prop {string} imageUrl - imageUrl | ||
* @prop {string} title - title | ||
* @prop {string} author - author | ||
* @prop {string} description - description | ||
* | ||
* @return {component} ImageText | ||
*/ | ||
const ImageText = ({ | ||
title, | ||
author, | ||
description, | ||
imageUrl, | ||
titleFontSize, | ||
authorFontSize, | ||
descriptionFontSize, | ||
}) => { | ||
return ( | ||
<FlexContainer | ||
flexDirection="row" | ||
height="75%" | ||
padding="zero" | ||
> | ||
<FlexContainer | ||
padding="zero" | ||
containerWidth="imageWidth" | ||
> | ||
<Image | ||
imageUrl={imageUrl} | ||
width="100%" | ||
/> | ||
</FlexContainer> | ||
<FlexContainer | ||
containerWidth="articleWidth" | ||
backgroundColor="primary" | ||
padding="xxl" | ||
paddingLeft="xl" | ||
> | ||
<FlexContainer | ||
backgroundColor="primary" | ||
> | ||
{title && (renderTitle(titleFontSize))} | ||
{author && (renderAuthor(authorFontSize))} | ||
</FlexContainer> | ||
<FlexContainer | ||
backgroundColor="primary" | ||
> | ||
{description && (renderDescription(descriptionFontSize))} | ||
</FlexContainer> | ||
</FlexContainer> | ||
</FlexContainer> | ||
); | ||
|
||
|
||
function renderTitle(size) { | ||
return ( | ||
<Title | ||
fontSize={size} | ||
color="lightBrown" | ||
content="true" | ||
paddingBottom="zero" | ||
> | ||
{title} | ||
</Title> | ||
); | ||
} | ||
|
||
function renderAuthor(size) { | ||
return ( | ||
<div> | ||
<Text | ||
fontSize={size} | ||
color="lightBrown" | ||
content="true" | ||
lineHeight="0rem" | ||
> | ||
{author} | ||
</Text> | ||
</div> | ||
); | ||
} | ||
|
||
function renderDescription(size) { | ||
return ( | ||
<div> | ||
<Text | ||
fontSize={size} | ||
color="white001" | ||
content="true" | ||
lineHeight="6.2rem" | ||
> | ||
{description} | ||
</Text> | ||
</div> | ||
); | ||
} | ||
}; | ||
|
||
ImageText.defaultProps = { | ||
titleFontSize: 'xlarge', | ||
authorFontSize: 'medx', | ||
descriptionFontSize: 'medx', | ||
}; | ||
|
||
ImageText.propTypes = { | ||
imageUrl: PropTypes.string, | ||
width: PropTypes.string, | ||
height: PropTypes.string, | ||
display: PropTypes.oneOf(['block', 'inline', 'flex', 'inline-block', 'none']), | ||
text: PropTypes.string, | ||
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)), | ||
}; | ||
|
||
export default ImageText; |
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,22 @@ | ||
ImageText Default: | ||
|
||
```jsx | ||
<ImageText | ||
/> | ||
``` | ||
|
||
Icon with all attributes | ||
```jsx | ||
import FlexContainer from '<atoms>/layouts/FlexContainer/FlexContainer'; | ||
<FlexContainer> | ||
<ImageText | ||
imageUrl="https://www.cubesmart.com/blog/wp-content/uploads/Brooklyn-Bridge-at-Night-1140x704.jpg" | ||
title="City by the bay" | ||
author="By : Emmy Joans" | ||
description="This is a description of an article" | ||
titleFontSize="normal" | ||
authorFontSize="normal" | ||
descriptionFontSize="normal" | ||
/> | ||
</FlexContainer> | ||
``` |
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,41 @@ | ||
/* eslint-disable max-len */ | ||
import React from 'react'; | ||
import { render, cleanup } from '<src>/helpers/testUtils'; | ||
import ImageText from './ImageText'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
|
||
afterEach(cleanup); | ||
|
||
const setup = (props) => { | ||
const utils = render( | ||
<ImageText {...props}/>, | ||
); | ||
|
||
return { ...utils }; | ||
}; | ||
|
||
describe('ImageText', () => { | ||
it('should render the ImageText component', () => { | ||
const { container } = setup(); | ||
|
||
expect(container).toBeTruthy(); | ||
}); | ||
|
||
it('should render ImageText with title', () => { | ||
const { getByText } = render(<ImageText title='City by the bay' />); | ||
|
||
expect(getByText('City by the bay')).toBeTruthy(); | ||
}); | ||
|
||
it('should render ImageText with author', () => { | ||
const { getByText } = render(<ImageText author='By : Emmy Joan' />); | ||
|
||
expect(getByText('By : Emmy Joan')).toBeTruthy(); | ||
}); | ||
|
||
it('should render ImageText with description', () => { | ||
const { getByText } = render(<ImageText description='This is a description' />); | ||
|
||
expect(getByText('This is a description')).toBeTruthy(); | ||
}); | ||
}); |
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
Oops, something went wrong.