Skip to content

Theme 4.0 for ActiveAdmin 4 - #78

Draft
senid231 wants to merge 3 commits into
activeadmin-plugins:masterfrom
senid231:activeadmin-v4
Draft

senid231 wants to merge 3 commits into
activeadmin-plugins:masterfrom
senid231:activeadmin-v4

Conversation

@senid231

@senid231 senid231 commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Theme 4.0 for ActiveAdmin 4. ActiveAdmin 4 replaced its Sass and jQuery front end with Tailwind CSS v4, Flowbite and import maps, so theme 3 can't be ported file by file. This PR rebuilds the theme on the new layout. Theme 3 moves to the 3.x maintenance branch.

Decisions to review

  • ActiveAdmin views copied. The theme overrides 10 ActiveAdmin 4.0.0.beta23 views (layout, header, navigation, page header, sidebar, show page, _html_head). Rails always renders the copy, so ActiveAdmin fixes to those files don't reach theme users. test/aa_overrides_test.rb records a digest of each original and fails when a new ActiveAdmin version changes one. Run it with UPDATE_AA_DIGESTS=1 after you merge the upstream change into the copy.
  • JavaScript. ActiveAdmin pages render only ActiveAdmin.importmap, so the engine pins the theme modules there. The theme's _html_head imports the modules listed in ActiveAdminTheme.javascripts. A pin in the host's own config/importmap.rb loads nothing on ActiveAdmin pages; the README says so.
  • CSS. The theme ships two delivery routes. The npm package exports ./css. The gem-path route uses rake active_admin_theme:css, which writes the machine-specific gem path into a git-ignored active_admin_theme.generated.css.
  • Requirements. Ruby 3.3 or later and ActiveAdmin 4.0.0.beta23 or later, the same as ActiveAdmin 4. The version is 4.0.0.pre.

Upstream proposals

These would shrink the copied views. None has been merged or reviewed yet.

activeadmin/activeadmin#9146 makes the layout extensible without copying views. With all five pull requests below, the theme drops its copies of the layout, _site_header, _main_navigation, _html_head and _page_header, and overrides small partials instead. I tested this against a branch that merges all five.

activeadmin/activeadmin#9147 supports running ActiveAdmin from a Rails engine and adding JavaScript to its pages:

Checklist

Packaging:

  • Gemspec, Gemfile, npm package.json (exports ./css and ./*), version 4.0.0.pre
  • CI: Ruby 3.3 and 3.4 with Node 22, bundle exec rake test
  • Dummy app rebuilt on ActiveAdmin 4 (Propshaft, importmap, Tailwind CLI), with customers, orders, countries and cities
  • Push 3.x to this repository; it is only on a fork today

Layout:

  • Top menu from 768px with dropdown submenus; drawer menu below 768px
  • Compact header with server clock, dark mode switch, user and logout icon
  • Compact breadcrumbs, title and action items; action items styled as buttons
  • Sidebar on the left, collapsible, and above the content on mobile
  • Index tables scroll sideways; cells stay on one line
  • Theme 3 colors, density and dark mode as --aat-* CSS custom properties
  • Side-by-side comparison with theme 3 screenshots
  • Logged-out layout checked on a real login page (the dummy has no Devise)

DSL and components:

  • columns / column, tabs / tab, panels around sidebar sections and the show page
  • confirm_dialog on the Flowbite modal, with form fields
  • status_tag color variants and a color: option
  • Searchable select on Tom Select (vendored 2.6.2): form and filter inputs, JSON source DSL, paging, dependent selects
  • truncate_text, secret_reveal, with_tooltip, pre_wrap
  • Server clock and table crisscross as ES modules without jQuery

Docs and release:

  • README rewritten for theme 4
  • docs/migrating-from-v3.md
  • Switch to the ActiveAdmin hooks once they are released
  • Release 4.0.0

Verification

bundle exec rake test passes locally: 68 runs, including headless Chrome tests for the layout, components, confirm dialog and searchable select. I checked index, show and form pages at 1280px, 820px and 390px, in light and dark mode, with test/screenshot.rb.

Rebuilds the theme on ActiveAdmin 4's Tailwind layout. Theme 3 stays on
the 3.x branch. The theme copies ten ActiveAdmin views, so
test/aa_overrides_test.rb fails when ActiveAdmin changes one of them.

Co-Authored-By: Clanker
The theme's markup now lives in the partials that ActiveAdmin's pending
layout hooks render. When the installed ActiveAdmin lacks them, the engine
adds app/views_compat, whose copies of the layout and headers render the
same partials. The JavaScript list and the import map cache watch use the
new ActiveAdmin settings when present. The searchable_select_options DSL
is included before host initializers, so a host's own version wins.

Co-Authored-By: Clanker
ActiveAdmin 4 dropped parent chains and raises TypeError for
`menu parent: [...]`, which apps upgrading from ActiveAdmin 3 still use.
The theme restores the chain and renders any depth in the top menu
and the drawer.

Co-Authored-By: Clanker
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