Replies: 3 comments
-
|
Hello, Thanks again for exploring this area and sharing your findings, community experiments like this are highly valuable I would like to point out a key concern regarding the generated file:
My main hesitation is the absolute file path being produced by the generator rather than constructed dynamically at runtime. This leads to questions such as:
If the path changes, the generated CSS might break unless re-generated in each environment. It feels fragile to rely on this for environments like CI or Heroku, where install paths can differ between deploys.
At the moment, our documentation encourages running separate Tailwind CSS builds (executables) in parallel if you need to split admin and frontend styles, so this aligns with our recommendations.
Updating to Flowbite 4 would be a significant shift, but I have some reservations:
|
Beta Was this translation helpful? Give feedback.
-
|
Thanks for feedback, happy to contribute where I can. The file is generated by Its written to the build dir which is added to My initial commit adding app/assets/tailwind/active_admin/engine.css is the minimum required to support the feature. A user can choose to opt into the technique by adding the additional Getting off topic and probably another discussion, but I should probably clarify this statement:
I actually think Flowbite combined with making Tailwind a requirement in the build flow isn't ideal. I know gems like Any dependency comes with a maintenance cost and I already regret adding Tailwind to some projects now stuck on v3. After digging into Basecamp's fizzy repo, especially their css, my mind has further shifted to less build tools is a win, keep it simple and return to plain old css, it's what I first learn't 25+ years ago, it ain't going anywhere. But I acknowledge that takes time so I think the best approach is at least a rake task enhancing |
Beta Was this translation helpful? Give feedback.
-
|
As a sidenote, I decided to look into a solution as beta19 broke my previous method of loading plugin.js via the tailwind-active_admin.config.js. The issue I believe is that the config file is now loaded as an ES module, With no way forward other than possibly copying plugin.js into the app I finally threw in the towel and resorted to activeadmin_assets. Being a little adverse to monkey patches I wanted to find a solution that works with minimal changes. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I know there are existing conversations about this but with tailwindcss-rails recently adding experimental support for engines and activeadmin supporting tailwind v4 I decided to see whats required to get it working and it probably warranted a new discussion on approaches.
Only the following change is required to support the engines feature:
app/assets/tailwind/active_admin/engine.css
Note that it doesn't
@sourcethe app directories, you can add the relevant@sourceto your ownapplication.cssif required, which creates a clear separation of concerns.The relative paths all work correctly within the installed activeadmin directory to get everything loaded. The only thing tailwindcss-rails does is create a file with an absolute
@importto the engine.css:app/assets/builds/tailwind/active_admin.cssTo implement you just need to import the generated file:
app/assets/tailwind/application.css:Also ensure
app/views/active_admin/_html_head.html.erbloadstailwindinstead ofactive_admin:Note that
tailwindcss-railshas hardcoded imports/exports and from what I can tell they have no plans to change that approach. If you want to usetailwindcss-railsyou have to loadtailwind.csswhich means no splitting styles between an admin and frontend, the only alternative is to roll your own rake tasks for the the css build.Since the technique was so simple I created another branch to play around with the install generators to create the correct css files for tailwindcss-rails or cssbundling-rails. May need a different approach and most likely need some rake tasks to ensure the file exists before assets:precompile.
master...jsntv200:activeadmin:feat/engine-css-generator
Test it out (your mileage may vary) with:
Let me know if you want this fleshed out into a PR?
Personally I think the proper approach is to get activeadmin updated to Flowbite v4 and use their default plugin with theming support rather than the current customised plugin.js which looks like it will be difficult to maintain. Pretty sure thats on the roadmap though, now that tailwind is updated. The existing custom styles in plugin.js for elements like formtastic could be ported to regular css and updated to use the themed css vars. ActiveAdmin could then generate the active_admin.css itself and the user doesn't have to worry about these implementation issues and can just tweak some css vars if required, at the moment we're stuck on blue unless you want to try and maintain your own plugin.js. The method exposed above could still be used for further customisation if required with the knowledge that you're working outside the default system, much like copying active_admin partials.
Beta Was this translation helpful? Give feedback.
All reactions