-
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.
Add menu, card and message components
- Loading branch information
Showing
29 changed files
with
683 additions
and
11 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
app/components/bulma/components/card/footer/form_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,27 @@ | ||
module Bulma | ||
module Components | ||
module Card | ||
module Footer | ||
class FormComponent < ItemComponent | ||
def initialize(name = nil, options = nil, **html_attributes) | ||
@name = name | ||
@options = options | ||
|
||
super(**html_attributes) | ||
end | ||
|
||
def call | ||
html_options = root_attributes(:item) | ||
|
||
if content? | ||
html_options = @options.merge(html_options) if @options.is_a?(Hash) | ||
return button_to(@name, html_options) { content } | ||
end | ||
|
||
button_to(@name, @options, html_options) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
app/components/bulma/components/card/footer/link_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,27 @@ | ||
module Bulma | ||
module Components | ||
module Card | ||
module Footer | ||
class LinkComponent < ItemComponent | ||
def initialize(name = nil, options = nil, **html_attributes) | ||
@name = name | ||
@options = options | ||
|
||
super(**html_attributes) | ||
end | ||
|
||
def call | ||
html_options = root_attributes(:item) | ||
|
||
if content? | ||
html_options = @options.merge(html_options) if @options.is_a?(Hash) | ||
return link_to(@name, html_options) { content } | ||
end | ||
|
||
link_to(@name, @options, html_options) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
app/components/bulma/components/card/footer/mail_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,27 @@ | ||
module Bulma | ||
module Components | ||
module Card | ||
module Footer | ||
class MailComponent < ItemComponent | ||
def initialize(email_address = nil, name = nil, **html_attributes) | ||
@email_address = email_address | ||
@name = name | ||
|
||
super(**html_attributes) | ||
end | ||
|
||
def call | ||
html_options = root_attributes(:item) | ||
|
||
if content? | ||
html_options = @name.merge(html_options) if @name.is_a?(Hash) | ||
return mail_to(@email_address, html_options) { content } | ||
end | ||
|
||
mail_to(@email_address, @name, html_options) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
app/components/bulma/components/card/footer/phone_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,27 @@ | ||
module Bulma | ||
module Components | ||
module Card | ||
module Footer | ||
class PhoneComponent < ItemComponent | ||
def initialize(phone_number = nil, name = nil, **html_attributes) | ||
@phone_number = phone_number | ||
@name = name | ||
|
||
super(**html_attributes) | ||
end | ||
|
||
def call | ||
html_options = root_attributes(:item) | ||
|
||
if content? | ||
html_options = @name.merge(html_options) if @name.is_a?(Hash) | ||
return phone_to(@phone_number, html_options) { content } | ||
end | ||
|
||
phone_to(@phone_number, @name, html_options) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
27 changes: 27 additions & 0 deletions
27
app/components/bulma/components/card/footer/sms_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,27 @@ | ||
module Bulma | ||
module Components | ||
module Card | ||
module Footer | ||
class SmsComponent < ItemComponent | ||
def initialize(phone_number = nil, name = nil, **html_attributes) | ||
@phone_number = phone_number | ||
@name = name | ||
|
||
super(**html_attributes) | ||
end | ||
|
||
def call | ||
html_options = root_attributes(:item) | ||
|
||
if content? | ||
html_options = @name.merge(html_options) if @name.is_a?(Hash) | ||
return sms_to(@phone_number, html_options) { content } | ||
end | ||
|
||
sms_to(@phone_number, @name, html_options) | ||
end | ||
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
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,23 @@ | ||
module Bulma | ||
module Components | ||
module Menu | ||
class LabelComponent < ApplicationComponent | ||
self.root_tag = :p | ||
|
||
style do | ||
base { "menu-label" } | ||
end | ||
|
||
def initialize(text = nil, **html_attributes) | ||
@text = text | ||
|
||
super(**html_attributes) | ||
end | ||
|
||
def call | ||
content_tag(root_tag, safe_join([@text, content]), **root_attributes) | ||
end | ||
end | ||
end | ||
end | ||
end |
23 changes: 23 additions & 0 deletions
23
app/components/bulma/components/menu/list/item_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,23 @@ | ||
module Bulma | ||
module Components | ||
module Menu | ||
module List | ||
class ItemComponent < ApplicationComponent | ||
self.root_tag = :li | ||
|
||
# @dynamic submenu, with_submenu | ||
renders_one :submenu, ListComponent | ||
|
||
def call | ||
content_tag(root_tag, safe_join([content, submenu]), **root_attributes) | ||
end | ||
|
||
private :with_submenu | ||
def list(**html_attributes, &block) | ||
with_submenu(**html_attributes, &block) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
23 changes: 23 additions & 0 deletions
23
app/components/bulma/components/menu/list/list_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,23 @@ | ||
module Bulma | ||
module Components | ||
module Menu | ||
module List | ||
class ListComponent < ApplicationComponent | ||
self.root_tag = :ul | ||
|
||
# @dynamic list_items, with_list_item | ||
renders_many :list_items, ItemComponent | ||
|
||
def call | ||
content_tag(root_tag, safe_join([content, *list_items]), **root_attributes) | ||
end | ||
|
||
private :with_list_item | ||
def item(**html_attributes, &block) | ||
with_list_item(**html_attributes, &block) | ||
end | ||
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,25 @@ | ||
module Bulma | ||
module Components | ||
module Menu | ||
class ListComponent < ApplicationComponent | ||
# @dynamic list_items, with_list_item | ||
renders_many :list_items, List::ItemComponent | ||
|
||
self.root_tag = :ul | ||
|
||
style do | ||
base { "menu-list" } | ||
end | ||
|
||
def call | ||
content_tag(root_tag, safe_join([content, *list_items]), **root_attributes) | ||
end | ||
|
||
private :with_list_item | ||
def item(**html_attributes, &block) | ||
with_list_item(**html_attributes, &block) | ||
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,31 @@ | ||
module Bulma | ||
module Components | ||
class MenuComponent < ApplicationComponent | ||
self.root_tag = :aside | ||
|
||
# @dynamic menu_elements, with_menu_element_label, with_menu_element_list | ||
renders_many :menu_elements, types: { | ||
label: Menu::LabelComponent, | ||
list: Menu::ListComponent | ||
} | ||
|
||
style do | ||
base { "menu" } | ||
end | ||
|
||
def call | ||
content_tag(root_tag, safe_join([*menu_elements, content]), **root_attributes) | ||
end | ||
|
||
private :with_menu_element_label | ||
def label(text = nil, **html_attributes, &block) | ||
with_menu_element_label(text, **html_attributes, &block) | ||
end | ||
|
||
private :with_menu_element_list | ||
def list(**html_attributes, &block) | ||
with_menu_element_list(**html_attributes, &block) | ||
end | ||
end | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
app/components/bulma/components/message/header_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,11 @@ | ||
module Bulma | ||
module Components | ||
module Message | ||
class HeaderComponent < ApplicationComponent | ||
style do | ||
base { "message-header" } | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.