backoffice-components 0.0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/lib/app/components/attachment_card_component.html.erb +26 -0
  3. data/lib/app/components/attachment_card_component.rb +9 -0
  4. data/lib/app/components/attachments_list_component.html.erb +9 -0
  5. data/lib/app/components/attachments_list_component.rb +5 -0
  6. data/lib/app/components/current_user_mini_card_component.html.erb +8 -0
  7. data/lib/app/components/current_user_mini_card_component.rb +7 -0
  8. data/lib/app/components/form_component.html.erb +36 -0
  9. data/lib/app/components/form_component.rb +14 -0
  10. data/lib/app/components/forms/breadcrumb_component.html.erb +18 -0
  11. data/lib/app/components/forms/breadcrumb_component.rb +9 -0
  12. data/lib/app/components/forms/delete_button_component.html.erb +3 -0
  13. data/lib/app/components/forms/delete_button_component.rb +9 -0
  14. data/lib/app/components/forms/divider_component.html.erb +8 -0
  15. data/lib/app/components/forms/divider_component.rb +9 -0
  16. data/lib/app/components/forms/submit_button_component.html.erb +7 -0
  17. data/lib/app/components/forms/submit_button_component.rb +6 -0
  18. data/lib/app/components/forms/subtitle_component.html.erb +5 -0
  19. data/lib/app/components/forms/subtitle_component.rb +9 -0
  20. data/lib/app/components/forms/title_component.html.erb +3 -0
  21. data/lib/app/components/forms/title_component.rb +9 -0
  22. data/lib/app/components/icons/collection_component.html.erb +3 -0
  23. data/lib/app/components/icons/collection_component.rb +6 -0
  24. data/lib/app/components/icons/home_component.html.erb +3 -0
  25. data/lib/app/components/icons/home_component.rb +6 -0
  26. data/lib/app/components/icons/mic_component.html.erb +3 -0
  27. data/lib/app/components/icons/mic_component.rb +6 -0
  28. data/lib/app/components/icons/news_paper_component.html.erb +3 -0
  29. data/lib/app/components/icons/news_paper_component.rb +6 -0
  30. data/lib/app/components/icons/office_building_component.html.erb +3 -0
  31. data/lib/app/components/icons/office_building_component.rb +6 -0
  32. data/lib/app/components/icons/question_mark_circle_component.html.erb +3 -0
  33. data/lib/app/components/icons/question_mark_circle_component.rb +7 -0
  34. data/lib/app/components/icons/trash_component.html.erb +3 -0
  35. data/lib/app/components/icons/trash_component.rb +6 -0
  36. data/lib/app/components/icons/users_component.html.erb +3 -0
  37. data/lib/app/components/icons/users_component.rb +6 -0
  38. data/lib/app/components/index_component.html.erb +9 -0
  39. data/lib/app/components/index_component.rb +5 -0
  40. data/lib/app/components/index_header_add_component.html.erb +3 -0
  41. data/lib/app/components/index_header_add_component.rb +7 -0
  42. data/lib/app/components/index_header_component.html.erb +15 -0
  43. data/lib/app/components/index_header_component.rb +10 -0
  44. data/lib/app/components/input/file_component.html.erb +11 -0
  45. data/lib/app/components/input/file_component.rb +29 -0
  46. data/lib/app/components/sidebar_component.html.erb +23 -0
  47. data/lib/app/components/sidebar_component.rb +6 -0
  48. data/lib/app/components/sidebar_item_component.html.erb +9 -0
  49. data/lib/app/components/sidebar_item_component.rb +9 -0
  50. data/lib/app/components/sign_out_button_component.html.erb +5 -0
  51. data/lib/app/components/sign_out_button_component.rb +4 -0
  52. data/lib/app/components/tables/table_component.html.erb +21 -0
  53. data/lib/app/components/tables/table_component.rb +8 -0
  54. data/lib/app/components/tables/tbody_component.html.erb +5 -0
  55. data/lib/app/components/tables/tbody_component.rb +7 -0
  56. data/lib/app/components/tables/td_component.html.erb +3 -0
  57. data/lib/app/components/tables/td_component.rb +6 -0
  58. data/lib/app/components/tables/th_component.html.erb +3 -0
  59. data/lib/app/components/tables/th_component.rb +6 -0
  60. data/lib/app/components/tables/thead_component.html.erb +7 -0
  61. data/lib/app/components/tables/thead_component.rb +7 -0
  62. data/lib/app/components/tables/tr_component.html.erb +6 -0
  63. data/lib/app/components/tables/tr_component.rb +11 -0
  64. data/lib/app/helpers/application_helper.rb +5 -0
  65. data/lib/app/helpers/flash_helper.rb +16 -0
  66. data/lib/app/javascript/controllers/flash_controller.js +7 -0
  67. data/lib/backoffice-components.rb +49 -0
  68. metadata +136 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0bd65e465f82b95e55c0d8fb1968951fa0368cb50ccf0f852313b907d167f1ef
4
+ data.tar.gz: 51042d93d4df29a57ae7ddcfdcbee0fd120924003f01633ce2462a95f4f4ad23
5
+ SHA512:
6
+ metadata.gz: 7ad569197c0b6819b08442f979b005386d91cccd73c10e28b34e4eea98786d6e0b6b17458e58095b42646aa869f1c18867a467c0fb1229c0febe4a4af562c118
7
+ data.tar.gz: af4aeb9a7fda038eb3ffa348975e4c71e94840091a66dbf92e51439aa1d6a52fcaa52d5b816a20c9dae2b7dd96e4dc6f3259199d2f9964fba10c75c1e217bcce
@@ -0,0 +1,26 @@
1
+ <%= turbo_frame_tag @attachment do %>
2
+ <li class="col-span-1 flex rounded-md shadow-sm">
3
+ <div class="flex-shrink-0 flex items-center justify-center w-16 bg-gray-100 text-gray-500 text-sm font-medium rounded-l-md border-t border-r border-b border-gray-200 ">
4
+
5
+ <% if @attachment.image? %>
6
+ <%= image_tag @attachment %>
7
+ <% else %>
8
+ <%= @attachment.blob.filename.extension.upcase %>
9
+ <% end %>
10
+
11
+ </div>
12
+
13
+ <div class="flex flex-1 items-center justify-between truncate rounded-r-md border-t border-r border-b border-gray-200 bg-white">
14
+ <div class="flex-1 truncate px-4 py-2 text-sm">
15
+ <span href="#" class="font-medium text-gray-900 hover:text-gray-600" title="<%= @attachment.blob.filename %>"><%= @attachment.blob.filename %></span>
16
+ <p class="text-gray-500"><%= (@attachment.blob.byte_size.to_f / 1000000).round(2) %> Mb</p>
17
+ </div>
18
+
19
+ <div class="flex-shrink-0 pr-2">
20
+ <%= button_tag type: :button, data: { controller: "attachments", attachments_method_value: 'delete', attachments_url_value: remove_attachment_admin_thematic_path(@attachment.record), attachments_attachment_id_value: @attachment.id, action: "click->attachments#toggle" } do %>
21
+ <span class="sr-only">Delete</span>
22
+ <%= render(Icons::TrashComponent.new) %>
23
+ <% end %>
24
+ </div>
25
+ </li>
26
+ <% end %>
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ include Turbo::FramesHelper, Turbo::Streams::StreamName, Turbo::Streams::Broadcasts
4
+
5
+ class AttachmentCardComponent < ViewComponent::Base
6
+ def initialize(attachment:)
7
+ @attachment = attachment
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ <div>
2
+ <ul role="list" class="my-3 grid grid-cols-1 gap-2 sm:grid-cols-2 sm:gap-2 lg:grid-cols-2">
3
+
4
+ <% attachments.each do |attachment| %>
5
+ <%= attachment %>
6
+ <% end %>
7
+
8
+ </ul>
9
+ </div>
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AttachmentsListComponent < ViewComponent::Base
4
+ renders_many :attachments, AttachmentCardComponent
5
+ end
@@ -0,0 +1,8 @@
1
+ <div class="flex-shrink-0 flex justify-between items-center border-t border-sidebar-200 p-4">
2
+ <div class="flex items-center">
3
+ <p class="text-sm ml-3 font-medium text-white">
4
+ <%= "#{@user.first_name} #{@user.last_name}" %>
5
+ </p>
6
+ </div>
7
+ <%= render(SignOutButtonComponent.new) %>
8
+ </div>
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CurrentUserMiniCardComponent < ViewComponent::Base
4
+ def initialize(user:)
5
+ @user = user
6
+ end
7
+ end
@@ -0,0 +1,36 @@
1
+ <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
2
+ <div class="max-w-2xl mx-auto ">
3
+
4
+ <% if breadcrumb? %>
5
+ <%= breadcrumb %>
6
+ <% end %>
7
+
8
+ <div class="my-5 mb-10">
9
+ <div class="mt-2 md:flex md:items-center md:justify-between">
10
+
11
+ <% if title? %>
12
+ <%= title %>
13
+ <% end %>
14
+
15
+ <% if delete_button? %>
16
+ <%= delete_button %>
17
+ <% end %>
18
+
19
+ </div>
20
+ </div>
21
+
22
+ <% if @nav_bar %>
23
+ <%= render(@nav_bar) %>
24
+ <% end %>
25
+
26
+ <% if item.is_a?(ApplicationRecord) && item.errors.any? %>
27
+ <div class="error-message">
28
+ <%= render('layouts/errors', errors: item.errors.full_messages.to_sentence.capitalize) %>
29
+ </div>
30
+ <% end %>
31
+
32
+ <div class="px-4 py-5 bg-white space-y-6 sm:p-6 shadow sm:rounded-md sm:overflow-hidden">
33
+ <%= content %>
34
+ </div>
35
+ </div>
36
+ </div>
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ class FormComponent < ViewComponent::Base
4
+ renders_one :breadcrumb, Forms::BreadcrumbComponent
5
+ renders_one :title, Forms::TitleComponent
6
+ renders_one :delete_button, Forms::DeleteButtonComponent
7
+
8
+ def initialize(item:, nav_bar: nil)
9
+ @item = item
10
+ @nav_bar = nav_bar
11
+ end
12
+
13
+ attr_reader :item
14
+ end
@@ -0,0 +1,18 @@
1
+ <ol role="list" class="flex items-center space-x-4">
2
+
3
+ <% @items.each.with_index do |item, i| %>
4
+ <li>
5
+ <div class="flex items-center">
6
+ <% if i.positive? %>
7
+ <!-- Heroicon name: solid/chevron-right -->
8
+ <svg class="flex-shrink-0 h-5 w-5 text-gray-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
9
+ <path fill-rule="evenodd" d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z" clip-rule="evenodd" />
10
+ </svg>
11
+ <% end %>
12
+ <a href="<%= item[:path] %>" class="<%= 'ml-4' unless i.zero? %> text-sm font-medium text-gray-500 hover:text-gray-700">
13
+ <%= item[:label] %>
14
+ </a>
15
+ </div>
16
+ </li>
17
+ <% end %>
18
+ </ol>
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Forms
4
+ class BreadcrumbComponent < ViewComponent::Base
5
+ def initialize(items)
6
+ @items = items
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ <button type="button" class="inline-flex items-center px-3 py-2 border border-gray-300 shadow-sm text-sm leading-4 font-medium rounded-md text-gray-700 bg-white hover:bg-red-400 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" type="delete">
2
+ <%= link_to "Supprimer", @path, data: { "turbo-method": :delete, turbo_confirm: 'Êtes vous sûr ?' } %>
3
+ </button>
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Forms
4
+ class DeleteButtonComponent < ViewComponent::Base
5
+ def initialize(path)
6
+ @path = path
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ <div class="relative">
2
+ <div class="absolute inset-0 flex items-center" aria-hidden="true">
3
+ <div class="w-full border-t border-gray-300"></div>
4
+ </div>
5
+ <div class="relative flex justify-center">
6
+ <span class="bg-white px-2 text-sm text-gray-500"><%= @title %></span>
7
+ </div>
8
+ </div>
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Forms
4
+ class DividerComponent < ViewComponent::Base
5
+ def initialize(title)
6
+ @title = title
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ <div class="pt-5">
2
+ <div class="flex justify-end">
3
+ <button type="submit" class="ml-3 inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
4
+ Sauvegarder
5
+ </button>
6
+ </div>
7
+ </div>
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Forms
4
+ class SubmitButtonComponent < ViewComponent::Base
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ <div class="my-5">
2
+ <h3 class="text-lg leading-6 font-medium text-gray-900">
3
+ <%= @subtitle %>
4
+ </h3>
5
+ </div>
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Forms
4
+ class SubtitleComponent < ViewComponent::Base
5
+ def initialize(subtitle)
6
+ @subtitle = subtitle
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ <div class="flex-1 min-w-0">
2
+ <h2 class="text-2xl font-bold leading-7 text-gray-900 sm:text-3xl sm:truncate"><%= @title %></h2>
3
+ </div>
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Forms
4
+ class TitleComponent < ViewComponent::Base
5
+ def initialize(title)
6
+ @title = title
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ <svg class="mr-3 flex-shrink-0 h-6 w-6 text-sidebar-50" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">
2
+ <path stroke-linecap="round" stroke-linejoin="round" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" />
3
+ </svg>
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icons
4
+ class CollectionComponent < ViewComponent::Base
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ <svg class="mr-3 flex-shrink-0 h-6 w-6 text-sidebar-50" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">
2
+ <path stroke-linecap="round" stroke-linejoin="round" d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" />
3
+ </svg>
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icons
4
+ class HomeComponent < ViewComponent::Base
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ <svg class="mr-3 flex-shrink-0 h-6 w-6 text-sidebar-50" xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
2
+ <path stroke-linecap="round" stroke-linejoin="round" d="M11 5.882V19.24a1.76 1.76 0 01-3.417.592l-2.147-6.15M18 13a3 3 0 100-6M5.436 13.683A4.001 4.001 0 017 6h1.832c4.1 0 7.625-1.234 9.168-3v14c-1.543-1.766-5.067-3-9.168-3H7a3.988 3.988 0 01-1.564-.317z" />
3
+ </svg>
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icons
4
+ class MicComponent < ViewComponent::Base
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ <svg class="mr-3 flex-shrink-0 h-6 w-6 text-sidebar-50" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
2
+ <path stroke-linecap="round" stroke-linejoin="round" d="M12 7.5h1.5m-1.5 3h1.5m-7.5 3h7.5m-7.5 3h7.5m3-9h3.375c.621 0 1.125.504 1.125 1.125V18a2.25 2.25 0 01-2.25 2.25M16.5 7.5V18a2.25 2.25 0 002.25 2.25M16.5 7.5V4.875c0-.621-.504-1.125-1.125-1.125H4.125C3.504 3.75 3 4.254 3 4.875V18a2.25 2.25 0 002.25 2.25h13.5M6 7.5h3v3H6v-3z" />
3
+ </svg>
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icons
4
+ class NewsPaperComponent < ViewComponent::Base
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ <svg class="mr-3 flex-shrink-0 h-6 w-6 text-sidebar-50" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">
2
+ <path stroke-linecap="round" stroke-linejoin="round" d="M19 21V5a2 2 0 00-2-2H7a2 2 0 00-2 2v16m14 0h2m-2 0h-5m-9 0H3m2 0h5M9 7h1m-1 4h1m4-4h1m-1 4h1m-5 10v-5a1 1 0 011-1h2a1 1 0 011 1v5m-4 0h4" />
3
+ </svg>
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icons
4
+ class OfficeBuildingComponent < ViewComponent::Base
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ <svg class="mr-3 flex-shrink-0 h-6 w-6 text-sidebar-50" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">
2
+ <path stroke-linecap="round" stroke-linejoin="round" d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
3
+ </svg>
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icons
4
+ # FAQ
5
+ class QuestionMarkCircleComponent < ViewComponent::Base
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ <svg class="mr-3 flex-shrink-0 h-6 w-6" xmlns="http://www.w3.org/2000/svg" className="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
2
+ <path strokeLinecap="round" strokeLinejoin="round" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
3
+ </svg>
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icons
4
+ class TrashComponent < ViewComponent::Base
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ <svg class="mr-3 flex-shrink-0 h-6 w-6 text-sidebar-50" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" aria-hidden="true">
2
+ <path stroke-linecap="round" stroke-linejoin="round" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/>
3
+ </svg>
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icons
4
+ class UsersComponent < ViewComponent::Base
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ <div class="px-4 sm:px-6 lg:px-8">
2
+
3
+ <% if header? %>
4
+ <% header %>
5
+ <% end %>
6
+
7
+ <%= content %>
8
+
9
+ </div>
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class IndexComponent < ViewComponent::Base
4
+ renders_one :header, IndexHeaderComponent
5
+ end
@@ -0,0 +1,3 @@
1
+ <div class="mt-4 sm:mt-0 sm:ml-16 sm:flex-none">
2
+ <%= link_to '+', @path, class: "inline-flex items-center justify-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 sm:w-auto" %>
3
+ </div>
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ class IndexHeaderAddComponent < ViewComponent::Base
4
+ def initialize(path:)
5
+ @path = path
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ <div class="sm:flex sm:items-center">
2
+ <div class="sm:flex-auto">
3
+ <h1 class="text-xl font-semibold text-gray-900">
4
+ <%= @title %>
5
+ </h1>
6
+ <p class="mt-2 text-sm text-gray-700">
7
+ <%= @subtitle %>
8
+ </p>
9
+ </div>
10
+
11
+ <% if add_button? %>
12
+ <%= add_button %>
13
+ <% end %>
14
+
15
+ </div>
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class IndexHeaderComponent < ViewComponent::Base
4
+ renders_one :add_button, IndexHeaderAddComponent
5
+
6
+ def initialize(title:, subtitle:)
7
+ @title = title
8
+ @subtitle = subtitle
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ <div>
2
+ <label class="block my-5 block text-sm font-medium text-gray-700 string optional text-sm font-medium text-gray-600">
3
+ <%= label %>
4
+ <% if @object.attached? && object.variable? %>
5
+ <%= image_tag @picture, class: 'border-2 border-dashed border-gray-300 mb-4' %>
6
+ <% elsif @object.attached? %>
7
+ <div><%= link_to @object.filename, url_for(@object) %></div>
8
+ <% end %>
9
+ <%= @form.file_field @field, class: "font-normal block text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 file:mr-5 file:py-2 file:px-6 file:border-0 pr-5" %>
10
+ </label>
11
+ </div>
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Input
4
+ class FileComponent < ViewComponent::Base
5
+ def initialize(item:, field:, form:, variant: nil)
6
+ @item = item
7
+ @field = field
8
+ @form = form
9
+ @label = label
10
+ @variant = variant
11
+ @picture = picture
12
+ @object = object
13
+ end
14
+
15
+ def label
16
+ I18n.t("#{@item.class.name.downcase}.attributes.#{@field}")
17
+ end
18
+
19
+ def picture
20
+ return object unless @variant
21
+
22
+ object.variant(@variant)
23
+ end
24
+
25
+ def object
26
+ @item.send(@field)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,23 @@
1
+ <div class=" md:flex md:w-64 md:flex-col md:fixed md:inset-y-0">
2
+ <div class="flex-1 flex flex-col min-h-0 bg-sidebar">
3
+ <div class="flex-1 flex flex-col pt-5 pb-4 overflow-y-auto">
4
+ <div class="flex items-center flex-shrink-0 px-4">
5
+ <%= image_tag("logo.png", alt: "logo rif", class: 'mx-auto h-15 w-auto') %>
6
+ </div>
7
+
8
+ <nav class="mt-5 flex-1 px-2 space-y-1" aria-label="Sidebar">
9
+
10
+ <% items.each do |item| %>
11
+ <%= item %>
12
+ <% end %>
13
+
14
+ </nav>
15
+
16
+ </div>
17
+
18
+ <% if current_user_card? %>
19
+ <%= current_user_card %>
20
+ <% end %>
21
+
22
+ </div>
23
+ </div>
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SidebarComponent < ViewComponent::Base
4
+ renders_many :items, SidebarItemComponent
5
+ renders_one :current_user_card, CurrentUserMiniCardComponent
6
+ end
@@ -0,0 +1,9 @@
1
+ <% current_class = current_page?(@path) ? 'bg-sidebar-900 text-white hover:bg-sidebar-900' : '' %>
2
+
3
+ <%= link_to @path, class: "#{current_class} group flex items-center px-2 py-2 text-sm font-medium rounded-md hover:bg-sidebar-200" do %>
4
+ <%= render(@icon.new) %>
5
+
6
+ <span class="flex-1 text-white">
7
+ <%= @label %>
8
+ </span>
9
+ <% end %>
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SidebarItemComponent < ViewComponent::Base
4
+ def initialize(path:, label:, icon: Icons::HomeComponent)
5
+ @path = path
6
+ @icon = icon
7
+ @label = label
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ <%= button_to sign_out_path, class:"flex items-center", method: :delete do %>
2
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="white" stroke-width="2">
3
+ <path stroke-linecap="round" stroke-linejoin="round" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"/>
4
+ </svg>
5
+ <% end %>
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SignOutButtonComponent < ViewComponent::Base
4
+ end
@@ -0,0 +1,21 @@
1
+
2
+ <div class="mt-8 flex flex-col">
3
+ <div class="-my-2 -mx-4 overflow-x-auto sm:-mx-6 lg:-mx-8">
4
+ <div class="inline-block min-w-full py-2 align-middle md:px-6 lg:px-8">
5
+ <div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg">
6
+ <table class="min-w-full divide-y divide-gray-300">
7
+
8
+ <% if thead? %>
9
+ <%= thead %>
10
+ <% end %>
11
+
12
+ <% if tbody? %>
13
+ <%= tbody %>
14
+ <% end %>
15
+
16
+ </table>
17
+
18
+ </div>
19
+ </div>
20
+ </div>
21
+ </div>
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tables
4
+ class TableComponent < ViewComponent::Base
5
+ renders_one :thead, Tables::TheadComponent
6
+ renders_one :tbody, Tables::TbodyComponent
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ <tbody class="bg-white">
2
+ <% trs.each do |tr| %>
3
+ <%= tr %>
4
+ <% end %>
5
+ </tbody>
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tables
4
+ class TbodyComponent < ViewComponent::Base
5
+ renders_many :trs, Tables::TrComponent
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ <td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-gray-900">
2
+ <%= content %>
3
+ </td>
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tables
4
+ class TdComponent < ViewComponent::Base
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ <th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">
2
+ <%= content %>
3
+ </th>
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tables
4
+ class ThComponent < ViewComponent::Base
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ <thead class="bg-gray-50">
2
+ <tr>
3
+ <% ths.each do |th| %>
4
+ <%= th %>
5
+ <% end %>
6
+ </tr>
7
+ </thead>
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tables
4
+ class TheadComponent < ViewComponent::Base
5
+ renders_many :ths, Tables::ThComponent
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ <tr class=<%= @bg_color %>>
2
+
3
+ <% tds.each do |td| %>
4
+ <%= td %>
5
+ <% end %>
6
+ </tr>
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Tables
4
+ class TrComponent < ViewComponent::Base
5
+ renders_many :tds, Tables::TdComponent
6
+
7
+ def initialize(index: 0)
8
+ @bg_color = 'bg-gray-50' if index.odd?
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ApplicationHelper
4
+ # include Pagy::Frontend
5
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FlashHelper
4
+ # todo remove me and create a custom administrator authentification
5
+ def current_user
6
+ OpenStruct.new(email: "michel@tymate.com")
7
+ end
8
+
9
+ def classes_for_flash(key)
10
+ if %w[error alert].include?(key)
11
+ 'red'
12
+ else
13
+ 'green'
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ import { Controller } from "@hotwired/stimulus";
2
+
3
+ export default class extends Controller {
4
+ dismiss() {
5
+ this.element.remove();
6
+ }
7
+ }
@@ -0,0 +1,49 @@
1
+ autoload 'AttachmentCardComponent', 'app/components/attachment_card_component'
2
+ autoload 'AttachmentsListComponent', 'app/components/attachments_list_component'
3
+ autoload 'CurrentUserMiniCardComponent', 'app/components/current_user_mini_card_component'
4
+ autoload 'FormComponent', 'app/components/form_component'
5
+ autoload 'IndexComponent', 'app/components/index_component'
6
+ autoload 'IndexHeaderAddComponent', 'app/components/index_header_add_component'
7
+ autoload 'IndexHeaderComponent', 'app/components/index_header_component'
8
+ autoload 'SidebarComponent', 'app/components/sidebar_component'
9
+ autoload 'SidebarItemComponent', 'app/components/sidebar_item_component'
10
+ autoload 'SignOutButtonComponent', 'app/components/sign_out_button_component'
11
+
12
+ module Forms
13
+ autoload 'BreadcrumbComponent', 'app/components/forms/breadcrumb_component'
14
+ autoload 'DeleteButtonComponent', 'app/components/forms/delete_button_component'
15
+ autoload 'DividerComponent', 'app/components/forms/divider_component'
16
+ autoload 'SubmitButtonComponent', 'app/components/forms/submit_button_component'
17
+ autoload 'SubtitleComponent', 'app/components/forms/subtitle_component'
18
+ autoload 'TitleComponent', 'app/components/forms/title_component'
19
+ end
20
+
21
+ module Icons
22
+ autoload 'CollectionComponent', 'app/components/icons/collection_component'
23
+ autoload 'HomeComponent', 'app/components/icons/home_component'
24
+ autoload 'MicComponent', 'app/components/icons/mic_component'
25
+ autoload 'NewsPaperComponent', 'app/components/icons/news_paper_component'
26
+ autoload 'OfficeBuildingComponent', 'app/components/icons/office_building_component'
27
+ autoload 'QuestionMarkCircleComponent', 'app/components/icons/question_mark_circle_component'
28
+ autoload 'TrashComponent', 'app/components/icons/trash_component'
29
+ autoload 'UsersComponent', 'app/components/icons/users_component'
30
+ end
31
+
32
+ module Input
33
+ autoload 'FileComponent', 'app/components/input/file_component'
34
+ end
35
+
36
+ module Tables
37
+ autoload 'TableComponent', 'app/components/tables/table_component'
38
+ autoload 'TbodyComponent', 'app/components/tables/tbody_component'
39
+ autoload 'TdComponent', 'app/components/tables/td_component'
40
+ autoload 'ThComponent', 'app/components/tables/th_component'
41
+ autoload 'TheadComponent', 'app/components/tables/thead_component'
42
+ autoload 'TrComponent', 'app/components/tables/tr_component'
43
+ end
44
+
45
+ class String
46
+ def julien
47
+ 'wow2'
48
+ end
49
+ end
metadata ADDED
@@ -0,0 +1,136 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: backoffice-components
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Julien Camblan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-10-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: turbo-rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: stimulus-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.1.0
41
+ description: Collection of ViewComponents objects for backoffice
42
+ email: julien@tymate.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/app/components/attachment_card_component.html.erb
48
+ - lib/app/components/attachment_card_component.rb
49
+ - lib/app/components/attachments_list_component.html.erb
50
+ - lib/app/components/attachments_list_component.rb
51
+ - lib/app/components/current_user_mini_card_component.html.erb
52
+ - lib/app/components/current_user_mini_card_component.rb
53
+ - lib/app/components/form_component.html.erb
54
+ - lib/app/components/form_component.rb
55
+ - lib/app/components/forms/breadcrumb_component.html.erb
56
+ - lib/app/components/forms/breadcrumb_component.rb
57
+ - lib/app/components/forms/delete_button_component.html.erb
58
+ - lib/app/components/forms/delete_button_component.rb
59
+ - lib/app/components/forms/divider_component.html.erb
60
+ - lib/app/components/forms/divider_component.rb
61
+ - lib/app/components/forms/submit_button_component.html.erb
62
+ - lib/app/components/forms/submit_button_component.rb
63
+ - lib/app/components/forms/subtitle_component.html.erb
64
+ - lib/app/components/forms/subtitle_component.rb
65
+ - lib/app/components/forms/title_component.html.erb
66
+ - lib/app/components/forms/title_component.rb
67
+ - lib/app/components/icons/collection_component.html.erb
68
+ - lib/app/components/icons/collection_component.rb
69
+ - lib/app/components/icons/home_component.html.erb
70
+ - lib/app/components/icons/home_component.rb
71
+ - lib/app/components/icons/mic_component.html.erb
72
+ - lib/app/components/icons/mic_component.rb
73
+ - lib/app/components/icons/news_paper_component.html.erb
74
+ - lib/app/components/icons/news_paper_component.rb
75
+ - lib/app/components/icons/office_building_component.html.erb
76
+ - lib/app/components/icons/office_building_component.rb
77
+ - lib/app/components/icons/question_mark_circle_component.html.erb
78
+ - lib/app/components/icons/question_mark_circle_component.rb
79
+ - lib/app/components/icons/trash_component.html.erb
80
+ - lib/app/components/icons/trash_component.rb
81
+ - lib/app/components/icons/users_component.html.erb
82
+ - lib/app/components/icons/users_component.rb
83
+ - lib/app/components/index_component.html.erb
84
+ - lib/app/components/index_component.rb
85
+ - lib/app/components/index_header_add_component.html.erb
86
+ - lib/app/components/index_header_add_component.rb
87
+ - lib/app/components/index_header_component.html.erb
88
+ - lib/app/components/index_header_component.rb
89
+ - lib/app/components/input/file_component.html.erb
90
+ - lib/app/components/input/file_component.rb
91
+ - lib/app/components/sidebar_component.html.erb
92
+ - lib/app/components/sidebar_component.rb
93
+ - lib/app/components/sidebar_item_component.html.erb
94
+ - lib/app/components/sidebar_item_component.rb
95
+ - lib/app/components/sign_out_button_component.html.erb
96
+ - lib/app/components/sign_out_button_component.rb
97
+ - lib/app/components/tables/table_component.html.erb
98
+ - lib/app/components/tables/table_component.rb
99
+ - lib/app/components/tables/tbody_component.html.erb
100
+ - lib/app/components/tables/tbody_component.rb
101
+ - lib/app/components/tables/td_component.html.erb
102
+ - lib/app/components/tables/td_component.rb
103
+ - lib/app/components/tables/th_component.html.erb
104
+ - lib/app/components/tables/th_component.rb
105
+ - lib/app/components/tables/thead_component.html.erb
106
+ - lib/app/components/tables/thead_component.rb
107
+ - lib/app/components/tables/tr_component.html.erb
108
+ - lib/app/components/tables/tr_component.rb
109
+ - lib/app/helpers/application_helper.rb
110
+ - lib/app/helpers/flash_helper.rb
111
+ - lib/app/javascript/controllers/flash_controller.js
112
+ - lib/backoffice-components.rb
113
+ homepage: https://rubygems.org/gems/backoffice-components
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubygems_version: 3.2.32
133
+ signing_key:
134
+ specification_version: 4
135
+ summary: ''
136
+ test_files: []