From 5636711ae4fc40f6085493600fc9d173a6c62796 Mon Sep 17 00:00:00 2001 From: Jason Zimdars Date: Fri, 13 Sep 2024 17:03:43 -0500 Subject: [PATCH] Clean up with partials --- app/views/bubbles/_boosts.html.erb | 8 +++ app/views/bubbles/_bubble.html.erb | 83 ++++--------------------- app/views/bubbles/_date.html.erb | 19 ++++++ app/views/bubbles/_image.html.erb | 23 +++++++ app/views/bubbles/_tags.html.erb | 11 ++++ app/views/bubbles/index.html.erb | 17 +---- app/views/bubbles/list/_bubble.html.erb | 19 ++++++ 7 files changed, 94 insertions(+), 86 deletions(-) create mode 100644 app/views/bubbles/_boosts.html.erb create mode 100644 app/views/bubbles/_date.html.erb create mode 100644 app/views/bubbles/_image.html.erb create mode 100644 app/views/bubbles/_tags.html.erb create mode 100644 app/views/bubbles/list/_bubble.html.erb diff --git a/app/views/bubbles/_boosts.html.erb b/app/views/bubbles/_boosts.html.erb new file mode 100644 index 000000000..fb7a2b48c --- /dev/null +++ b/app/views/bubbles/_boosts.html.erb @@ -0,0 +1,8 @@ +<%= tag.div class: "bubble__bubble bubble__meta bubble__boosts", + data: { + controller: "animation toggle-class", + animation_play_class: "boosting", + toggle_class_toggle_class: "boosting", + action: "animationend->toggle-class#toggle" } do %> + <%= turbo_frame_tag dom_id(bubble, :boosts), src: bubble_boosts_path(bubble) %> +<% end %> diff --git a/app/views/bubbles/_bubble.html.erb b/app/views/bubbles/_bubble.html.erb index 3ce7d5d05..c7a5301bf 100644 --- a/app/views/bubbles/_bubble.html.erb +++ b/app/views/bubbles/_bubble.html.erb @@ -1,78 +1,21 @@
-

- <%= turbo_frame_tag bubble, :edit do %> - <%= link_to bubble.title, edit_bubble_path(bubble), class: "txt-undecorated" %> - <% end %> -

+

+ <%= turbo_frame_tag bubble, :edit do %> + <%= link_to bubble.title, edit_bubble_path(bubble), class: "txt-undecorated" %> + <% end %> +

- + + + + <%= link_to bubble, class: "bubble__link" do %> <%= bubble.title %> <% end %> -
- <%= image_tag bubble.image.attached? ? bubble.image : "", data: { upload_preview_target: "image" } %> -
- - <%= form_with model: bubble, data: { controller: "form" } do | form | %> -
- <% if bubble.image.attached? %> - <%= tag.label class: "btn btn--plain", style: "--btn-icon-size: 3em; margin-block-start: -0.5em; margin-inline-end: -0.2em", data: { action: "click->upload-preview#clear click->form#submit", upload_preview_target: "button" } do %> - - <%= form.hidden_field :bubble, value: bubble.id %> - <%= check_box_tag "remove_image", "true" %> - Remove imagee - <% end %> - <% else %> - - <% end %> -
- <% end %> - - <% if bubble.due_on.present? %> - <%= form_with model: bubble, data: { controller: "form" } do | form | %> - - <% end %> - <% else %> -
- <%= form_with model: bubble, data: { controller: "form" } do | form | %> - - <% end %> -
- <% end %> - - <% bubble.tags.each do |tag| %> - <%= link_to "##{tag.title}", bubbles_path(tag_id: tag), class: "bubble__bubble bubble__meta bubble__tag" %> - <% end %> - - <% if bubble.tags.size < 3 %> - - <%= turbo_frame_tag :new_tag do %> - <%= link_to "#", new_bubble_tag_path(bubble), class: "bubble__tag--new" %> - <% end %> - - <% end %> - - <%= tag.div class: "bubble__bubble bubble__meta bubble__boosts", - data: { - controller: "animation toggle-class", - animation_play_class: "boosting", - toggle_class_toggle_class: "boosting", - action: "animationend->toggle-class#toggle" } do %> - <%= turbo_frame_tag dom_id(bubble, :boosts), src: bubble_boosts_path(bubble) %> - <% end %> + <%= render "boosts", bubble: bubble %> + <%= render "date", bubble: bubble %> + <%= render "image", bubble: bubble %> + <%= render "tags", bubble: bubble %>
diff --git a/app/views/bubbles/_date.html.erb b/app/views/bubbles/_date.html.erb new file mode 100644 index 000000000..e57d4c056 --- /dev/null +++ b/app/views/bubbles/_date.html.erb @@ -0,0 +1,19 @@ +<% if bubble.due_on.present? %> + <%= form_with model: bubble, data: { controller: "form" } do | form | %> + + <% end %> +<% else %> +
+ <%= form_with model: bubble, data: { controller: "form" } do | form | %> + + <% end %> +
+<% end %> diff --git a/app/views/bubbles/_image.html.erb b/app/views/bubbles/_image.html.erb new file mode 100644 index 000000000..9f0a2574d --- /dev/null +++ b/app/views/bubbles/_image.html.erb @@ -0,0 +1,23 @@ +
+ <%= image_tag bubble.image.attached? ? bubble.image : "", data: { upload_preview_target: "image" } %> +
+ +<%= form_with model: bubble, data: { controller: "form" } do | form | %> +
+ <% if bubble.image.attached? %> + <%= tag.label class: "btn btn--plain", style: "--btn-icon-size: 3em; margin-block-start: -0.5em; margin-inline-end: -0.2em", data: { action: "click->upload-preview#clear click->form#submit", upload_preview_target: "button" } do %> + + <%= form.hidden_field :bubble, value: bubble.id %> + <%= check_box_tag "remove_image", "true" %> + Remove imagee + <% end %> + <% else %> + + <% end %> +
+<% end %> diff --git a/app/views/bubbles/_tags.html.erb b/app/views/bubbles/_tags.html.erb new file mode 100644 index 000000000..93bfaceeb --- /dev/null +++ b/app/views/bubbles/_tags.html.erb @@ -0,0 +1,11 @@ +<% bubble.tags.each do |tag| %> + <%= link_to "##{tag.title}", bubbles_path(tag_id: tag), class: "bubble__bubble bubble__meta bubble__tag" %> +<% end %> + +<% if bubble.tags.size < 3 %> + + <%= turbo_frame_tag :new_tag do %> + <%= link_to "#", new_bubble_tag_path(bubble), class: "bubble__tag--new" %> + <% end %> + +<% end %> diff --git a/app/views/bubbles/index.html.erb b/app/views/bubbles/index.html.erb index 55dd6765a..e5c3b5ab2 100644 --- a/app/views/bubbles/index.html.erb +++ b/app/views/bubbles/index.html.erb @@ -33,21 +33,6 @@
diff --git a/app/views/bubbles/list/_bubble.html.erb b/app/views/bubbles/list/_bubble.html.erb new file mode 100644 index 000000000..88b4a67e5 --- /dev/null +++ b/app/views/bubbles/list/_bubble.html.erb @@ -0,0 +1,19 @@ +
  • +
    + + + + +
    + + <%= link_to bubble, class: "bubble__title-link flex align-center gap flex-item-grow min-width" do %> + <%= bubble.title %> + <% end %> + + + <% bubble.tags.each do |tag| %> + <%= link_to "##{tag.title}", bubbles_path(tag_id: tag.id), style: "color: #{ bubble.color }" %> + <% end %> + + +