-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(article-card):article card component
To install prop-types To create an article card component [#167623915]
- Loading branch information
1 parent
690e95d
commit 672a766
Showing
13 changed files
with
203 additions
and
17 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -7,4 +7,4 @@ module.exports = { | |
moduleNameMapper: { | ||
'\\.scss$': require.resolve('./src/testUtils/styleMocks.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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,77 @@ | ||
@import '../../styles/partials/variables.scss'; | ||
|
||
.articleCard { | ||
width: 322px; | ||
border-radius: 10px; | ||
box-shadow: 0px 0px 26px rgba(0, 0, 0, 0.3); | ||
|
||
.card-img-top { | ||
width: 320px; | ||
height: 182px; | ||
border-radius: 4px 4px 0px 0px; | ||
} | ||
|
||
.card-body { | ||
padding: 10px 0px 0px 0px; | ||
border-radius: 0px 0px 4px 4px; | ||
} | ||
|
||
.card-body h5 { | ||
font-size: 18px; | ||
text-align: left; | ||
margin-bottom: 15px; | ||
margin-left: 7px; | ||
line-height: 112.4%; | ||
} | ||
|
||
.avatar { | ||
width: 76%; | ||
} | ||
.avatarImage { | ||
width: 36px; | ||
height: 36px; | ||
margin: 0px 5px; | ||
border-radius: 50%; | ||
box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.42); | ||
} | ||
|
||
.flex { | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
|
||
.avatar p { | ||
font-size: 10px; | ||
margin-top: 7px; | ||
line-height: 12px; | ||
} | ||
|
||
.avatar p small { | ||
font-weight: 300; | ||
font-size: 6px; | ||
line-height: 7px; | ||
} | ||
|
||
.mins-read small { | ||
padding: 7px; | ||
font-family: $secondary-font; | ||
font-size: 7px; | ||
line-height: 8px; | ||
margin-top: 4px; | ||
} | ||
} | ||
|
||
.dark-theme { | ||
color: white; | ||
background: rgba(22, 22, 22, 0.89); | ||
} | ||
|
||
.light-theme { | ||
color: #000000; | ||
.avatar img { | ||
box-shadow: inset 0 0 0 3px rgba(212, 210, 210, 0.1); | ||
} | ||
.avatar small { | ||
color: rgba(68, 68, 70, 0.81); | ||
} | ||
} |
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,58 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import './ArticleCard.scss'; | ||
|
||
// how to make use of the image tag | ||
{ | ||
/* <img src={'../../src/assets/images/react.png'} className="float-left avatarImage" alt="author" /> */ | ||
} | ||
|
||
const articleCard = props => { | ||
console.log(12, props); | ||
let cardBodyClass = ['card-body', 'dark-theme']; | ||
|
||
if (props.light) { | ||
cardBodyClass.pop(); | ||
cardBodyClass.push('light-theme'); | ||
} | ||
return ( | ||
<div className="card articleCard"> | ||
<img className="card-img-top" src={props.articleImage} alt="article" /> | ||
<div className={cardBodyClass.join(' ')}> | ||
<h5 className="card-title">{props.articleTitle}</h5> | ||
<p className="card-text flex"> | ||
<div className="avatar"> | ||
<img | ||
src={props.authorImage} | ||
className="float-left avatarImage" | ||
alt="author" | ||
/> | ||
|
||
<p> | ||
{props.author} | ||
<br /> | ||
<small>{props.email}</small> | ||
</p> | ||
</div> | ||
|
||
<div className="flex mins-read"> | ||
<small>{props.readTime} read</small> | ||
<small>ade</small> | ||
</div> | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
articleCard.propTypes = { | ||
articleImage: PropTypes.any, | ||
light: PropTypes.bool, | ||
articleTitle: PropTypes.any, | ||
authorImage: PropTypes.any, | ||
author: PropTypes.string, | ||
email: PropTypes.any, | ||
readTime: PropTypes.any | ||
}; | ||
|
||
export default articleCard; |
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,24 @@ | ||
import React from 'react'; | ||
import { shallow, configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import ArticleCard from './index'; | ||
|
||
|
||
configure({ adapter: new Adapter() }); | ||
|
||
describe('<ArticleCard />', () => { | ||
const props = { | ||
light: true | ||
}; | ||
|
||
const prop = { | ||
light: false, | ||
}; | ||
it('should render light theme ArticleCard', () => { | ||
shallow(<ArticleCard {...props} />); | ||
}); | ||
|
||
it('should render dark theme ArticleCard', () => { | ||
shallow(<ArticleCard {...prop} />); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
.cardDetails { | ||
background-color: pink; | ||
width: 100px; | ||
@import '../partials/variables.scss'; | ||
h1, h2, h3, h4, h5 { | ||
font-family: $primary-font; | ||
font-style: normal; | ||
font-weight: normal; | ||
} |
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
$color-sassy: #cc4397; | ||
$color-blue: #0059ff; | ||
|
||
$primary-font: 'Poppins', sans-serif; | ||
$secondary-font: 'Roboto', sans-serif; |
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 |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import React from 'react'; | ||
|
||
const landingPage = () => ( | ||
<div> | ||
<div className="App"> | ||
<h1>Team Persephone - Author's Haven</h1> | ||
<div className="perse-phone">Team Perse-phone is the Best!!!</div> | ||
import ArticleCard from '../../components/ArticleCard'; | ||
|
||
const landingPage = () => { | ||
const articleDetails = { | ||
articleImage: '../../src/assets/images/profileImage.jpg', | ||
light: false, | ||
articleTitle: 'Understanding React and redux', | ||
authorImage: '../../src/assets/images/react.png', | ||
author: 'Damilola Adekoya', | ||
email: 'damilola.adekoya@andela.com', | ||
readTime: '6 mins' | ||
}; | ||
return ( | ||
<div> | ||
<div className="App"> | ||
<h1>Team Persephone - Author's Haven</h1> | ||
<div className="perse-phone">Team Perse-phone is the Best!!!</div> | ||
</div> | ||
<h1>This is a demo Landing tunde page</h1> | ||
<ArticleCard {...articleDetails} /> | ||
</div> | ||
<h1>This is a demo Landing tunde page</h1> | ||
</div> | ||
); | ||
); | ||
}; | ||
|
||
export default landingPage; |