Skip to content

Frontend

The server renders HTML; Turbo makes it feel like a SPA; Stimulus adds the small behaviors; daisyUI gives the components. Replay compares pages by visible text, so keep every piece of content and every flow; the markup is yours.

Setup (front-door does most of it)

  • app/assets/tailwind/application.css:
    css
    @import "tailwindcss";
    @plugin "./daisyui.mjs" { themes: light --default, dark --prefersdark; }
    
    daisyui.mjs and daisyui-theme.mjs sit next to it (downloaded from the daisyUI releases; Tailwind's standalone CLI loads them without Node). Run bin/dev (or bin/rails tailwindcss:watch) while editing views.
  • Theme: <html data-theme="light"> in the layout; a theme switcher is a Stimulus controller that sets document.documentElement.dataset.theme and stores it in a cookie.
  • Layout: daisyUI navbar (or drawer for side navigation) with the original's links, main with container mx-auto p-4, flash messages as alert alert-success / alert-error.

Mapping

Original Rails
Page / route component (React, Vue, Angular, Svelte, Next.js page) Controller action + app/views/<resource>/<action>.html.erb
Reusable component (<ProductCard>) Partial _product_card.html.erb (or a ViewComponent once repeated with logic)
Props Partial locals: render "product_card", product: p
Client router links (<Link>, router.push) link_to / button_to; Turbo Drive does the SPA navigation
useState / ref for UI-only state (open, tab, toggle) Stimulus controller with static values and targets
Fetch-then-render (useEffect(fetch), SWR, React Query) Render on the server; lazy parts in <turbo-frame src=... loading="lazy">
Form with client-side submit + JSON API form_with model:; errors re-render with status: :unprocessable_entity
Optimistic update / live list Turbo Stream response (turbo_stream.append/replace/remove)
WebSocket / polling updates turbo_stream_from @room + broadcasts_to on the model (Action Cable)
Modal daisyUI modal (<dialog>) opened by a Stimulus controller, content in a turbo-frame id="modal"
Infinite scroll / "load more" Turbo Frame with loading="lazy" for the next page
Debounced search-as-you-type Stimulus controller that submits the form after 300 ms; results in a Turbo Frame
Client-side validation (zod, yup) ActiveModel validations, HTML5 required/pattern; daisyUI validator class
CSS modules / styled-components / Bootstrap classes Tailwind utilities + daisyUI components
Global store (Redux, Pinia, Context) The server is the store; session for per-user state; Stimulus outlets for cross-controller UI
i18n strings config/locales/*.yml + t(".key")
Server templates (Jinja, Thymeleaf, Blade, EJS, Razor, Go templates) ERB: {{ x }} -> <%= x %>, {% for %} -> <% each do %>, blocks/sections -> content_for / yield, includes -> partials

daisyUI components to reach for

btn (btn-primary, btn-ghost, btn-sm), card (card-body, card-title, card-actions), navbar, menu, drawer, table (table-zebra), badge, alert, modal, tabs, dropdown, input/select/textarea with fieldset + label (daisyUI 5), join for grouped buttons and pagination, stat for dashboards, steps for wizards, toast for flash, skeleton and loading for lazy frames.

Rules

  • Same URLs, same page titles (content_for :title), same headings, labels, button text, table columns and empty states as the original: replay checks the text.
  • Forms post to the same paths with the same field names unless an ADR says otherwise; keep name attributes so recorded POST cases still work.
  • Server-render everything the original showed on first load; only things that were lazy in the original become lazy frames.
  • Accessibility: real <button>/<a>, <label for>, aria-live on Turbo Stream targets, focus moved into modals. daisyUI components are accessible when you use the right element.
  • No inline <script>. Behavior goes in app/javascript/controllers/*_controller.js (bin/rails generate stimulus name), pinned by importmap.
  • System tests (bin/rails generate system_test) for each flow that has JavaScript behavior.
Edit this page on GitHub →