Skip to content

Conversation

zhravan
Copy link
Owner

@zhravan zhravan commented May 2, 2025

Summary by CodeRabbit

  • New Features

    • Added sidebar navigation with responsive and dark mode support.
    • Introduced animated header with action buttons for dark mode toggle and shortcuts.
    • Enhanced mock data generator UI with clearer grouping and additional output/stats containers.
  • Improvements

    • Restructured app layout from header-based to sidebar-driven navigation.
    • Improved tree view and preview sections with scrolling, spacing, and styled scrollbars.
    • Added responsive design adjustments for mobile and tablet viewports.
  • Style

    • Added comprehensive CSS for new layout components, including sidebar, main content, and mobile controls.
    • Enhanced mock preview table styling with sticky headers, error states, and dark mode variants.
    • Updated scrollbar theming for both light and dark modes.
  • Chores

    • Added pre-commit hooks enforcing formatting, linting, and validation.
    • Introduced Biome configuration for consistent code formatting and linting.
    • Updated package scripts and dependencies to support new tooling and workflows.

Copy link

coderabbitai bot commented May 2, 2025

Walkthrough

This update adds tooling and configuration to improve code quality and developer workflow. A Husky pre-commit hook is introduced to run formatting, linting, and checks before commits. The Biome toolchain is configured via a new biome.json file to enforce code style, lint rules, and import organization with specific rules disabled. Corresponding npm scripts and dependencies for Biome and Husky are added in package.json. The CSS file is extended with new styles supporting a sidebar-driven app layout, responsive design, tree view component with scrolling and dark mode theming, and a styled mock preview table. The HTML document is restructured from a simple header to a sidebar navigation layout with animated header and expanded mock data generator section. The document title is updated accordingly.

Changes

File(s) Change Summary
.husky/pre-commit Added pre-commit hook script to run format, lint, and check npm scripts sequentially before commits.
biome.json Added Biome configuration enabling import organization, linting with recommended rules, and formatting with custom style preferences.
package.json Added npm scripts: format, lint, check, prepare; added devDependencies @biomejs/biome and husky.
index.css Added comprehensive new app layout styles with sidebar navigation and main content area; responsive and dark mode adjustments; added .tree-view with scrolling and custom scrollbar styling; enhanced .preview-section and .tree-node spacing; styled .mock-preview-table with sticky headers, error states, and responsive horizontal scrolling.
index.html Changed document title from "JSONP - Multi tab JSON toolkit" to "JSONP - Dev toolkit"; restructured UI from top header to sidebar navigation with feature items and mobile toggle; added animated header with action buttons; expanded mock data generator section layout; reformatted shortcut modal list items.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Git
    participant Husky Pre-commit Hook
    participant NPM Scripts (format/lint/check)
    User->>Git: git commit
    Git->>Husky Pre-commit Hook: Trigger pre-commit
    Husky Pre-commit Hook->>NPM Scripts (format): Run format
    NPM Scripts (format)-->>Husky Pre-commit Hook: Success/Fail
    alt Format success
        Husky Pre-commit Hook->>NPM Scripts (lint): Run lint
        NPM Scripts (lint)-->>Husky Pre-commit Hook: Success/Fail
        alt Lint success
            Husky Pre-commit Hook->>NPM Scripts (check): Run check
            NPM Scripts (check)-->>Husky Pre-commit Hook: Success/Fail
            alt Check success
                Husky Pre-commit Hook->>Git: Allow commit
            else Check fail
                Husky Pre-commit Hook-->>User: Abort commit
            end
        else Lint fail
            Husky Pre-commit Hook-->>User: Abort commit
        end
    else Format fail
        Husky Pre-commit Hook-->>User: Abort commit
    end
Loading

Possibly related PRs

  • feat: mock data generator #32: Implements the mock data generator feature with UI, logic, and related CSS; related to this PR’s styling additions for the mock preview table.

Poem

🐇
A pre-commit hop, so neat and tight,
Formatting, linting, all just right.
Sidebar gleams with colors bright,
Scrollbars dance in dark mode light.
This bunny’s toolkit takes a flight,
Code and style in pure delight!
🌙✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@zhravan zhravan changed the title feat: add text editor and move to SWAL2 feat: setup biome and formatting May 2, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (7)
index.html (7)

10-19: Secure external resource loading with SRI and crossorigin.
The CDN imports for Font Awesome, Faker, Marked, Toast UI Editor, and SweetAlert2 currently lack Subresource Integrity (integrity attribute) and the crossorigin setting, which helps prevent tampering and MITM attacks.

Example diff for Font Awesome:

-<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" />
+<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"
+      integrity="sha384-…"
+      crossorigin="anonymous" />

11-15: Consolidate Faker imports to a single module.
You load Faker via <script src="…/faker@8.4.0/+esm" type="module"> and immediately re-import it in the next <script type="module">. Consider dropping the first <script src> or merging into one import that assigns window.faker.


26-31: Move inline event handlers to JavaScript.
Inline onclick attributes on buttons (dark-mode toggle, shortcut modal, mode selectors) scatter behavior across markup. For cleaner separation of concerns and easier testing, bind these event listeners in index.js using addEventListener.

Also applies to: 37-60


24-24: Extract inline styles into CSS classes.
Multiple elements use style="display: flex;…" or style="display: none". Define utility classes (e.g., .hidden, .flex-center) in your stylesheet and toggle those classes via JS or by default in markup.

Also applies to: 77-77, 89-89, 101-101, 173-178


26-28: Specify type="button" on non-submit buttons.
Buttons default to type="submit" in form contexts. Even if not inside a form today, it's safer to declare <button type="button"> explicitly to guard against future refactoring into a form.

Also applies to: 37-39


189-195: Enhance modal accessibility with ARIA attributes.
The shortcut modal uses a <div> and <span> without ARIA roles. Add role="dialog", aria-modal="true", and link the close button with aria-label or aria-labelledby. Replace the <span> close icon with a <button type="button"> for better keyboard support.


153-154: Use a descriptive ID for the file-name input.
The download name <input id="userInput"> is generic and may collide elsewhere. Rename to something like mockgen-filename to clarify its purpose and avoid potential conflicts.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07b1e14 and d0b1ccf.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • .husky/pre-commit (1 hunks)
  • biome.json (1 hunks)
  • index.css (1 hunks)
  • index.html (1 hunks)
  • package.json (2 hunks)
🔇 Additional comments (8)
package.json (2)

7-11: Well-structured npm scripts for code quality enforcement.

The added scripts properly integrate the Biome toolchain and Husky for enforcing code quality standards. The sequential execution in the pre-commit hook will ensure all code meets formatting and linting standards before being committed.


24-26: Appropriate dependencies with proper versioning.

The added development dependencies use caret versioning (^) which allows for compatibility with minor and patch updates while maintaining major version stability. Both tools are industry-standard choices for code quality maintenance.

.husky/pre-commit (1)

1-4: Well-configured pre-commit hook.

The hook is correctly set up to source Husky's environment and execute the code quality scripts in the right order.

biome.json (1)

1-32: Comprehensive Biome configuration with well-considered rule selections.

The configuration establishes a solid foundation for code quality with:

  • Automatic import organization
  • Recommended linting rules with sensible exceptions (noForEach and useTemplate disabled)
  • Consistent formatting settings (2-space indentation, 100 character line width)
  • JavaScript-specific rules that align with industry practices

This configuration will help maintain consistent code style across the project.

index.css (3)

453-466: Well-designed language-specific code output styling.

The distinct styling for different languages (Python, Go, TypeScript) provides good visual differentiation while maintaining a consistent theme. This enhances usability when working with multiple language outputs.


623-673: Comprehensive dark mode styling for Toast UI Editor.

The dark mode implementation for the editor is thorough, applying appropriate styling to all editor components including toolbar, content areas, and code blocks. The use of !important is justified here to override the editor's default styling.


582-616: Clean tab management styling for editor section.

The styling for the editor section's tab navigation is well-organized and consistent with the overall UI design. The active tab states and content visibility rules are properly implemented.

index.html (1)

178-184: Verify Markdown Editor initialization.
The editor-section only provides an empty tabs container and a content placeholder. Confirm that addEditorTab() in index.js correctly instantiates Toast UI Editor instances, attaches them to the DOM, and applies the intended themes.

Comment on lines 491 to 580
.tree-children {
margin-left: 20px;
overflow: hidden;
transition: max-height 0.3s ease, opacity 0.3s ease;
max-height: 1000px;
opacity: 1;
}

.tree-children.collapsed {
max-height: 0;
opacity: 0;
pointer-events: none;
}

.tree-key {
position: relative;
cursor: pointer;
padding: 4px 6px;
display: inline-block;
border-radius: 3px;
transition: background-color 0.2s ease, box-shadow 0.2s ease;
outline: none;
}

.tree-key:hover,
.tree-key:focus {
background-color: rgba(0, 123, 255, 0.12);
box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.tree-key:active {
background-color: rgba(0, 123, 255, 0.25);
}

.tree-key::before {
content: "\25B6";
display: inline-block;
transition: transform 0.2s ease;
margin-right: 6px;
font-size: 0.8em;
color: #555;
}

.tree-key.expanded::before {
transform: rotate(90deg);
color: #007bff;
}

.tree-key .node-info {
font-size: 0.8em;
color: #999;
margin-left: 6px;
}

.tree-key[title] {
position: relative;
}

.tree-key[title]:hover::after {
content: attr(title);
position: absolute;
top: 100%;
left: 0;
background: rgba(0, 0, 0, 0.75);
color: #fff;
font-size: 12px;
padding: 4px 6px;
border-radius: 4px;
white-space: nowrap;
margin-top: 4px;
z-index: 10;
pointer-events: none;
}

body.dark-mode .tree-key[title]:hover::after {
background: rgba(255, 255, 255, 0.1);
color: #e0e0e0;
border: 1px solid #666;
}

/* Accessibility: keyboard focus outline */
.tree-key:focus-visible {
outline: 2px solid #007bff;
outline-offset: 2px;
}

/* Shift-click recursive expand/collapse (JS logic must add 'recursive' class to target for styling if needed) */
.tree-key.shift-toggle {
background-color: rgba(0, 123, 255, 0.08);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove duplicated CSS code for tree components.

There's significant code duplication between lines 345-423 and 491-580, both containing nearly identical CSS rules for tree view components. This duplication makes maintenance difficult and increases the file size unnecessarily.

Remove the duplicated section:

-
-.tree-children {
-  margin-left: 20px;
-  overflow: hidden;
-  transition: max-height 0.3s ease, opacity 0.3s ease;
-  max-height: 1000px;
-  opacity: 1;
-}
-
-.tree-children.collapsed {
-  max-height: 0;
-  opacity: 0;
-  pointer-events: none;
-}
-
-.tree-key {
-  position: relative;
-  cursor: pointer;
-  padding: 4px 6px;
-  display: inline-block;
-  border-radius: 3px;
-  transition: background-color 0.2s ease, box-shadow 0.2s ease;
-  outline: none;
-}
-
-.tree-key:hover,
-.tree-key:focus {
-  background-color: rgba(0, 123, 255, 0.12);
-  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
-}
-
-.tree-key:active {
-  background-color: rgba(0, 123, 255, 0.25);
-}
-
-.tree-key::before {
-  content: "\25B6";
-  display: inline-block;
-  transition: transform 0.2s ease;
-  margin-right: 6px;
-  font-size: 0.8em;
-  color: #555;
-}
-
-.tree-key.expanded::before {
-  transform: rotate(90deg);
-  color: #007bff;
-}
-
-.tree-key .node-info {
-  font-size: 0.8em;
-  color: #999;
-  margin-left: 6px;
-}
-
-.tree-key[title] {
-  position: relative;
-}
-
-.tree-key[title]:hover::after {
-  content: attr(title);
-  position: absolute;
-  top: 100%;
-  left: 0;
-  background: rgba(0, 0, 0, 0.75);
-  color: #fff;
-  font-size: 12px;
-  padding: 4px 6px;
-  border-radius: 4px;
-  white-space: nowrap;
-  margin-top: 4px;
-  z-index: 10;
-  pointer-events: none;
-}
-
-body.dark-mode .tree-key[title]:hover::after {
-  background: rgba(255, 255, 255, 0.1);
-  color: #e0e0e0;
-  border: 1px solid #666;
-}
-
-/* Accessibility: keyboard focus outline */
-.tree-key:focus-visible {
-  outline: 2px solid #007bff;
-  outline-offset: 2px;
-}
-
-/* Shift-click recursive expand/collapse (JS logic must add 'recursive' class to target for styling if needed) */
-.tree-key.shift-toggle {
-  background-color: rgba(0, 123, 255, 0.08);
-}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.tree-children {
margin-left: 20px;
overflow: hidden;
transition: max-height 0.3s ease, opacity 0.3s ease;
max-height: 1000px;
opacity: 1;
}
.tree-children.collapsed {
max-height: 0;
opacity: 0;
pointer-events: none;
}
.tree-key {
position: relative;
cursor: pointer;
padding: 4px 6px;
display: inline-block;
border-radius: 3px;
transition: background-color 0.2s ease, box-shadow 0.2s ease;
outline: none;
}
.tree-key:hover,
.tree-key:focus {
background-color: rgba(0, 123, 255, 0.12);
box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}
.tree-key:active {
background-color: rgba(0, 123, 255, 0.25);
}
.tree-key::before {
content: "\25B6";
display: inline-block;
transition: transform 0.2s ease;
margin-right: 6px;
font-size: 0.8em;
color: #555;
}
.tree-key.expanded::before {
transform: rotate(90deg);
color: #007bff;
}
.tree-key .node-info {
font-size: 0.8em;
color: #999;
margin-left: 6px;
}
.tree-key[title] {
position: relative;
}
.tree-key[title]:hover::after {
content: attr(title);
position: absolute;
top: 100%;
left: 0;
background: rgba(0, 0, 0, 0.75);
color: #fff;
font-size: 12px;
padding: 4px 6px;
border-radius: 4px;
white-space: nowrap;
margin-top: 4px;
z-index: 10;
pointer-events: none;
}
body.dark-mode .tree-key[title]:hover::after {
background: rgba(255, 255, 255, 0.1);
color: #e0e0e0;
border: 1px solid #666;
}
/* Accessibility: keyboard focus outline */
.tree-key:focus-visible {
outline: 2px solid #007bff;
outline-offset: 2px;
}
/* Shift-click recursive expand/collapse (JS logic must add 'recursive' class to target for styling if needed) */
.tree-key.shift-toggle {
background-color: rgba(0, 123, 255, 0.08);
}
🤖 Prompt for AI Agents (early access)
In index.css between lines 491 and 580, there is a duplicated set of CSS rules for tree view components that also appear between lines 345 and 423. To fix this, remove the entire duplicated block from lines 491 to 580, keeping only the first occurrence to reduce redundancy and improve maintainability.

@zhravan zhravan merged commit 919e4a2 into main May 2, 2025
@zhravan zhravan deleted the improv branch May 2, 2025 20:39
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
index.css (1)

347-420: Remove duplicated CSS code for tree view components.

The entire .tree-children and .tree-key blocks are repeated between lines 347–420 and again at 493–580. This duplication makes maintenance error-prone and bloats the stylesheet. Consolidate into one definition.

Also applies to: 493-580

🧹 Nitpick comments (2)
index.css (2)

5-11: Suggest using CSS variables for theme colors.

You’ve hard-coded light theme colors (#f0f0f0, #333, #007bff, etc.) throughout. Defining them as CSS custom properties in :root (and overriding in body.dark-mode) will make future theme tweaks far easier and ensure consistency.

For example:

:root {
  --bg-color: #f0f0f0;
  --text-color: #333;
  --primary-color: #007bff;
  --secondary-bg: #ffffff;
  /* … */
}
body.dark-mode {
  --bg-color: #121212;
  --text-color: #e0e0e0;
  --secondary-bg: #2e2e2e;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color 0.3s, color 0.3s;
}

Then reuse var(--primary-color) etc. across all selectors.


753-768: New App Layout styling looks solid.

The .app-container flex layout and .sidebar styling correctly implement the sidebar-driven design as per the HTML changes.

Consider whether both body and .app-container need the same background-color or if inheritance suffices.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 036e389 and 1943a06.

📒 Files selected for processing (2)
  • index.css (1 hunks)
  • index.html (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant