Skip to content

Instantly share code, notes, and snippets.

@georgekettle
georgekettle / PhlexMailerLayout.rb
Last active March 3, 2025 08:47
Phlex Mailer layout
You'll need to update the following variables:
- ENV['APP_NAME']
- ENV['COMPANY_ADDRESS']
- ENV['HOST']
Make sure you have app/assets/images/logo.svg for this line:
helpers.image_url('logo.svg')
And also update the CSS variables to match your color scheme:
:root {
@georgekettle
georgekettle / builder.rb
Created February 6, 2024 04:47
PhlexUI::Form::Builder
# frozen_string_literal: true
module PhlexUI
class Form::Builder < Base
# include Phlex::Rails::Helpers::FormAuthenticityToken
def initialize(model: nil, scope: nil, url: nil, format: nil, method: :post, **attrs)
@object = model
@scope = scope
@url = url
# frozen_string_literal: true
SimpleForm.setup do |config|
# Button class (already Tailwind)
config.button_class = "relative inline-flex items-center rounded-md bg-sky-600 px-2.5 py-2 text-sm font-semibold text-white shadow-xs hover:bg-sky-500 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-sky-600"
# Boolean label class (tailwind switch)
config.boolean_label_class = "ml-2 text-sm font-medium text-gray-700"
config.label_text = lambda { |label, required, explicit_label| "#{label} #{required}" }