A small, beginner-friendly web app to manage a personal book library. Add books, mark them read/unread, remove books — and everything persists in your browser via localStorage. Perfect as a portfolio piece or as the basis for a React rewrite.
- Add books (title, author, pages, read status) via a modal form
- List books as responsive cards
- Toggle read / unread on each book
- Delete books with confirmation
- Data persisted in
localStorageso your library survives page reloads - Clean, responsive CSS and accessible
<dialog>modal - Simple, easy-to-follow code — great for beginners
- HTML5
- CSS3
- Vanilla JavaScript (ES6+)
localStoragefor persistence
No build tools or Node required to run the current project. You only need a modern browser.
If you prefer to run a tiny local server (recommended for consistent behavior of the <dialog> element), you can use one of these:
-
python(any version 3+):python -m http.server 3000
-
npx serve(Node):npx serve .
-
Clone the repo:
git clone <your-repo-url> cd <your-repo-folder>
-
Open
index.htmldirectly in your browser or run a simple server (recommended):python -m http.server 3000 # then open http://localhost:3000 in your browser
/ (repo root)
├── index.html # main markup, includes <dialog> modal
├── style-cp.css # main stylesheet (cards, dialog styling)
├── script.js # all app logic (Book constructor, display, handlers, storage)
├── dashboard-project.png # screenshot (optional)
└── README.md
Bookconstructor creates book objects with acrypto.randomUUID()id and atoggleRead()prototype method.myLibraryarray holds all Book instances.displayLibrary()renders the array into "cards" inside#library-container.- Actions (toggle, delete) are handled with event delegation on the container using
data-idattributes to map DOM to data. saveLibrary()/loadLibrary()serialize the array to JSON and restore instances on load (so prototype methods still work).
- To add undo for deletes: store a temporary backup of the deleted book and offer “Undo” for a few seconds.
- For validation improvements: replace
alert()with inline validation messages in the modal. - Accessibility: ensure focus is trapped inside the modal while open, and return focus back to the New Book button after close.
- To add tests: convert logic functions to pure functions (where helpful) and test with Jest.
You mentioned rebuilding in React — here’s a simple plan:
-
Initialize a React app (Vite recommended for speed):
npm create vite@latest library-react -- --template react cd library-react npm install npm run dev -
Create components:
App— root container + stateBookCard— displays one book (toggle/delete)BookFormModal— add/edit formLibraryGrid— layout for cards
-
Keep persistence with
localStorage(useuseEffectto sync). -
Optionally add Context or Zustand for state if app grows.
If you’d like, I can scaffold the full React version for you (components, CSS, and localStorage integration).
Contributions are welcome. If you want to suggest features or send improvements:
- Fork the repo
- Create a feature branch:
git checkout -b feat/my-feature - Commit your changes and open a PR with a short description
This project is released under the MIT License — feel free to use it for learning, portfolio, or personal projects.
