BorderedTextareaWithLabels
The provided code defines a Ruby class named `TextAreaComponent` that inherits from `ApplicationComponent`. This class is designed to generate a block of HTML markup intended for use within web interfaces, specifically to create a text area with labels for user input. The `template` method, when invoked, constructs an HTML structure that includes:
- A surrounding label element acting as a form control.
- A div with a sub-label indicating a primary label text "Your bio" and an alternative label text "Alt label" positioned above the text area.
- A textarea element for user input, styled with the classes `textarea`, `textarea-bordered`, and `h-24` (indicating height), and a placeholder text "Bio".
- Another div element with label texts similar to the second bullet but positioned after the text area.
This component appears to be part of a larger system or framework designed for building web applications, allowing developers to include a customizable text area in their forms with predefined styles and sizes, as well as optional surrounding labels.
# frozen_string_literal: true
# Text areas can be modified with the following classes:
# color: textarea-primary, textarea-secondary, textarea-accent, textarea-info, textarea-success, textarea-warning, textarea-error
# size: textarea-lg, textarea-md, textarea-sm, textarea-xs
# misc: textarea-bordererd, textarea-ghost
# all surrounding labels are optional
class TextAreaComponent < ApplicationComponent
def template
label(class: "form-control") do
div(class: "label") do
span(class: "label-text") { "Your bio" }
span(class: "label-text-alt") { "Alt label" }
end
textarea(class: "textarea textarea-bordered h-24", placeholder: "Bio")
div(class: "label") do
span(class: "label-text-alt") { "Your bio" }
span(class: "label-text-alt") { "Alt label" }
end
end
end
end