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

component for recognition listing #163

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
77f495d
add button core component
jitendrasbunde May 19, 2020
76a0e76
add button core component
jitendrasbunde May 19, 2020
7368046
add Label core component
jitendrasbunde May 19, 2020
c65501b
restructure of core component
jitendrasbunde May 19, 2020
1a1b42f
add test case files of button and core components
jitendrasbunde May 19, 2020
bd33748
add video core component with test file
jitendrasbunde May 19, 2020
0559dbc
update directory structure in src
jitendrasbunde May 20, 2020
720da69
update the component path in core componet test files
jitendrasbunde May 20, 2020
63e0cca
update button core component path in ButtonComponent test file
jitendrasbunde May 20, 2020
a8d97f3
resolved comment's on PR and add core-component for Row Col
jitendrasbunde May 25, 2020
72b7c78
separate import module and third party module using add empty line
jitendrasbunde May 25, 2020
ed077ab
added profile shared component
avinash-mane May 25, 2020
0b9d388
added text area core component
avinash-mane May 25, 2020
86c23cf
added recognition text component
avinash-mane May 26, 2020
205c866
added core value icon component
avinash-mane May 26, 2020
8bc8d0b
changes in core value icon component
avinash-mane May 26, 2020
ba6ec59
added recognition text component
avinash-mane May 27, 2020
c0767c0
added recognition top bar component
avinash-mane May 27, 2020
17d462a
added profile shared component
avinash-mane May 27, 2020
096ca02
added recognition card component
avinash-mane May 28, 2020
8b03dac
added recognition list component
avinash-mane May 29, 2020
b9e5616
create card core-component
avinash-mane May 29, 2020
944053a
added test cases for comonent
avinash-mane Jun 2, 2020
2383504
change props type of card component and added test case
avinash-mane Jun 2, 2020
fc5bfee
resolve comments and added icons core component
avinash-mane Jun 2, 2020
9925ed3
write test case for all recognition component
avinash-mane Jun 9, 2020
f652b62
added snapshot
avinash-mane Jun 9, 2020
ff4b0e7
added mock response for recognition list test
avinash-mane Jun 10, 2020
6bfaac2
remove extra div
avinash-mane Jun 11, 2020
e2fad1d
changed style for button component and update test cases
avinash-mane Jun 11, 2020
fc9c34f
changes in recognition list reponse
avinash-mane Jun 17, 2020
96228eb
change mock response
avinash-mane Jun 17, 2020
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
53 changes: 53 additions & 0 deletions mock-responses/recognition-listning/recognitionList.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"recognitionList":[
{
"id":1,
"text":
"i give high five to avinash for writing block on react strap document",
"given_for_user": {
"id": 1,
"first_name": "avinash",
"last_name": "mane",
"profile_image_url":"https://i.picsum.photos/id/2/200/200.jpg"
},
"given_by_user": {
"id": 2,
"first_name": "onkar",
"last_name": "hasabe",
"profile_image_url": "https://i.picsum.photos/id/2/200/200.jpg"
},
"given_at": 1234567890,
"coreValue": {
"id": 3,
"text": "core value text",
"description": "desc",
"thumbnail": "https://i.picsum.photos/id/654/300/200.jpg"
}
},

{
"id":1,
"text":"give high five to avinash writing block on react strap document",
"given_for_user": {
"id": 1,
"first_name": "avinash",
"last_name": "mane",
"profile_image_url":"https://i.picsum.photos/id/2/200/200.jpg"
},
"given_by_user": {
"id": 2,
"first_name": "onkar",
"last_name": "hasabe",
"profile_image_url": "https://i.picsum.photos/id/2/200/200.jpg"
},
"given_at": 1234567890,
"coreValue": {
"id": 3,
"text": "core value text",
"description": "desc",
"thumbnail_url": "https://i.picsum.photos/id/654/300/200.jpg"
}
}

]
}
8 changes: 8 additions & 0 deletions react-frontend/package-lock.json

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

1 change: 1 addition & 0 deletions react-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"react": "^16.13.1",
"react-bootstrap": "^1.0.0",
"react-dom": "^16.13.1",
"react-icons": "^3.10.0",
"react-redux": "^7.2.0",
"react-router-dom": "^5.1.2",
"react-scripts": "3.4.1",
Expand Down
1 change: 1 addition & 0 deletions react-frontend/src/core-components/card/CardComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Card } from "react-bootstrap";
1 change: 1 addition & 0 deletions react-frontend/src/core-components/icon/icons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { BsCircle } from "react-icons/bs";
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import React from "react";
import PropTypes from "prop-types";
import styled from "styled-components";

import { Row, Col } from "core-components/grid/GridComponent";
import { Card } from "core-components/card/CardComponent";
import { BsCircle } from "core-components/icon/icons";
import ImageComponent from "core-components/image/ImageComponent";
import RecognitionCardHeaderComponent from "recognition-list-components/RecognitionCardHeaderComponent";
import RecognitionTextComponent from "recognition-list-components/RecognitionTextComponent";
import HighFiveComponent from "shared-components/high-five-components/HighFiveComponent";

const CoreValueImage = styled(ImageComponent)`
border-radius: 20px;
overflow: hidden;
`;

const HighFive = styled(HighFiveComponent)`
position: absolute;
bottom: 50px;
`;

const CardComponent = styled(Card)`
border-radius: 20px;
margin: 20px 20px;
box-shadow: 0px 5px 20px var(--box-shadow-color);
opacity: 1;
background: var(--white) 0% 0% no-repeat padding-box;
`;

const RecognitionCardComponent = ({
givenByName,
givenByImage,
givenForName,
givenForImage,
givenAt,
text,
coreValue,
coreValueImage,
}) => (
<CardComponent>
<Card.Body>
<Row>
<Col sm="12" md="7">
<RecognitionCardHeaderComponent
givenAt={givenAt}
givenForName={givenForName}
coreValue={coreValue}
givenForImage={givenForImage}
/>
<CoreValueImage
src={coreValueImage}
alt="Core value"
className="d-sm-block d-xs-block d-md-none mt-2"
/>
<RecognitionTextComponent
givenByImage={givenByImage}
givenByName={givenByName}
text={text}
/>
</Col>
<Col className="d-none d-md-block text-center">
<div>
<CoreValueImage
src={coreValueImage}
alt="Core value"
className="mt-2"
/>
</div>
<BsCircle size="50px" className="mt-4" color="red" />
</Col>
</Row>
<HighFive />
<Card.Footer className="bg-white">
<span className="font-weight-bold text-muted">+</span>
<span className="font-weight-bold text-dark">1</span>
</Card.Footer>
</Card.Body>
</CardComponent>
);

RecognitionCardComponent.propTypes = {
givenByName: PropTypes.string.isRequired,
givenByImage: PropTypes.string,
givenForName: PropTypes.string.isRequired,
givenForImage: PropTypes.string,
givenAt: PropTypes.string.isRequired,
text: PropTypes.string.isRequired,
coreValue: PropTypes.string.isRequired,
coreValueImage: PropTypes.string,
};

RecognitionCardComponent.defaultProps = {
coreValueImage: "https://i.picsum.photos/id/654/300/200.jpg",
};

export default React.memo(RecognitionCardComponent);
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import { render } from "@testing-library/react";

import RecognitionCardComponent from "recognition-list-components/RecognitionCardComponent";

describe("Recognition Card Component test", () => {
test("should equal snapshot", () => {
const { asFragment } = render(
<RecognitionCardComponent
givenByName="Roy"
givenForName="David"
givenAt="Today 10:30 AM"
coreValue="positive"
text="give high five for good work"
/>
);
expect(asFragment()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import React from "react";
import PropTypes from "prop-types";
import styled from "styled-components";

import { Form } from "core-components/form/FormComponent";
import { Button } from "core-components/button/ButtonComponent";
import ImageComponent from "core-components/image/ImageComponent";

const ProfileImage = styled.div`
width: 12vh;
`;

const MenuButton = styled(Button)`
color: var(--black);
background-color: var(--white);
font-weight: bold;
border: none;
`;

const RecognitionCardHeaderComponent = ({
givenAt,
givenForName,
givenForImage,
coreValue,
}) => {
return (
<div>
<div className="d-flex justify-content-end">
<MenuButton>...</MenuButton>
</div>
<div className="d-flex flex-row">
<ProfileImage>
<ImageComponent
src={givenForImage}
roundedCircle={true}
alt="Profile"
/>
</ProfileImage>
<div className="text-start ml-2">
<Form.Label className="font-weight-bold ">{givenForName}</Form.Label>
<div>
<Form.Label> got a high five for</Form.Label>
<Form.Label className="ml-1 font-weight-bold">
{coreValue}
</Form.Label>
</div>
<Form.Label className="text-muted">{givenAt}</Form.Label>
</div>
</div>
</div>
);
};
RecognitionCardHeaderComponent.propTypes = {
givenForName: PropTypes.string.isRequired,
givenForImage: PropTypes.string,
givenAt: PropTypes.string.isRequired,
coreValue: PropTypes.string.isRequired,
};

RecognitionCardHeaderComponent.defaultProps = {
givenForImage: "https://i.picsum.photos/id/2/200/200.jpg",
};

export default React.memo(RecognitionCardHeaderComponent);
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react";
import { render } from "@testing-library/react";

import RecognitionCardHeaderComponent from "recognition-list-components/RecognitionCardHeaderComponent";

describe("Recognition card header Component test", () => {
test("should equal snapshot", () => {
const { asFragment } = render(
<RecognitionCardHeaderComponent
givenForName="Roy"
coreValue="positive"
givenAt="Today 10:30 AM"
/>
);
expect(asFragment()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from "react";
import PropTypes from "prop-types";
import styled from "styled-components";

import RecognitionCardComponent from "recognition-list-components/RecognitionCardComponent";

const Wrapper = styled.div`
border: 1px solid var(--grey);
background: var(--white) 0% 0% no-repeat padding-box;
border-radius: 36px;
opacity: 1;
`;

const RecognitionListComponent = ({ recognitionList }) => {
const getDateFormate = (timestamp) =>
new Date(timestamp * 1000).toDateString();

return (
<Wrapper>
{recognitionList.map((recognition, index) => (
<RecognitionCardComponent
key={index}
givenByName={`${recognition.given_by_user.first_name} ${recognition.given_by_user.last_name}`}
givenByImage={recognition.given_by_user.profile_image_url}
givenForName={`${recognition.given_for_user.first_name} ${recognition.given_for_user.last_name}`}
givenForImage={recognition.given_for_user.profile_image_url}
givenAt={getDateFormate(recognition.given_at)}
text={recognition.text}
coreValue={recognition.coreValue.text}
coreValueImage={recognition.coreValue.thumbnail_url}
/>
))}
</Wrapper>
);
};

RecognitionListComponent.propTypes = {
recognitionList: PropTypes.array.isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the inconsistent naming convention? some places you have maintained kebab case for props/variables and some places camelCase? use camelCase always for props/variables

cc: @sahilbhatia

};

export default React.memo(RecognitionListComponent);
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from "react";
import { render } from "@testing-library/react";

import RecognitionListComponent from "recognition-list-components/RecognitionListComponent";
import recognitionList from "../../../mock-responses/recognition-listning/recognitionList.json";

describe("Recognition list Component test", () => {
test("should equal snapshot", () => {
const { asFragment } = render(
<RecognitionListComponent
recognitionList={recognitionList.recognitionList}
/>
);
expect(asFragment()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import React from "react";
import PropTypes from "prop-types";
import styled from "styled-components";

import { Form } from "core-components/form/FormComponent";
import ImageComponent from "core-components/image/ImageComponent";

const Border = styled.fieldset`
border: 1px solid var(--grey);
border-radius: 11px;
opacity: 1;
margin-left: 5%;
margin-right: 5%;
`;

const Legend = styled.legend`
width: auto;
margin-left: 10%;
`;

const ProfileImage = styled(ImageComponent)`
width: 7vh;
margin-right: 5%;
`;

const RecognitionTextComponent = ({ text, givenByName, givenByImage }) => (
<div>
<Border>
<Legend>“</Legend>
<Form.Label className="px-2 pb-2 pt-0">{text}</Form.Label>
</Border>
<div className="d-flex justify-content-end w-100">
<Form.Label className="font-weight-bold text-dark">
{givenByName}
</Form.Label>
<ProfileImage src={givenByImage} roundedCircle={true} alt="Profile" />
</div>
</div>
);

RecognitionTextComponent.propTypes = {
text: PropTypes.string.isRequired,
givenByName: PropTypes.string.isRequired,
givenByImage: PropTypes.string,
};

RecognitionTextComponent.defaultProps = {
givenByImage: "https://i.picsum.photos/id/2/200/200.jpg",
};

export default React.memo(RecognitionTextComponent);
Loading