-
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.
- Loading branch information
Showing
9 changed files
with
293 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* eslint-disable no-use-before-define */ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import FlexContainer from '<atoms>/layouts/FlexContainer/FlexContainer'; | ||
import StyledLink from '<atoms>/StyledLink/StyledLink'; | ||
import Image from '<atoms>/Image/Image'; | ||
import { boxShadows } from '<variables>/shadows'; | ||
|
||
/** | ||
* @description - ButtonRow Component | ||
* | ||
* @prop {string} images - images | ||
* | ||
* @return {component} ButtonRow | ||
*/ | ||
const ButtonRow = ({ | ||
images, | ||
}) => { | ||
return ( | ||
<FlexContainer alignItems="center" justifyContent="center"> | ||
{renderImages()} | ||
</FlexContainer> | ||
); | ||
|
||
function renderImages() { | ||
return images.map((image, index) => { | ||
return ( | ||
<StyledLink key={index}> | ||
<Image | ||
imageUrl={image.url} | ||
width="58px" | ||
height="58px" | ||
boxShadow="icon" | ||
altText="social media button" | ||
margin="xs" | ||
/> | ||
</StyledLink> | ||
); | ||
}); | ||
} | ||
}; | ||
|
||
ButtonRow.propTypes = { | ||
images: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
imageUrl: PropTypes.string, | ||
width: PropTypes.string, | ||
height: PropTypes.string, | ||
boxShadow: PropTypes.oneOf(Object.keys(boxShadows)), | ||
altText: PropTypes.string, | ||
margin: PropTypes.string, | ||
}), | ||
), | ||
}; | ||
|
||
export default ButtonRow; |
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,51 @@ | ||
ButtonRow Default: | ||
|
||
```jsx | ||
import { BrowserRouter as Router } from 'react-router-dom'; | ||
const images = [ | ||
{ | ||
name: 'twitter', | ||
url: 'https://cdn2.downdetector.com/static/uploads/c/300/5d4ec/twitter-logo_16.png', | ||
}, | ||
{ | ||
name: 'facebook', | ||
url: 'https://png.pngtree.com/element_our/sm/20180301/sm_5a9794da1b10e.png', | ||
}, | ||
{ | ||
name: 'google', | ||
url: 'http://pluspng.com/img-png/google-logo-png-open-2000.png', | ||
}, | ||
]; | ||
<Router> | ||
<ButtonRow images={images} /> | ||
</Router> | ||
``` | ||
|
||
ButtonRow with all props | ||
```jsx | ||
import { BrowserRouter as Router } from 'react-router-dom'; | ||
const images = [ | ||
{ | ||
name: 'twitter', | ||
url: 'https://cdn2.downdetector.com/static/uploads/c/300/5d4ec/twitter-logo_16.png', | ||
}, | ||
{ | ||
name: 'facebook', | ||
url: 'https://png.pngtree.com/element_our/sm/20180301/sm_5a9794da1b10e.png', | ||
}, | ||
{ | ||
name: 'google', | ||
url: 'http://pluspng.com/img-png/google-logo-png-open-2000.png', | ||
}, | ||
]; | ||
<Router> | ||
<ButtonRow | ||
images={images} | ||
width="58px" | ||
height="58px" | ||
boxShadow="icon" | ||
altText="social media button" | ||
margin="xs" | ||
/> | ||
</Router> | ||
``` |
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,45 @@ | ||
import React from 'react'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import { render, cleanup } from '<src>/helpers/testUtils'; | ||
import ButtonRow from './ButtonRow'; | ||
import '@testing-library/jest-dom/extend-expect'; | ||
|
||
afterEach(cleanup); | ||
|
||
const images = [ | ||
{ | ||
name: 'facebook', | ||
url: 'https://png.pngtree.com/element_our/sm/20180301/sm_5a9794da1b10e.png', | ||
}, | ||
{ | ||
name: 'google', | ||
url: 'http://pluspng.com/img-png/google-logo-png-open-2000.png', | ||
}, | ||
]; | ||
|
||
const setup = (props) => { | ||
const utils = render( | ||
<MemoryRouter> | ||
<ButtonRow images={images} {...props}/> | ||
</MemoryRouter>, | ||
); | ||
|
||
return { ...utils }; | ||
}; | ||
|
||
describe('ButtonRow', () => { | ||
it('should render the ButtonRow component', () => { | ||
const { container } = setup(); | ||
|
||
expect(container).toBeTruthy(); | ||
}); | ||
|
||
it('should render the ButtonRow component with default props', () => { | ||
const { container } = setup(); | ||
|
||
expect(container.lastChild).toHaveStyle(` | ||
height: 58px, | ||
width: 58px, | ||
`); | ||
}); | ||
}); |
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 @@ | ||
const images = [ | ||
{ | ||
name: 'twitter', | ||
// eslint-disable-next-line max-len | ||
url: 'https://cdn2.downdetector.com/static/uploads/c/300/5d4ec/twitter-logo_16.png', | ||
}, | ||
{ | ||
name: 'facebook', | ||
url: 'https://png.pngtree.com/element_our/sm/20180301/sm_5a9794da1b10e.png', | ||
}, | ||
{ | ||
name: 'google', | ||
url: 'http://pluspng.com/img-png/google-logo-png-open-2000.png', | ||
}, | ||
]; | ||
|
||
export default images; |
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