Skip to content

Commit

Permalink
feat: Cria componente Text Area (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
karinevieira authored Sep 17, 2024
1 parent 9b5ebf9 commit 92266c1
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= tag.textarea(**attributes) { attributes[:value] } %>
28 changes: 28 additions & 0 deletions app/components/ink_components/forms/text_area/component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

module InkComponents
module Forms
module TextArea
class Component < ApplicationComponent
style do
base {
%w[
block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300
focus:ring-pink-500 focus:border-pink-500 dark:bg-gray-700 dark:border-gray-600
dark:placeholder-gray-400 dark:text-white dark:focus:ring-pink-500 dark:focus:border-pink-500
]
}
end

def initialize(**extra_attributes)
super(**extra_attributes)
end

private
def default_attributes
{ class: style }
end
end
end
end
end
17 changes: 17 additions & 0 deletions app/components/ink_components/forms/text_area/preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# frozen_string_literal: true

module InkComponents
module Forms
module TextArea
class Preview < Lookbook::Preview
# @param placeholder text
# @param value text
# @param rows number
# @param cols number
def playground(placeholder: "Write your thoughts here...", value: nil, rows: nil, cols: nil)
render InkComponents::Forms::TextArea::Component.new(placeholder:, value:, rows:, cols:)
end
end
end
end
end
11 changes: 11 additions & 0 deletions spec/components/ink_components/forms/text_area_component_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require "rails_helper"

RSpec.describe InkComponents::Forms::TextArea::Component, type: :component do
it "renders component" do
component = render_inline(described_class.new(placeholder: "Write something"))

expect(component.to_html).to include("textarea", "placeholder=\"Write something\"")
end
end
1 change: 1 addition & 0 deletions spec/dummy/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const inkComponentsConfig = require("./ink_components.tailwind.config.js")

module.exports = {
plugins: [require("flowbite/plugin")],
darkMode: "class",
content: [
'./app/views/**/*.html.erb',
Expand Down

0 comments on commit 92266c1

Please sign in to comment.