Skip to content

feat: Implement complete lift simulator with interactive UI#42

Open
Soumava-221B wants to merge 3 commits into
RealDevSquad:mainfrom
Soumava-221B:soumava_lift_simulator
Open

feat: Implement complete lift simulator with interactive UI#42
Soumava-221B wants to merge 3 commits into
RealDevSquad:mainfrom
Soumava-221B:soumava_lift_simulator

Conversation

@Soumava-221B
Copy link
Copy Markdown

Date: 16/05/26

Developer Name: Soumava Das


Description

This PR introduces a complete lift simulator web application with interactive UI and realistic lift movement animations. The application allows users to configure the number of floors and lifts, then interact with the simulator through floor call buttons.

Screenrecording

Screen.Recording.2026-05-16.at.8.58.24.PM.mov

- Add HTML structure with input form for floors and lifts configuration
- Create responsive CSS styling for lift doors, floors, and controls
- Implement JavaScript logic for lift movement, door animations, and call handling
- Add lift availability tracking and queue management system
- Support multiple lifts with automatic assignment and movement timing
- Include visual door opening/closing animations with CSS transforms
- Add floor control buttons (up/down) for lift calls
- Implement input validation and error handling
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: cca9b2fb-9c51-4e3b-8a87-1c8e3c3b5dec

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This PR introduces a complete Lift Simulator web application, starting with a user input form that collects floor and lift counts, then dynamically rendering a visual grid of floors with control buttons and animated lift elements. The JavaScript coordinates lift dispatch, movement animations, and door control via state-tracked calls and availability queues.

Changes

Lift Simulator Application

Layer / File(s) Summary
HTML Structure and VS Code Configuration
.vscode/settings.json, src/index.html
Adds Lift Simulator HTML with header, input form, output container, and asset links; configures VS Code Live Server to port 5501.
CSS Theming and Layout
src/css/main.css
Defines theme variables, global box-sizing reset, input/output form styling, floor/lift row layout, door element styling with left/right borders, and transform animation classes for lift and door movement.
JavaScript State and Input Handling
src/js/main.js (lines 1–28)
Wires form submission, validates input, initializes state Maps for floor-to-lift assignments and lift availability, queues pending calls, and triggers floor/lift DOM rendering.
Floor and Lift DOM Generation
src/js/main.js (lines 30–103)
Generates floor rows with up/down buttons wired to call handlers; creates lift DOM elements with state initialization.
Call Dispatch, Movement, and Door Control
src/js/main.js (lines 105–182)
Selects available lifts or enqueues calls, computes travel distance and CSS transition timing, animates lift movement via transforms, opens/closes doors with timed toggles, and processes queued calls when lifts become available.

Sequence Diagram(s)

sequenceDiagram
  participant Floor as Floor Button
  participant Handler as handleLiftCall()
  participant Movement as liftMovement()
  participant Doors as doorOpenClose()
  participant Queue as Call Queue
  
  Floor->>Handler: Click up/down button
  Handler->>Handler: Check available lifts
  alt Lift available
    Handler->>Movement: Animate to floor
    Movement->>Movement: CSS transform
    Movement->>Doors: Schedule door ops
    Doors->>Doors: Open/close doors
    Doors->>Handler: Mark available again
    Handler->>Queue: Process next call
  else No lift available
    Handler->>Queue: Enqueue floor request
  end
  Queue->>Handler: Dequeue when lift ready
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A lift springs to life with floors so grand,
Buttons await with a gentle hand,
Doors slide open, lifts ascend,
Each call queued until the end!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: implementing a complete lift simulator with interactive UI, which matches the changeset perfectly.
Description check ✅ Passed The description is directly related to the changeset, providing context about the lift simulator web application, developer information, and a demo link.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@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: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/css/main.css`:
- Around line 5-11: The CSS custom properties --bg-color, --text-color,
--upButton-color, --downButton-color, --lift-color, --border-color, and
--door-color are defined with quoted hex strings which makes var(--text-color)
and similar usages invalid; update each variable value to be a raw hex color
(e.g., `#2D2727` instead of "`#2D2727`") so color: var(--text-color) and other var()
usages resolve correctly.

In `@src/index.html`:
- Around line 23-31: Labels use for="floorInput" and for="liftInput" but the
corresponding <input> elements only have name attributes; add id="floorInput" to
the input with name="floorInput" and id="liftInput" to the input with
name="liftInput" so the label's for attributes correctly bind to the input
elements (ensure ids are unique and match the label values).
- Around line 12-15: The HTML has a mismatched element: <section
class="countShow_section"> is opened but not closed before the closing
</header>; fix this by inserting a closing </section> before </header> so the
section (countShow_section) encloses its h3 elements and the header is properly
closed; locate the markup around the countShow_section and header tags and add
the missing </section> to restore valid HTML structure.

In `@src/js/main.js`:
- Around line 36-41: Replace the innerHTML construction for topFloor with DOM
methods: create the section element with class "floor-details", create a button
with classes "lift-control down" and set its type attribute and textContent to
"↓", create a p element with class "floor-number" and set its textContent to
`Floor-${totalFloors}`, then append the button and p into the section and append
the section into the topFloor container; update references to topFloor and
totalFloors accordingly and remove the innerHTML assignment to avoid
string-based DOM insertion.
- Around line 16-21: floorCount and liftCount are being read as strings from
floorInput.value and liftInput.value so non-numeric values like "abc" bypass the
numeric check; convert the inputs to numbers (e.g., using Number(...) or
parseInt(...,10)) before comparing and then validate with Number.isFinite or
isNaN (e.g., ensure !isNaN(floorCount) && floorCount > 0) so invalid or
non-integer inputs are rejected; update the assignment of floorCount and
liftCount and the validation branch that currently calls handleFloor to use the
parsed numeric values and reject on NaN or non-positive values.
- Line 107: The code uses event.composedPath()[2].id which is brittle; replace
this DOM traversal with a robust ancestor lookup: find the clicked element
(event.target or event.currentTarget) and call closest(...) to locate the floor
element (e.g., using a selector like '.floor' or a data attribute such as
'[data-floor]'), then read its id; also add a null-check and early return or
error handling if closest(...) returns null to avoid runtime errors — update the
logic around the floorId declaration accordingly (the symbol to change is the
floorId assignment where event.composedPath()[2].id is used).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: ab153c35-34ed-48bd-9cff-0cfbad5fca1e

📥 Commits

Reviewing files that changed from the base of the PR and between 454f201 and 039289c.

📒 Files selected for processing (4)
  • .vscode/settings.json
  • src/css/main.css
  • src/index.html
  • src/js/main.js

Comment thread src/css/main.css Outdated
Comment thread src/index.html Outdated
Comment thread src/index.html
Comment thread src/js/main.js Outdated
Comment thread src/js/main.js Outdated
Comment thread src/js/main.js Outdated
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