Skip to content

feat: add FittedBox control - #46

Merged
AdamMusa merged 2 commits into
mainfrom
feat/fitted-box
Oct 29, 2026
Merged

AdamMusa merged 2 commits into
mainfrom
feat/fitted-box

Conversation

@AdamMusa

Copy link
Copy Markdown
Owner

Adds the Ruby side of FittedBox (Work Package F, item F4).

Engine counterpart (renderer): AdamMusa/ruflet-engine#31

Usage

fitted_box(text("$1,299.00", size: 40), width: 120, height: 40, fit: "scaleDown")
fittedbox(content: image(src: "logo.png"), fit: "cover", alignment: { x: -1, y: 0 }, expand: true)

API

  • Class: controls/shared/fittedbox_control.rb, RufletComponents::FittedBoxControl, TYPE fittedbox, WIRE FittedBox.
  • CLASS_MAP has fitted_box and fittedbox in both the shared and the top-level registry.
  • DSL helpers fitted_box(content = nil, **props) and fittedbox are in material_control_methods.rb, shared_control_forwarders.rb and dsl.rb.
  • KEYWORDS: alignment clip_behavior content fit plus the common layout keywords. Events: on_animation_end, on_size_change.
  • The Ruby side sends no defaults: Flutter's contain, center and none apply.
  • Deviation from the spec: content is not enforced in Ruby. As with rotated_box, nil content renders an empty box rather than raising, so a hidden or late-bound child cannot break the page.

Tests

  • New test/fitted_box_compatibility_test.rb (5 runs). It covers:
    • _c, positional and keyword content, and the serialized props;
    • the compact alias, Ruflet.control(:fitted_box) and the Ruflet::DSL helpers;
    • no defaults are sent;
    • has_handler? for the layout events;
    • unknown keyword raises ArgumentError.
  • verify_pr.sh with RUBY_PKGS="ruflet_core ruflet_rails": ruflet_core 146/146 files, 623 runs; ruflet_rails 15/15 files, 278 runs. The engine pair passes too (+720 tests, analyze clean). The wire-key audit shows 0 new findings.

Add fitted_box/fittedbox helpers and the FittedBox wire type with fit, alignment, clip_behavior, content and the common layout keywords.
@AdamMusa
AdamMusa merged commit 64deced into main Oct 29, 2026
5 checks passed
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