-
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: Adiciona card component * refactor: Ajuste no codigo * refactor: Adiciona mais exemplos de preview * refactor: Ajsute no nome do teste
- Loading branch information
1 parent
67766af
commit 55f93ef
Showing
4 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
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,3 @@ | ||
<%= content_tag :div, attributes do %> | ||
<%= content %> | ||
<% 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,37 @@ | ||
# frozen_string_literal: true | ||
|
||
module InkComponents | ||
module Card | ||
class Component < ApplicationComponent | ||
style do | ||
base { "p-6 bg-white border border-gray-200 rounded-lg shadow dark:bg-gray-800 dark:border-gray-700" } | ||
|
||
variants { | ||
orientation { | ||
vertical { "max-w-sm" } | ||
horizontal { "flex flex-col items-center md:flex-row md:max-w-xl" } | ||
} | ||
} | ||
|
||
defaults { { orientation: :vertical } } | ||
end | ||
|
||
attr_reader :orientation | ||
|
||
def initialize(orientation: nil, **extra_attributes) | ||
@orientation = orientation | ||
|
||
super(**extra_attributes) | ||
end | ||
|
||
private | ||
def default_attributes | ||
{ class: style(orientation:) } | ||
end | ||
|
||
def render? | ||
content.present? | ||
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,72 @@ | ||
# frozen_string_literal: true | ||
|
||
module InkComponents | ||
module Card | ||
class Preview < Lookbook::Preview | ||
# @param orientation select { choices: [vertical, horizontal] } | ||
def playground(orientation: :vertical) | ||
render InkComponents::Card::Component.new(orientation:) do | ||
tag.p "Here are the biggest enterprise technology acquisitions of 2021 so far, in reverse chronological order.", class: "font-normal text-gray-700 dark:text-gray-400" | ||
end | ||
end | ||
|
||
# @!group Orientations | ||
def vertical_orientation | ||
render InkComponents::Card::Component.new(orientation: :vertical) do | ||
tag.p "Here are the biggest enterprise technology acquisitions of 2021 so far, in reverse chronological order.", class: "font-normal text-gray-700 dark:text-gray-400" | ||
end | ||
end | ||
|
||
def horizontal_orientation | ||
render InkComponents::Card::Component.new(orientation: :horizontal) do | ||
tag.p "Here are the biggest enterprise technology acquisitions of 2021 so far, in reverse chronological order.", class: "font-normal text-gray-700 dark:text-gray-400" | ||
end | ||
end | ||
# @!endgroup | ||
|
||
def with_html_content | ||
render InkComponents::Card::Component.new do | ||
'<a href="#"> | ||
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white">Noteworthy technology acquisitions 2021</h5> | ||
</a> | ||
<p class="mb-3 font-normal text-gray-700 dark:text-gray-400">Here are the biggest enterprise technology acquisitions of 2021 so far, in reverse chronological order.</p> | ||
<a href="#" class="inline-flex items-center px-3 py-2 text-sm font-medium text-center text-white bg-blue-700 rounded-lg hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"> | ||
Read more | ||
<svg class="rtl:rotate-180 w-3.5 h-3.5 ms-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 10"> | ||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 5h12m0 0L9 1m4 4L9 9"/> | ||
</svg> | ||
</a>'.html_safe | ||
end | ||
end | ||
|
||
def with_html_form | ||
render InkComponents::Card::Component.new do | ||
'<form class="space-y-6" action="#"> | ||
<h5 class="text-xl font-medium text-gray-900 dark:text-white">Sign in to our platform</h5> | ||
<div> | ||
<label for="email" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your email</label> | ||
<input type="email" name="email" id="email" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" placeholder="[email protected]" required /> | ||
</div> | ||
<div> | ||
<label for="password" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your password</label> | ||
<input type="password" name="password" id="password" placeholder="••••••••" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400 dark:text-white" required /> | ||
</div> | ||
<div class="flex items-start"> | ||
<div class="flex items-start"> | ||
<div class="flex items-center h-5"> | ||
<input id="remember" type="checkbox" value="" class="w-4 h-4 border border-gray-300 rounded bg-gray-50 focus:ring-3 focus:ring-blue-300 dark:bg-gray-700 dark:border-gray-600 dark:focus:ring-blue-600 dark:ring-offset-gray-800 dark:focus:ring-offset-gray-800" required /> | ||
</div> | ||
<label for="remember" class="ms-2 text-sm font-medium text-gray-900 dark:text-gray-300">Remember me</label> | ||
</div> | ||
<a href="#" class="ms-auto text-sm text-blue-700 hover:underline dark:text-blue-500">Lost Password?</a> | ||
</div> | ||
<button type="submit" class="w-full text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">Login to your account</button> | ||
<div class="text-sm font-medium text-gray-500 dark:text-gray-300"> | ||
Not registered? <a href="#" class="text-blue-700 hover:underline dark:text-blue-500">Create account</a> | ||
</div> | ||
</form>'.html_safe | ||
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,21 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe InkComponents::Card::Component, type: :component do | ||
context "when the content is provided" do | ||
it "renders the component" do | ||
component = render_inline(described_class.new) { "Some text" } | ||
|
||
expect(component.to_html).to include("Some text") | ||
end | ||
end | ||
|
||
context "when no content is provided" do | ||
it "doesn't render the component" do | ||
component = render_inline(described_class.new) | ||
|
||
expect(component.to_html).to be_empty | ||
end | ||
end | ||
end |