fix: format template source codes and implement non destructive cache migration#152
Open
theblag wants to merge 1 commit into
Open
fix: format template source codes and implement non destructive cache migration#152theblag wants to merge 1 commit into
theblag wants to merge 1 commit into
Conversation
Contributor
|
@theblag is attempting to deploy a commit to the debmallya-03's projects Team on Vercel. A member of the Team first needs to authorize it. |
❌ Deploy Preview for webifynet failed. Why did it fail? →
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue: #117
Description
This PR formats all built-in template codes (HTML, CSS, and JS) to use clean, readable, multi-line formatting instead of the previous single-line minified layouts. It also introduces a type-safe, non-destructive upgrade migration for browser profiles that have cached template code in localStorage.
Changes
Template Code Formatting: Reformatted template contents (landing-page, interactive-card, todo-app, stopwatch, login-form, and signup-form) to make them readable.
Non-Destructive Cache Upgrade: Updated the useState initializer and loadTemplate handler to whitespace-insensitively match stored user cache against default templates. If the cached template code is unmodified, it automatically upgrades to the formatted versions.
TypeScript Compilation Fix: Resolved a type assignment error in loadTemplate where undefined was being assigned to a CodeContent type.
NOTE
Important Note on Cached Browser Memory (LocalStorage) If a user has previously loaded a template and made even a minor modification to their code (like adding a space or changing text), the code is treated as customized and will persist as-is. It will not be auto-formatted to avoid wiping out user changes. In these cases, users can format their code manually using the built-in Format code button in the UI (Ctrl + K -> "Format code") or clear their browser's local cache.