Skip to content

Commit

Permalink
Adding the emptycard component
Browse files Browse the repository at this point in the history
  • Loading branch information
javpet committed Nov 15, 2019
1 parent e215c7c commit 154933a
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/components/Shared/EmptyCard/EmptyCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'
import PropTypes from 'prop-types'

const EmptyCard = props => {
return (
<div className="empty-card">
<h4 className="card-message">
Uh, oh it seems there is not much to show here.
</h4>
<button>Add {props.itemName}</button>
</div>
)
}

EmptyCard.propTypes = {
itemName: PropTypes.string.isRequired
}

export default EmptyCard
20 changes: 20 additions & 0 deletions src/components/Shared/EmptyCard/EmptyCard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.empty-card {
width: 100%;
padding: $padding-s;
color: $primary-color-white;
text-align: center;
background-color: $primary-color-darkblue-lighter;
margin-bottom: $margin-r;
border: 2px dashed rgba($primary-color-white, 0.6);
display: flex;
flex-direction: column;
justify-content: space-between;
min-height: 300px;
}

@media only screen and (min-width: 576px) {
.empty-card {
width: 48%;
max-width: 400px;
}
}
30 changes: 30 additions & 0 deletions src/components/Shared/EmptyCard/EmptyCard.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react'
import EmptyCard from './EmptyCard'

import { shallow } from 'enzyme'

describe('<EmptyCard />', () => {
let emptyCardWrapper

let props = {
itemName: 'Artist'
}

beforeEach(() => {
emptyCardWrapper = shallow(<EmptyCard {...props} />)
})

it('contains a headline that raise awareness of missing information', () => {
expect(emptyCardWrapper.find('h4.card-message').text()).toEqual(
'Uh, oh it seems there is not much to show here.'
)
})

it('contains the button which enables to create one item', () => {
expect(emptyCardWrapper.find('button').length).toEqual(1)
})

it('contains the button with the label of the missing item', () => {
expect(emptyCardWrapper.find('button').text()).toEqual('Add Artist')
})
})
1 change: 1 addition & 0 deletions src/containers/Artists/ExploreArtists/ExploreArtists.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react'
import ArtistCard from '../../../components/Artists/ArtistCard/ArtistCard'
import Paginate from '../../../components/Paginate/Paginate'

class ExploreArtists extends Component {
render() {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react'
import { NavLink } from 'react-router-dom'
import CauseCard from '../../../components/Causes/CauseCard/CauseCard'
import EmptyCard from '../../../components/Shared/EmptyCard/EmptyCard'

class CampaignsEndingSoon extends Component {
render() {
Expand All @@ -24,6 +25,7 @@ class CampaignsEndingSoon extends Component {
daysToGo={45}
organization="UNICEF"
/>
<EmptyCard itemName="Cause" />
</div>
<NavLink activeClassName="nav__item--selected" to="/causes?q=ending">
See all ending causes
Expand Down
1 change: 1 addition & 0 deletions src/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
@import "components/Shared/Banner/Banner.scss";
@import "components/Shared/Loader/Loader.scss";
@import "components/Shared/Alert/Alert.scss";
@import "components/Shared/EmptyCard/EmptyCard.scss";
@import "containers/Cause/SupportingArtists/SupportingArtists.scss";
@import "containers/Cause/RelatedCauses/RelatedCauses.scss";
@import "containers/Cause/RecentDonors/RecentDonors.scss";
Expand Down

0 comments on commit 154933a

Please sign in to comment.