Code Monkey home page Code Monkey logo

article-browser's Introduction

Article Browser - Sample React Application

NOTE: This is a sample application used for training and interview tasks. It is intentionally anemic but feel free to use it if you find it useful.

Vite is used for tooling. It uses Tailwind CSS for styling built using PostCSS.

Available Scripts

In the project directory, you can run:

npm start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

npm test

Launches the test runner in the interactive watch mode.

npm run build

Builds the app for production to the dist folder.

npm run lint

Run eslint and report any errors/warnings.

npm run lint:fix

Fix any linting errors that can be automatically fixed.

npm run format

(Re)format code using prettier

Tasks

Task 1: Load articles from an API

Out of the box the application displays three articles on the page. This uses hardcoded placeholder data in a single article component (./src/components/Article.jsx). The first step is to replace these placeholder article boxes and their placeholder strings with data loaded from an API.

The fake article API provides 100 fake articles regenerated each time it's called. Each of these articles is in one of four fake journals ("Journal A", "Journal B", "Journal C", "Journal D").

The API is available here: https://fake-article-api.vercel.app/articles

Example of a single article:

{
  "id": "90444900-9820-448b-9780-b6fea57ac116",
  "publishedOn": "2000-10-17",
  "title": "Minima corrupti hic",
  "abstract": "Laborum recusandae nesciunt earum quisquam rerum. Voluptatem velit ipsum est nesciunt cupiditate.",
  "journal": {
    "id": "A",
    "name": "Journal A"
  },
  "authors": [
    "Ari Bednar",
    "Cedrick Batz",
    "Wayne Klein",
    "Jasper Auer"
  ]
}

Add functionality to fetch the articles from this API on page load and display each article on the page.

Task 2: Add an article detail view

Clicking an article should display a more detailed view that includes the abstract, publication date, and other details in a more expansive format.

Task 3: Add filtering by journal

Now that we have articles dynamically displaying we'd like to let the user filter by journal. Provide a component that allows the user to select one or more journals ("Journal A", "Journal B", etc.). The journal parameter on the /articles API endpoint above allows filtering by journal using the journal ID. When the journals are selected update the call to the API to include them as parameters.

Example: Return only articles in "Journal A":

https://fake-article-api.vercel.app/articles?journal=A

Example: Return only articles in "Journal A" and "Journal B":

https://fake-article-api.vercel.app/articles?journal=A&journal=B

Task 4: Add search functionality

Add a search text box to the header that when submitted looks returns only the articles that match the text entered. The text may appear in the title, abstract, or author names. If the user enters multiple terms only articles that include all terms should be returned but those terms may match across fields. For example, given the articles:

[
  { 
    "id": "4673a875-8caa-4675-9f11-832204cf9c32",
    "title": "Distinctio deleniti dolorem",
    "authors": [
      "Virgil Raynor",
      "Carmella Connelly",
      "Aniya Miller"
    ]
  }
  {
    "id": "a7810fce-3544-4306-806d-5a95b1aabbe2",
    "title": "Distinctio maiores odio",
    "authors": [
      "Alana Schuppe",
      "Joan Baumbach",
      "Myriam Kris"
    ]
  }
]

If the user enters the search term "distinctio" both articles should be returned since this term matches their titles. If the user enters the search terms "distinctio raynor" only the first article should be returned since it is the only one that matches both terms ("distinctio" in the title, and "raynor" in the authors).

No search API endpoint is provided so the search functionality will need to operate on the set of articles loaded from the API at the time of page load (all search functionality will be client side).

Task 5: Add tests

Add a unit test for the Article component created above using Enzyme. The file ./src/components/Article.test.jsx contains stubbed out test expections which should be made to pass along with any other test coverage you feel is appropriate.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.