Skip to content

Commit

Permalink
Id is rails kit base prop, rails text logic more conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
ElisaShapiro committed Oct 31, 2024
1 parent 9ae794f commit 84ddfae
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 34 deletions.
72 changes: 40 additions & 32 deletions playbook/app/pb_kits/playbook/pb_form_pill/form_pill.html.erb
Original file line number Diff line number Diff line change
@@ -1,47 +1,55 @@
<%= content_tag(:div, id: object.id, data: object.data, class: object.classname + object.size_class, tabindex: object.tabindex, **combined_html_options) do %>
<% if object.name.present? %>
<%= pb_rails("avatar", props: { name: object.name, image_url: object.avatar_url, size: "xxs" }) %>
<div>
<%= pb_rails("title", props: {
classname: "pb_form_pill_text #{object.truncate ? "truncate_#{object.truncate}" : ""}",
id: object.id,
size: 4,
text: object.name,
}) %>
<% if object.truncate && object.id.present? %>
<%= pb_rails("tooltip", props: {
position: "top",
tooltip_id: "tooltip-#{object.id}",
trigger_element_selector: "##{object.id}"
}) do %>
<%= object.name %>
<% if object.truncate %>
<div>
<%= pb_rails("title", props: {
classname: "pb_form_pill_text truncate_#{object.truncate}",
id: object.id,
size: 4,
text: object.name,
}) %>
<% if object.id.present? %>
<%= pb_rails("tooltip", props: {
position: "top",
tooltip_id: "tooltip-#{object.id}",
trigger_element_selector: "##{object.id}"
}) do %>
<%= object.name %>
<% end %>
<% end %>
<% end %>
</div>
</div>
<% else %>
<%= pb_rails("title", props: { classname: "pb_form_pill_text", id: object.id, size: 4, text: object.name }) %>
<% end %>
<% if object.icon.present? %>
<%= pb_rails("icon", props: { classname: "pb_form_pill_icon", color: object.color, icon: object.icon }) %>
<% end %>
<% elsif object.text.present? %>
<% if object.icon.present? %>
<%= pb_rails("icon", props: { classname: "pb_form_pill_icon", color: object.color, icon: object.icon }) %>
<% end %>
<div>
<%= pb_rails("title", props: {
classname: "pb_form_pill_tag #{object.truncate ? "truncate_#{object.truncate}" : ""}",
id: object.id,
size: 4,
text: object.text
}) %>
<% if object.truncate && object.id.present? %>
<%= pb_rails("tooltip", props: {
position: "top",
tooltip_id: "tooltip-#{object.id}",
trigger_element_selector: "##{object.id}"
}) do %>
<%= object.text %>
<% if object.truncate %>
<div>
<%= pb_rails("title", props: {
classname: "pb_form_pill_tag truncate_#{object.truncate}",
id: object.id,
size: 4,
text: object.text,
}) %>
<% if object.id.present? %>
<%= pb_rails("tooltip", props: {
position: "top",
tooltip_id: "tooltip-#{object.id}",
trigger_element_selector: "##{object.id}"
}) do %>
<%= object.text %>
<% end %>
<% end %>
<% end %>
</div>
</div>
<% else %>
<%= pb_rails("title", props: { classname: "pb_form_pill_tag", id: object.id, size: 4, text: object.text, }) %>
<% end %>
<% end %>
<%= pb_rails("body", props: { classname: "pb_form_pill_close" }) do %>
<%= pb_rails("icon", props: { icon: 'times', fixed_width: true, size: object.close_icon_size }) %>
Expand Down
2 changes: 0 additions & 2 deletions playbook/app/pb_kits/playbook/pb_form_pill/form_pill.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class FormPill < Playbook::KitBase
default: "primary"
prop :tabindex
prop :icon
prop :id, type: Playbook::Props::String,
default: ""

def classname
generate_classname("pb_form_pill_kit", color, icon_class, name, text, text_transform)
Expand Down

0 comments on commit 84ddfae

Please sign in to comment.