Skip to content

Add uniform baseplate option to Gridfinity calculator#17

Merged
ntindle merged 3 commits into
devfrom
basic-same-sizing
Aug 11, 2025
Merged

Add uniform baseplate option to Gridfinity calculator#17
ntindle merged 3 commits into
devfrom
basic-same-sizing

Conversation

@ntindle
Copy link
Copy Markdown
Owner

@ntindle ntindle commented Aug 11, 2025

Description

Add "Prefer uniform baseplate sizes" toggle that allows users to optimize for uniform baseplate dimensions instead of mixed sizes. The feature intelligently
avoids creating impractical 1xN baseplates by enforcing a minimum size of 2x2 grids.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring

Related Issue

Implements user request for uniform baseplate option

Changes Made

  • Added preferUniformBaseplates setting to state management system
  • Implemented smart calculateUniformBaseplates algorithm that:
    • Prioritizes fewer baseplate variants (1-3 types max)
    • Enforces minimum baseplate size of 2x2 grids (no 1xN pieces)
    • Accepts 85%+ coverage to avoid creating tiny edge pieces
  • Added UI toggle in Bin Options section for the new preference
  • Updated calculation logic to use uniform baseplates when enabled
  • Added comprehensive test suite for uniform baseplate calculations

Testing

  • All existing tests pass (194 tests passing)
  • Added new tests for new functionality (7 new tests)
  • Tested manually in browser
  • Tested with different drawer dimensions
  • Tested with custom printer settings
  • Tested with half-size bins enabled/disabled

Test Results:

  • 41.5" x 13.5" drawer: Successfully generates 10 × 5x4 uniform baseplates (vs 5 × 5x5 + 5 × 5x3 mixed)
  • Odd dimensions: Correctly avoids 1xN pieces by accepting slight undercoverage
  • Edge cases: All baseplates maintain minimum 2x2 size constraint

Screenshots

Feature adds a new toggle "Prefer uniform baseplate sizes" in the Bin Options panel
image

Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have used unitMath service for all calculations (no native JS math operations)
  • I have used @/ import paths consistently

Introduces a 'prefer uniform baseplates' option to the Gridfinity calculator, allowing users to generate layouts with maximally uniform baseplate sizes when possible. Updates context, settings, and calculation logic to support this feature, and adds tests to verify correct behavior and edge cases.
Updated uniform baseplate calculation to avoid creating 1xN or Nx1 baseplates by enforcing a minimum size of 2x2. The selection now prefers solutions with fewer baseplate variants, even if it means slightly less coverage. Added and updated tests to verify these constraints and preferences.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 11, 2025

PR Quality Report 📊

Check Status
TypeScript
ESLint
Tests
Build

View detailed results

Updated all useGridfinityCalculation test cases to include the preferUniformBaseplates property in the options object. This ensures tests remain consistent with the updated hook interface.
@ntindle ntindle merged commit 3a1d019 into dev Aug 11, 2025
26 checks passed
@ntindle ntindle mentioned this pull request Aug 11, 2025
@ntindle ntindle deleted the basic-same-sizing branch August 11, 2025 05:17
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