1️⃣ Frontend deployed at https://helpful-human-challenge.netlify.app/ and accompanying Backend deployed at https://morning-spire-68989.herokuapp.com/
- Please refer to the helpful-human-server documentation at https://github.com/karsevar/helpful-human-server to learn about the different endpoints in which run this application.
Stated briefly, the core goal is to create a simple but functional app that has a data, view and logic layer. The app will display color swatches, and that's about it!
The core goals should be completed in full.
- Replicate design
- Font
- Styles
- Iconography
- Replicate functionality
- Create a database of colors (minimum 100)
- Paginate your data to show a certain number of swatches at a time
- Display both the color swatch and the label of the color
- Ability to select random color and modify view accordingly
- Clicking swatch changes to color detail view
- Design
- Make it responsive
- Functionality
- Generate color list from a script
-
Design
- Include interaction design
- Add tints/shades in detail view
-
Functionality
- Add search functionality
- Color generation script guarantees same colors and order
- Group by color (Make sidebar menu functional)
-
Data
- Fetch data with GraphQL
- React (for dom manipulation and userflow framework)
- React-Router-Dom (to alternate between the overall color list view with pagination controls and the individual color detail view)
- node-sass (as the main CSS compiler for the project)
- axios (for http pull requests to the accompanying server)
- Replicate Design
- Replicate Functionality
- Create a database of colors (minimum 100)
- Paginate your data to show a certain number of swatches at a time (check https://github.com/karsevar/helpful-human-server)
- Display both the color swatch and the label of the color
- Ability to select random color and modify view accordingly
- Clicking swatch changes to color detail view
-
The ColorsParentComponent is used as the containing component for the two routes in the application,
/
and/colorDetail/:id
that mountsPaginationComponent
andColorDetailComponent
respectively, andSideMenuComponent
. -
The main purpose of this component is to give structure to where
SideMenuComponent
is placed within the application in relation toPaginationComponent
andColorDetailComponent
, sinceSideMenuComponent
will need to remain static between the two routes. In addition, this component givesSideMenuComponent
the total number of color entries in the database through the hooktotalColors
andPaginationComponent
the total number of page buttons that need to be rendered to display all the colors throughPages
. -
Constraints include the addition of the currentPage hook declaration in the parent component of
PaginationComponent
, the reason for this oversight was switching from the color detail view (/colorDetail/:id
) to the home view (/
) the currentPage hook would be overwritten to1
if the hook was included inPaginationComponent
.
-
The only finished piece of functionality in
SideMenuComponent
was the random button feature which takes in the proptotalColors
fromColorsParentComponent
and calculates a random number between 1 andtotalColors
. After the random value is calculated the application redirects the user to the color detail route/colorDetail/:id
using the value as the dynamic route. -
handleRandomClick
manages all of the component's functionality.
HeaderComponent
is only used as decoration since search functionality hasn't been implemented.
-
PaginationComponent
contains theSwatchesComponent
and the pagination navigation menu. -
Four props are passed into the component.
- Pages, which is initially declared in
ColorsParentComponent
and used to display the total number of navigatable pages the server's database can render. - history, used as a prop for
SwatchesComponent
since each individual color swatch carries an onClick handler that redirects the user to the/colorDetail/:id
route using the swatch's database id as the dynamic variable. - currentPage, used to highlight the current page data the
SwatchesComponent
is rendering wihtin<div class='pagination-container></div>
and as a prop forSwatchesComponent
that tells the component which page to render from the database. - setCurrentPage, used to modify currentPage through the
handlePaginationClick
that is placed on each of the page div layers.
- Pages, which is initially declared in
SwatchesComponent
takes two props,currentPage
andhistory
.currentPage
is used within the backend get request within a query string (example/getColorsByPagination?page=[currentPage]
). This logic tells the http request which page to render into the component.history
is used within thehandleSwatchClick
function that is attached to each of the rendered color swatch cards. The overall purpose of thehandleSwatchClick
function is to redirect the user to a color detail view (route/colorDetail/[database id of color clicked on]
) of the color swatch he/she clicked on.
-
Unlike the other components,
ColorDetailComponent
is very much self contained with the only exceptions of taking in a prop from the dynamic route (colorId
) and the object history.colorId
is an integer representation that matches with the color's database id in the helpful-human-server. This variable is used within the get request url/getColorById/[color id from dynamic route]
. If the get request is successful colorInfo is overwritten with thecolorId
's information.
-
handleBackClick
function is used with the<button class='back-btn'>
element to redirect the user back to the home route (/
).
- This component is largely incomplete due to most of the RGB to hexadecimal reference functions converting the lighter and darker RGB shades from the function
lightenOrDarken
into incorrect values. Other than thergbToHex
bug the overall logic works just fine.hexToRgb
converts every passed in hexadecimal value into accurate RGB values and thelightenOrDarken
function perfectly creates appropriate shades of the passed incolorInfo.hexString
prop.