Code Monkey home page Code Monkey logo

article-preview-component's Introduction

Frontend Mentor - Article preview component solution

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

Note: Delete this note and update the table of contents based on what sections you keep.

Overview

The mini project is a front-end practice project from frontendmentor.io I have used SCSS and vanilla javascript for this.

The challenge

Users should be able to:

  • View the optimal layout for the component depending on their device's screen size
  • See the social media share links when they click the share icon

My process

The basic structure of the project was quite easy to build, however the challenge was to place the share menu on the correct spot.

The share menu was implemented using flexbox and pseudo element was used to create the downward arrow.

I used javascript to position the share menu for desktop and tablet view. In order to determine the coordinates of the button, i used clientHeight and offsetHeight property for the button. And further adjusted it for the pseudo element and the gap b/w menu and the button.

I also added and event listener for clicks to the windows element to turn off the share menu whenever a click is registered outside the share menu and the share button. Used the closest() method to determine if the event target's closest div is a button or the menu.

For mobile view, (the script would always overwrite any css therefore), I used !important attribute for the menu position.

Built with

  • Semantic HTML5 markup
  • SCSS
  • Flexbox
  • CSS Grid

Useful resources

Used stackoverflow and w3schools documentation throughout the development.

  • SCSS course - Got familiar with SCSS with this course. Really amazing course.

Author

article-preview-component's People

Contributors

gautamjuyal avatar

Stargazers

Suraj Aswal 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.