Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                 <div class="popup">
      <div class="content">
        <h1 class="title-text">Add New Task</h1>
        <div class="input-container">
          <input class="new-task-input" type="text" />
        </div>
        <div class="btn-container">
          <a class="btn add-new-task-button disabled">ADD</a>
        </div>
      </div>
      <span class="close-btn">
        <img src="https://jssecrets.com/wp-content/uploads/2023/02/cross.svg" alt="close btn" />
      </span>
    </div>

    <div class="overlay"></div>
    <!-- ------------END popup-------------- -->

    <!-- tasks list -->
    <div class="tasks-list-container">
      <h1 class="tasks-list-title">Active tasks</h1>
      <ul class="tasks-list"></ul>
      <div class="add-new-task-container">
        <button class="plus-button hello">
          <img src="https://jssecrets.com/wp-content/uploads/2023/02/plus.svg" alt="add button" />
        </button>
      </div>
    </div>
    <!--END tasks list -->

    <!-- tabs -->
    <div class="tasks-list-settings">
      <ul class="tabs">
        <li class="tab active showActive">
          <span class="title">Active</span>
        </li>
        <li class="tab showCompleted">
          <span class="title">Completed</span>
        </li>
        <div class="slider"></div>
      </ul>
    </div>
    <!--END tabs -->

    <!-- made in jssecrets.com -->
    <a class="jssecrets" href="https://jssecrets.com/" target="_blank"
      >jssecrets.com</a
    >
    <!-- made in jssecrets.com -->
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;800&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Urbanist:wght@500&display=swap");
*,
::before,
::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}

ul {
  list-style: none;
}

.btn {
  padding: 16px 32px;
  font-size: 1em;
  border: none;
  outline: none;
  cursor: pointer;
  text-align: center;
  border-radius: 9px;
  position: relative;
  transition: all 0.2s linear;
}

body {
  height: 100vh;
  background: hsl(225deg, 14%, 12%);
  position: relative;
  overflow: hidden;
  color: #292d34;
}

.tasks-list-title {
  text-align: center;
  margin-bottom: 40px;
  color: white;
  font-size: 32px;
}
@media (max-width: 320px) {
  .tasks-list-title {
    font-size: 24px;
  }
}

.tasks-list-container {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  opacity: 1;
  transition: all 0.7s ease-out;
}

.tasks-list {
  width: 480px;
  margin-left: auto;
  margin-right: auto;
  border-radius: 10px;
  background-color: hsl(225deg, 14%, 17%);
  border: 1.5px solid rgba(0, 0, 0, 0.38);
  box-shadow: 0 8px 32px 0 hsl(225deg, 14%, 12%);
  backdrop-filter: blur(40px);
  padding: 24px;
}
@media (max-width: 575px) {
  .tasks-list {
    width: 400px;
    padding: 16px;
  }
}
@media (max-width: 440px) {
  .tasks-list {
    width: 360px;
    padding: 12px;
  }
}
@media (max-width: 400px) {
  .tasks-list {
    width: 300px;
  }
}
@media (max-width: 400px) {
  .tasks-list {
    width: 240px;
    padding: 8px;
  }
}
.tasks-list .task {
  width: 100%;
  padding: 16px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.5s ease-out;
  background-color: hsl(225deg, 14%, 22%);
  backdrop-filter: blur(40px);
  border: 1px solid rgba(0, 0, 0, 0.33);
  box-shadow: 0 8px 32px 0 hsl(225deg, 14%, 12%);
}
@media (max-width: 320px) {
  .tasks-list .task {
    padding: 8px;
  }
}
.tasks-list .task:not(:first-of-type) {
  margin-top: 16px;
}
.tasks-list .task.completed {
  display: none;
}
.tasks-list .task .complete-task {
  display: block;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background-color: transparent;
  border: 2px solid #56d0f5;
  box-shadow: 0 0 12px rgba(86, 208, 245, 0.5);
  cursor: pointer;
}
.tasks-list .task .complete-task.no-border {
  border: none;
}
.tasks-list .task .complete-task.empty {
  border: 2px solid #56d0f5;
}
.tasks-list .task .complete-task.empty .checkmark {
  opacity: 0;
  visibility: hidden;
}
.tasks-list .task .complete-task .checkmark {
  vertical-align: middle;
  fill-rule: evenodd;
  clip-rule: evenodd;
  stroke-linejoin: round;
  stroke-miterlimit: 10;
  box-shadow: inset 0px 0px 0px #56d0f5;
  border-radius: 50%;
  background-color: transparent;
  pointer-events: none;
}
.tasks-list .task .complete-task .checkmark * {
  fill: transparent;
  stroke: transparent;
}
.tasks-list .task .complete-task .checkmark.animated {
  animation: fill-checkmark 0.4s ease-in-out 0.4s forwards, scale 0.3s ease-in-out 0.9s both;
}
.tasks-list .task .complete-task .checkmark.animated .circle {
  fill: none;
  stroke-width: 2;
  stroke-miterlimit: 10;
  stroke: #56d0f5;
  stroke-dasharray: 79;
  stroke-dashoffset: 79;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.tasks-list .task .complete-task .checkmark.animated .check {
  fill: none;
  fill-rule: nonzero;
  stroke: #fff;
  stroke-width: 2.5px;
  stroke-dasharray: 23;
  stroke-dashoffset: 23;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
.tasks-list .task .delete-task {
  display: block;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  border: 2px solid hsl(354deg, 89%, 65%);
  box-shadow: 0 0 12px rgba(245, 86, 102, 0.5);
  background: transparent;
  cursor: pointer;
}
.tasks-list .task .delete-task.no-border {
  border: none;
}
.tasks-list .task .delete-task .crossmark {
  vertical-align: middle;
  fill-rule: evenodd;
  clip-rule: evenodd;
  stroke-linejoin: round;
  stroke-miterlimit: 10;
  box-shadow: inset 0px 0px 0px hsl(354deg, 89%, 65%);
  border-radius: 50%;
  background-color: transparent;
  pointer-events: none;
}
.tasks-list .task .delete-task .crossmark * {
  fill: transparent;
  stroke: transparent;
}
.tasks-list .task .delete-task .crossmark.animated {
  animation: fill-crossmark 0.4s ease-in-out 0.4s forwards, scale 0.3s ease-in-out 0.9s both;
}
.tasks-list .task .delete-task .crossmark.animated .circle {
  fill: none;
  stroke-width: 2;
  stroke-miterlimit: 10;
  stroke: hsl(354deg, 89%, 65%);
  stroke-dasharray: 79;
  stroke-dashoffset: 79;
  animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}
.tasks-list .task .delete-task .crossmark.animated .stick-1 {
  fill: none;
  stroke: #fff;
  stroke-width: 2px;
  stroke-dasharray: 18;
  stroke-dashoffset: 18;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
.tasks-list .task .delete-task .crossmark.animated .stick-2 {
  fill: none;
  stroke: #fff;
  stroke-width: 2px;
  stroke-dasharray: 18;
  stroke-dashoffset: 18;
  animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}
.tasks-list .task .task-name {
  width: calc(100% - 84px);
  font-size: 22px;
  font-weight: 500;
  color: white;
  border: none;
  outline: none;
  user-select: none;
  background: transparent;
  cursor: pointer;
  padding: 12px;
  border-radius: 12px;
}
@media (max-width: 400px) {
  .tasks-list .task .task-name {
    font-size: 16px;
  }
}
.tasks-list .task .task-name::selection {
  background: #f5cd51;
  color: white;
}
.tasks-list .task .task-name.isEditing {
  border: 2px solid #f7ce51;
  box-shadow: 0 10px 25px rgba(245, 205, 81, 0.4);
  background: transparent;
}
.tasks-list.showCompleted .task.active {
  display: none;
}
.tasks-list.showCompleted .task.completed {
  display: flex;
}
.tasks-list.showCompleted .task.completed .checkmark {
  box-shadow: inset 0px 0px 0px 30px #56d0f5;
  transform: none;
  pointer-events: none;
}
.tasks-list.showCompleted .task.completed .checkmark .circle {
  stroke-dashoffset: 0;
  fill: none;
  stroke-width: 2;
  stroke-miterlimit: 10;
  stroke: #56d0f5;
}
.tasks-list.showCompleted .task.completed .checkmark .check {
  stroke-dashoffset: 23;
  fill: none;
  fill-rule: nonzero;
  stroke: #fff;
  stroke-width: 2.5px;
}

.add-new-task-container {
  text-align: center;
  margin-top: 32px;
}
.add-new-task-container .plus-button {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background-color: hsl(225deg, 14%, 17%);
  border: 2px solid rgba(0, 0, 0, 0.38);
  box-shadow: 0 8px 32px 0 hsl(225deg, 14%, 12%);
  backdrop-filter: blur(40px);
  transition: all 0.3s ease-out;
}
.add-new-task-container .plus-button:hover {
  transform: translateY(-2px);
}
.add-new-task-container .plus-button img {
  vertical-align: middle;
}

.tasks-list-settings {
  width: 320px;
  border-radius: 10px;
  background-color: hsl(225deg, 14%, 17%);
  border: 1.5px solid rgba(0, 0, 0, 0.38);
  box-shadow: 0 8px 32px 0 hsl(225deg, 14%, 12%);
  backdrop-filter: blur(40px);
  padding: 16px;
  position: absolute;
  left: 50%;
  top: 5%;
  transform: translate(-50%, -5%);
  opacity: 1;
  transition: all 0.7s ease-out;
}
@media (max-width: 400px) {
  .tasks-list-settings {
    width: 240px;
    padding: 8px;
  }
}

.tabs {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}
.tabs .slider {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 100%;
  width: 50%;
  background: linear-gradient(45deg, rgb(245, 205, 81) 0%, rgb(247, 206, 81) 100%);
  box-shadow: 0 10px 25px rgba(245, 205, 81, 0.4);
  border-radius: 9px;
  z-index: 0;
  transition: all 0.3s linear;
}
.tabs .tab {
  width: 50%;
  height: 100%;
  display: block;
  text-align: center;
  cursor: pointer;
  padding: 16px 0 16px 0;
  border-radius: 9px;
  font-size: 16px;
  z-index: 1;
  position: relative;
  color: #7c828d;
  transition: all 0.3s linear;
}
.tabs .tab:hover {
  color: #f7ce51;
}
.tabs .tab .title {
  font-size: 16px;
}
.tabs .tab.active .title {
  font-weight: 900;
  color: hsl(225deg, 14%, 12%);
}
.tabs .tab:nth-of-type(1).active ~ .slider {
  left: 0;
}
.tabs .tab:nth-of-type(2).active ~ .slider {
  left: 50%;
}

.overlay {
  position: fixed;
  z-index: 1000;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: hsla(225deg, 14%, 14%, 0.0025);
  transition: all 1s;
  opacity: 0;
  visibility: hidden;
}

.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 50%;
  height: auto;
  max-width: 630px;
  min-width: 320px;
  z-index: 2000;
  visibility: hidden;
  backface-visibility: hidden;
  transform: translateX(-50%) translateY(-50%);
  perspective: 1300px;
}
@media (max-width: 400px) {
  .popup {
    min-width: 240px;
  }
}
.popup .content {
  padding: 24px;
  padding-top: 48px;
  padding-bottom: 48px;
  border-radius: 9px;
  box-shadow: 0 10px 25px rgba(124, 130, 141, 0.2);
  transition: all 0.7s;
  transform: rotateX(-70deg);
  opacity: 0;
  transform-style: preserve-3d;
  background-color: hsl(225deg, 14%, 17%);
  backdrop-filter: blur(4.5px);
  -webkit-backdrop-filter: blur(4.5px);
  border: 1.5px solid rgba(0, 0, 0, 0.38);
  box-shadow: 0 8px 32px 0 hsl(225deg, 14%, 12%);
}
@media (max-width: 400px) {
  .popup .content {
    padding: 48px 12px;
  }
}
.popup .content .input-container {
  text-align: center;
  margin-bottom: 48px;
}
@media (max-width: 400px) {
  .popup .content .input-container {
    margin-bottom: 16px;
  }
}
.popup .content .input-container .new-task-input {
  width: 100%;
  border: 2px solid #f7ce51;
  box-shadow: 0 10px 25px rgba(245, 205, 81, 0.4);
  background: transparent;
  outline: none;
  font-size: 24px;
  padding: 16px;
  border-radius: 12px;
  color: white;
  transform: translateY(100px);
  transition: all 0.8s ease-out;
  opacity: 0.1;
}
@media (max-width: 400px) {
  .popup .content .input-container .new-task-input {
    font-size: 16px;
    padding: 8px;
  }
}
.popup .content .title-text {
  text-align: center;
  margin-bottom: 16px;
  transform: translateY(80px);
  transition: all 0.7s ease-out;
  opacity: 0.1;
  color: white;
  font-size: 32px;
}
@media (max-width: 400px) {
  .popup .content .title-text {
    font-size: 20px;
  }
}
.popup .content .btn-container {
  text-align: center;
  transform: translateY(120px);
  transition: all 0.9s ease-out;
  opacity: 0.1;
}
.popup .content .btn-container .btn {
  background: linear-gradient(45deg, rgb(245, 205, 81) 0%, rgb(247, 206, 81) 100%);
  box-shadow: 0 10px 25px rgba(245, 205, 81, 0.4);
  color: white;
  transition: all 0.9s ease;
  opacity: 0.9;
}
@media (max-width: 400px) {
  .popup .content .btn-container .btn {
    font-size: 16px;
    padding: 8px 12px;
  }
}
.popup .content .btn-container .btn:hover {
  opacity: 1;
}
.popup .content .btn-container .btn.disabled {
  background: #b9bec7;
  box-shadow: 0 8px 16px rgba(185, 190, 199, 0.0025);
  pointer-events: none;
  opacity: 0.5;
}
.popup .close-btn {
  position: absolute;
  top: 4px;
  right: 11px;
  font-size: 2em;
  color: white;
  cursor: pointer;
  transition: all 0.7s;
  opacity: 0;
  transform: rotateY(90deg);
}
.popup.show {
  visibility: visible;
}
.popup.show ~ .overlay {
  opacity: 1;
  visibility: visible;
}
.popup.show .content {
  transform: rotateX(0deg);
  opacity: 1;
}
.popup.show .content .title-text {
  transform: translateY(0px);
  opacity: 1;
}
.popup.show .content .new-task-input {
  transform: translateY(0px);
  opacity: 1;
}
.popup.show .content .btn-container {
  transform: translateY(0px);
  opacity: 1;
}
.popup.show .close-btn {
  opacity: 0.7;
  transform: rotateY(0deg);
}
.popup.show ~ .tasks-list-container {
  transform: translate(-50%, calc(-50% + 200px));
  opacity: 0;
}
.popup.show ~ .tasks-list-settings {
  transform: translate(-50%, calc(-50% - 200px));
  opacity: 0;
}

@keyframes stroke {
  100% {
    stroke-dashoffset: 0;
  }
}
@keyframes scale {
  0%, 100% {
    transform: none;
  }
  50% {
    transform: scale3d(1.1, 1.1, 1);
  }
}
@keyframes fill-checkmark {
  100% {
    box-shadow: inset 0px 0px 0px 30px #56d0f5;
  }
}
@keyframes fill-crossmark {
  100% {
    box-shadow: inset 0px 0px 0px 30px hsl(354deg, 89%, 65%);
  }
}
.jssecrets {
  font-weight: 500;
  text-decoration: none !important;
  font-family: "Urbanist";
  padding: 16px;
  background: #ffc805;
  color: #000000;
  font-size: 1.2em;
  letter-spacing: 0.2px;
  border-radius: 8px;
  box-shadow: 0px 4px 12px rgba(184, 144, 0, 0.1882352941), 0px 8px 24px rgba(184, 144, 0, 0.3764705882);
  position: absolute;
  bottom: 24px;
  right: 24px;
  transition: all 0.3s;
}

.jssecrets:hover {
  transform: translateY(-4px);
}
              
            
!

JS

              
                // Varibles
//////////////////////////////////////////////
const plusButton = document.querySelector('.plus-button');
const popup = document.querySelector('.popup');
const addNewTaskButton = document.querySelector('.add-new-task-button');
const tasksList = document.querySelector('.tasks-list');
const newTaskInput = document.querySelector('.new-task-input');
const tabs = document.querySelectorAll('.tabs .tab');
const tasksListTitle = document.querySelector('.tasks-list-title');
const popupCloseBtn = document.querySelector('.close-btn');

//////////////////////////////////////////////
// Functions
//////////////////////////////////////////////
// Utility functions

// addClass function - adds class to an element
const addClass = (element, className) => {
  element.classList.add(className);
};

// removeClass function - removes class from an element
const removeClass = (element, className) => {
  element.classList.remove(className);
};

// I've decided to create and use them,
// as there are many occurrences of this functionality
/////////////////////////////////ß/////////////

// 1. Show popup
// reveals popup window for adding new task
const showPopup = () => {
  addClass(popup, 'show');
};

// 2. Add new task
// adds new task
// I use prepared HTML
// each "Task" component consists of three elements
// "Complete" button. I use <svg>, as I have an animation effect.
// Input field. I use <input>, and not some text element, as I need to have editing functionality
// "Delete" button. I use <svg>, as I have an animation effect.
const addNewTask = () => {
  tasksList.insertAdjacentHTML(
    'beforeend',
    `<li class="task active">

        <span class="complete-task" onclick="completeTask(event)">
        <svg
        class="checkmark"
        xmlns="http://www.w3.org/2000/svg"
        viewBox="0 0 26 26"
      >
        <circle class="circle" cx="13" cy="13" r="12.5" />
        <path class="check" d="m5 13.807 4.773 4.84L21 7.353" />
      </svg>
        </span>

        <input class="task-name" ondblclick="editTask(event)" onclick="saveTask(event)" value="${newTaskInput.value}" type="text" readonly />

        <span class="delete-task" onclick="deleteTask(event)">
        <svg
        class="crossmark"
        xmlns="http://www.w3.org/2000/svg"
        viewBox="0 0 26 26"
      >
        <circle class="circle" cx="13" cy="13" r="12.5" />
        <path class="stick-1" d="m6.69 6.69 12.62 12.62" />
        <path class="stick-2" d="M6.69 19.31 19.31 6.69" />
      </svg>
        </span>
      </li>`
  );

  // set states to default

  // clean "new task" input
  newTaskInput.value = '';
  // close popup
  removeClass(popup, 'show');
  // disable "Add" button
  addClass(addNewTaskButton, 'disabled');
};

// 3. Delete task animation
const deleteTask = (event) => {
  // animation classes
  addClass(event.currentTarget, 'no-border');
  addClass(event.currentTarget.firstElementChild, 'animated');

  // I use timer, so the animation could finish
  setTimeout(() => {
    // remove "Task" component from DOM
    event.target.parentElement.remove();
  }, 1800);
};

// 4. Complete task
const completeTask = (event) => {
  //
  // animation classes
  addClass(event.currentTarget, 'no-border');
  addClass(event.currentTarget.firstElementChild, 'animated');
  removeClass(event.currentTarget, 'empty');
  //
  // I set "unCompleteTask" function onClick
  // if user decides to move the task from "Completed" back into "Active"
  event.currentTarget.setAttribute('onclick', 'unCompleteTask(event)');

  // I use timer, so the animation could finish
  setTimeout(() => {
    addClass(event.target.parentElement, 'active');
    addClass(event.target.parentElement, 'completed');
    removeClass(event.target.firstElementChild, 'animated');
  }, 1800);
};

// 4.1. Uncomplete task
const unCompleteTask = (event) => {
  // animation classes
  removeClass(event.currentTarget, 'no-border');
  addClass(event.currentTarget, 'empty');
  //
  // I set "completeTask" function onClick
  // so user can move the task from "Active" to "Completed"
  event.currentTarget.setAttribute('onclick', 'completeTask(event)');

  // I use timer, so the animation could finish
  setTimeout(() => {
    addClass(event.target.parentElement, 'active');
    removeClass(event.target.parentElement, 'completed');
  }, 300);
};

// 5. Edit task
const editTask = (event) => {
  // I remove "readonly" attribute, so user can access the input
  event.currentTarget.removeAttribute('readonly');
  // highlighting input to indicate the active state
  addClass(event.currentTarget, 'isEditing');
};

// 6. Save task
const saveTask = (event) => {
  // I add "readonly" attribute, so user can't access the input
  event.currentTarget.setAttribute('readonly', 'readonly');
  // remove the highlighting
  removeClass(event.currentTarget, 'isEditing');
};

// 7. Set active tab
const setActiveTab = (event) => {
  // tabs indication
  removeClass(document.querySelector('.tab.active'), 'active');
  addClass(event.currentTarget, 'active');

  // toggle between "Active" and "Completed" tasks
  if (event.currentTarget.classList.contains('showCompleted')) {
    addClass(tasksList, 'showCompleted');
    tasksListTitle.innerText = 'Completed tasks';
  } else {
    removeClass(tasksList, 'showCompleted');
    tasksListTitle.innerText = 'Active tasks';
  }
};

// 8. Check if input is empty
const ifEmpty = () => {
  // if new "Task" is empty then the "Add" button is disabled
  if (!newTaskInput.value.trim().length || newTaskInput.value === '') {
    addClass(addNewTaskButton, 'disabled');
  } else {
    removeClass(addNewTaskButton, 'disabled');
  }
};

// 9. Close popup
const closePopup = () => {
  // clear the input
  newTaskInput.value = '';
  // close the popup
  removeClass(popup, 'show');
  // disable the button
  addClass(addNewTaskButton, 'disabled');
};

//////////////////////////////////////////////
// Event listeners
//////////////////////////////////////////////
plusButton.addEventListener('click', showPopup);
//
addNewTaskButton.addEventListener('click', addNewTask);
//
tabs.forEach((tab) => {
  tab.addEventListener('click', setActiveTab);
});
//
newTaskInput.addEventListener('input', ifEmpty);
//
popupCloseBtn.addEventListener('click', closePopup);

              
            
!
999px

Console