-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Cria componente Text Area (#53)
- Loading branch information
1 parent
9b5ebf9
commit 92266c1
Showing
5 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
app/components/ink_components/forms/text_area/component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= tag.textarea(**attributes) { attributes[:value] } %> |
28 changes: 28 additions & 0 deletions
28
app/components/ink_components/forms/text_area/component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
11
spec/components/ink_components/forms/text_area_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters