Skip to content

πŸ“± πŸ‘ͺ πŸ’» Profile Cards APP || Developed with HTML5, CSS3 and JavaScript || Module 2 Team Project of the Adalab Digital Frontend Development Bootcamp || Developed by: @almudenabr, @Emma-cebada, @anaguerraabaroa, @Celiamf and @IreneRuedaVega

License

Notifications You must be signed in to change notification settings

anaguerraabaroa/profile-cards

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Landing Mobile Landing Tablet Landing Tablet

Card Generator Mobile Card Generator Tablet Card Generator Desktop

Profile Cards

About

Module 2 team project of the Adalab Digital Frontend Development Bootcamp.

This is a profile cards app developed with and

Project URL is available on GitHub Pages.

NOTE: original project has been updated to improve development and design features.

DevilAPPers Team

This project has been developed by DevilAPPers Team:

Quick start guide

Instructions to start this project:

Installation

  • Clone repository:
git clone [repository]
  • Install NPM packages and dependencies:
npm install
  • Run project on local server:
npm start

Features

  • Landing page
  • Generator card page
  • Collapsable design sections: colour palettes, personal data form and create profile card
  • Control patterns on form inputs
  • Render data on card while it is being filled
  • Keep data on LocalStorage
  • Reset button to remove data from design sections, card and LocalStorage
  • Send data to APIRest and get a link with filled profile card
  • Button to share card on Twitter

Usage

1. Collapsables

function getCollapsable(event) {
  event.currentTarget.classList.toggle("rotateArrow");

  const arrowId = event.currentTarget.id;
  const section = document.querySelector(".section-" + arrowId);
  section.classList.toggle("hideCollapsable");
}

2. Palettes

  • Handle select palette:
function selectPalette() {
  if (palette1.checked === true) {
    form.palette = 1;
  } else if (palette2.checked === true) {
    form.palette = 2;
  } else if (palette3.checked === true) {
    form.palette = 3;
  } else if (palette4.checked === true) {
    form.palette = 4;
  }

  renderPalette();
  setLocalStorage();
}
  • Render selected palette on card:
function renderPalette() {
  cardContainer.classList.add("palette1");
  cardContainer.classList.remove("palette2");
  cardContainer.classList.remove("palette3");
  cardContainer.classList.remove("palette4");
  if (form.palette === 1) {
    cardContainer.classList.add("palette1");
  } else if (form.palette === 2) {
    cardContainer.classList.add("palette2");
  } else if (form.palette === 3) {
    cardContainer.classList.add("palette3");
  } else if (form.palette === 4) {
    cardContainer.classList.add("palette4");
  }
}
  • Reset palettes:
function resetPalette() {
  if (palette1.checked !== true) {
    palette1.checked = true;
  } else if (palette2.checked === true) {
    palette2.checked = false;
  } else if (palette3.checked === true) {
    palette3.checked = false;
  } else if (palette4.checked === true) {
    palette4.checked = false;
  }
  renderPalette();
}

3. Form

  • Handle form fields data:
function saveField(event) {
  inputValue = event.currentTarget.value;
  inputId = event.currentTarget.id;
  form[inputId] = inputValue;
  renderCard();
  setLocalStorage();
}
  • Render form fields data on the profile card:
function renderCard() {
  document.querySelector(".js-nameCard").innerHTML =
    form.name || "Nombre completo";
  document.querySelector(".js-positionCard").innerHTML = form.job || "Puesto";
  document.querySelector(".js-tlCard").href = "tel:" + form.phone;
  document.querySelector(".js-emailCard").href = "mailto:" + form.email;
  document.querySelector(".js-linkedinCard").href = form.linkedin;
  document.querySelector(".js-gitHubCard").href =
    "https://github.com" + form.github;
  profileImage.style.backgroundImage = `url(${form.photo})`;
}
  • Handle reset form fields:
const handleReset = function () {
  form.palette = 1;
  form.name = "";
  form.job = "";
  form.email = "";
  form.phone = "";
  form.linkedin = "";
  form.github = "";
  form.photo =
    "url(https://i.picasion.com/pic90/02b56d6431f0a6fe7082958c95d7788d.gif)";
  localStorage.removeItem("formData");
  for (const input of inputList) {
    input.value = "";
  }
  profileImage.style.backgroundImage =
    "url(https://i.picasion.com/pic90/02b56d6431f0a6fe7082958c95d7788d.gif)";
  profilePreview.style.backgroundImage =
    "url(https://i.picasion.com/pic90/02b56d6431f0a6fe7082958c95d7788d.gif)";

  renderCard();
  resetPalette();
  setLocalStorage();
};

4. Card image

  • Handle an automatic click on hidden input when an image is uploaded:
function fakeFileClick() {
  fileField.click();
}
  • Handle get image from hidden input:
function getImage(e) {
  const myFile = e.currentTarget.files[0];
  fr.addEventListener("load", writeImage);
  fr.readAsDataURL(myFile);
}
  • Render image on the profile card:
function writeImage() {
  profileImage.style.backgroundImage = `url(${fr.result})`;
  profilePreview.style.backgroundImage = `url(${fr.result})`;
  form.photo = fr.result;
  setLocalStorage();
}

5. Create card

  • Handle share collapsable container border:
function hideShareBorder() {
  shareCollapsableBorder.classList.toggle("hideLineShare");
}
  • Handle collapsable card link and change create card button colour:
function showLink() {
  createCardbtn.classList.add("btnClick");
  createCardCollapsable.classList.remove("hideCollapsable");
}

6. Fetch

  • Handle API request:
function sendRequest() {
  fetch("https://us-central1-awesome-cards-cf6f0.cloudfunctions.net/card/", {
    method: "POST",
    body: JSON.stringify(form),
    headers: {
      "content-type": "application/json",
    },
  })
    .then(function (resp) {
      return resp.json();
    })
    .then(function (result) {
      showURL(result);
    })
    .catch(function (error) {
      console.log(error);
      cardLink.innerHTML = "Error en el servidor";
    });
}
  • Render API response:
function showURL(result) {
  if (result.success) {
    cardLink.href = result.cardURL;
    cardLink.innerHTML = cardLink.href;
  } else {
    cardLink.innerHTML = "ERROR: " + result.error;
  }
}
  • Share card link on Twitter:
function createTwitterLink(result) {
  const twitterText = encodeURIComponent(
    "Β‘Ya formo parte del mundo de las sombras gracias a DevilAPPers Profile Cards!:"
  );
  const twitterURL = cardLink.innerHTML;
  twitterButton.href = `https://twitter.com/intent/tweet?text=${twitterText}&url=${twitterURL}`;
}

7. LocalStorage

  • Set data in LocalStorage:
function setLocalStorage() {
  localStorage.setItem("formData", JSON.stringify(form));
}
  • Get data from LocalStorage:
function getLocalStorage() {
  const localFormData = JSON.parse(localStorage.getItem("formData"));
  if (localFormData !== null) {
    form = localFormData;
    document.querySelector(".js-nameInput").value = form.name;
    document.querySelector(".js-positionInput").value = form.job;
    document.querySelector(".js-tlInput").value = form.phone;
    document.querySelector(".js-emailInput").value = form.email;
    document.querySelector(".js-linkedinInput").value = form.linkedin;
    document.querySelector(".js-gitHubInput").value = form.github;
    profileImage.style.backgroundImage = `url(${form.photo})`;
    profilePreview.style.backgroundImage = `url(${form.photo})`;
    const selectedPalette = document.querySelector("#palette" + form.palette);
    selectedPalette.click();
  }
  renderCard();
  listenSaveField();
}

Folder Structure

Profile Cards
β”œβ”€β”€ docs
β”œβ”€β”€ node_modules
β”œβ”€β”€ src
β”‚   β”œβ”€β”€ html
β”‚   β”‚   β”œβ”€β”€ partials
β”‚   β”‚   β”‚   β”œβ”€β”€ footer.html
β”‚   β”‚   β”‚   β”œβ”€β”€ header.html
β”‚   β”‚   β”‚   β”œβ”€β”€ mainCard.html
β”‚   β”‚   β”‚   β”œβ”€β”€ mainDesign.html
β”‚   β”‚   β”‚   β”œβ”€β”€ mainForm.html
β”‚   β”‚   β”‚   β”œβ”€β”€ mainLanding.html
β”‚   β”‚   β”‚   β”œβ”€β”€ mainOptions.html
β”‚   β”‚   β”‚   β”œβ”€β”€ mainProfileCards.html
β”‚   β”‚   β”‚   β”œβ”€β”€ mainShare.html
β”‚   β”‚   β”‚   └── menu.html
β”‚   β”‚   β”œβ”€β”€ index.html
β”‚   β”‚   └── profileCards.html
β”‚   β”œβ”€β”€ images
β”‚   β”‚    β”œβ”€β”€ card_desktop.png
β”‚   β”‚    β”œβ”€β”€ card_mobile.png
β”‚   β”‚    β”œβ”€β”€ card_tablet.png
β”‚   β”‚    β”œβ”€β”€ default_image.gif
β”‚   β”‚    β”œβ”€β”€ landing_desktop.png
β”‚   β”‚    β”œβ”€β”€ landing_mobile.png
β”‚   β”‚    β”œβ”€β”€ landing_tablet.png
β”‚   β”‚    β”œβ”€β”€ logo-adalab.png
β”‚   β”‚    β”œβ”€β”€ logo-awesome-profile-cards.svg
β”‚   β”‚    └── logo-devilappers.svg
β”‚   β”œβ”€β”€ js
β”‚   β”‚    β”œβ”€β”€ 01collapsables.js
β”‚   β”‚    β”œβ”€β”€ 02palettes.js
β”‚   β”‚    β”œβ”€β”€ 03form.js
β”‚   β”‚    β”œβ”€β”€ 04card-image.js
β”‚   β”‚    β”œβ”€β”€ 05create-card.js
β”‚   β”‚    β”œβ”€β”€ 06fetch.js
β”‚   β”‚    └── 07localStorage.js
β”‚   └── scss
β”‚       β”œβ”€β”€ components
β”‚       β”‚   β”œβ”€β”€ _colorOptions.scss
β”‚       β”‚   β”œβ”€β”€ _mainForm.scss
β”‚       β”‚   └── _mainOptionsMenu.scss
β”‚       β”œβ”€β”€ core
β”‚       β”‚   β”œβ”€β”€ _reset.scss
β”‚       β”‚   └── _variables.scss
β”‚       β”œβ”€β”€ layout
β”‚       β”‚   β”œβ”€β”€ _footer.scss
β”‚       β”‚   β”œβ”€β”€ _header.scss
β”‚       β”‚   β”œβ”€β”€ _mainCard.scss
β”‚       β”‚   β”œβ”€β”€ _mainDesign.scss
β”‚       β”‚   β”œβ”€β”€ _mainLanding.scss
β”‚       β”‚   β”œβ”€β”€ _mainOptions.scss
β”‚       β”‚   β”œβ”€β”€ _mainProfileCards.scss
β”‚       β”‚   β”œβ”€β”€ _mainShare.scss
β”‚       β”‚   └── _page.scss
β”‚       └── main.scss
β”œβ”€β”€ .browserslistrc
β”œβ”€β”€ .csscomb.json
β”œβ”€β”€ .eslintrc.json
β”œβ”€β”€ .gitignore
β”œβ”€β”€ config.json
β”œβ”€β”€ gulp-flow.png
β”œβ”€β”€ gulpfile.js
β”œβ”€β”€ LICENSE
β”œβ”€β”€ package-lock.json
β”œβ”€β”€ package.json
β”œβ”€β”€ README.md
└── robots.txt

License

This project is licensed under GitHub

Languages

  • SCSS 38.8%
  • JavaScript 32.6%
  • HTML 28.6%