Skip to content

emil6957/shortly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shortly URL shortening API Challenge

This is a solution to the Shortly URL shortening API Challenge challenge on Frontend Mentor.

Overview

The challenge

  • View the optimal layout for the site depending on their device's screen size
  • Shorten any valid URL
  • See a list of their shortened links
  • Copy the shortened link to their clipboard in a single click
  • Receive an error message when the form is submitted if:
    • The input field is empty
    • The input is given an invalid URL

Screenshot

Shortly

Links

My process

Built With

What I learned

  • Using a mobile-first workflow and using media queries

  • Using Switch statements to handle Error messages

if (data.ok === false) {
    linkInput.style.border = "4px solid var(--red)";
    const errMsg = document.querySelector(".err-msg");
    switch(data.error_code) {
    case 1:
        errMsg.textContent = "Please add a URL to shorten";
        break;
    case 2:
        errMsg.textContent = "Invalid URL given";
        break;
    case 3:
        errMsg.textContent = "Rate limit reached. Wait a second and try again";
        break;
    case 4:
        errMsg.textContent = "IP-Address has been blocked for violating shrtcode's terms of service";
        break;
    case 5:
        errMsg.textcontent = "shrtcode already taken/in use. Try again";
        break;
    case 6:
        errMsg.textContent = "Unknown error";
        break;
    case 10:
        errMsg.textContent = "The link you entered is disallowed";
}
  • Creating and using small CSS animations with @keyframes
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-1rem);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 1s;
}

Useful resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published