Skip to content

Commit

Permalink
feat(myActivities): Add StatusIndicatorComponent
Browse files Browse the repository at this point in the history
 - add statusIndicator scss file
 - add colors representing the various statuses
 - make use of status indicator component in MyActivities and SocietyStats components
  • Loading branch information
Chris Maina committed Feb 22, 2019
1 parent 0f8f8d5 commit f2ba8ed
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/app/Dashboard/components/MyActivitiesComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import dateFns from 'date-fns';

import { TableComponent } from '../../common/components';
import { TableComponent, StatusIndicatorComponent } from '../../common/components';
import TruncateDescriptionComponent from './TruncateDescriptionComponent';

const MyActivitiesComponent = (props) => {
Expand Down Expand Up @@ -32,7 +32,7 @@ const MyActivitiesComponent = (props) => {
<TruncateDescriptionComponent description={description} wordCount={80} />
</td>
<td>{points}</td>
<td>{status}</td>
<td><StatusIndicatorComponent status={status} /></td>
</tr>
);
});
Expand Down
8 changes: 4 additions & 4 deletions src/app/Dashboard/components/SocietyStatsComponent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';

import { StatusIndicatorComponent } from '../../common/components';

import { societyStats } from '../constants';

const SocietyStatsComponent = (props) => {
Expand All @@ -27,11 +29,11 @@ const SocietyStatsComponent = (props) => {
</div>
<div className='society-stats__desc'>
<div className='society-stats__desc__points'>
<span className='society-stats__desc-indicator' id='blue-circle' />
<StatusIndicatorComponent className='society-stats--used-points-indicator' status='completed' />
<span className='society-stats__desc-text'> Used points</span>
</div>
<div className='society-stats__desc__points' id='society-stats__desc--remaining-points'>
<span className='society-stats__desc-indicator' id='green-circle' />
<StatusIndicatorComponent status='approved' />
<span className='society-stats__desc-text'> Total Remaining Points</span>
</div>
</div>
Expand All @@ -50,7 +52,6 @@ const SocietyStatsComponent = (props) => {
);
};


SocietyStatsComponent.defaultProps = {
society: societyStats.society,
usedPoints: societyStats.usedPoints,
Expand All @@ -63,5 +64,4 @@ SocietyStatsComponent.propTypes = {
remainingPoints: PropTypes.number,
};


export default SocietyStatsComponent;
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ describe('<MyActivitiesComponent />', () => {
shallowWrapper,
};
};
// const props = {
// userActivities: activities
// }

it('should have a TableComponent', () => {
const { shallowWrapper } = setUpWrapper();
Expand Down
10 changes: 3 additions & 7 deletions src/app/Dashboard/styles/societyStats.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
border-radius: 0;

#progress-bar--blue {
background-color: $checkmarkBlue!important;
background-color: $andelaBlue!important;
width: 60%;
}

#progress-bar--green {
background-color: $checkmarkGreen!important;
background-color: $approvedStatusGreen!important;
width: 40%;
}
}
Expand Down Expand Up @@ -56,14 +56,10 @@
font-size: rem(30px);
}

#blue-circle {
color: $checkmarkBlue;
.society-stats--used-points-indicator {
margin-left: rem(10px);
}

#green-circle {
color: $checkmarkGreen;
}

#used-points {
margin-left: rem(10px);
Expand Down
18 changes: 18 additions & 0 deletions src/app/common/components/StatusIndicatorComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import PropTypes from 'prop-types';

const StatusIndicatorComponent = ({ className, status }) => (
<span className={`indicator ${className} ${status.replace(/\s/g, '').toLowerCase()}`} />
);

StatusIndicatorComponent.defaultProps = {
status: '',
className: '',
};

StatusIndicatorComponent.propTypes = {
status: PropTypes.string,
className: PropTypes.string,
};

export default StatusIndicatorComponent;
1 change: 1 addition & 0 deletions src/app/common/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export { default as NavbarComponent } from './NavbarComponent';
export { default as ButtonComponent } from './ButtonComponent';
export { default as SidebarComponent } from './SidebarComponent';
export { default as NavItemComponent } from './NavItemComponent';
export { default as StatusIndicatorComponent } from './StatusIndicatorComponent';
11 changes: 11 additions & 0 deletions src/app/common/components/tests/StatusIndicatorComponent.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react';
import { shallow } from 'enzyme';
import StatusIndicatorComponent from '../StatusIndicatorComponent';

describe('<StatusIndicatorComponent />', () => {
const shallowWrapper = shallow(<StatusIndicatorComponent />);

it('should have span tag with class indicator', () => {
expect(shallowWrapper.find('.indicator')).toHaveLength(1);
});
});
1 change: 1 addition & 0 deletions src/app/common/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
@import './button.scss';
@import './sidebar.scss';
@import './table.scss';
@import './statusIndicator.scss';
24 changes: 24 additions & 0 deletions src/app/common/styles/statusIndicator.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.indicator:before {
content: ' \25CF';
font-size: rem(30px);
}

.completed {
color: $andelaBlue;
}

.approved {
color: $approvedStatusGreen;
}

.rejected {
color: $rejectedStatusRed;
}

.pending {
color: $andelaGold;
}

.inreview {
color: $inReviewStatusYellow;
}
2 changes: 1 addition & 1 deletion src/app/common/styles/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
&:first-child {
padding-left: rem(30px);
}
}
}
5 changes: 3 additions & 2 deletions src/styles/_vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ $lightGray: #9B9B9B;
$andelaBlue: #3359DF;
$andelaGold: #FFAF30;
$darkGray: #666666;
$checkmarkBlue: #3A84FF;
$checkmarkGreen: #7ED321;
$approvedStatusGreen: #7ED321;
$separatorBlue: #5DA5F3;
$footerTextGray: #ACACBF;
$darkBlue: #101444;
$darkerBlue: #000564;
$whiteShadow: rgba(255, 255, 255, 0.5);
$grayShadow: rgba(48,48,48,0.13);
$tableBodyTextColor: #51516B;
$rejectedStatusRed: #D0021B;
$inReviewStatusYellow: #F8E71C;

0 comments on commit f2ba8ed

Please sign in to comment.