Giter Club home page Giter Club logo

image-finder's Introduction

UnImage Finder

UnImage Finder is a simple React and Node/Express app that fetches images from Unsplash via a search feature

API Side

On the API side of things, I created a basic setup of Express with cors, an image routes file in the routes folder, an Unsplash repository in the repositories folder, and an image controller file in the controllers folder. Since I have not worked with Node as much, I may not know all of the best practices, but am looking at this from an MVC standpoint from my experience with Laravel, and I personally think this would scale nicely if grown.

Another thing I decided to add in was TypeScript. TypeScript allowed me to implement some basic type checking on parameters passed to the route, the controller, and the repository function as well, which caught some bugs during my time. Lastly, I made sure to return a status code for errors and for successful requests, as this is something I would always do in a real- world application.

Client Side

For the client side, I naturally went with React with TypeScript, but added in one of my new favorite component libraries: Mantine UI. I was going to either user React-Hook-Form or Mantine's form library, but I thought it would be overkill considering I'd only be using one input throughout the entire application. Thus, I did things the old fashioned way with state and onChange on the input itself. In order to communicate with the API easier, I installed axios and exported a base function to search for images, which I used asynchronously in the submit function for the form. I added some basic error checking and added in an error message as well. I was thinking about adding in a debounce functionality to search after entering some characters, but it would defeat the purpose of the button, which was a requirement. Instead, since I wanted to limit massive queries as much as possible, I opted for a compromise at requiring at least three characters to be entered.

After the search feature was complete and I was getting data back correctly, I installed the React-Infinite-Scroller component and wrapped it around some fetching methods once images, the state variable, was set. This included easy pagination, detected when the page was at the bottom, and gave me the ability to add in a loader as well. Since I'm a stickler for displaying information to the user, I also added in a placeholder for the image to show it is being loaded. Normally I wouldn't have to do such a thing if I was working with smaller data, but alas, the images are large.

Lastly, for the actual lightbox-feature itself, I decided to just use the common modal component to show the image when it's clicked, along with a hover effect. Since I didn't like the blank space at the top of the modal, I added in the description of the image to the title.

image-finder's People

Contributors

bcaylor10 avatar

Watchers

 avatar

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.