Skip to content

Copy view components, previews, specs, and JS from rails_template#122

Merged
sethherr merged 15 commits intomainfrom
sethherr/add-view-components
Apr 14, 2026
Merged

Copy view components, previews, specs, and JS from rails_template#122
sethherr merged 15 commits intomainfrom
sethherr/add-view-components

Conversation

@sethherr
Copy link
Copy Markdown
Member

@sethherr sethherr commented Apr 13, 2026

  • Adds ViewComponent gem and Lookbook for component previews
  • Copies all components from rails_template: form (input, group), alerts (flash_messages, object_errors), navbar, and UI (alert, badge, button, button_link, card, chart, dropdown, header, modal, pagination, table, table_column, time)
  • Adds Stimulus controllers (alert, collapse, dropdown, modal, theme), collapse_utils.js, and SethTemplateFormBuilder
  • Adds @floating-ui/dom npm package for dropdown positioning
  • Includes Lookbook previews and RSpec specs for all components

sethherr and others added 15 commits April 12, 2026 18:40
Adds ViewComponent infrastructure with all components from rails_template:
form (input, group), alerts (flash_messages, object_errors), navbar, and
UI (alert, badge, button, button_link, card, chart, dropdown, header,
modal, pagination, table, table_column, time). Includes Lookbook previews,
RSpec specs, Stimulus controllers (alert, collapse, dropdown, modal,
theme), collapse_utils.js, SethTemplateFormBuilder, and @floating-ui/dom.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes FrozenError in test environment caused by Lookbook trying to
modify frozen autoload paths in Rails 8.1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes FrozenError caused by Rails 8.1 freezing autoload paths before
engine initializers run. Also adds ViewComponent preview layout config
and component view paths initializer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
view_component 4.6.0 causes FrozenError when trying to modify
autoload_paths in Rails 8.1. Pinning to 4.5.0 which is known to
work with Rails 8.1.3.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The view components use `module UI` but Zeitwerk maps the `ui/` directory
to `Ui` by default. This only fails in CI where eager_load is enabled.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This project doesn't have capybara in its bundle. These system specs
(which test JS interactions via browser) can be added back if capybara
is added later.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add capybara, selenium-webdriver, axe-core-rspec to test group
- Move lookbook to development+test group (needed for preview URLs in system specs)
- Configure ViewComponent test helpers, Capybara matchers, and headless Chrome
- Define SKIPPABLE_AXE_RULES constant for accessibility testing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Replace cssbundling-rails with tailwindcss-rails gem
- Add config/tailwind.config.js matching rails_template setup
- Create app/assets/tailwind/application.css with Tailwind v4 syntax
  - Includes existing section CSS imports
  - Adds rails_template component styles (dark mode, .twlink, dropdown, table)
  - Custom theme values (@theme) for colors, spacing, fonts
- Remove PostCSS/Tailwind/autoprefixer Node dependencies from package.json
- Remove postcss.config.js (no longer needed)
- Copy tom-select CSS to vendor directory (standalone binary can't resolve node_modules)
- Update Procfile.dev to use tailwindcss:watch
- Update layouts to reference tailwind stylesheet
- Fix @apply of custom classes for Tailwind v4 compatibility

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update all components to match rails_template: slot-based dropdown API,
link color for buttons, flattened module syntax for badge/card/chart,
new radio_button_group form component, and updated previews/specs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Mount Lookbook in test env for system specs (auto-mounts only in dev)
- Fix system spec URLs to use actual preview method names, not group names
- Fix form specs to use :username instead of :name (User has no name column)
- Fix time spec expectations to match project's localize_time format
- Add nil guard in UsernameValidator for blank username_slug
- Skip pagination specs (project uses kaminari, not pagy)
- Simplify table cache_key tests (test env uses null_store)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Set view_component.preview_paths to app/components (previews are colocated)
- Set lookbook.preview_paths to app/components (separate from VC config)
- Enable view_component.show_previews in test env
- Revert system spec URLs back to Lookbook group names (they were correct)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add config/initializers/lookbook.rb with theme and preview_paths
- Remove redundant lookbook.preview_paths from application.rb
- Add view_component.instrumentation_enabled for rack-mini-profiler
- Mount Lookbook in all envs (not just test), matching rails_template
- Remove show_previews from test.rb (Lookbook handles its own discovery)
- Add view_component/system_test_helpers to rails_helper

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add super_diff gem for better test output diffs
- Add Capybara colon-escaping helpers for Tailwind CSS class selectors
- Unpin view_component version (was ~> 4.5.0, now matches rails_template)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sethherr sethherr merged commit 951aa3c into main Apr 14, 2026
2 checks passed
@sethherr sethherr deleted the sethherr/add-view-components branch April 14, 2026 15:35
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