├── src ├── react-app-env.d.ts ├── index.tsx ├── index.css ├── Data │ └── languages.ts ├── App.tsx ├── App.css └── Components │ └── Dict.tsx ├── public ├── robots.txt ├── favicon.ico ├── logo192.png ├── logo512.png ├── manifest.json └── index.html ├── .gitignore ├── tsconfig.json ├── package.json └── README.md /src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProgrammingFire/word-hunt-react/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProgrammingFire/word-hunt-react/HEAD/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ProgrammingFire/word-hunt-react/HEAD/public/logo512.png -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import "./index.css"; 4 | import App from "./App"; 5 | 6 | ReactDOM.render( 7 | 8 | 9 | , 10 | document.getElementById("root") 11 | ); 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", 4 | "Droid Sans", "Helvetica Neue", sans-serif; 5 | -webkit-font-smoothing: antialiased; 6 | -moz-osx-font-smoothing: grayscale; 7 | background-color: #212121; 8 | color: white; 9 | } 10 | 11 | code { 12 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 13 | monospace; 14 | } 15 | -------------------------------------------------------------------------------- /src/Data/languages.ts: -------------------------------------------------------------------------------- 1 | export const languages = [ 2 | { label: "English", value: "en" }, 3 | { label: "Spanish", value: "es" }, 4 | { label: "French", value: "fr" }, 5 | { label: "Japanese", value: "ja" }, 6 | { label: "Russian", value: "ru" }, 7 | { label: "German", value: "de" }, 8 | { label: "Italian", value: "it" }, 9 | { label: "Korean", value: "ko" }, 10 | { label: "Brazilian Portuguese", value: "pt-BR" }, 11 | { label: "Arabic", value: "ar" }, 12 | { label: "Turkish", value: "tr" }, 13 | { label: "Hindi", value: "hi" }, 14 | ]; 15 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "strict": true, 14 | "forceConsistentCasingInFileNames": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react-jsx" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /src/App.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import "./App.css"; 3 | import Container from "@material-ui/core/Container"; 4 | import { Dict } from "./Components/Dict"; 5 | import { 6 | createTheme, 7 | ThemeProvider, 8 | ThemeProviderProps, 9 | } from "@material-ui/core/styles"; 10 | 11 | const darkTheme = createTheme({ 12 | palette: { 13 | type: "dark", 14 | }, 15 | }); 16 | 17 | function App() { 18 | return ( 19 |
20 | 21 | 22 | 23 | 24 | 25 |
26 | ); 27 | } 28 | 29 | export default App; 30 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "word-hunt", 3 | "homepage": "https://programmingfire.github.io/word-hunt-react", 4 | "version": "0.1.0", 5 | "private": true, 6 | "dependencies": { 7 | "@material-ui/core": "^4.12.3", 8 | "@material-ui/icons": "^4.11.2", 9 | "@testing-library/jest-dom": "^5.14.1", 10 | "@testing-library/react": "^11.2.7", 11 | "@testing-library/user-event": "^12.8.3", 12 | "@types/jest": "^26.0.24", 13 | "@types/node": "^12.20.19", 14 | "@types/react": "^17.0.18", 15 | "@types/react-dom": "^17.0.9", 16 | "axios": "^0.21.1", 17 | "gh-pages": "^3.2.3", 18 | "react": "^17.0.2", 19 | "react-dom": "^17.0.2", 20 | "react-scripts": "4.0.3", 21 | "typescript": "^4.3.5", 22 | "web-vitals": "^1.1.2" 23 | }, 24 | "scripts": { 25 | "predeploy": "npm run build", 26 | "deploy": "gh-pages -d build", 27 | "start": "react-scripts start", 28 | "build": "react-scripts build", 29 | "test": "react-scripts test", 30 | "eject": "react-scripts eject" 31 | }, 32 | "eslintConfig": { 33 | "extends": [ 34 | "react-app", 35 | "react-app/jest" 36 | ] 37 | }, 38 | "browserslist": { 39 | "production": [ 40 | ">0.2%", 41 | "not dead", 42 | "not op_mini all" 43 | ], 44 | "development": [ 45 | "last 1 chrome version", 46 | "last 1 firefox version", 47 | "last 1 safari version" 48 | ] 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 22 | 26 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Word Hunt 2 | Word Hunt Is A Dictionary App that uses React And [FreeDictionaryApi](https://dictionaryapi.dev) 3 | 4 | ## Available Scripts 5 | 6 | In the project directory, you can run: 7 | 8 | ### `npm start` 9 | 10 | Runs the app in the development mode.\ 11 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 12 | 13 | The page will reload if you make edits.\ 14 | You will also see any lint errors in the console. 15 | 16 | ### `npm test` 17 | 18 | Launches the test runner in the interactive watch mode.\ 19 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 20 | 21 | ### `npm run build` 22 | 23 | Builds the app for production to the `build` folder.\ 24 | It correctly bundles React in production mode and optimizes the build for the best performance. 25 | 26 | The build is minified and the filenames include the hashes.\ 27 | Your app is ready to be deployed! 28 | 29 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 30 | 31 | ### `npm run eject` 32 | 33 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 34 | 35 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 36 | 37 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 38 | 39 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 40 | 41 | ## Learn More 42 | 43 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 44 | 45 | To learn React, check out the [React documentation](https://reactjs.org/). 46 | -------------------------------------------------------------------------------- /src/Components/Dict.tsx: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect, useRef } from "react"; 2 | import axios, { AxiosResponse } from "axios"; 3 | import { languages } from "../Data/languages"; 4 | import { makeStyles, createTheme } from "@material-ui/core/styles"; 5 | import TextField from "@material-ui/core/TextField"; 6 | import MenuItem from "@material-ui/core/MenuItem"; 7 | import { List, ListItem, ListItemText } from "@material-ui/core"; 8 | import Divider from "@material-ui/core/Divider"; 9 | import Typography from "@material-ui/core/Typography"; 10 | 11 | const useStyles = makeStyles((theme) => ({ 12 | root: { 13 | "& .MuiTextField-root": { 14 | margin: theme.spacing(1), 15 | width: "25ch", 16 | }, 17 | }, 18 | })); 19 | 20 | export const Dict: React.FC = () => { 21 | const classes = useStyles(); 22 | 23 | const [meanings, setMeanings] = useState([]); 24 | const [word, setWord] = useState(""); 25 | const [lang, setLang] = useState("en"); 26 | 27 | const fetchData: Function = async () => { 28 | try { 29 | const data = await axios.get( 30 | `https://api.dictionaryapi.dev/api/v2/entries/${lang}/${word}` 31 | ); 32 | // if (data.status === 404) { 33 | // setMeanings(null); 34 | // } else { 35 | setMeanings(data.data); 36 | // } 37 | } catch (error) { 38 | console.error(error); 39 | } 40 | }; 41 | 42 | useEffect(() => { 43 | fetchData(); 44 | }, [word, lang]); 45 | 46 | return ( 47 |
48 | 49 | Word Hunt 50 | 51 | setWord(e.target.value)} 53 | id="word" 54 | placeholder="Type The Word" 55 | variant="outlined" 56 | /> 57 | setLang(e.target.value)} 63 | > 64 | {languages.map((language, index) => ( 65 | 66 | {language.label} 67 | 68 | ))} 69 | 70 | {meanings !== null && 71 | meanings.map((meaning: any | string) => ( 72 | <> 73 | 74 | {meaning.word} 75 | 76 | {meaning.meanings.map((wordMeanings: any | Object, index: any) => ( 77 | 78 | 79 | {wordMeanings.partOfSpeech} 80 | 81 | {wordMeanings.definitions.map( 82 | (wordDef: any | [], index: any) => ( 83 | <> 84 | 85 | {wordDef.definition} 86 | 87 | 88 | 89 | ) 90 | )} 91 | 92 | ))} 93 | 94 | ))} 95 |
96 | ); 97 | }; 98 | --------------------------------------------------------------------------------