DEV Community

Cover image for โœจ Building a Cosmic Note-Taking App: A Journey Through Space and Code
Arvin Jafary
Arvin Jafary

Posted on

โœจ Building a Cosmic Note-Taking App: A Journey Through Space and Code

Have you ever wanted to take your note-taking experience to the next level? ๐ŸŒŒ What if I told you we could create a beautiful, interactive note-taking application that feels like you're writing in the cosmos? In this article, I'll walk you through the creation of "Cosmic Notes" - a space-themed note-taking application built with vanilla JavaScript and CSS. Let's embark on this cosmic coding adventure! ๐Ÿ›ธ

๐ŸŒŸ Features That Will Blow Your Mind

  • โœจ Beautiful cosmic-themed UI with animated stars and particles
  • ๐Ÿ“ Create, read, update, and delete notes with ease
  • ๐ŸŽจ Color-coded notes with different themes
  • ๐Ÿท๏ธ Tag system for better organization
  • ๐Ÿ” Real-time search functionality
  • ๐Ÿ“ฑ Responsive design for both desktop and mobile
  • ๐ŸŒˆ Smooth animations and transitions
  • ๐ŸชŸ Interactive modal system

๐Ÿš€ Getting Started with the Cosmos

The project structure is as clean as a starry night:

๐ŸŸฉ Cosmic Notes/
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ design/                   # Visual design references
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ฑ mobile-design.jpg     # Mobile viewport designs
โ”‚   โ””โ”€โ”€ ๐Ÿ–ฅ๏ธ desktop-design.jpg    # Desktop viewport designs
โ”‚
โ”œโ”€โ”€ ๐Ÿ“ src/                      # Source code organization
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ styles/               # CSS architecture
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ main.css          # Primary stylesheet
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ reset.css         # CSS normalization
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ typography.css    # Text styling presets
โ”‚   โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ variables.css     # Design tokens & fonts
โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“„ ...
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ ๐Ÿ“ scripts/              # JavaScript modules
โ”‚   โ”‚   โ””โ”€โ”€ ๐Ÿ“„ app.js            # Main application logic
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ ๐Ÿ“ assets/               # All project assets
โ”‚        โ”œโ”€โ”€ ๐Ÿ“ fonts/           # fonts assets
โ”‚        โ”‚   โ”œโ”€โ”€ ๐Ÿ—› Inter.ttf
โ”‚        โ”‚   โ””โ”€โ”€ ๐Ÿ—› Orbitron.ttf
โ”‚        โ”‚
โ”‚        โ””โ”€โ”€ ๐Ÿ“ images/          # Images and icons
โ”‚            โ””โ”€โ”€ ๐Ÿ–ผ๏ธ preview.gif
โ”‚
โ”œโ”€โ”€ ๐Ÿ“„ index.html                # Main entry point with semantic HTML
โ”œโ”€โ”€ ๐Ÿ“„ README.md                 # Project documentation & deployment guide
โ”œโ”€โ”€ ๐Ÿ“„ style-guide.md            # Design system specifications
โ”œโ”€โ”€ ๐Ÿ“„ .gitignore                # Version control exclusions
โ””โ”€โ”€ ๐Ÿ“„ DEVELOPMENT.md            # Learning notes & challenges faced
Enter fullscreen mode Exit fullscreen mode

๐Ÿ’ซ Creating the Cosmic Background

One of the most eye-catching features of our app is the animated starry background. Here's how we bring the cosmos to life:

function generateStarField() {
  const starField = document.getElementById("stars");
  if (!starField) return;

  Array.from({ length: 100 }).forEach(() => {
    const star = document.createElement("div");
    star.className = "star";
    star.style.left = `${Math.random() * 100}%`;
    star.style.top = `${Math.random() * 100}%`;
    star.style.animationDelay = `${Math.random() * 3}s`;
    starField.appendChild(star);
  });
}
Enter fullscreen mode Exit fullscreen mode

We also add some magical particle effects to make the background more dynamic:

function startParticleEffects() {
  setInterval(() => {
    if (Math.random() < 0.1) createParticle();
  }, 200);
}

function createParticle() {
  const particle = document.createElement("div");
  particle.className = "particle";
  particle.style.left = `${Math.random() * 100}%`;
  particle.style.background = `hsl(${Math.random() * 360}, 70%, 70%)`;
  document.body.appendChild(particle);
  setTimeout(() => particle.remove(), 4000);
}
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“ Managing Your Cosmic Notes

The core functionality of our app revolves around managing notes. Each note is like a star in our cosmic collection:

{
  title: "Note Title", // ๐ŸŒŸ
  content: "Note content", // ๐Ÿ“„
  date: "Creation date", // ๐Ÿ“…
  color: "theme color", // ๐ŸŽจ
  tag: "category", // ๐Ÿท๏ธ
  completed: false // โœ…
}
Enter fullscreen mode Exit fullscreen mode

โœจ Creating New Notes

The note creation process is handled through a magical modal interface:

function handleNoteCreation() {
  const addNoteBtn = document.querySelector(".actio-btn__add");

  addNoteBtn.addEventListener("click", (e) => {
    e.preventDefault();

    const title = document.querySelector("#form__name").value.trim();
    const content = document.querySelector("#form__textarea").value.trim();
    const color = document.querySelector(".colorpictext").value || "blue";
    const tag = document.querySelector("#note-tag").value.trim() || "General";

    if (!title || !content) {
      alert(
        "๐ŸŒŸ Please fill out both title and content to create your cosmic note!"
      );
      return;
    }

    const newNote = {
      title,
      content,
      date: new Date().toLocaleDateString(),
      color,
      tag,
      completed: false,
    };

    notes.push(newNote);
    renderNotes(notes);
  });
}
Enter fullscreen mode Exit fullscreen mode

๐Ÿ” Searching Through the Cosmos

The app includes a powerful real-time search feature that helps you find your notes across the universe:

function bindSearch() {
  const input = document.querySelector(".input__search");

  input.addEventListener("input", () => {
    const query = input.value.toLowerCase().trim();

    if (query === "") {
      renderNotes(notes);
    } else {
      const filtered = notes.filter(
        (note) =>
          note.title.toLowerCase().includes(query) ||
          note.content.toLowerCase().includes(query) ||
          note.tag.toLowerCase().includes(query)
      );
      renderNotes(filtered);
    }
  });
}
Enter fullscreen mode Exit fullscreen mode

๐ŸŽจ Painting the Cosmos with Colors

Users can choose from different color themes for their notes, each representing a different cosmic energy:

  • ๐ŸŒธ Pink - The energy of creativity
  • ๐Ÿ’  Cyan - The power of wisdom
  • ๐Ÿ’œ Purple - The mystery of the cosmos
  • ๐ŸŠ Orange - The warmth of inspiration
  • ๐Ÿ’™ Blue - The calm of the universe

The color picker is implemented with a simple click handler:

function initColorPicker() {
  const colorPickText = document.querySelector(".colorpictext");

  document.querySelectorAll(".option").forEach((option) => {
    option.addEventListener("click", () => {
      document
        .querySelectorAll(".option")
        .forEach((el) => el.classList.remove("active"));
      option.classList.add("active");

      if (colorPickText) {
        colorPickText.value = option.classList[1];
      }
    });
  });
}
Enter fullscreen mode Exit fullscreen mode

๐ŸŒˆ Magical UI/UX Features

The app includes several user experience enhancements that make it feel like magic:

  1. โœจ Smooth animations for note transitions
  2. ๐ŸŽฏ Toast notifications for user actions
  3. โš ๏ธ Confirmation dialogs for destructive actions
  4. ๐Ÿ“ฑ Responsive design that works on both desktop and mobile
  5. ๐ŸชŸ Interactive modal system for note creation and editing

๐ŸŽฏ Future Cosmic Improvements

Some potential improvements to make our app even more stellar:

  1. ๐Ÿ’พ Add local storage to persist notes
  2. ๐ŸŽฎ Implement drag-and-drop functionality
  3. ๐ŸŽจ Add more color themes
  4. ๐Ÿ“ Include markdown support
  5. ๐Ÿ“ค Add export/import functionality
  6. ๐Ÿ” Implement user authentication
  7. โ˜๏ธ Add cloud sync capabilities

๐Ÿš€ Conclusion: To Infinity and Beyond!

Building Cosmic Notes was a fun project that demonstrates how vanilla JavaScript and CSS can create beautiful, interactive web applications. The space theme adds a unique touch to the traditional note-taking experience, making it more engaging and enjoyable to use.

You can find the complete source code on GitHub. Feel free to fork it, modify it, and make it your own! ๐ŸŒŸ

๐Ÿ”— Resources to Launch Your Journey


Made with โค๏ธ by Arvin Jafary ๐Ÿ‘จโ€๐Ÿ’ป

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.