Skip to content

lauriselvijs/3-column-preview-card-component

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Frontend Mentor - 3-column preview card component solution

This is a solution to the 3-column preview card component challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.

Table of contents

Overview

The challenge

Users should be able to:

  • View the optimal layout depending on their device's screen size
  • See hover states for interactive elements

Screenshot

Three cards unchecked

Three cards checked

Three cards unchecked mobile

Three cards checked mobile

Installation

Steps to Setup

  1. Have node JS installed.
  2. In the project root directory, run npm install

Steps to Run

  1. In the project root directory, run npm run start

Links

My process

Built with

  • HTML5 markup
  • SCSS - advanced variant of CSS
  • React - JS library
  • React Icons - Include popular icons in your React projects easily with react-icons
  • TypeScript - Strongly typed programming language for JS

What I learned

Using render props to implement DRY approach

  <MainWrapper>
        <LearnMoreClickedWrapper
          render={(learnMoreClicked, onLearnMoreBtnClick) => (
            <Sedan
              learnMoreClicked={learnMoreClicked}
              onLearnMoreBtnClick={onLearnMoreBtnClick}
            />
          )}
        />
        <LearnMoreClickedWrapper
          render={(learnMoreClicked, onLearnMoreBtnClick) => (
            <Suv
              learnMoreClicked={learnMoreClicked}
              onLearnMoreBtnClick={onLearnMoreBtnClick}
            />
          )}
        />
        <LearnMoreClickedWrapper
          render={(learnMoreClicked, onLearnMoreBtnClick) => (
            <Luxury
              learnMoreClicked={learnMoreClicked}
              onLearnMoreBtnClick={onLearnMoreBtnClick}
            />
          )}
        />
      </MainWrapper>
  const LearnMoreClickedWrapper = ({ render }: ILearnMoreClickedWrapper) => {
  const [learnMoreClicked, setLearnMoreClicked] = useState<boolean>(false);

  const onLearnMoreBtnClick = (): void => {
    setLearnMoreClicked(!learnMoreClicked);
  };

  return (
    <div className="learn-more-clicked-wrapper">
      {render(learnMoreClicked, onLearnMoreBtnClick)}
    </div>
  );
};

Continued development

Learning more about SCSS and using it in future projects

Useful resources

Author