solidus_admin 0.0.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc.json +7 -0
  3. data/README.md +2 -2
  4. data/Rakefile +26 -0
  5. data/app/assets/builds/.keep +0 -0
  6. data/app/assets/builds/solidus_admin/tailwind.css +2799 -0
  7. data/app/assets/config/solidus_admin_manifest.js +1 -0
  8. data/app/assets/stylesheets/solidus_admin/application.tailwind.css +4 -0
  9. data/app/assets/stylesheets/solidus_admin/dark.css +12 -0
  10. data/app/assets/stylesheets/solidus_admin/dimmed.css +11 -0
  11. data/app/components/solidus_admin/adjustment_reasons/index/component.rb +43 -0
  12. data/app/components/solidus_admin/base_component.rb +29 -1
  13. data/app/components/solidus_admin/layout/feedback/component.html.erb +15 -0
  14. data/app/components/solidus_admin/layout/feedback/component.rb +4 -0
  15. data/app/components/solidus_admin/layout/feedback/component.yml +3 -0
  16. data/app/components/solidus_admin/layout/navigation/account/component.html.erb +74 -0
  17. data/app/components/solidus_admin/layout/navigation/account/component.js +16 -0
  18. data/app/components/solidus_admin/layout/navigation/account/component.rb +36 -0
  19. data/app/components/solidus_admin/{sidebar → layout/navigation}/component.html.erb +9 -9
  20. data/app/components/solidus_admin/layout/navigation/component.rb +26 -0
  21. data/app/components/solidus_admin/{sidebar → layout/navigation}/item/component.html.erb +5 -5
  22. data/app/components/solidus_admin/{sidebar → layout/navigation}/item/component.rb +2 -2
  23. data/app/components/solidus_admin/layout/page_helpers.rb +55 -0
  24. data/app/components/solidus_admin/{skip_link → layout/skip_link}/component.rb +2 -4
  25. data/app/components/solidus_admin/option_types/index/component.rb +71 -0
  26. data/app/components/solidus_admin/orders/cart/component.html.erb +77 -0
  27. data/app/components/solidus_admin/orders/cart/component.js +37 -0
  28. data/app/components/solidus_admin/orders/cart/component.rb +7 -0
  29. data/app/components/solidus_admin/orders/cart/component.yml +3 -0
  30. data/app/components/solidus_admin/orders/cart/result/component.html.erb +26 -0
  31. data/app/components/solidus_admin/orders/cart/result/component.rb +11 -0
  32. data/app/components/solidus_admin/orders/index/component.rb +92 -23
  33. data/app/components/solidus_admin/orders/index/component.yml +10 -4
  34. data/app/components/solidus_admin/orders/show/address/component.html.erb +67 -0
  35. data/app/components/solidus_admin/orders/show/address/component.js +9 -0
  36. data/app/components/solidus_admin/orders/show/address/component.rb +53 -0
  37. data/app/components/solidus_admin/orders/show/address/component.yml +14 -0
  38. data/app/components/solidus_admin/orders/show/component.html.erb +76 -0
  39. data/app/components/solidus_admin/orders/show/component.js +7 -0
  40. data/app/components/solidus_admin/orders/show/component.rb +40 -0
  41. data/app/components/solidus_admin/orders/show/component.yml +21 -0
  42. data/app/components/solidus_admin/orders/show/customer_search/component.html.erb +14 -0
  43. data/app/components/solidus_admin/orders/show/customer_search/component.js +14 -0
  44. data/app/components/solidus_admin/orders/show/customer_search/component.rb +7 -0
  45. data/app/components/solidus_admin/orders/show/customer_search/component.yml +2 -0
  46. data/app/components/solidus_admin/orders/show/customer_search/result/component.html.erb +17 -0
  47. data/app/components/solidus_admin/orders/show/customer_search/result/component.rb +11 -0
  48. data/app/components/solidus_admin/orders/show/email/component.html.erb +18 -0
  49. data/app/components/solidus_admin/orders/show/email/component.rb +15 -0
  50. data/app/components/solidus_admin/orders/show/email/component.yml +8 -0
  51. data/app/components/solidus_admin/orders/show/summary/component.html.erb +14 -0
  52. data/app/components/solidus_admin/orders/show/summary/component.rb +7 -0
  53. data/app/components/solidus_admin/orders/show/summary/component.yml +8 -0
  54. data/app/components/solidus_admin/payment_methods/index/component.rb +103 -0
  55. data/app/components/solidus_admin/payment_methods/index/component.yml +10 -0
  56. data/app/components/solidus_admin/products/index/component.rb +48 -41
  57. data/app/components/solidus_admin/products/index/component.yml +8 -7
  58. data/app/components/solidus_admin/products/show/component.html.erb +32 -38
  59. data/app/components/solidus_admin/products/show/component.rb +2 -0
  60. data/app/components/solidus_admin/products/show/component.yml +5 -5
  61. data/app/components/solidus_admin/products/status/component.rb +20 -18
  62. data/app/components/solidus_admin/products/status/component.yml +1 -0
  63. data/app/components/solidus_admin/products/stock/component.rb +38 -0
  64. data/app/components/solidus_admin/products/stock/component.yml +5 -0
  65. data/app/components/solidus_admin/promotion_categories/index/component.rb +56 -0
  66. data/app/components/solidus_admin/promotions/index/component.rb +104 -0
  67. data/app/components/solidus_admin/promotions/index/component.yml +10 -0
  68. data/app/components/solidus_admin/properties/index/component.rb +64 -0
  69. data/app/components/solidus_admin/refund_reasons/index/component.rb +53 -0
  70. data/app/components/solidus_admin/refunds_and_returns/component.rb +40 -0
  71. data/app/components/solidus_admin/refunds_and_returns/component.yml +3 -0
  72. data/app/components/solidus_admin/reimbursement_types/index/component.rb +27 -0
  73. data/app/components/solidus_admin/return_reasons/index/component.rb +42 -0
  74. data/app/components/solidus_admin/shipping/component.rb +30 -0
  75. data/app/components/solidus_admin/shipping/component.yml +3 -0
  76. data/app/components/solidus_admin/shipping_categories/index/component.rb +46 -0
  77. data/app/components/solidus_admin/shipping_methods/index/component.rb +61 -0
  78. data/app/components/solidus_admin/stock_items/edit/component.html.erb +89 -0
  79. data/app/components/solidus_admin/stock_items/edit/component.js +17 -0
  80. data/app/components/solidus_admin/stock_items/edit/component.rb +23 -0
  81. data/app/components/solidus_admin/stock_items/edit/component.yml +10 -0
  82. data/app/components/solidus_admin/stock_items/index/component.rb +174 -0
  83. data/app/components/solidus_admin/stock_items/index/component.yml +10 -0
  84. data/app/components/solidus_admin/stock_locations/index/component.rb +89 -0
  85. data/app/components/solidus_admin/stock_locations/index/component.yml +3 -0
  86. data/app/components/solidus_admin/store_credit_reasons/index/component.rb +52 -0
  87. data/app/components/solidus_admin/stores/index/component.rb +58 -0
  88. data/app/components/solidus_admin/tax_categories/index/component.rb +58 -0
  89. data/app/components/solidus_admin/tax_rates/index/component.rb +88 -0
  90. data/app/components/solidus_admin/taxes/component.rb +25 -0
  91. data/app/components/solidus_admin/taxes/component.yml +3 -0
  92. data/app/components/solidus_admin/taxonomies/index/component.rb +53 -0
  93. data/app/components/solidus_admin/ui/badge/component.rb +18 -8
  94. data/app/components/solidus_admin/ui/badge/component.yml +3 -0
  95. data/app/components/solidus_admin/ui/button/component.rb +32 -32
  96. data/app/components/solidus_admin/ui/details_list/component.html.erb +10 -0
  97. data/app/components/solidus_admin/ui/details_list/component.rb +7 -0
  98. data/app/components/solidus_admin/ui/dropdown/component.html.erb +50 -0
  99. data/app/components/solidus_admin/ui/dropdown/component.js +16 -0
  100. data/app/components/solidus_admin/ui/dropdown/component.rb +28 -0
  101. data/app/components/solidus_admin/ui/dropdown/component.yml +2 -0
  102. data/app/components/solidus_admin/ui/forms/address/component.html.erb +36 -0
  103. data/app/components/solidus_admin/ui/forms/address/component.js +34 -0
  104. data/app/components/solidus_admin/ui/forms/address/component.rb +14 -0
  105. data/app/components/solidus_admin/ui/forms/field/component.html.erb +5 -4
  106. data/app/components/solidus_admin/ui/forms/field/component.rb +53 -15
  107. data/app/components/solidus_admin/ui/forms/input/component.rb +11 -5
  108. data/app/components/solidus_admin/ui/forms/search/component.html.erb +52 -0
  109. data/app/components/solidus_admin/ui/forms/search/component.js +116 -0
  110. data/app/components/solidus_admin/ui/forms/search/component.rb +8 -0
  111. data/app/components/solidus_admin/ui/forms/search/component.yml +4 -0
  112. data/app/components/solidus_admin/ui/forms/search/result/component.rb +12 -0
  113. data/app/components/solidus_admin/ui/forms/search_field/component.html.erb +20 -0
  114. data/app/{javascript/solidus_admin/controllers/hello_controller.js → components/solidus_admin/ui/forms/search_field/component.js} +4 -2
  115. data/app/components/solidus_admin/ui/forms/search_field/component.rb +10 -0
  116. data/app/components/solidus_admin/ui/forms/search_field/component.yml +2 -0
  117. data/app/components/solidus_admin/ui/forms/switch/component.rb +27 -31
  118. data/app/components/solidus_admin/ui/forms/switch_field/component.html.erb +20 -0
  119. data/app/components/solidus_admin/ui/forms/switch_field/component.rb +11 -0
  120. data/app/components/solidus_admin/ui/icon/component.rb +4 -0
  121. data/app/components/solidus_admin/ui/modal/component.html.erb +37 -0
  122. data/app/components/solidus_admin/ui/modal/component.rb +12 -0
  123. data/app/components/solidus_admin/ui/modal/component.yml +2 -0
  124. data/app/components/solidus_admin/ui/pages/index/component.html.erb +30 -0
  125. data/app/components/solidus_admin/ui/pages/index/component.rb +119 -0
  126. data/app/components/solidus_admin/ui/pages/index/component.yml +4 -0
  127. data/app/components/solidus_admin/ui/panel/component.html.erb +26 -12
  128. data/app/components/solidus_admin/ui/panel/component.rb +17 -0
  129. data/app/components/solidus_admin/ui/panel/component.yml +1 -3
  130. data/app/components/solidus_admin/ui/resource_item/component.html.erb +10 -0
  131. data/app/components/solidus_admin/ui/resource_item/component.rb +9 -0
  132. data/app/components/solidus_admin/ui/tab/component.rb +9 -8
  133. data/app/components/solidus_admin/ui/table/component.html.erb +147 -135
  134. data/app/components/solidus_admin/ui/table/component.js +56 -17
  135. data/app/components/solidus_admin/ui/table/component.rb +94 -70
  136. data/app/components/solidus_admin/ui/table/component.yml +0 -1
  137. data/app/components/solidus_admin/ui/table/ransack_filter/component.html.erb +72 -0
  138. data/app/components/solidus_admin/ui/table/ransack_filter/component.js +73 -0
  139. data/app/components/solidus_admin/ui/table/ransack_filter/component.rb +68 -0
  140. data/app/components/solidus_admin/ui/table/ransack_filter/component.yml +3 -0
  141. data/app/components/solidus_admin/ui/table/toolbar/component.rb +21 -0
  142. data/app/components/solidus_admin/ui/thumbnail/component.rb +46 -0
  143. data/app/components/solidus_admin/ui/toast/component.html.erb +9 -5
  144. data/app/components/solidus_admin/ui/toast/component.js +9 -6
  145. data/app/components/solidus_admin/ui/toast/component.rb +2 -2
  146. data/app/components/solidus_admin/ui/toggletip/component.html.erb +14 -10
  147. data/app/components/solidus_admin/ui/toggletip/component.js +22 -4
  148. data/app/components/solidus_admin/ui/toggletip/component.rb +8 -85
  149. data/app/components/solidus_admin/users/index/component.rb +96 -0
  150. data/app/components/solidus_admin/users/index/component.yml +15 -0
  151. data/app/components/solidus_admin/zones/index/component.rb +63 -0
  152. data/app/controllers/solidus_admin/addresses_controller.rb +92 -0
  153. data/app/controllers/solidus_admin/adjustment_reasons_controller.rb +40 -0
  154. data/app/controllers/solidus_admin/base_controller.rb +1 -0
  155. data/app/controllers/solidus_admin/controller_helpers/authorization.rb +5 -1
  156. data/app/controllers/solidus_admin/controller_helpers/locale.rb +2 -2
  157. data/app/controllers/solidus_admin/controller_helpers/search.rb +48 -0
  158. data/app/controllers/solidus_admin/controller_helpers/theme.rb +30 -0
  159. data/app/controllers/solidus_admin/countries_controller.rb +12 -0
  160. data/app/controllers/solidus_admin/customers_controller.rb +29 -0
  161. data/app/controllers/solidus_admin/line_items_controller.rb +45 -0
  162. data/app/controllers/solidus_admin/option_types_controller.rb +46 -0
  163. data/app/controllers/solidus_admin/orders_controller.rb +104 -7
  164. data/app/controllers/solidus_admin/payment_methods_controller.rb +52 -0
  165. data/app/controllers/solidus_admin/products_controller.rb +26 -17
  166. data/app/controllers/solidus_admin/promotion_categories_controller.rb +29 -0
  167. data/app/controllers/solidus_admin/promotions_controller.rb +46 -0
  168. data/app/controllers/solidus_admin/properties_controller.rb +33 -0
  169. data/app/controllers/solidus_admin/refund_reasons_controller.rb +40 -0
  170. data/app/controllers/solidus_admin/reimbursement_types_controller.rb +31 -0
  171. data/app/controllers/solidus_admin/return_reasons_controller.rb +40 -0
  172. data/app/controllers/solidus_admin/shipping_categories_controller.rb +40 -0
  173. data/app/controllers/solidus_admin/shipping_methods_controller.rb +40 -0
  174. data/app/controllers/solidus_admin/stock_items_controller.rb +67 -0
  175. data/app/controllers/solidus_admin/stock_locations_controller.rb +40 -0
  176. data/app/controllers/solidus_admin/store_credit_reasons_controller.rb +40 -0
  177. data/app/controllers/solidus_admin/stores_controller.rb +40 -0
  178. data/app/controllers/solidus_admin/tax_categories_controller.rb +40 -0
  179. data/app/controllers/solidus_admin/tax_rates_controller.rb +40 -0
  180. data/app/controllers/solidus_admin/taxonomies_controller.rb +46 -0
  181. data/app/controllers/solidus_admin/users_controller.rb +50 -0
  182. data/app/controllers/solidus_admin/zones_controller.rb +40 -0
  183. data/app/javascript/solidus_admin/controllers/components.js +3 -1
  184. data/app/javascript/solidus_admin/controllers/confirm_controller.js +21 -0
  185. data/app/javascript/solidus_admin/controllers/details_click_outside_controller.js +12 -0
  186. data/app/javascript/solidus_admin/controllers/readonly_when_submitting_controller.js +17 -0
  187. data/app/javascript/solidus_admin/controllers/sortable_controller.js +33 -0
  188. data/app/views/layouts/solidus_admin/application.html.erb +16 -10
  189. data/app/views/layouts/solidus_admin/preview.html.erb +2 -1
  190. data/app/views/solidus_admin/base/unauthorized.html.erb +4 -0
  191. data/config/importmap.rb +2 -0
  192. data/config/initializers/view_component.rb +20 -0
  193. data/config/locales/adjustment_reasons.en.yml +6 -0
  194. data/config/locales/customers.en.yml +7 -0
  195. data/config/locales/errors.en.yml +7 -0
  196. data/config/locales/line_items.en.yml +9 -0
  197. data/config/locales/{main_nav.en.yml → menu_item.en.yml} +8 -2
  198. data/config/locales/option_types.en.yml +6 -0
  199. data/config/locales/orders.en.yml +9 -0
  200. data/config/locales/payment_methods.en.yml +6 -0
  201. data/config/locales/promotion_categories.en.yml +6 -0
  202. data/config/locales/promotions.en.yml +6 -0
  203. data/config/locales/properties.en.yml +6 -0
  204. data/config/locales/refund_reasons_.en.yml +6 -0
  205. data/config/locales/reimbursement_types.en.yml +4 -0
  206. data/config/locales/return_reasons.en.yml +6 -0
  207. data/config/locales/shipping_categories.en.yml +6 -0
  208. data/config/locales/shipping_methods.en.yml +6 -0
  209. data/config/locales/stock_items.en.yml +4 -0
  210. data/config/locales/stock_locations.en.yml +6 -0
  211. data/config/locales/store_credit_reasons.en.yml +6 -0
  212. data/config/locales/stores.en.yml +6 -0
  213. data/config/locales/tax_categories.en.yml +6 -0
  214. data/config/locales/tax_rates.en.yml +6 -0
  215. data/config/locales/taxonomies.en.yml +6 -0
  216. data/config/locales/users.en.yml +6 -0
  217. data/config/locales/zones.en.yml +6 -0
  218. data/config/routes.rb +50 -3
  219. data/config/tailwind.config.js +119 -0
  220. data/docs/{customizing_main_navigation.md → customizing_menu_items.md} +2 -2
  221. data/docs/customizing_tailwindcss.md +57 -0
  222. data/docs/customizing_view_components.md +17 -38
  223. data/lib/generators/solidus_admin/install/install_generator.rb +13 -4
  224. data/lib/generators/solidus_admin/install/templates/config/initializers/{solidus_admin.rb → solidus_admin.rb.tt} +10 -14
  225. data/lib/solidus_admin/admin_resources.rb +23 -0
  226. data/lib/solidus_admin/configuration.rb +95 -67
  227. data/lib/solidus_admin/install_tailwindcss.rb +102 -0
  228. data/lib/solidus_admin/{main_nav_item.rb → menu_item.rb} +2 -2
  229. data/lib/solidus_admin/version.rb +1 -1
  230. data/lib/solidus_admin.rb +1 -2
  231. data/lib/tasks/tailwind.rake +10 -0
  232. data/solidus_admin.gemspec +3 -4
  233. metadata +193 -50
  234. data/app/assets/stylesheets/solidus_admin/application.tailwind.css.erb +0 -35
  235. data/app/components/solidus_admin/feedback/component.html.erb +0 -11
  236. data/app/components/solidus_admin/feedback/component.rb +0 -4
  237. data/app/components/solidus_admin/feedback/component.yml +0 -5
  238. data/app/components/solidus_admin/orders/index/component.html.erb +0 -31
  239. data/app/components/solidus_admin/products/index/component.html.erb +0 -30
  240. data/app/components/solidus_admin/sidebar/account_nav/component.html.erb +0 -67
  241. data/app/components/solidus_admin/sidebar/account_nav/component.rb +0 -15
  242. data/app/components/solidus_admin/sidebar/component.rb +0 -21
  243. data/app/components/solidus_admin/ui/panel/component.js +0 -14
  244. data/config/solidus_admin/tailwind.config.js.erb +0 -95
  245. data/docs/customizing_tailwind.md +0 -78
  246. data/lib/solidus_admin/tailwindcss.rb +0 -58
  247. data/lib/tasks/tailwindcss.rake +0 -55
  248. /data/app/components/solidus_admin/{sidebar/account_nav → layout/navigation/account}/component.yml +0 -0
  249. /data/app/components/solidus_admin/{sidebar → layout/navigation}/component.js +0 -0
  250. /data/app/components/solidus_admin/{sidebar → layout/navigation}/component.yml +0 -0
  251. /data/app/components/solidus_admin/{skip_link → layout/skip_link}/component.yml +0 -0
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::UI::Forms::Search::Component < SolidusAdmin::BaseComponent
4
+ def initialize(id: nil, **attributes)
5
+ @id = id
6
+ @attributes = attributes
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ en:
2
+ loading: "Loading..."
3
+ initial: "Type to search"
4
+ empty: "No results"
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::UI::Forms::Search::Result::Component < SolidusAdmin::BaseComponent
4
+ def call
5
+ tag.div(
6
+ content,
7
+ class: "rounded p-2 hover:bg-gray-25 aria-selected:bg-gray-25 cursor-pointer",
8
+ "data-#{component('ui/forms/search').stimulus_id}-target": "result",
9
+ "data-action": "click->#{component('ui/forms/search').stimulus_id}#clickedResult",
10
+ )
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ <label
2
+ data-controller="<%= stimulus_id %>"
3
+ class="items-center gap-1 p-0 inline-flex w-full justify-start relative"
4
+ >
5
+ <%= render component("ui/icon").new(
6
+ name: "search-line",
7
+ class: "w-[1.4em] h-[1.4em] fill-gray-500 absolute ml-3",
8
+ ) %>
9
+ <%= render component("ui/forms/input").new(**@attributes) %>
10
+ <button
11
+ class="absolute right-0 mr-3 peer-placeholder-shown:hidden"
12
+ data-action="<%= stimulus_id %>#clear"
13
+ aria-label="<%= t('.clear') %>"
14
+ >
15
+ <%= render component("ui/icon").new(
16
+ name: "close-circle-fill",
17
+ class: "w-[1.4em] h-[1.4em] fill-gray-500"
18
+ ) %>
19
+ </button>
20
+ </label>
@@ -1,7 +1,9 @@
1
1
  import { Controller } from "@hotwired/stimulus"
2
2
 
3
3
  export default class extends Controller {
4
- greet() {
5
- console.log(`Hello World! ${new Date()}`)
4
+ static targets = ["input"]
5
+
6
+ clear() {
7
+ this.inputTarget.value = ""
6
8
  }
7
9
  }
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::UI::Forms::SearchField::Component < SolidusAdmin::BaseComponent
4
+ def initialize(**attributes)
5
+ @attributes = attributes
6
+ @attributes[:type] ||= :search
7
+ @attributes[:class] = "search-cancel:appearance-none peer !px-10 #{@attributes[:class]}"
8
+ @attributes[:"data-#{stimulus_id}-target"] = "input"
9
+ end
10
+ end
@@ -0,0 +1,2 @@
1
+ en:
2
+ clear: Clear
@@ -2,46 +2,42 @@
2
2
 
3
3
  class SolidusAdmin::UI::Forms::Switch::Component < SolidusAdmin::BaseComponent
4
4
  SIZES = {
5
- s: '
6
- w-8 h-5
7
-
8
- after:w-4 after:h-4
9
- after:top-0.5 after:left-0.5
10
-
11
- active:after:w-4
12
- after:checked:left-[1.875rem]
13
- ',
14
- m: '
15
- w-10 h-6
16
-
17
- after:w-5 after:h-5
18
- after:top-0.5 after:left-0.5
19
-
20
- active:after:w-5
21
- after:checked:left-[2.375rem]
22
- ',
5
+ s: 'w-8 h-5 after:w-4 after:h-4 after:checked:translate-x-3',
6
+ m: 'w-10 h-6 after:w-5 after:h-5 after:checked:translate-x-4',
23
7
  }.freeze
24
8
 
25
- def initialize(size: :m, **attributes)
9
+ def initialize(size: :m, include_hidden: false, **attributes)
26
10
  @size = size
27
11
  @attributes = attributes
12
+ @include_hidden = include_hidden
13
+ @attributes[:class] = "
14
+ #{SIZES.fetch(@size)}
15
+ rounded-full after:rounded-full
16
+ appearance-none inline-block relative p-0.5 cursor-pointer
17
+
18
+ outline-none
19
+ focus:ring focus:ring-gray-300 focus:ring-0.5 focus:ring-offset-1
20
+ active:ring active:ring-gray-300 active:ring-0.5 active:ring-offset-1
21
+
22
+ disabled:cursor-not-allowed
23
+ after:top-0 after:left-0
24
+ after:content-[''] after:block
25
+ after:transition-all after:duration-300 after:ease-in-out
26
+
27
+ bg-gray-200 after:bg-white
28
+ hover:bg-gray-300
29
+ checked:bg-gray-500 checked:hover:bg-gray-70
30
+ disabled:opacity-40
31
+ #{attributes[:class]}
32
+ "
28
33
  end
29
34
 
30
35
  def call
31
- tag.input(
36
+ input = tag.input(
32
37
  type: 'checkbox',
33
- class: "
34
- #{SIZES.fetch(@size)}
35
- appearance-none outline-0 cursor-pointer bg-gray-200 inline-block rounded-full relative
36
-
37
- after:content-[''] after:absolute after:bg-white
38
- after:duration-300 after:rounded-full after:checked:-translate-x-full
39
-
40
- hover:bg-gray-300
41
- disabled:opacity-40 disabled:cursor-not-allowed
42
- checked:bg-gray-500 checked:hover:bg-gray-700
43
- ",
44
38
  **@attributes,
45
39
  )
40
+
41
+ @include_hidden ? hidden_field_tag(@attributes.fetch(:name), false) + input : input
46
42
  end
47
43
  end
@@ -0,0 +1,20 @@
1
+ <label class="flex flex-wrap items-center gap-2 w-full border border-gray-100 rounded px-4 py-2">
2
+ <div class="flex gap-1 items-center grow py-2">
3
+ <span class="text-gray-700 font-semibold text-base"><%= @label %></span>
4
+
5
+ <%= render component("ui/toggletip").new(text: @tip) if @tip.present? %>
6
+ </div>
7
+
8
+ <%= render component("ui/forms/switch").new(**@attributes) %>
9
+
10
+ <% if @hint.present? || @error.present? %>
11
+ <div
12
+ class="
13
+ w-full font-normal text-sm [:disabled~&]:text-gray-300 text-gray-500 flex gap-1 flex-col pt-2 pb-4
14
+ "
15
+ >
16
+ <%= tag.span @hint if @hint.present? %>
17
+ <%= tag.span safe_join(@error, tag.br), class: "text-red-400" if @error.present? %>
18
+ </div>
19
+ <% end %>
20
+ </label>
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::UI::Forms::SwitchField::Component < SolidusAdmin::BaseComponent
4
+ def initialize(label:, error:, hint: nil, tip: nil, **attributes)
5
+ @label = label
6
+ @error = error
7
+ @hint = hint
8
+ @tip = tip
9
+ @attributes = attributes
10
+ end
11
+ end
@@ -16,6 +16,10 @@ class SolidusAdmin::UI::Icon::Component < SolidusAdmin::BaseComponent
16
16
 
17
17
  # Hide the icon from screen readers by default.
18
18
  @attrs['aria-hidden'] = true unless @attrs.key?('aria-hidden')
19
+
20
+ # Default icons without style to 16x16, mostly useful in test snapshots.
21
+ @attrs['width'] = '16'
22
+ @attrs['height'] = '16'
19
23
  end
20
24
 
21
25
  def call
@@ -0,0 +1,37 @@
1
+ <dialog
2
+ data-controller="<%= stimulus_id %>"
3
+ <%= tag.attributes(
4
+ "aria-label": @title,
5
+ class: "relative z-10",
6
+ **@attributes
7
+ ) %>
8
+ >
9
+ <a href="<%= @close_path %>" aria-hidden="true" class="cursor-default fixed inset-0 bg-full-black/50 overflow-y-auto"></a>
10
+ <div class="fixed inset-0 z-10 pointer-events-none flex min-h-full justify-center p-4 text-center items-center">
11
+ <div class="min-w-[40rem] max-h-screen pointer-events-auto cursor-auto relative transform overflow-auto rounded-lg bg-white text-left shadow-xl max-w-lg divide-y divide-gray-100">
12
+
13
+ <header class="flex items-center justify-between p-4 sticky top-0 bg-inherit">
14
+ <h3 class="text-xl font-semibold text-gray-900">
15
+ <%= @title %>
16
+ </h3>
17
+ <%= render component('ui/button').new(
18
+ tag: :a,
19
+ href: @close_path,
20
+ icon: 'close-line',
21
+ scheme: :ghost,
22
+ title: t('.close'),
23
+ ) %>
24
+ </header>
25
+
26
+ <div class="p-4 overflow-auto">
27
+ <%= content %>
28
+ </div>
29
+
30
+ <% if actions? %>
31
+ <footer class="p-4 flex gap-2 justify-end sticky bottom-0 bg-inherit">
32
+ <%= actions %>
33
+ </footer>
34
+ <% end %>
35
+ </div>
36
+ </div>
37
+ </dialog>
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::UI::Modal::Component < SolidusAdmin::BaseComponent
4
+ renders_one :actions
5
+
6
+ def initialize(title:, close_path: nil, open: true, **attributes)
7
+ @title = title
8
+ @close_path = close_path
9
+ @attributes = attributes
10
+ @attributes[:open] = open
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ en:
2
+ close: Close
@@ -0,0 +1,30 @@
1
+ <%= page do %>
2
+ <% if @tabs %>
3
+ <%= page_header do %>
4
+ <%= page_header_title title %>
5
+ <% end %>
6
+
7
+ <%= page_header do %>
8
+ <% rendered_tabs = capture do %>
9
+ <% @tabs.each do %>
10
+ <%= render(component("ui/button").new(tag: :a, scheme: :ghost, text: _1.text, 'aria-current': _1.current, href: _1.href)) %>
11
+ <% end %>
12
+ <% end %>
13
+ <%= page_header_title rendered_tabs %>
14
+ <%= page_header_actions do %>
15
+ <%= page_actions %>
16
+ <% end %>
17
+ <% end %>
18
+
19
+ <% else %>
20
+ <%= page_header do %>
21
+ <%= page_header_title title %>
22
+
23
+ <%= page_header_actions do %>
24
+ <%= page_actions %>
25
+ <% end %>
26
+ <% end %>
27
+ <% end %>
28
+
29
+ <%= render_table %>
30
+ <% end %>
@@ -0,0 +1,119 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::UI::Pages::Index::Component < SolidusAdmin::BaseComponent
4
+ include SolidusAdmin::Layout::PageHelpers
5
+
6
+ Tab = Struct.new(:text, :href, :current, keyword_init: true)
7
+
8
+ def tabs
9
+ nil
10
+ end
11
+
12
+ def initialize(page:)
13
+ @page = page
14
+ @tabs = tabs&.map { |tab| Tab.new(**tab) }
15
+ end
16
+
17
+ def row_fade(_record)
18
+ false
19
+ end
20
+
21
+ def model_class
22
+ nil
23
+ end
24
+
25
+ def title
26
+ model_class.model_name.human.pluralize
27
+ end
28
+
29
+ def search_key
30
+ nil
31
+ end
32
+
33
+ def search_params
34
+ params[:q]
35
+ end
36
+
37
+ def search_name
38
+ :q
39
+ end
40
+
41
+ def search_url
42
+ nil
43
+ end
44
+
45
+ def table_id
46
+ stimulus_id
47
+ end
48
+
49
+ def rows
50
+ @page.records
51
+ end
52
+
53
+ def row_url(_record)
54
+ nil
55
+ end
56
+
57
+ def batch_actions
58
+ []
59
+ end
60
+
61
+ def scopes
62
+ []
63
+ end
64
+
65
+ def filters
66
+ []
67
+ end
68
+
69
+ def columns
70
+ []
71
+ end
72
+
73
+ def prev_page_path
74
+ solidus_admin.url_for(**request.params, page: @page.number - 1, only_path: true) unless @page.first?
75
+ end
76
+
77
+ def next_page_path
78
+ solidus_admin.url_for(**request.params, page: @page.next_param, only_path: true) unless @page.last?
79
+ end
80
+
81
+ def search_options
82
+ return unless search_url
83
+
84
+ {
85
+ name: search_name,
86
+ value: search_params,
87
+ url: search_url,
88
+ searchbar_key: search_key,
89
+ filters: filters,
90
+ scopes: scopes,
91
+ }
92
+ end
93
+
94
+ def sortable_options
95
+ nil
96
+ end
97
+
98
+ def render_table
99
+ render component('ui/table').new(
100
+ id: stimulus_id,
101
+ data: {
102
+ class: model_class,
103
+ rows: rows,
104
+ fade: -> { row_fade(_1) },
105
+ prev: prev_page_path,
106
+ next: next_page_path,
107
+ columns: columns,
108
+ batch_actions: batch_actions,
109
+ url: -> { row_url(_1) },
110
+ },
111
+ search: search_options,
112
+ sortable: sortable_options,
113
+ )
114
+ end
115
+
116
+ def page_actions
117
+ nil
118
+ end
119
+ end
@@ -0,0 +1,4 @@
1
+ en:
2
+ batch_actions:
3
+ delete: 'Delete'
4
+ add: 'Add new'
@@ -8,29 +8,43 @@
8
8
  flex-col
9
9
  justify-start
10
10
  items-start
11
- gap-6
12
11
  inline-flex
13
12
  w-full
14
- py-6
13
+ relative
15
14
  "
16
15
  data-controller="<%= stimulus_id %>"
17
16
  >
17
+ <% if menus? %>
18
+ <%= render component('ui/dropdown').new(
19
+ size: :s,
20
+ class: "absolute top-0 right-0 m-6",
21
+ ).with_content(safe_join(menus)) %>
22
+ <% end %>
23
+
18
24
  <% if @title %>
19
- <h2 class="mt-0 px-6 w-full">
20
- <span class="body-title"><%= @title %></span>
21
- <%= render component('ui/toggletip').new(text: @title_hint, position: :left) if @title_hint %>
22
- </h2>
25
+ <section class="border-gray-100 border-t w-full first-of-type:border-t-0 p-6">
26
+ <h2>
27
+ <span class="font-semibold text-xl"><%= @title %></span>
28
+ <%= render component("ui/toggletip").new(text: @title_hint) if @title_hint %>
29
+ </h2>
30
+ </section>
31
+ <% end %>
32
+
33
+ <% sections.each do |section| %>
34
+ <%= section %>
23
35
  <% end %>
24
36
 
25
- <% if content&.present? %>
26
- <div class="px-6 w-full flex flex-col gap-6">
37
+ <% if content.present? %>
38
+ <section class="border-gray-100 border-t w-full first-of-type:border-t-0 p-6">
27
39
  <%= content %>
28
- </div>
40
+ </section>
29
41
  <% end %>
30
42
 
31
43
  <% if action? %>
32
- <div class="flex gap-2 items-center border-t border-gray-100 px-6 pt-6 w-full">
33
- <%= action %>
34
- </div>
44
+ <section class="border-gray-100 border-t w-full first-of-type:border-t-0 p-6">
45
+ <div class="flex justify-between items-center">
46
+ <%= action %>
47
+ </div>
48
+ </section>
35
49
  <% end %>
36
50
  </div>
@@ -10,6 +10,23 @@ class SolidusAdmin::UI::Panel::Component < SolidusAdmin::BaseComponent
10
10
  )
11
11
  }
12
12
 
13
+ renders_many :sections, ->(wide: false, high: false, **args, &block) do
14
+ tag.section(**args, class: "
15
+ border-gray-100 border-t w-full first-of-type:border-t-0
16
+ #{'px-6' unless wide}
17
+ #{'py-6' unless high}
18
+ #{args[:class]}
19
+ ", &block)
20
+ end
21
+
22
+ renders_many :menus, ->(name, url, **args) do
23
+ if args[:method]
24
+ button_to(name, url, **args)
25
+ else
26
+ link_to(name, url, **args)
27
+ end
28
+ end
29
+
13
30
  # @param title [String] the title of the panel
14
31
  # @param title_hint [String] the title hint of the panel
15
32
  def initialize(title: nil, title_hint: nil)
@@ -1,4 +1,2 @@
1
- # Add your component translations here.
2
- # Use the translation in the example in your template with `t(".hello")`.
3
1
  en:
4
- hello: "Hello world!"
2
+ more: "More"
@@ -0,0 +1,10 @@
1
+ <div class="flex gap-2 grow">
2
+ <%= render component("ui/thumbnail").new(
3
+ src: @thumbnail,
4
+ alt: @title,
5
+ ) if @thumbnail %>
6
+ <div class="flex-col">
7
+ <div class="leading-5 text-black font-semibold text-sm"><%= @title %></div>
8
+ <div class="leading-5 text-gray-500 font-normal text-sm"><%= @subtitle %></div>
9
+ </div>
10
+ </div>
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SolidusAdmin::UI::ResourceItem::Component < SolidusAdmin::BaseComponent
4
+ def initialize(title:, subtitle:, thumbnail: nil)
5
+ @thumbnail = thumbnail
6
+ @title = title
7
+ @subtitle = subtitle
8
+ end
9
+ end
@@ -2,12 +2,13 @@
2
2
 
3
3
  class SolidusAdmin::UI::Tab::Component < SolidusAdmin::BaseComponent
4
4
  SIZES = {
5
- s: %w[h-7 px-1.5 body-small-bold],
6
- m: %w[h-9 px-3 body-small-bold],
7
- l: %w[h-12 px-4 body-text-bold],
5
+ s: %w[h-7 px-1.5 font-semibold text-sm],
6
+ m: %w[h-9 px-3 font-semibold text-sm],
7
+ l: %w[h-12 px-4 font-semibold text-base],
8
8
  }
9
9
 
10
- def initialize(text:, size: :m, current: false, disabled: false, **attributes)
10
+ def initialize(text:, tag: :a, size: :m, current: false, disabled: false, **attributes)
11
+ @tag = tag
11
12
  @text = text
12
13
  @size = size
13
14
  @attributes = attributes
@@ -22,11 +23,11 @@ class SolidusAdmin::UI::Tab::Component < SolidusAdmin::BaseComponent
22
23
  hover:bg-gray-75 hover:text-gray-700
23
24
  focus:bg-gray-25 focus:text-gray-700
24
25
 
25
- active:bg-gray-50 active:text-black
26
+ active:bg-gray-75 active:text-black
26
27
  aria-current:bg-gray-50 aria-current:text-black
27
28
 
28
- disabled:bg-gray-100 disabled:text-gray-400
29
- aria-disabled:bg-gray-100 aria-disabled:text-gray-400
29
+ disabled:bg-gray-75 disabled:text-gray-400
30
+ aria-disabled:bg-gray-75 aria-disabled:text-gray-400
30
31
  ],
31
32
  SIZES.fetch(@size.to_sym),
32
33
  @attributes.delete(:class),
@@ -35,7 +36,7 @@ class SolidusAdmin::UI::Tab::Component < SolidusAdmin::BaseComponent
35
36
 
36
37
  def call
37
38
  content_tag(
38
- :a,
39
+ @tag,
39
40
  @text,
40
41
  **@attributes
41
42
  )