-
-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Contact Topics (#5388) #5517
Changes from 8 commits
53e1bf7
93e4408
e683423
646dea4
bdb0390
daf7fea
3358747
897d5f7
a822a4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ on: | |
jobs: | ||
docker: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
env: | ||
RAILS_ENV: test | ||
steps: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
ruby 3.2.2 | ||
yarn 1.22.19 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div class="dropdown <%= @class %>"> | ||
<button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> | ||
<% if icon? %> | ||
<%= render_icon %> | ||
<% else %> | ||
<svg width="5" height="20" viewBox="0 0 5 20" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||
<title><%= @menu_title %></title> | ||
<path d="M2.5 0.9375C1.82292 0.9375 1.23698 1.17188 0.742187 1.64063C0.247396 2.10938 -7.68364e-08 2.69531 -1.07571e-07 3.39844C-1.38306e-07 4.10156 0.247396 4.70052 0.742187 5.19531C1.23698 5.6901 1.82292 5.9375 2.5 5.9375C3.17708 5.9375 3.76302 5.6901 4.25781 5.19531C4.7526 4.70052 5 4.10156 5 3.39844C5 2.69531 4.7526 2.10938 4.25781 1.64063C3.76302 1.17188 3.17708 0.9375 2.5 0.9375ZM2.5 7.5C1.82292 7.5 1.23698 7.7474 0.742187 8.24219C0.247395 8.73698 -3.66538e-07 9.32292 -3.96134e-07 10C-4.25731e-07 10.6771 0.247395 11.263 0.742187 11.7578C1.23698 12.2526 1.82292 12.5 2.5 12.5C3.17708 12.5 3.76302 12.2526 4.25781 11.7578C4.7526 11.263 5 10.6771 5 10C5 9.32292 4.7526 8.73698 4.25781 8.24219C3.76302 7.7474 3.17708 7.5 2.5 7.5ZM2.5 14.0625C1.82292 14.0625 1.23698 14.3099 0.742187 14.8047C0.247395 15.2995 -6.53963e-07 15.8984 -6.84698e-07 16.6016C-7.15432e-07 17.3047 0.247395 17.8906 0.742187 18.3594C1.23698 18.8281 1.82292 19.0625 2.5 19.0625C3.17708 19.0625 3.76302 18.8281 4.25781 18.3594C4.7526 17.8906 5 17.3047 5 16.6016C5 15.8984 4.7526 15.2995 4.25781 14.8047C3.76302 14.3099 3.17708 14.0625 2.5 14.0625Z" fill="#5D657B" /> | ||
</svg> | ||
<% end %> | ||
<%= button_label %> | ||
</button> | ||
<ul class="dropdown-menu"> | ||
<%= content %> | ||
</ul> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
class DropdownMenuComponent < ViewComponent::Base | ||
renders_one :icon | ||
|
||
def initialize(menu_title:, icon_name: nil, hide_label: false, render_check: true, klass: nil) | ||
@menu_title = menu_title | ||
@render_check = render_check | ||
@hide_label = hide_label | ||
@icon_name = icon_name | ||
@class = klass | ||
end | ||
|
||
def render_icon | ||
return icon if icon.present? | ||
|
||
content_tag(:i, nil, class: "lni mr-10 lni-#{@icon_name}") | ||
end | ||
|
||
def icon? | ||
icon.present? || @icon_name.present? | ||
end | ||
|
||
def render? | ||
@render_check && @menu_title.present? && content.present? | ||
end | ||
|
||
def button_label | ||
content_tag(:span, @menu_title, class: @hide_label ? "sr-only" : nil) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div class="modal-body <%= @class %>"> | ||
<%= body_content %> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
class Modal::BodyComponent < ViewComponent::Base | ||
def initialize(text: nil, klass: nil, render_check: true) | ||
@text = text | ||
@render_check = render_check | ||
@class = klass | ||
end | ||
|
||
def body_content | ||
return content if content.present? | ||
|
||
Array.wrap(@text).map do |text| | ||
content_tag :p, text | ||
end.join.html_safe | ||
end | ||
|
||
def render? | ||
@render_check && (@text.present? || content.present?) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="modal-footer <%= @class %>"> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> | ||
<%= content %> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class Modal::FooterComponent < ViewComponent::Base | ||
def initialize(klass: nil, render_check: true) | ||
@render_check = render_check | ||
@class = klass | ||
end | ||
|
||
def render? | ||
@render_check && content.present? | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="modal fade <%= @class %>" id="<%= @id %>" tabindex="-1" aria-labelledby="<%= @id %>-label" aria-hidden="true"> | ||
<div class="modal-dialog modal-dialog-centered"> | ||
<div class="modal-content"> | ||
<%= header %> | ||
<%= body %> | ||
<%= footer %> | ||
</div> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
class Modal::GroupComponent < ViewComponent::Base | ||
renders_one :header, Modal::HeaderComponent | ||
renders_one :body, Modal::BodyComponent | ||
renders_one :footer, Modal::FooterComponent | ||
|
||
def initialize(id:, klass: nil, render_check: true) | ||
@id = id | ||
@class = klass | ||
@render_check = render_check | ||
end | ||
|
||
def render? | ||
@render_check && (body.present? || header.present?) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div class="modal-header <%= @class %>"> | ||
<%= header_content %> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
class Modal::HeaderComponent < ViewComponent::Base | ||
def initialize(id:, text: nil, icon: nil, klass: nil, render_check: true) | ||
@text = text | ||
@id = id | ||
@icon = icon | ||
@render_check = render_check | ||
@class = klass | ||
end | ||
|
||
def header_content | ||
return content if content.present? | ||
|
||
content_tag :h1, class: "modal-title fs-5", id: "#{@id}-label" do | ||
concat(content_tag(:i, nil, class: "lni mr-10 lni-#{@icon}")) if @icon.present? | ||
concat(@text) | ||
end | ||
end | ||
|
||
def render? | ||
@render_check && (@text.present? || content.present?) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<button type="button" class="btn <%= @class %>" data-bs-toggle="modal" data-bs-target="<%= "##{@target}" %>"> | ||
<% if @icon %> | ||
<i class="lni mr-10 lni-<%= @icon %>"></i> | ||
<% end %> | ||
<%= open_button %> | ||
</button> |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea was to provide two different options to open the model. As a button tag and a link tag, they format slightly differently. In most situations you would want to use a button because it's semantically correct. But in some situations you're forced to use a link like in my case. So I wanted to have both. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
class Modal::OpenButtonComponent < ViewComponent::Base | ||
def initialize(target:, text: nil, klass: nil, icon: nil, render_check: true) | ||
@target = target | ||
@text = text | ||
@icon = icon | ||
@render_check = render_check | ||
@class = klass | ||
end | ||
|
||
def open_button | ||
return content if content.present? | ||
|
||
@text | ||
end | ||
|
||
def render? | ||
@render_check && (@text.present? || content.present?) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<a href="#" role="button" class="btn <%= @class %>" data-bs-toggle="modal" data-bs-target="<%= "##{@target}" %>"> | ||
<% if @icon %> | ||
<i class="lni mr-10 lni-<%= @icon %>"></i> | ||
<% end %> | ||
<%= open_link %> | ||
</a> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
class Modal::OpenLinkComponent < ViewComponent::Base | ||
def initialize(target:, text: nil, icon: nil, klass: nil, render_check: true) | ||
@target = target | ||
@text = text | ||
@icon = icon | ||
@class = klass | ||
@render_check = render_check | ||
end | ||
|
||
def open_link | ||
return content if content.present? | ||
|
||
@text | ||
end | ||
|
||
def render? | ||
@render_check && (@text.present? || content.present?) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems pretty restrictive to what can go in to the body. Why not just insert what the content is and do something like this when rendering...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do that, currently if you provide a block it overrides and text is optional.
It's just if you provide text as a string or array of strings. It gets wrapped in ptags.
casa/spec/components/modal/body_component_spec.rb
Line 20 in 897d5f7