GithubHelp home page GithubHelp logo

jnembhard / solar-system Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 1.71 MB

Solar System Planet Fact Site built with React.

Home Page: https://planetfacts.vercel.app/Earth

HTML 1.80% JavaScript 98.20%
reactjs react styled-components framer-motion framer

solar-system's Introduction

Planets Facts

Table of contents

Overview

The challenge

Users should be able to:

  • View the optimal layout for the app depending on their device's screen size
  • See hover states for all interactive elements on the page
  • View each planet page and toggle between "Overview", "Internal Structure", and "Surface Geology"

Screenshot

Solar System

Links

My process

Built with

What I learned

This website can be fairly easy or hard to build depending on the strategy you choose to go with. At first, I was attempting to use Redux to handle state changes on each individual planet page, but quickly realized a simple tab strategy would lessen the complexity of the build.

In this case, the data will remain relatively "fixed" without a need to plan for updates. There are only 8 planets, and 3 facts associated with each planet.

Each link and tab had its own individual color that needed to be associated by page. I created a new hook to handle this problem as seen here:

import { useEffect, useState } from "react";

export const useMediaQuery = (query) => {
  const mediaMatch = window.matchMedia(query);
  const [matches, setMatches] = useState(mediaMatch.matches);

  useEffect(() => {
    const handler = (e) => setMatches(e.matches);
    mediaMatch.addEventListener("change", handler);
    return () => mediaMatch.removeEventListener("change", handler);
  });
  return matches;
};

For this part of the code, the size of the screen will dictate when a certain styling effect is shown to the user, which in this case is a tab with a bottom border or a li tag with a filled in background color.

const styles = {
  container: (isScreenSize767) => ({
    backgroundColor: isScreenSize767
      ? `${handlePlanetColors(name)}`
      : "transparent",
    borderColor: isScreenSize767 ? `${handlePlanetColors(name)}` : "",
    borderBottom: isScreenSize767
      ? "none"
      : `5px solid ${handlePlanetColors(name)}`,
  }),
};

Overall, the main thing I gained from this is to have a clear idea of which strategy will lessen the complexity of your work. Choosing the right tool is essential.

Continued development

I expect to encounter problems like this again, so it may be time to create a Storybook for some reusable components. As I become more experienced, I expect to come up with more efficient implementation strategies, but past work can help speed up my development.

Author

solar-system's People

Contributors

jnembhard 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.