-
Notifications
You must be signed in to change notification settings - Fork 7
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
avinash-mane
wants to merge
32
commits into
master
Choose a base branch
from
feature/react/159/core-component-and-shared-component-for-recognition-listing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 76a0e76
add button core component
jitendrasbunde 7368046
add Label core component
jitendrasbunde c65501b
restructure of core component
jitendrasbunde 1a1b42f
add test case files of button and core components
jitendrasbunde bd33748
add video core component with test file
jitendrasbunde 0559dbc
update directory structure in src
jitendrasbunde 720da69
update the component path in core componet test files
jitendrasbunde 63e0cca
update button core component path in ButtonComponent test file
jitendrasbunde a8d97f3
resolved comment's on PR and add core-component for Row Col
jitendrasbunde 72b7c78
separate import module and third party module using add empty line
jitendrasbunde ed077ab
added profile shared component
avinash-mane 0b9d388
added text area core component
avinash-mane 86c23cf
added recognition text component
avinash-mane 205c866
added core value icon component
avinash-mane 8bc8d0b
changes in core value icon component
avinash-mane ba6ec59
added recognition text component
avinash-mane c0767c0
added recognition top bar component
avinash-mane 17d462a
added profile shared component
avinash-mane 096ca02
added recognition card component
avinash-mane 8b03dac
added recognition list component
avinash-mane b9e5616
create card core-component
avinash-mane 944053a
added test cases for comonent
avinash-mane 2383504
change props type of card component and added test case
avinash-mane fc5bfee
resolve comments and added icons core component
avinash-mane 9925ed3
write test case for all recognition component
avinash-mane f652b62
added snapshot
avinash-mane ff4b0e7
added mock response for recognition list test
avinash-mane 6bfaac2
remove extra div
avinash-mane e2fad1d
changed style for button component and update test cases
avinash-mane fc9c34f
changes in recognition list reponse
avinash-mane 96228eb
change mock response
avinash-mane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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" | ||
} | ||
} | ||
|
||
] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Card } from "react-bootstrap"; |
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 @@ | ||
export { BsCircle } from "react-icons/bs"; |
97 changes: 97 additions & 0 deletions
97
react-frontend/src/recognition-list-components/RecognitionCardComponent.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
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); |
19 changes: 19 additions & 0 deletions
19
react-frontend/src/recognition-list-components/RecognitionCardComponent.test.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
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(); | ||
}); | ||
}); |
64 changes: 64 additions & 0 deletions
64
react-frontend/src/recognition-list-components/RecognitionCardHeaderComponent.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
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); |
17 changes: 17 additions & 0 deletions
17
react-frontend/src/recognition-list-components/RecognitionCardHeaderComponent.test.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
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(); | ||
}); | ||
}); |
41 changes: 41 additions & 0 deletions
41
react-frontend/src/recognition-list-components/RecognitionListComponent.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
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, | ||
}; | ||
|
||
export default React.memo(RecognitionListComponent); |
16 changes: 16 additions & 0 deletions
16
react-frontend/src/recognition-list-components/RecognitionListComponent.test.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
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(); | ||
}); | ||
}); |
51 changes: 51 additions & 0 deletions
51
react-frontend/src/recognition-list-components/RecognitionTextComponent.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
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); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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