Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 5 months ago

Responsive Social Links Profile using HTML, CSS, and JavaScript

P
Angel Díaz•50
@angeledv
A solution to the Social links profile challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What specific areas of your project would you like help with?

Any feedback would be very helpful. Thanks!

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Muhammad Farhan Rosidi•70
    @MuhammadFarhanRosidi
    Posted 5 months ago

    JavaScript (script.js) - Suggestions for Improvement:

    1. Avoid querying the DOM repeatedly:

      • The cardContainer and dustContainer elements are being queried inside the mousemove event listener on every movement. Since these elements do not change, it's better to query them once and store them outside the event listener.

      Improvement:

      const cardContainer = document.querySelector('.card-container');
      const dustContainer = document.querySelector('.dust-container');
      
      document.addEventListener('mousemove', (e) => {
          if (!cardContainer.contains(e.target)) {
              createDust(e);
          }
      });
      
      function createDust(e) {
          const dust = document.createElement('div');
          dust.classList.add('dust');
          dust.style.left = `${e.pageX - 4}px`;
          dust.style.top = `${e.pageY - 4}px`;
          dustContainer.appendChild(dust);
      
          setTimeout(() => dust.remove(), 500);
      }
      

      This approach improves performance by avoiding repeated DOM queries.

    2. Refactor the dust creation process:

      • The dust creation logic can be separated into a dedicated function (as shown in the above improvement) to make the code more modular and reusable.
    3. Check if dustContainer exists:

      • Before appending dust, make sure the dustContainer is available, especially if it is dynamically created or removed.

    CSS (styles.css) - Suggestions for Improvement:

    1. Use rem or em for consistent spacing:

      • Instead of using fixed pixel values like px, it’s a good practice to use rem or em for margins, padding, and font sizes. This ensures better responsiveness and scalability across different screen sizes.

      Improvement:

      h1 {
          font-size: 1.5rem;  /* Already using rem, which is good */
      }
      .card-container {
          width: 24rem;  /* 384px becomes 24rem */
          padding: 2.5rem; /* 40px becomes 2.5rem */
      }
      
    2. Consider adding a fallback for the background-color:

      • While you’ve defined a primary color palette with :root, it's still good to ensure fallback colors for broader compatibility.

      Improvement:

      .card-container {
          background-color: var(--medium-gray, #1F1F1F); /* Added fallback color */
      }
      
    3. Improve animation for dust trail:

      • The dust animation could be smoother by adjusting timing, easing functions, or adding keyframes for better visual appeal. For instance, slowing down the animation for a more lasting effect.

      Improvement:

      @keyframes dust-animation {
          0% {
              transform: scale(1);
              opacity: 0.7;
          }
          50% {
              transform: scale(2);
              opacity: 0.4;
          }
          100% {
              transform: scale(3);
              opacity: 0;
          }
      }
      
    4. Media Queries (Improve Responsiveness):

      • Add more breakpoints for different screen sizes. Right now, it only has 768px for tablets and 375px for small mobile devices. You could add more to make it more adaptable for larger tablets, phablets, etc.

      Improvement:

      /* For large tablets */
      @media screen and (max-width: 1024px) {
          .card-container {
              width: 30rem; /* 480px */
          }
      }
      
      /* For smaller devices */
      @media screen and (max-width: 480px) {
          .card-container {
              width: 100%; /* Full width on very small screens */
          }
      }
      
    5. Dark Mode Considerations:

      • If you want to extend the design to support a dark mode toggle, consider using CSS custom properties (variables) that can be switched dynamically. This would make the site more versatile for different user preferences.

    General Improvement Suggestions:

    • Performance optimization: Using requestAnimationFrame for better handling of the mousemove event could help optimize performance, especially if the mouse trail becomes more complex.

      Example:

      let lastTime = 0;
      document.addEventListener('mousemove', (e) => {
          const currentTime = Date.now();
          if (currentTime - lastTime >= 16) { // approx 60 FPS
              if (!cardContainer.contains(e.target)) {
                  createDust(e);
              }
              lastTime = currentTime;
          }
      });
      
    • Accessibility considerations: Ensure your links have meaningful, accessible content (for screen readers), such as using aria-label for social media links to make it more inclusive for users with disabilities.

    Marked as helpful
  • 0maa•40
    @0maa
    Posted 5 months ago

    A very nice design. Looks almost like the given project, well done!

  • Anderson Paulo•50
    @AndersonPaulo
    Posted 5 months ago

    Compared to other codes I've seen, this one stands out for its quality and performance." Code optimization is above average, which demonstrates special care for performance.

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub