Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Image Components #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added src/assets/images/test-image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 41 additions & 0 deletions src/components/image/Image/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react'
import styled, { css } from 'styled-components'
import PropTypes from 'prop-types'

import borderRadius from 'mixins/borderRadius'

function applyImageStyles ({ radius }) {
return css`
border-radius: ${radius};
`
}

const StyledImage = styled.img`
${applyImageStyles};
`

const Image = ({ src, alt, radius, width, height }) => (
<StyledImage
src={src}
alt={alt}
radius={radius}
height={height}
width={width}
/>
)

Image.defaultProps = {
radius: borderRadius.image,
height: 142,
width: 142,
}

Image.propTypes = {
src: PropTypes.string.isRequired,
alt: PropTypes.string,
width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
radius: PropTypes.string,
}

export default Image
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export { default as CoreStyle } from 'core'
export { default as Button } from 'components/button/Button'

export { default as FacebookButton } from 'components/button/FacebookButton'

export { default as Image } from 'components/image/Image'
3 changes: 3 additions & 0 deletions src/mixins/borderRadius/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
image: '16px',
}
8 changes: 8 additions & 0 deletions stories/Image/NormalImage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import Image from 'components/image/Image'

const testImage = require('assets/images/test-image.jpg')

const NormalImage = () => <Image src={testImage} />

export default NormalImage
6 changes: 6 additions & 0 deletions stories/Image/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import baseStory from 'stories/utils/baseStory'

baseStory('Image', module).addWithJSX(
'Normal Image',
require('./NormalImage').default,
)
1 change: 1 addition & 0 deletions stories/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require('./Typography')
require('./Color')
require('./Button')
require('./Image')
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {
use: 'babel-loader',
},
{
test: /\.(eot|svg|ttf|woff|woff2|otf)$/,
test: /\.(eot|svg|ttf|woff|woff2|otf|jpg|png)$/,
loader: 'file-loader',
},
],
Expand Down