├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── codeql-analysis.yml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── NOTICE ├── README.md ├── SECURITY.md ├── package-lock.json ├── package.json ├── public ├── favicon.ico └── index.html └── src ├── App.js ├── NavButtons.js ├── Query.js ├── RepoInfo.js ├── SearchBox.js ├── custom.scss └── index.js /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Codeowners for these exercise files: 2 | # * (asterisk) deotes "all files and folders" 3 | @dewanahartley @planetoftheweb 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | ## Issue Overview 9 | 10 | 11 | ## Describe your environment 12 | 13 | 14 | ## Steps to Reproduce 15 | 16 | 1. 17 | 2. 18 | 3. 19 | 4. 20 | 21 | ## Expected Behavior 22 | 23 | 24 | ## Current Behavior 25 | 26 | 27 | ## Possible Solution 28 | 29 | 30 | ## Screenshots / Video 31 | 32 | 33 | ## Related Issues 34 | 35 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ main ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ main ] 20 | schedule: 21 | - cron: '27 0 * * 1' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | 28 | strategy: 29 | fail-fast: false 30 | matrix: 31 | language: [ 'javascript' ] 32 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 33 | # Learn more: 34 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 35 | 36 | steps: 37 | - name: Checkout repository 38 | uses: actions/checkout@v2 39 | 40 | # Initializes the CodeQL tools for scanning. 41 | - name: Initialize CodeQL 42 | uses: github/codeql-action/init@v1 43 | with: 44 | languages: ${{ matrix.language }} 45 | # If you wish to specify custom queries, you can do so here or in a config file. 46 | # By default, queries listed here will override any specified in a config file. 47 | # Prefix the list here with "+" to use these queries and those in the config file. 48 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 49 | 50 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 51 | # If this step fails, then you should remove it and run the build manually (see below) 52 | - name: Autobuild 53 | uses: github/codeql-action/autobuild@v1 54 | 55 | # ℹ️ Command-line programs to run using the OS shell. 56 | # 📚 https://git.io/JvXDl 57 | 58 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 59 | # and modify them (or add more) to build your code if your project 60 | # uses a compiled language 61 | 62 | #- run: | 63 | # make bootstrap 64 | # make release 65 | 66 | - name: Perform CodeQL Analysis 67 | uses: github/codeql-action/analyze@v1 68 | -------------------------------------------------------------------------------- /.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/db.js 25 | .eslintcache 26 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | Contribution Agreement 3 | ====================== 4 | 5 | This repository does not accept pull requests (PRs). All pull requests will be closed. 6 | 7 | However, if any contributions (through pull requests, issues, feedback or otherwise) are provided, as a contributor, you represent that the code you submit is your original work or that of your employer (in which case you represent you have the right to bind your employer). By submitting code (or otherwise providing feedback), you (and, if applicable, your employer) are licensing the submitted code (and/or feedback) to LinkedIn and the open source community subject to the BSD 2-Clause license. 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | LinkedIn Learning Exercise Files License Agreement 2 | ================================================== 3 | 4 | This License Agreement (the "Agreement") is a binding legal agreement 5 | between you (as an individual or entity, as applicable) and LinkedIn 6 | Corporation (“LinkedIn”). By downloading or using the LinkedIn Learning 7 | exercise files in this repository (“Licensed Materials”), you agree to 8 | be bound by the terms of this Agreement. If you do not agree to these 9 | terms, do not download or use the Licensed Materials. 10 | 11 | 1. License. 12 | - a. Subject to the terms of this Agreement, LinkedIn hereby grants LinkedIn 13 | members during their LinkedIn Learning subscription a non-exclusive, 14 | non-transferable copyright license, for internal use only, to 1) make a 15 | reasonable number of copies of the Licensed Materials, and 2) make 16 | derivative works of the Licensed Materials for the sole purpose of 17 | practicing skills taught in LinkedIn Learning courses. 18 | - b. Distribution. Unless otherwise noted in the Licensed Materials, subject 19 | to the terms of this Agreement, LinkedIn hereby grants LinkedIn members 20 | with a LinkedIn Learning subscription a non-exclusive, non-transferable 21 | copyright license to distribute the Licensed Materials, except the 22 | Licensed Materials may not be included in any product or service (or 23 | otherwise used) to instruct or educate others. 24 | 25 | 2. Restrictions and Intellectual Property. 26 | - a. You may not to use, modify, copy, make derivative works of, publish, 27 | distribute, rent, lease, sell, sublicense, assign or otherwise transfer the 28 | Licensed Materials, except as expressly set forth above in Section 1. 29 | - b. Linkedin (and its licensors) retains its intellectual property rights 30 | in the Licensed Materials. Except as expressly set forth in Section 1, 31 | LinkedIn grants no licenses. 32 | - c. You indemnify LinkedIn and its licensors and affiliates for i) any 33 | alleged infringement or misappropriation of any intellectual property rights 34 | of any third party based on modifications you make to the Licensed Materials, 35 | ii) any claims arising from your use or distribution of all or part of the 36 | Licensed Materials and iii) a breach of this Agreement. You will defend, hold 37 | harmless, and indemnify LinkedIn and its affiliates (and our and their 38 | respective employees, shareholders, and directors) from any claim or action 39 | brought by a third party, including all damages, liabilities, costs and 40 | expenses, including reasonable attorneys’ fees, to the extent resulting from, 41 | alleged to have resulted from, or in connection with: (a) your breach of your 42 | obligations herein; or (b) your use or distribution of any Licensed Materials. 43 | 44 | 3. Open source. This code may include open source software, which may be 45 | subject to other license terms as provided in the files. 46 | 47 | 4. Warranty Disclaimer. LINKEDIN PROVIDES THE LICENSED MATERIALS ON AN “AS IS” 48 | AND “AS AVAILABLE” BASIS. LINKEDIN MAKES NO REPRESENTATION OR WARRANTY, 49 | WHETHER EXPRESS OR IMPLIED, ABOUT THE LICENSED MATERIALS, INCLUDING ANY 50 | REPRESENTATION THAT THE LICENSED MATERIALS WILL BE FREE OF ERRORS, BUGS OR 51 | INTERRUPTIONS, OR THAT THE LICENSED MATERIALS ARE ACCURATE, COMPLETE OR 52 | OTHERWISE VALID. TO THE FULLEST EXTENT PERMITTED BY LAW, LINKEDIN AND ITS 53 | AFFILIATES DISCLAIM ANY IMPLIED OR STATUTORY WARRANTY OR CONDITION, INCLUDING 54 | ANY IMPLIED WARRANTY OR CONDITION OF MERCHANTABILITY OR FITNESS FOR A 55 | PARTICULAR PURPOSE, AVAILABILITY, SECURITY, TITLE AND/OR NON-INFRINGEMENT. 56 | YOUR USE OF THE LICENSED MATERIALS IS AT YOUR OWN DISCRETION AND RISK, AND 57 | YOU WILL BE SOLELY RESPONSIBLE FOR ANY DAMAGE THAT RESULTS FROM USE OF THE 58 | LICENSED MATERIALS TO YOUR COMPUTER SYSTEM OR LOSS OF DATA. NO ADVICE OR 59 | INFORMATION, WHETHER ORAL OR WRITTEN, OBTAINED BY YOU FROM US OR THROUGH OR 60 | FROM THE LICENSED MATERIALS WILL CREATE ANY WARRANTY OR CONDITION NOT 61 | EXPRESSLY STATED IN THESE TERMS. 62 | 63 | 5. Limitation of Liability. LINKEDIN SHALL NOT BE LIABLE FOR ANY INDIRECT, 64 | INCIDENTAL, SPECIAL, PUNITIVE, CONSEQUENTIAL OR EXEMPLARY DAMAGES, INCLUDING 65 | BUT NOT LIMITED TO, DAMAGES FOR LOSS OF PROFITS, GOODWILL, USE, DATA OR OTHER 66 | INTANGIBLE LOSSES . IN NO EVENT WILL LINKEDIN'S AGGREGATE LIABILITY TO YOU 67 | EXCEED $100. THIS LIMITATION OF LIABILITY SHALL: 68 | - i. APPLY REGARDLESS OF WHETHER (A) YOU BASE YOUR CLAIM ON CONTRACT, TORT, 69 | STATUTE, OR ANY OTHER LEGAL THEORY, (B) WE KNEW OR SHOULD HAVE KNOWN ABOUT 70 | THE POSSIBILITY OF SUCH DAMAGES, OR (C) THE LIMITED REMEDIES PROVIDED IN THIS 71 | SECTION FAIL OF THEIR ESSENTIAL PURPOSE; AND 72 | - ii. NOT APPLY TO ANY DAMAGE THAT LINKEDIN MAY CAUSE YOU INTENTIONALLY OR 73 | KNOWINGLY IN VIOLATION OF THESE TERMS OR APPLICABLE LAW, OR AS OTHERWISE 74 | MANDATED BY APPLICABLE LAW THAT CANNOT BE DISCLAIMED IN THESE TERMS. 75 | 76 | 6. Termination. This Agreement automatically terminates upon your breach of 77 | this Agreement or termination of your LinkedIn Learning subscription. On 78 | termination, all licenses granted under this Agreement will terminate 79 | immediately and you will delete the Licensed Materials. Sections 2-7 of this 80 | Agreement survive any termination of this Agreement. LinkedIn may discontinue 81 | the availability of some or all of the Licensed Materials at any time for any 82 | reason. 83 | 84 | 7. Miscellaneous. This Agreement will be governed by and construed in 85 | accordance with the laws of the State of California without regard to conflict 86 | of laws principles. The exclusive forum for any disputes arising out of or 87 | relating to this Agreement shall be an appropriate federal or state court 88 | sitting in the County of Santa Clara, State of California. If LinkedIn does 89 | not act to enforce a breach of this Agreement, that does not mean that 90 | LinkedIn has waived its right to enforce this Agreement. The Agreement does 91 | not create a partnership, agency relationship, or joint venture between the 92 | parties. Neither party has the power or authority to bind the other or to 93 | create any obligation or responsibility on behalf of the other. You may not, 94 | without LinkedIn’s prior written consent, assign or delegate any rights or 95 | obligations under these terms, including in connection with a change of 96 | control. Any purported assignment and delegation shall be ineffective. The 97 | Agreement shall bind and inure to the benefit of the parties, their respective 98 | successors and permitted assigns. If any provision of the Agreement is 99 | unenforceable, that provision will be modified to render it enforceable to the 100 | extent possible to give effect to the parties’ intentions and the remaining 101 | provisions will not be affected. This Agreement is the only agreement between 102 | you and LinkedIn regarding the Licensed Materials, and supersedes all prior 103 | agreements relating to the Licensed Materials. 104 | 105 | Last Updated: March 2019 106 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Copyright 2021 LinkedIn Corporation 2 | All Rights Reserved. 3 | 4 | Licensed under the LinkedIn Learning Exercise File License (the "License"). 5 | See LICENSE in the project root for license information. 6 | 7 | ATTRIBUTIONS: 8 | 9 | Bootstrap 10 | https://github.com/twbs/bootstrap 11 | Copyright (c) 2011-2021 Twitter, Inc. 12 | Copyright (c) 2011-2021 The Bootstrap Authors 13 | License: MIT 14 | https://opensource.org/licenses/MIT 15 | 16 | Bootstrap Icons 17 | https://github.com/twbs/icons 18 | Copyright (c) 2019-2020 The Bootstrap Authors 19 | License: MIT 20 | https://opensource.org/licenses/MIT 21 | 22 | React 23 | https://github.com/facebook/react 24 | Copyright (c) Facebook, Inc. and its affiliates. 25 | License: MIT 26 | https://opensource.org/licenses/MIT 27 | 28 | 29 | Please note, this project may automatically load third party code from external 30 | repositories (for example, NPM modules, Composer packages, or other dependencies). 31 | If so, such third party code may be subject to other license terms than as set 32 | forth above. In addition, such third party code may also depend on and load 33 | multiple tiers of dependencies. Please review the applicable licenses of the 34 | additional dependencies. 35 | 36 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 37 | 38 | MIT License 39 | 40 | Permission is hereby granted, free of charge, to any person obtaining a copy 41 | of this software and associated documentation files (the "Software"), to deal 42 | in the Software without restriction, including without limitation the rights 43 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 44 | copies of the Software, and to permit persons to whom the Software is 45 | furnished to do so, subject to the following conditions: 46 | 47 | The above copyright notice and this permission notice shall be included in all 48 | copies or substantial portions of the Software. 49 | 50 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 51 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 52 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 53 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 54 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 55 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 56 | SOFTWARE. 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Building a GraphQL Project with React.js 2 | This is the repository for the LinkedIn Learning course Building a GraphQL Project with React.js. The full course is available from [LinkedIn Learning][lil-course-url]. 3 | 4 | ![Building a GraphQL Project with React.js][lil-thumbnail-url] 5 | Are you a web developer creating apps? GraphQL gives you a clean way to query complex server data efficiently, and React makes it easy to present that information as a web application in the browser. In this course, instructor Ray Villalobos teaches you how to assemble these parts, using the familiar structure of GitHub as a source for information. Ray first walks you through installing React, including how to use the command-line interface (CLI), as well as how to customize and add the node modules you will need for this project. He explores what you can do with the GitHub API using GraphiQL, then shows you how to retrieve data, generate a query component, and more. Ray goes over each step in building the React app, concluding with how to create the pagination interface. 6 | 7 | ## Instructions 8 | This repository has branches for each of the videos in the course. You can use the branch pop up menu in github to switch to a specific branch and take a look at the course at that stage, or you can add `/tree/BRANCH_NAME` to the URL to go to the branch you want to access. 9 | 10 | ## Branches 11 | The branches are structured to correspond to the videos in the course. The naming convention is `CHAPTER#_MOVIE#`. As an example, the branch named `02_03` corresponds to the second chapter and the third video in that chapter. 12 | Some branches will have a beginning and an end state. These are marked with the letters `b` for "beginning" and `e` for "end". The `b` branch contains the code as it is at the beginning of the movie. The `e` branch contains the code as it is at the end of the movie. The `main` branch holds the final state of the code when in the course. 13 | 14 | When switching from one exercise files branch to the next after making changes to the files, you may get a message like this: 15 | 16 | error: Your local changes to the following files would be overwritten by checkout: [files] 17 | Please commit your changes or stash them before you switch branches. 18 | Aborting 19 | 20 | To resolve this issue: 21 | 22 | Add changes to git using this command: git add . 23 | Commit changes using this command: git commit -m "some message" 24 | 25 | ## Installing 26 | 1. To use these exercise files, you must have the following installed: 27 | - [Node.js](https://nodejs.org/) 28 | - [Git](https://git-scm.com/) 29 | 2. Clone this repository into your local machine using the terminal (Mac), CMD (Windows), or a GUI tool like SourceTree. 30 | 3. Watch the `Using the Exercises for this course` video for further instructions. 31 | 32 | 33 | 34 | ### Instructor 35 | 36 | **Ray Villalobos** 37 | 38 | _Senior Staff Instructor at LinkedIn Learning_ 39 | 40 | Check out my other courses on [LinkedIn Learning](https://www.linkedin.com/learning/instructors/ray-villalobos?u=104). 41 | 42 | [lil-course-url]: https://www.linkedin.com/learning/building-a-graphql-project-with-react-js 43 | [lil-thumbnail-url]: https://cdn.lynda.com/course/2875095/2875095-1615224395432-16x9.jpg 44 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | 5.1.x | :white_check_mark: | 11 | | 5.0.x | :x: | 12 | | 4.0.x | :white_check_mark: | 13 | | < 4.0 | :x: | 14 | 15 | ## Reporting a Vulnerability 16 | 17 | Use this section to tell people how to report a vulnerability. 18 | 19 | Tell them where to go, how often they can expect to get an update on a 20 | reported vulnerability, what to expect if the vulnerability is accepted or 21 | declined, etc. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "reactgraphql", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.11.9", 7 | "@testing-library/react": "^11.2.3", 8 | "@testing-library/user-event": "^12.6.0", 9 | "bootstrap": "^5.0.0-beta1", 10 | "bootstrap-icons": "^1.3.0", 11 | "react": "^17.0.1", 12 | "react-dom": "^17.0.1", 13 | "react-scripts": "4.0.1", 14 | "sass": "^1.32.5", 15 | "web-vitals": "^0.2.4" 16 | }, 17 | "scripts": { 18 | "start": "react-scripts start", 19 | "build": "react-scripts build", 20 | "test": "react-scripts test", 21 | "eject": "react-scripts eject" 22 | }, 23 | "eslintConfig": { 24 | "extends": [ 25 | "react-app", 26 | "react-app/jest" 27 | ] 28 | }, 29 | "browserslist": { 30 | "production": [ 31 | ">0.2%", 32 | "not dead", 33 | "not op_mini all" 34 | ], 35 | "development": [ 36 | "last 1 chrome version", 37 | "last 1 firefox version", 38 | "last 1 safari version" 39 | ] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LinkedInLearning/react-graphql-2875095/1a7d26bcbb8f8f37e1e6fcf36cdb5565723c3669/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | React App 6 | 7 | 8 | 9 |
10 | 11 | 12 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import github from "./db.js"; 2 | import { useEffect, useState, useCallback } from "react"; 3 | import query from "./Query"; 4 | import RepoInfo from "./RepoInfo"; 5 | import SearchBox from "./SearchBox"; 6 | import NavButtons from "./NavButtons"; 7 | 8 | function App() { 9 | let [userName, setUserName] = useState(""); 10 | let [repoList, setRepoList] = useState(null); 11 | let [pageCount, setPageCount] = useState(10); 12 | let [queryString, setQueryString] = useState(""); 13 | let [totalCount, setTotalCount] = useState(null); 14 | 15 | let [startCursor, setStartCursor] = useState(null); 16 | let [endCursor, setEndCursor] = useState(null); 17 | let [hasPreviousPage, setHasPreviousPage] = useState(false); 18 | let [hasNextPage, setHasNextPage] = useState(true); 19 | let [paginationKeyword, setPaginationKeyword] = useState("first"); 20 | let [paginationString, setPaginationString] = useState(""); 21 | 22 | const fetchData = useCallback(() => { 23 | const queryText = JSON.stringify( 24 | query(pageCount, queryString, paginationKeyword, paginationString) 25 | ); 26 | 27 | fetch(github.baseURL, { 28 | method: "POST", 29 | headers: github.headers, 30 | body: queryText, 31 | }) 32 | .then((response) => response.json()) 33 | .then((data) => { 34 | const viewer = data.data.viewer; 35 | const repos = data.data.search.edges; 36 | const total = data.data.search.repositoryCount; 37 | const start = data.data.search.pageInfo?.startCursor; 38 | const end = data.data.search.pageInfo?.endCursor; 39 | const next = data.data.search.pageInfo?.hasNextPage; 40 | const prev = data.data.search.pageInfo?.hasPreviousPage; 41 | 42 | setUserName(viewer.name); 43 | setRepoList(repos); 44 | setTotalCount(total); 45 | 46 | setStartCursor(start); 47 | setEndCursor(end); 48 | setHasNextPage(next); 49 | setHasPreviousPage(prev); 50 | }) 51 | .catch((err) => { 52 | console.log(err); 53 | }); 54 | }, [pageCount, queryString, paginationString, paginationKeyword]); 55 | 56 | useEffect(() => { 57 | fetchData(); 58 | }, [fetchData]); 59 | 60 | return ( 61 |
62 |

63 | Repos 64 |

65 |

Hey there {userName}

66 | { 71 | setPageCount(myNumber); 72 | }} 73 | onQueryChange={(myString) => { 74 | setQueryString(myString); 75 | }} 76 | /> 77 | { 83 | setPaginationKeyword(myKeyword); 84 | setPaginationString(myString); 85 | }} 86 | /> 87 | {repoList && ( 88 |
    89 | {repoList.map((repo) => ( 90 | 91 | ))} 92 |
93 | )} 94 | 95 | { 101 | setPaginationKeyword(myKeyword); 102 | setPaginationString(myString); 103 | }} 104 | /> 105 |
106 | ); 107 | } 108 | 109 | export default App; 110 | -------------------------------------------------------------------------------- /src/NavButtons.js: -------------------------------------------------------------------------------- 1 | const NavButtons = ({ start, end, next, previous, onPage }) => { 2 | return ( 3 |
4 | {previous && ( 5 | 8 | )} 9 | {next && ( 10 | 13 | )} 14 |
15 | ); 16 | }; 17 | 18 | export default NavButtons; 19 | -------------------------------------------------------------------------------- /src/Query.js: -------------------------------------------------------------------------------- 1 | const githubQuery = ( 2 | pageCount, 3 | queryString, 4 | paginationKeyword, 5 | paginationString 6 | ) => { 7 | return { 8 | query: ` 9 | { 10 | viewer { 11 | name 12 | } 13 | search(query: "${queryString} user:planetoftheweb sort:updated-desc", type: REPOSITORY, ${paginationKeyword}: ${pageCount}, ${paginationString}) { 14 | repositoryCount 15 | edges { 16 | cursor 17 | node { 18 | ... on Repository { 19 | name 20 | description 21 | id 22 | url 23 | viewerSubscription 24 | licenseInfo { 25 | spdxId 26 | } 27 | } 28 | } 29 | } 30 | pageInfo { 31 | startCursor 32 | endCursor 33 | hasNextPage 34 | hasPreviousPage 35 | } 36 | } 37 | } 38 | `, 39 | }; 40 | }; 41 | 42 | export default githubQuery; 43 | -------------------------------------------------------------------------------- /src/RepoInfo.js: -------------------------------------------------------------------------------- 1 | const RepoInfo = ({ repo }) => { 2 | let license; 3 | 4 | switch (repo.licenseInfo?.spdxId) { 5 | case undefined: 6 | license = ( 7 | 10 | NO LICENSE 11 | 12 | ); 13 | break; 14 | case "NOASSERTION": 15 | license = ( 16 | 19 | {repo.licenseInfo.spdxId} 20 | 21 | ); 22 | break; 23 | default: 24 | license = ( 25 | 28 | {repo.licenseInfo.spdxId} 29 | 30 | ); 31 | } 32 | 33 | return ( 34 |
  • 35 |
    36 |
    37 | 38 | {repo.name} 39 | 40 |

    {repo.description}

    41 |
    42 |
    43 | {license} 44 | 52 | {repo.viewerSubscription} 53 | 54 |
    55 |
    56 |
  • 57 | ); 58 | }; 59 | 60 | export default RepoInfo; 61 | -------------------------------------------------------------------------------- /src/SearchBox.js: -------------------------------------------------------------------------------- 1 | const SearchBox = ({ 2 | totalCount, 3 | pageCount, 4 | queryString, 5 | onTotalChange, 6 | onQueryChange, 7 | }) => { 8 | return ( 9 |
    10 |
    11 | 14 | { 20 | onQueryChange(event.target.value); 21 | }} 22 | /> 23 |
    24 |
    25 | 28 | { 36 | onTotalChange(event.target.value); 37 | }} 38 | /> 39 |
    40 |
    41 | Total: 42 | {totalCount} 43 |
    44 |
    45 | ); 46 | }; 47 | 48 | export default SearchBox; 49 | -------------------------------------------------------------------------------- /src/custom.scss: -------------------------------------------------------------------------------- 1 | $primary: #6f42c1; 2 | $light: #e9ecef; 3 | @import "~bootstrap/scss/bootstrap.scss"; 4 | @import "~bootstrap-icons/font/bootstrap-icons.css"; 5 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import App from "./App"; 4 | import "./custom.scss"; 5 | 6 | ReactDOM.render( 7 | 8 | 9 | , 10 | document.getElementById("root") 11 | ); 12 | --------------------------------------------------------------------------------