Skip to content

Commit

Permalink
Assignment Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Kotagiri Yaswanth Sai committed Jun 21, 2024
0 parents commit 67f4541
Show file tree
Hide file tree
Showing 32 changed files with 16,071 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
coverage
build
60 changes: 60 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"env": {
"browser": true,
"es2021": true
},
"parser": "babel-eslint",
"extends": ["react-app", "airbnb", "prettier"],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": ["prettier"],
"overrides": [
{
"files": ["styledComponents.js"],
"rules": {
"import/prefer-default-export": "off"
}
}
],
"rules": {
"prettier/prettier": "error",
"react/jsx-filename-extension": [1, {"extensions": [".js", ".jsx"]}],
"react/state-in-constructor": "off",
"react/react-in-jsx-scope": "off",
"react/jsx-uses-react": "off",
"no-console": "off",
"react/prop-types": "off",
"jsx-a11y/label-has-associated-control": [
2,
{
"labelAttributes": ["htmlFor"]
}
],
"jsx-a11y/click-events-have-key-events": 0,
"jsx-a11y/no-noninteractive-element-interactions": [
"off",
{
"handlers": ["onClick"]
}
],
"react/prefer-stateless-function": [
0,
{
"ignorePureComponents": true
}
],
"no-unused-vars": "warn",
"jsx-a11y/alt-text": 1,
"react/no-unused-state": "warn",
"react/button-has-type": "warn",
"react/no-unescaped-entities": "warn",
"react/jsx-props-no-spreading": "off",
"operator-assignment": ["warn", "always"],
"radix": "off"
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

.idea/
.eslintcache
.vscode/
.results
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
registry=https://registry.npmjs.org/
package-lock=true
save-exact=true
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
coverage
build
26 changes: 26 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"arrowParens": "avoid",
"bracketSpacing": false,
"endOfLine": "lf",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"overrides": [
{
"files": "*.md",
"options": {
"printWidth": 1000
}
}
],
"proseWrap": "always",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": false
}
127 changes: 127 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
In this project, let's build a **Match Game** by applying the concepts we have learned till now.

### Refer to the video below:

<br/>
<div style="text-align: center;">
<video style="max-width:80%;box-shadow:0 2.8px 2.2px rgba(0, 0, 0, 0.12);outline:none;" loop="true" autoplay="autoplay" controls="controls" muted>
<source src="https://assets.ccbp.in/frontend/content/react-js/match-game-output.mp4" type="video/mp4">
</video>
</div>
<br/>

### Design Files

<details>
<summary>Click to view</summary>

- [Extra Small (Size < 576px) and Small (Size >= 576px)](https://assets.ccbp.in/frontend/content/react-js/match-game-sm-outputs.png)
- [Medium (Size >= 768px), Large (Size >= 992px) and Extra Large (Size >= 1200px) - Match Game](https://assets.ccbp.in/frontend/content/react-js/match-game-lg-output.png)
- [Medium (Size >= 768px), Large (Size >= 992px) and Extra Large (Size >= 1200px) - Scorecard](https://assets.ccbp.in/frontend/content/react-js/match-game-score-card-lg-output.png)

</details>

### Set Up Instructions

<details>
<summary>Click to view</summary>

- Download dependencies by running `npm install`
- Start up the app using `npm start`
</details>

### Completion Instructions

<details>
<summary>Functionality to be added</summary>
<br/>

The app must have the following functionalities

- Initially,
- Score should be `0` and time should be `60` sec
- The image to be matched should have the src attribute value as the value of the key `imageUrl` from the first object in **imagesList** provided
- The **Fruits** tab should be active and the thumbnails with **FRUIT** as their category should be displayed
- The timer should start running backwards from the `60` sec
- When a tab is clicked, then the thumbnails in the corresponding category should be displayed
- When a thumbnail is clicked, if that is matched with the image to be matched,
- Score is incremented by one
- The new image to be matched should be generated randomly among the value of the key `imageUrl` from **imagesList** provided
- When a thumbnail is clicked, if it is not matched with the image to be matched,
- The game should end, and the [Scorecard](https://assets.ccbp.in/frontend/content/react-js/match-game-score-card-lg-output.png) view should be displayed
- When **PLAY AGAIN** button is clicked, then we should be able to play the game again
- The score and time values should be reset to `0` and `60` sec respectively
- The image to be matched should reset to the value of the key `imageUrl` from the first object in **imagesList** provided
- The active tab should reset to **Fruits**, and the thumbnails with **FRUIT** as their category should be displayed
- When the timer reached `0` sec, then the game should end, and the [Scorecard](https://assets.ccbp.in/frontend/content/react-js/match-game-score-card-lg-output.png) view should be displayed
- The App is provided with `tabsList`. It consists of a list of tabItem objects with the following properties in each tabItem object

| Key | Data Type |
| :---------: | :-------: |
| tabId | String |
| displayText | String |

- The App is provided with `imagesList`. It consists of a list of imageItem objects with the following properties in each imageItem object

| Key | Data Type |
| :----------: | :-------: |
| id | String |
| imageUrl | String |
| thumbnailUrl | String |
| category | String |

</details>

### Important Note

<details>
<summary>Click to view</summary>

<br/>

**The following instructions are required for the tests to pass**

- The image to be matched in the app should have the alt as **match**
- The thumbnail images in the app should have the alt as **thumbnail**

</details>

### Resources

<details>
<summary>Image URLs</summary>

- [https://assets.ccbp.in/frontend/react-js/match-game-bg.png](https://assets.ccbp.in/frontend/react-js/match-game-bg.png)
- [https://assets.ccbp.in/frontend/react-js/match-game-score-card-lg-bg.png](https://assets.ccbp.in/frontend/react-js/match-game-score-card-lg-bg.png)
- [https://assets.ccbp.in/frontend/react-js/match-game-score-card-sm-bg.png](https://assets.ccbp.in/frontend/react-js/match-game-score-card-sm-bg.png)
- [https://assets.ccbp.in/frontend/react-js/match-game-website-logo.png](https://assets.ccbp.in/frontend/react-js/match-game-website-logo.png) alt should be **website logo**
- [https://assets.ccbp.in/frontend/react-js/match-game-timer-img.png](https://assets.ccbp.in/frontend/react-js/match-game-timer-img.png) alt should be **timer**
- [https://assets.ccbp.in/frontend/react-js/match-game-play-again-img.png](https://assets.ccbp.in/frontend/react-js/match-game-play-again-img.png) alt should be **reset**
- [https://assets.ccbp.in/frontend/react-js/match-game-trophy.png](https://assets.ccbp.in/frontend/react-js/match-game-trophy.png) alt should be **trophy**

</details>

<details>
<summary>Colors</summary>

<br/>

<div style="background-color:#2c0e3a; width: 150px; padding: 10px; color: white">Hex: #2c0e3a</div>
<div style="background-color:#ffffff; width: 150px; padding: 10px; color: black">Hex: #ffffff</div>
<div style="background-color:#fec653; width: 150px; padding: 10px; color: black">Hex: #fec653</div>
<div style="background-color:#cf60c8; width: 150px; padding: 10px; color: black">Hex: #cf60c8</div>
</details>

<details>
<summary>Font-families</summary>

- Roboto

</details>

> ### _Things to Keep in Mind_
>
> - All components you implement should go in the `src/components` directory.
> - Don't change the component folder names as those are the files being imported into the tests.
> - **Do not remove the pre-filled code**
> - Want to quickly review some of the concepts you’ve been learning? Take a look at the Cheat Sheets.
67 changes: 67 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "match-game",
"private": true,
"version": "1.0.0",
"engines": {
"node": "^10.13 || 12 || 14 || 15",
"npm": ">=6"
},
"dependencies": {
"@testing-library/jest-dom": "5.11.9",
"@testing-library/react": "11.2.5",
"@testing-library/user-event": "12.6.2",
"chalk": "4.1.0",
"react": "17.0.1",
"react-dom": "17.0.1"
},
"devDependencies": {
"eslint-config-airbnb": "18.2.1",
"eslint-config-prettier": "8.1.0",
"eslint-plugin-prettier": "3.3.1",
"husky": "4.3.8",
"lint-staged": "10.5.4",
"npm-run-all": "4.1.5",
"prettier": "2.2.1",
"react-scripts": "4.0.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"lint": "eslint .",
"lint:fix": "eslint --fix src/",
"format": "prettier --write \"./src\"",
"run-all": "npm-run-all --parallel test lint:fix"
},
"lint-staged": {
"*.js": [
"npm run lint:fix"
],
"*.{js, jsx, json, html, css}": [
"npm run format"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"jest": {
"collectCoverageFrom": [
"src/**/*.js"
]
},
"browserslist": {
"development": [
"last 2 chrome versions",
"last 2 firefox versions",
"last 2 edge versions"
],
"production": [
">1%",
"last 4 versions",
"Firefox ESR",
"not ie < 11"
]
}
}
Loading

0 comments on commit 67f4541

Please sign in to comment.