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.