Skip to content

Commit

Permalink
Merge 559f1e4 into 6338e32
Browse files Browse the repository at this point in the history
  • Loading branch information
Sojisoyoye committed Jul 16, 2019
2 parents 6338e32 + 559f1e4 commit e8b0ee8
Show file tree
Hide file tree
Showing 9 changed files with 293 additions and 80 deletions.
173 changes: 96 additions & 77 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/components/UI/atoms/Icon/Icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Icon with all attributes
color="black"
display="block"
margin="md"
icon="starEmpty"
iconName="starEmpty"
/>
```

Expand All @@ -28,7 +28,7 @@ Icon with color
```jsx
<Icon
color="gold"
icon="starFull"
iconName="starFull"
/>
```

Expand Down
6 changes: 6 additions & 0 deletions src/components/UI/atoms/Image/Image.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import styled from 'styled-components';
import { borderRadius } from '<variables>/border';
import { boxShadows } from '<variables>/shadows';
import { borderColors } from '<variables>/colorPalette';
import spacing from '<variables>/spacing';

/**
* @description - Image Component
Expand All @@ -28,6 +29,7 @@ const Image = (
boxShadow,
borderRadiusType,
borderColor,
margin,
},
) => {
return <Image.Container
Expand All @@ -39,6 +41,7 @@ const Image = (
boxShadow={boxShadow}
borderRadiusType={borderRadiusType}
borderColor={borderColor}
margin={margin}
/>;
};

Expand All @@ -50,6 +53,7 @@ ${({
boxShadow,
borderRadiusType,
borderColor,
margin,
theme,
}) => {
return `
Expand All @@ -58,6 +62,7 @@ ${({
box-shadow:${theme.boxShadows[boxShadow]};
border: ${`1px solid ${theme.borderColors[borderColor]}`};
border-radius:${theme.borderRadius[borderRadiusType]};
margin: ${theme.spacing[margin]}
`;
}}`;

Expand All @@ -69,6 +74,7 @@ Image.propTypes = {
height: PropTypes.string,
boxShadow: PropTypes.oneOf(Object.keys(boxShadows)),
borderColor: PropTypes.oneOf(Object.keys(borderColors)),
margin: PropTypes.oneOf(Object.keys(spacing)),
borderRadiusType: PropTypes.oneOf(Object.keys(borderRadius)),
};

Expand Down
16 changes: 15 additions & 1 deletion src/components/UI/atoms/layouts/FlexContainer/FlexContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import theme from '<variables>/mainTheme';
* @prop {string} borderColor - border color
* @prop {string} borderRadius - add border radius
* @prop {string} boxShadow - boxShadow
* @prop {string} alignItems - alignItems
* @prop {string} justifyContent - justifyContent
*
* @return {component} FlexContainer
*/
Expand All @@ -27,6 +29,8 @@ const FlexContainer = ({
borderColor,
borderRadius,
boxShadow,
alignItems,
justifyContent,
}) => (
<FlexContainer.Container
margin={margin}
Expand All @@ -36,6 +40,8 @@ const FlexContainer = ({
borderColor={borderColor}
borderRadius={borderRadius}
boxShadow={boxShadow}
alignItems={alignItems}
justifyContent={justifyContent}
>
{children}
</FlexContainer.Container>
Expand All @@ -50,6 +56,8 @@ FlexContainer.Container = styled.div`
boxShadow,
backgroundColor,
borderColor,
alignItems,
justifyContent,
theme: {
spacing, backgroundColors, borderColors, boxShadows,
},
Expand All @@ -62,6 +70,8 @@ FlexContainer.Container = styled.div`
border-radius: ${spacing[borderRadius]};
box-shadow: ${boxShadows[boxShadow]};
border: 1px solid ${borderColors[borderColor] || 'transparent'};
align-items: ${alignItems}
justify-content: ${justifyContent}
`}
`;

Expand All @@ -79,14 +89,18 @@ const {
} = theme;

FlexContainer.propTypes = {
children: PropTypes.node.isRequired,
children: PropTypes.node,
margin: PropTypes.oneOf(Object.keys(spacing)),
padding: PropTypes.oneOf(Object.keys(spacing)),
backgroundColor: PropTypes.oneOf(Object.keys(backgroundColors)),
display: PropTypes.oneOf(['block', 'inline', 'flex', 'inline-block', 'none']),
borderColor: PropTypes.oneOf(Object.keys(borderColors)),
borderRadius: PropTypes.oneOf(Object.keys(spacing)),
boxShadow: PropTypes.oneOf(Object.keys(boxShadows)),
alignItems: PropTypes.oneOf(['flex-start', 'flex-end',
'center', 'baseline', 'stretch']),
justifyContent: PropTypes.oneOf(['flex-start', 'flex-end',
'center', 'space-between', 'space-around']),
};

export default FlexContainer;
57 changes: 57 additions & 0 deletions src/components/UI/molecules/ButtonRow/ButtonRow.jsx
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;
51 changes: 51 additions & 0 deletions src/components/UI/molecules/ButtonRow/ButtonRow.md
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>
```
45 changes: 45 additions & 0 deletions src/components/UI/molecules/ButtonRow/ButtonRow.spec.js
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,
`);
});
});
17 changes: 17 additions & 0 deletions src/styles/variables/images.js
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;
4 changes: 4 additions & 0 deletions src/styles/variables/spacing.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const spacing = {
zero: '0rem',
xs: '0.9rem',
xxs: '1.5rem',
sm: '1.6rem',
smd: '25.8rem',
smm: '2.8rem',
med: '3.0rem',
md: '3.2rem',
mds: '3.8rem',
xxl: '8.2rem',
};

Expand Down

0 comments on commit e8b0ee8

Please sign in to comment.