forked from aptos-labs/aptos-core
-
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.
- Loading branch information
1 parent
aad3dd1
commit bd4a515
Showing
11 changed files
with
77 additions
and
8 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
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
1 change: 1 addition & 0 deletions
1
ecosystem/platform/server/app/components/button_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 @@ | ||
<%= content_tag @tag, content, **@rest %> |
30 changes: 30 additions & 0 deletions
30
ecosystem/platform/server/app/components/button_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,30 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) Aptos | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
SCHEME_CLASSES = { | ||
primary: 'bg-teal-400 hover:bg-teal-300 text-neutral-800 text-center font-mono uppercase font-bold', | ||
secondary: 'border border-teal-400 hover:border-teal-300 text-center text-white font-mono uppercase' | ||
}.freeze | ||
|
||
SIZE_CLASSES = { | ||
large: 'px-8 py-4 text-lg rounded', | ||
medium: 'p-2 text-lg rounded', | ||
small: 'py-1 text-sm rounded' | ||
}.freeze | ||
|
||
class ButtonComponent < ViewComponent::Base | ||
def initialize(scheme: :primary, | ||
size: :medium, | ||
**rest) | ||
@rest = rest | ||
|
||
@tag = rest[:href] ? :a : :button | ||
rest[:class] = [ | ||
SCHEME_CLASSES[scheme], | ||
SIZE_CLASSES[size], | ||
rest[:class] | ||
] | ||
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
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
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
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
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
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
18 changes: 18 additions & 0 deletions
18
ecosystem/platform/server/spec/components/button_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,18 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) Aptos | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe ButtonComponent, type: :component do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
|
||
# it "renders something useful" do | ||
# expect( | ||
# render_inline(described_class.new(attr: "value")) { "Hello, components!" }.css("p").to_html | ||
# ).to include( | ||
# "Hello, components!" | ||
# ) | ||
# end | ||
end |