Menu
Hello, world!
render Text.new(size: :md) { "Hello, world!" }
Add the component to your project
Run the following command in your terminal
bundle exec essence add text
Copy and paste the following code into your project
# frozen_string_literal: true
class Components::Text < Components::Essence
BASE = "text-base text-gray-600"
SIZES = {
sm: "text-sm",
md: "text-base",
lg: "text-lg"
}
attr_reader :size
def initialize(size: :md, **attributes)
@size = size
super(**attributes)
end
def view_template(&)
p(**attributes, &)
end
private
def initialize_merged_classes = merge_classes([ BASE, SIZES[size], attributes[:class] ])
end