tybo 0.0.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/tybo.rb +45 -0
  68. metadata +179 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9897851e74a06c11d9a138fd37ce454356f3d7d9df8735e481fafa40a45ecde1
4
+ data.tar.gz: fbd99b2a4e4ffae5ee374e8a2bf69623ca80dcc20512e717d8cfb68d360f4710
5
+ SHA512:
6
+ metadata.gz: 2c029d94231d4e20fe1b5498e3aac4f9f16c3d4c70b16316c0de63e55f3be79767e3ca174e1e90563d98b61d96ba505809440d95ca6bbda23cb69c4b68b63214
7
+ data.tar.gz: dcec0696f8fa822cc8898e761836eda344d030f1156eb31034f88d2127b6edd679516bb663302075575d0939acef606eda66b92d2f1b2997dec8b02d69a60c94
@@ -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("https://tymate.com/assets/logos/logo-full-tymate-white-44c399f36de12ec8b69a86ec02ab13fc5c80842dd2333117658ead762ff15f93.svg", 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
+ }
data/lib/tybo.rb ADDED
@@ -0,0 +1,45 @@
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
+ autoload 'ModalComponent', 'app/components/modal_component'
12
+
13
+ module Forms
14
+ autoload 'BreadcrumbComponent', 'app/components/forms/breadcrumb_component'
15
+ autoload 'DeleteButtonComponent', 'app/components/forms/delete_button_component'
16
+ autoload 'DividerComponent', 'app/components/forms/divider_component'
17
+ autoload 'SubmitButtonComponent', 'app/components/forms/submit_button_component'
18
+ autoload 'SubtitleComponent', 'app/components/forms/subtitle_component'
19
+ autoload 'TitleComponent', 'app/components/forms/title_component'
20
+ end
21
+
22
+ module Icons
23
+ autoload 'CollectionComponent', 'app/components/icons/collection_component'
24
+ autoload 'HomeComponent', 'app/components/icons/home_component'
25
+ autoload 'MicComponent', 'app/components/icons/mic_component'
26
+ autoload 'NewsPaperComponent', 'app/components/icons/news_paper_component'
27
+ autoload 'OfficeBuildingComponent', 'app/components/icons/office_building_component'
28
+ autoload 'QuestionMarkCircleComponent', 'app/components/icons/question_mark_circle_component'
29
+ autoload 'TrashComponent', 'app/components/icons/trash_component'
30
+ autoload 'UsersComponent', 'app/components/icons/users_component'
31
+ end
32
+
33
+ module Input
34
+ autoload 'FileComponent', 'app/components/input/file_component'
35
+ end
36
+
37
+ module Tables
38
+ autoload 'TableComponent', 'app/components/tables/table_component'
39
+ autoload 'TbodyComponent', 'app/components/tables/tbody_component'
40
+ autoload 'TdComponent', 'app/components/tables/td_component'
41
+ autoload 'ThComponent', 'app/components/tables/th_component'
42
+ autoload 'TheadComponent', 'app/components/tables/thead_component'
43
+ autoload 'TrComponent', 'app/components/tables/tr_component'
44
+ autoload 'ActiveRecordTotoComponent', 'app/components/tables/active_record_toto_component'
45
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tybo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Julien Camblan
8
+ - Michel Delpierre
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2022-12-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: turbo-rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: 1.1.1
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: 1.1.1
28
+ - !ruby/object:Gem::Dependency
29
+ name: stimulus-rails
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 1.1.0
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: 1.1.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: view_component
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: 2.62.0
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 2.62.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: tailwindcss-rails
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '2.0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '2.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: ransack
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: Collection of ViewComponents objects for backoffice
85
+ email: tech@tymate.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - lib/app/components/attachment_card_component.html.erb
91
+ - lib/app/components/attachment_card_component.rb
92
+ - lib/app/components/attachments_list_component.html.erb
93
+ - lib/app/components/attachments_list_component.rb
94
+ - lib/app/components/current_user_mini_card_component.html.erb
95
+ - lib/app/components/current_user_mini_card_component.rb
96
+ - lib/app/components/form_component.html.erb
97
+ - lib/app/components/form_component.rb
98
+ - lib/app/components/forms/breadcrumb_component.html.erb
99
+ - lib/app/components/forms/breadcrumb_component.rb
100
+ - lib/app/components/forms/delete_button_component.html.erb
101
+ - lib/app/components/forms/delete_button_component.rb
102
+ - lib/app/components/forms/divider_component.html.erb
103
+ - lib/app/components/forms/divider_component.rb
104
+ - lib/app/components/forms/submit_button_component.html.erb
105
+ - lib/app/components/forms/submit_button_component.rb
106
+ - lib/app/components/forms/subtitle_component.html.erb
107
+ - lib/app/components/forms/subtitle_component.rb
108
+ - lib/app/components/forms/title_component.html.erb
109
+ - lib/app/components/forms/title_component.rb
110
+ - lib/app/components/icons/collection_component.html.erb
111
+ - lib/app/components/icons/collection_component.rb
112
+ - lib/app/components/icons/home_component.html.erb
113
+ - lib/app/components/icons/home_component.rb
114
+ - lib/app/components/icons/mic_component.html.erb
115
+ - lib/app/components/icons/mic_component.rb
116
+ - lib/app/components/icons/news_paper_component.html.erb
117
+ - lib/app/components/icons/news_paper_component.rb
118
+ - lib/app/components/icons/office_building_component.html.erb
119
+ - lib/app/components/icons/office_building_component.rb
120
+ - lib/app/components/icons/question_mark_circle_component.html.erb
121
+ - lib/app/components/icons/question_mark_circle_component.rb
122
+ - lib/app/components/icons/trash_component.html.erb
123
+ - lib/app/components/icons/trash_component.rb
124
+ - lib/app/components/icons/users_component.html.erb
125
+ - lib/app/components/icons/users_component.rb
126
+ - lib/app/components/index_component.html.erb
127
+ - lib/app/components/index_component.rb
128
+ - lib/app/components/index_header_add_component.html.erb
129
+ - lib/app/components/index_header_add_component.rb
130
+ - lib/app/components/index_header_component.html.erb
131
+ - lib/app/components/index_header_component.rb
132
+ - lib/app/components/input/file_component.html.erb
133
+ - lib/app/components/input/file_component.rb
134
+ - lib/app/components/sidebar_component.html.erb
135
+ - lib/app/components/sidebar_component.rb
136
+ - lib/app/components/sidebar_item_component.html.erb
137
+ - lib/app/components/sidebar_item_component.rb
138
+ - lib/app/components/sign_out_button_component.html.erb
139
+ - lib/app/components/sign_out_button_component.rb
140
+ - lib/app/components/tables/table_component.html.erb
141
+ - lib/app/components/tables/table_component.rb
142
+ - lib/app/components/tables/tbody_component.html.erb
143
+ - lib/app/components/tables/tbody_component.rb
144
+ - lib/app/components/tables/td_component.html.erb
145
+ - lib/app/components/tables/td_component.rb
146
+ - lib/app/components/tables/th_component.html.erb
147
+ - lib/app/components/tables/th_component.rb
148
+ - lib/app/components/tables/thead_component.html.erb
149
+ - lib/app/components/tables/thead_component.rb
150
+ - lib/app/components/tables/tr_component.html.erb
151
+ - lib/app/components/tables/tr_component.rb
152
+ - lib/app/helpers/application_helper.rb
153
+ - lib/app/helpers/flash_helper.rb
154
+ - lib/app/javascript/controllers/flash_controller.js
155
+ - lib/tybo.rb
156
+ homepage: https://rubygems.org/gems/backoffice-components
157
+ licenses:
158
+ - MIT
159
+ metadata: {}
160
+ post_install_message:
161
+ rdoc_options: []
162
+ require_paths:
163
+ - lib
164
+ required_ruby_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ requirements: []
175
+ rubygems_version: 3.2.32
176
+ signing_key:
177
+ specification_version: 4
178
+ summary: ''
179
+ test_files: []