irelia 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (248) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +32 -10
  3. data/Rakefile +18 -4
  4. data/app/assets/config/irelia_manifest.js +2 -2
  5. data/app/assets/dist/javascripts/irelia.js +1 -0
  6. data/app/assets/dist/stylesheets/irelia.css +1 -0
  7. data/app/assets/src/main.js +2 -0
  8. data/app/assets/src/main.pcss +245 -0
  9. data/app/components/index.js +7 -0
  10. data/app/components/index.pcss +38 -0
  11. data/app/components/irelia/app_shell/component.html.erb +18 -0
  12. data/app/components/irelia/app_shell/component.rb +14 -0
  13. data/app/components/irelia/app_shell/index.pcss +20 -0
  14. data/app/{frontend/components/page/header → components/irelia/app_shell}/preview.rb +1 -1
  15. data/app/components/irelia/app_shell/previews/default.html.erb +21 -0
  16. data/app/components/irelia/avatar/component.html.erb +3 -0
  17. data/app/components/irelia/avatar/component.rb +16 -0
  18. data/app/components/irelia/avatar/index.pcss +8 -0
  19. data/{lib/generators/view_component/templates/preview.rb.tt → app/components/irelia/avatar/preview.rb} +1 -1
  20. data/app/components/irelia/breadcrumbs/component.html.erb +12 -0
  21. data/app/components/irelia/breadcrumbs/component.rb +18 -0
  22. data/app/components/irelia/breadcrumbs/index.pcss +16 -0
  23. data/app/{frontend/components/page/container → components/irelia/breadcrumbs}/preview.rb +1 -1
  24. data/app/components/irelia/button/component.html.erb +27 -0
  25. data/app/components/irelia/button/component.rb +40 -0
  26. data/app/components/irelia/button/index.pcss +57 -0
  27. data/app/components/irelia/button/preview.rb +79 -0
  28. data/app/components/irelia/card/component.html.erb +5 -0
  29. data/app/components/irelia/card/component.rb +15 -0
  30. data/app/components/irelia/card/index.pcss +9 -0
  31. data/app/components/irelia/card/preview.rb +18 -0
  32. data/app/components/irelia/component.rb +55 -0
  33. data/app/components/irelia/component_preview.rb +7 -0
  34. data/app/components/irelia/container/component.rb +30 -0
  35. data/app/components/irelia/container/index.pcss +45 -0
  36. data/app/components/irelia/container/preview.rb +18 -0
  37. data/app/components/irelia/div/component.html.erb +3 -0
  38. data/app/components/irelia/div/component.rb +15 -0
  39. data/app/components/irelia/div/index.pcss +7 -0
  40. data/app/components/irelia/divider/component.html.erb +7 -0
  41. data/app/components/irelia/divider/component.rb +10 -0
  42. data/app/components/irelia/divider/index.pcss +15 -0
  43. data/app/components/irelia/dropdown/component.html.erb +17 -0
  44. data/app/components/irelia/dropdown/component.rb +52 -0
  45. data/app/components/irelia/dropdown/controller.js +14 -0
  46. data/app/components/irelia/dropdown/index.pcss +37 -0
  47. data/app/components/irelia/dropdown/preview.rb +42 -0
  48. data/app/components/irelia/dropdown/previews/direction_up.html.erb +10 -0
  49. data/app/components/irelia/empty_collection/component.html.erb +19 -0
  50. data/app/components/irelia/empty_collection/component.rb +15 -0
  51. data/app/components/irelia/empty_collection/index.pcss +23 -0
  52. data/app/components/irelia/empty_collection/preview.rb +9 -0
  53. data/app/components/irelia/flex/component.html.erb +3 -0
  54. data/app/components/irelia/flex/component.rb +21 -0
  55. data/app/components/irelia/flex/index.pcss +37 -0
  56. data/app/components/irelia/form/base/component.rb +51 -0
  57. data/app/components/irelia/form/base/index.pcss +7 -0
  58. data/app/components/irelia/form/email_field/component.html.erb +3 -0
  59. data/app/components/irelia/form/email_field/component.rb +10 -0
  60. data/app/components/irelia/form/email_field/index.pcss +7 -0
  61. data/app/{frontend/components/page/breadcrumbs → components/irelia/form/email_field}/preview.rb +1 -1
  62. data/app/components/irelia/form/email_field/previews/default.html.erb +3 -0
  63. data/app/components/irelia/form/group/component.html.erb +19 -0
  64. data/app/components/irelia/form/group/component.rb +26 -0
  65. data/app/components/irelia/form/group/index.pcss +32 -0
  66. data/app/components/irelia/form/password_field/component.html.erb +3 -0
  67. data/app/components/irelia/form/password_field/component.rb +10 -0
  68. data/app/components/irelia/form/password_field/index.pcss +7 -0
  69. data/app/components/irelia/form/password_field/preview.rb +9 -0
  70. data/app/components/irelia/form/password_field/previews/default.html.erb +3 -0
  71. data/app/components/irelia/form/select/component.html.erb +3 -0
  72. data/app/components/irelia/form/select/component.rb +18 -0
  73. data/app/components/irelia/form/select/index.pcss +7 -0
  74. data/app/components/irelia/form/select/preview.rb +9 -0
  75. data/app/components/irelia/form/select/previews/default.html.erb +3 -0
  76. data/app/components/irelia/form/text_field/component.html.erb +3 -0
  77. data/app/components/irelia/form/text_field/component.rb +10 -0
  78. data/app/components/irelia/form/text_field/index.pcss +7 -0
  79. data/app/components/irelia/form/text_field/preview.rb +9 -0
  80. data/app/components/irelia/form/text_field/previews/default.html.erb +3 -0
  81. data/app/components/irelia/html/component.html.erb +3 -0
  82. data/app/components/irelia/html/component.rb +10 -0
  83. data/app/components/irelia/html/index.pcss +16 -0
  84. data/app/components/irelia/html/preview.rb +9 -0
  85. data/app/components/irelia/icon/component.rb +18 -0
  86. data/app/components/irelia/icon/index.pcss +7 -0
  87. data/app/components/irelia/icon/preview.rb +10 -0
  88. data/app/components/irelia/icon/previews/font_awesome.html.erb +23 -0
  89. data/app/components/irelia/modal/component.html.erb +28 -0
  90. data/app/components/irelia/modal/component.rb +29 -0
  91. data/app/components/irelia/modal/controller.js +50 -0
  92. data/app/components/irelia/modal/index.pcss +41 -0
  93. data/app/{frontend/components/navbar/select_account → components/irelia/modal}/preview.rb +5 -2
  94. data/app/components/irelia/modal/previews/remote_content.html.erb +6 -0
  95. data/app/components/irelia/modal/previews/static_content.html.erb +4 -0
  96. data/app/components/irelia/navbar/brand/component.rb +25 -0
  97. data/app/components/irelia/navbar/brand/index.pcss +9 -0
  98. data/app/components/irelia/navbar/brand/preview.rb +10 -0
  99. data/app/components/irelia/navbar/component.html.erb +10 -0
  100. data/app/components/irelia/navbar/component.rb +20 -0
  101. data/app/components/irelia/navbar/index.pcss +13 -0
  102. data/app/components/irelia/navbar/navigation/component.html.erb +5 -0
  103. data/app/components/irelia/navbar/navigation/component.rb +15 -0
  104. data/app/components/irelia/navbar/navigation/index.pcss +9 -0
  105. data/app/components/irelia/navbar/navigation/link/component.html.erb +5 -0
  106. data/app/components/irelia/navbar/navigation/link/component.rb +18 -0
  107. data/app/components/irelia/navbar/navigation/link/index.pcss +13 -0
  108. data/app/components/irelia/navbar/navigation/link/preview.rb +10 -0
  109. data/app/components/irelia/navbar/navigation/preview.rb +15 -0
  110. data/app/components/irelia/navbar/preview.rb +17 -0
  111. data/app/components/irelia/navbar/previews/default.html.erb +19 -0
  112. data/app/components/irelia/navbar/previews/full_width.html.erb +19 -0
  113. data/app/components/irelia/navbar/previews/navigation_right.html.erb +19 -0
  114. data/app/components/irelia/navbar/section/component.html.erb +3 -0
  115. data/app/components/irelia/navbar/section/component.rb +13 -0
  116. data/app/components/irelia/navbar/section/index.pcss +8 -0
  117. data/app/components/irelia/navbar/separator/component.rb +14 -0
  118. data/app/components/irelia/navbar/separator/index.pcss +8 -0
  119. data/app/components/irelia/navigation/component.html.erb +7 -0
  120. data/app/components/irelia/navigation/component.rb +23 -0
  121. data/app/components/irelia/navigation/index.pcss +7 -0
  122. data/app/components/irelia/navigation/preview.rb +14 -0
  123. data/app/components/irelia/notification/component.html.erb +9 -0
  124. data/app/components/irelia/notification/component.rb +27 -0
  125. data/app/components/irelia/notification/index.pcss +41 -0
  126. data/app/components/irelia/notification/preview.rb +22 -0
  127. data/app/components/irelia/page_header/component.html.erb +15 -0
  128. data/app/components/irelia/page_header/component.rb +17 -0
  129. data/app/components/irelia/page_header/index.pcss +36 -0
  130. data/app/components/irelia/page_header/preview.rb +13 -0
  131. data/app/components/irelia/sidebar/brand/component.html.erb +6 -0
  132. data/app/components/irelia/sidebar/brand/component.rb +19 -0
  133. data/app/components/irelia/sidebar/brand/index.pcss +13 -0
  134. data/app/components/irelia/sidebar/brand/preview.rb +10 -0
  135. data/app/components/irelia/sidebar/component.html.erb +8 -0
  136. data/app/components/irelia/sidebar/component.rb +16 -0
  137. data/app/components/irelia/sidebar/index.pcss +12 -0
  138. data/app/components/irelia/sidebar/navigation/component.html.erb +5 -0
  139. data/app/components/irelia/sidebar/navigation/component.rb +12 -0
  140. data/app/components/irelia/sidebar/navigation/index.pcss +8 -0
  141. data/app/components/irelia/sidebar/navigation/link/component.html.erb +10 -0
  142. data/app/components/irelia/sidebar/navigation/link/component.rb +26 -0
  143. data/app/components/irelia/sidebar/navigation/link/index.pcss +20 -0
  144. data/app/components/irelia/sidebar/navigation/link/preview.rb +14 -0
  145. data/app/components/irelia/sidebar/navigation/preview.rb +16 -0
  146. data/app/components/irelia/sidebar/preview.rb +9 -0
  147. data/app/components/irelia/sidebar/previews/default.html.erb +12 -0
  148. data/app/components/irelia/sidebar/section/component.html.erb +3 -0
  149. data/app/components/irelia/sidebar/section/component.rb +16 -0
  150. data/app/components/irelia/sidebar/section/index.pcss +11 -0
  151. data/app/components/irelia/split_screen/component.html.erb +8 -0
  152. data/app/components/irelia/split_screen/component.rb +18 -0
  153. data/app/components/irelia/split_screen/index.pcss +35 -0
  154. data/app/components/irelia/split_screen/preview.rb +12 -0
  155. data/app/components/irelia/stack/component.html.erb +3 -0
  156. data/app/components/irelia/stack/component.rb +21 -0
  157. data/app/components/irelia/stack/index.pcss +25 -0
  158. data/app/components/irelia/stack/preview.rb +47 -0
  159. data/app/components/irelia/stack/previews/default.html.erb +5 -0
  160. data/app/components/irelia/stack/previews/horizontal.html.erb +5 -0
  161. data/app/components/irelia/stack/previews/vertical.html.erb +5 -0
  162. data/app/components/irelia/table/component.html.erb +23 -0
  163. data/app/components/irelia/table/component.rb +31 -0
  164. data/app/components/irelia/table/index.pcss +32 -0
  165. data/app/components/irelia/table/preview.rb +9 -0
  166. data/app/components/irelia/table/previews/default.html.erb +19 -0
  167. data/app/components/irelia/table/row/component.html.erb +5 -0
  168. data/app/components/irelia/table/row/component.rb +34 -0
  169. data/app/components/irelia/table/row/index.pcss +7 -0
  170. data/app/helpers/irelia/components_helper.rb +62 -0
  171. data/app/helpers/irelia/form_helper.rb +9 -0
  172. data/app/helpers/irelia/head_helper.rb +7 -0
  173. data/app/views/irelia/_head.html.erb +25 -0
  174. data/lib/irelia/config.rb +18 -0
  175. data/lib/irelia/engine.rb +13 -11
  176. data/lib/irelia/form_builder.rb +48 -0
  177. data/lib/irelia/options/fixed.rb +26 -0
  178. data/lib/irelia/options/flex/direction.rb +22 -0
  179. data/lib/irelia/options/flex/gap.rb +25 -0
  180. data/lib/irelia/options/flex/grow.rb +21 -0
  181. data/lib/irelia/options/flex/items.rb +25 -0
  182. data/lib/irelia/options/flex/justify.rb +27 -0
  183. data/lib/irelia/options/padding.rb +46 -0
  184. data/lib/irelia/options/text_formatting.rb +30 -0
  185. data/lib/irelia/options/width.rb +19 -0
  186. data/lib/irelia/version.rb +1 -1
  187. data/lib/irelia.rb +20 -24
  188. metadata +199 -168
  189. data/app/frontend/components/application_view_component.rb +0 -5
  190. data/app/frontend/components/application_view_component_preview.rb +0 -5
  191. data/app/frontend/components/navbar/button/component.html.erb +0 -8
  192. data/app/frontend/components/navbar/button/component.rb +0 -13
  193. data/app/frontend/components/navbar/button/preview.rb +0 -12
  194. data/app/frontend/components/navbar/container/component.html.erb +0 -5
  195. data/app/frontend/components/navbar/container/component.rb +0 -8
  196. data/app/frontend/components/navbar/container/preview.rb +0 -12
  197. data/app/frontend/components/navbar/dark_mode_switcher/component.html.erb +0 -4
  198. data/app/frontend/components/navbar/dark_mode_switcher/component.rb +0 -8
  199. data/app/frontend/components/navbar/dark_mode_switcher/preview.rb +0 -12
  200. data/app/frontend/components/navbar/menu_items/component.html.erb +0 -3
  201. data/app/frontend/components/navbar/menu_items/component.rb +0 -8
  202. data/app/frontend/components/navbar/menu_items/preview.rb +0 -12
  203. data/app/frontend/components/navbar/navlink/component.html.erb +0 -8
  204. data/app/frontend/components/navbar/navlink/component.rb +0 -13
  205. data/app/frontend/components/navbar/navlink/preview.rb +0 -12
  206. data/app/frontend/components/navbar/right_section/component.html.erb +0 -3
  207. data/app/frontend/components/navbar/right_section/component.rb +0 -8
  208. data/app/frontend/components/navbar/right_section/preview.rb +0 -12
  209. data/app/frontend/components/navbar/select_account/component.html.erb +0 -36
  210. data/app/frontend/components/navbar/select_account/component.rb +0 -6
  211. data/app/frontend/components/navbar/separator/component.html.erb +0 -1
  212. data/app/frontend/components/navbar/separator/component.rb +0 -7
  213. data/app/frontend/components/navbar/separator/preview.rb +0 -12
  214. data/app/frontend/components/page/breadcrumbs/component.html.erb +0 -16
  215. data/app/frontend/components/page/breadcrumbs/component.rb +0 -6
  216. data/app/frontend/components/page/container/component.html.erb +0 -3
  217. data/app/frontend/components/page/container/component.rb +0 -4
  218. data/app/frontend/components/page/header/component.html.erb +0 -12
  219. data/app/frontend/components/page/header/component.rb +0 -6
  220. data/app/helpers/navbar_helper.rb +0 -35
  221. data/app/helpers/page_helper.rb +0 -15
  222. data/app/javascript/controllers/dark_mode_switcher_controller.js +0 -20
  223. data/app/javascript/controllers/dropdown_controller.js +0 -3
  224. data/app/views/devise/registrations/new.html.erb +0 -21
  225. data/app/views/devise/sessions/new.html.erb +0 -18
  226. data/app/views/layouts/application.html.erb +0 -11
  227. data/app/views/layouts/devise.html.erb +0 -23
  228. data/app/views/layouts/mailer.html.erb +0 -13
  229. data/app/views/layouts/mailer.text.erb +0 -1
  230. data/app/views/layouts/teamable.html.erb +0 -31
  231. data/app/views/shared/_head.html.erb +0 -26
  232. data/app/views/shared/_navbar.html.erb +0 -30
  233. data/app/views/shared/_navbar_logo.html.erb +0 -3
  234. data/app/views/teamable/accounts/new.html.erb +0 -10
  235. data/app/views/teamable/setup/new.html.erb +0 -8
  236. data/app/views/teamable/shared/_form.html.erb +0 -4
  237. data/config/importmap.rb +0 -7
  238. data/config/initializers/devise.rb +0 -313
  239. data/config/initializers/simple_form.rb +0 -148
  240. data/config/initializers/view_component.rb +0 -18
  241. data/lib/generators/irelia/install_generator.rb +0 -19
  242. data/lib/generators/templates/irelia.rb +0 -14
  243. data/lib/generators/view_component/USAGE +0 -15
  244. data/lib/generators/view_component/templates/component.html.erb.tt +0 -1
  245. data/lib/generators/view_component/templates/component.rb.tt +0 -8
  246. data/lib/generators/view_component/templates/component_system_test.rb.tt +0 -13
  247. data/lib/generators/view_component/templates/component_test.rb.tt +0 -19
  248. data/lib/generators/view_component/view_component_generator.rb +0 -53
@@ -0,0 +1,12 @@
1
+ <%= content_tag :div, html_options do %>
2
+ <nav class="flex justify-between">
3
+ <ol class="inline-flex items-center mb-3 space-x-1 [&_.active-breadcrumb]:text-neutral-600 [&_.active-breadcrumb]:font-medium sm:mb-0">
4
+ <% breadcrumbs.each_with_index do |crumb, index| %>
5
+ <li>
6
+ <%= link_to crumb.name, crumb.path %>
7
+ </li>
8
+ <%= helpers.irelia_icon { "fa fa-chevron-right" } unless index == last_index %>
9
+ <% end %>
10
+ </ol>
11
+ </nav>
12
+ <% end %>
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Irelia::Breadcrumbs::Component < Irelia::Component
4
+ option :breadcrumbs, default: -> { [] }
5
+
6
+ def variants
7
+ class_names(
8
+ "irelia-breadcrumbs",
9
+ "irelia-breadcrumbs--default": variant == :default
10
+ )
11
+ end
12
+
13
+ private
14
+
15
+ def last_index
16
+ breadcrumbs.count - 1
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ @layer components {
2
+ .irelia-breadcrumbs {
3
+ @apply flex gap-y-1.5 flex-col justify-center text-sm;
4
+
5
+ li {
6
+ @apply flex items-center h-full;
7
+ }
8
+
9
+ .irelia-icon svg.fa-chevron-right {
10
+ @apply text-xs px-2 text-gray-400;
11
+ }
12
+ }
13
+
14
+ .irelia-breadcrumbs--default {
15
+ }
16
+ }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Page::Container::Preview < ApplicationViewComponentPreview
3
+ class Irelia::Breadcrumbs::Preview < Irelia::ComponentPreview
4
4
  # You can specify the container class for the default template
5
5
  # self.container_class = "w-1/2 border border-gray-300"
6
6
 
@@ -0,0 +1,27 @@
1
+ <% content_html = capture do %>
2
+ <% if icon %>
3
+ <span class="irelia-button__icon">
4
+ <%= helpers.irelia_icon icon_class: icon %>
5
+ </span>
6
+ <% end %>
7
+
8
+ <% if content %>
9
+ <span class="irelia-button__content">
10
+ <span class="irelia-button__text"><%= content %></span>
11
+ </span>
12
+ <% end %>
13
+
14
+ <% if right_icon %>
15
+ <span class="irelia-button__icon">
16
+ <%= helpers.irelia_icon icon_class: right_icon %>
17
+ </span>
18
+ <% end %>
19
+ <% end %>
20
+
21
+ <% if skip_tag %>
22
+ <%= content_html %>
23
+ <% else %>
24
+ <%= content_tag @tag, html_options do %>
25
+ <%= content_html %>
26
+ <% end %>
27
+ <% end %>
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Irelia::Button::Component < Irelia::Component
4
+ include Irelia::Options::Width
5
+
6
+ option :url, default: -> { nil }
7
+ option :type, default: -> { :button }, in: [ :button, :submit, :reset ]
8
+ option :size, default: -> { :md }, in: [ :xs, :sm, :md, :lg, :xl ]
9
+ option :color, default: proc { :primary }, in: %i[primary secondary danger]
10
+ option :skip_tag, default: false, optional: true
11
+ option :modal, optional: true
12
+
13
+ option :icon, optional: true
14
+ option :right_icon, optional: true
15
+
16
+ def variants
17
+ class_names(
18
+ "irelia-button",
19
+ "irelia-button--default": variant == :default,
20
+ "irelia-button--dropdown-item": variant == :dropdown_item,
21
+ "irelia-button--color-primary": color == :primary,
22
+ "irelia-button--color-secondary": color == :secondary,
23
+ "irelia-button--color-danger": color == :danger,
24
+ "irelia-button--xs": size == :xs,
25
+ "irelia-button--sm": size == :sm,
26
+ "irelia-button--md": size == :md,
27
+ "irelia-button--lg": size == :lg,
28
+ "irelia-button--xl": size == :xl
29
+ )
30
+ end
31
+
32
+ def initialize(**options)
33
+ super
34
+
35
+ @tag = @url.present? ? :a : :button
36
+ @html_options[:href] = @url if @url.present?
37
+ @html_options[:type] = @type
38
+ @html_options["data-turbo-frame"] = @modal if @modal.present?
39
+ end
40
+ end
@@ -0,0 +1,57 @@
1
+ @layer components {
2
+ .irelia-button {
3
+ @apply inline-flex justify-center items-center cursor-pointer rounded no-underline transition text-nowrap;
4
+ }
5
+
6
+ .irelia-button--default {
7
+ @apply font-bold w-min;
8
+
9
+ &.irelia-button--color-primary {
10
+ @apply bg-irelia-primary hover:bg-irelia-primary-hover text-white;
11
+ }
12
+
13
+ &.irelia-button--color-secondary {
14
+ @apply bg-irelia-gray hover:bg-irelia-gray-hover text-irelia-primary;
15
+ }
16
+
17
+ &.irelia-button--color-danger {
18
+ @apply bg-irelia-danger hover:bg-irelia-danger-hover text-white;
19
+ }
20
+ }
21
+
22
+ .irelia-button--xs {
23
+ @apply px-3 py-1 gap-x-1.5 text-xs; /* Reduced padding for XS */
24
+ }
25
+
26
+ .irelia-button--sm {
27
+ @apply px-4 py-1.5 gap-x-2 text-sm; /* Adjusted padding for SM */
28
+ }
29
+
30
+ .irelia-button--md {
31
+ @apply px-5 py-2 gap-x-2.5 text-base; /* Slightly reduced padding for MD */
32
+ }
33
+
34
+ .irelia-button--lg {
35
+ @apply px-7 py-2.5 gap-x-3.5 text-lg; /* Reduced padding for LG */
36
+ }
37
+
38
+ .irelia-button--xl {
39
+ @apply px-10 py-4 gap-x-4 text-xl; /* Adjusted padding for XL */
40
+ }
41
+
42
+ .irelia-button--dropdown-item {
43
+ @apply relative flex justify-start w-full select-none items-center rounded px-2 py-1.5 hover:bg-neutral-100 hover:text-neutral-900 outline-none;
44
+
45
+ .irelia-button__content {
46
+ @apply pr-4;
47
+ }
48
+
49
+ .irelia-button__icon {
50
+ @apply w-[15px] text-center opacity-35;
51
+ }
52
+
53
+ .irelia-button__content + .irelia-button__icon {
54
+ @apply ml-auto;
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Irelia::Button::Preview < Irelia::ComponentPreview
4
+ # @label Default
5
+ # @param color select { choices: [primary, secondary, danger] } "Button theme color"
6
+ # @param size select { choices: [xs, sm, md, lg, xl] } "Size of the button"
7
+ def default(color: :primary, size: :md)
8
+ irelia_button(color:, size:) { "Default button" }
9
+ end
10
+
11
+ # @!group Colors
12
+
13
+ # @label Primary button (default)
14
+ def primary_color
15
+ irelia_button { "Button" }
16
+ end
17
+
18
+ # @label Secondary button
19
+ def secondary_color
20
+ irelia_button(color: :secondary) { "Button" }
21
+ end
22
+
23
+ # @label Danger button
24
+ def danger_color
25
+ irelia_button(color: :danger) { "Button" }
26
+ end
27
+
28
+ # @!endgroup
29
+
30
+ # @!group Sizes
31
+
32
+ # @label Extra small
33
+ def sizes_xs
34
+ irelia_button(size: :xs) { "Button" }
35
+ end
36
+
37
+ # @label Small
38
+ def sm_size
39
+ irelia_button(size: :sm) { "Button" }
40
+ end
41
+
42
+ # @label Medium (default)
43
+ def default_size
44
+ irelia_button(size: :md) { "Button" }
45
+ end
46
+
47
+ # @label Large
48
+ def lg_size
49
+ irelia_button(size: :lg) { "Large button" }
50
+ end
51
+
52
+ # @label Extra large
53
+ def xl_size
54
+ irelia_button(size: :xl) { "Extra large button" }
55
+ end
56
+
57
+ # @!endgroup
58
+
59
+ # @label Icon + text
60
+ def with_icon
61
+ irelia_button(icon: "fas fa-home", size: :md) { "Button with icon" }
62
+ end
63
+
64
+ # @label Text + icon
65
+ def with_right_icon
66
+ irelia_button(right_icon: "fas fa-arrow-right", size: :md) { "Button with icon" }
67
+ end
68
+
69
+ # @label Only icon
70
+ def only_icon
71
+ irelia_button(icon: "fas fa-save", size: :md)
72
+ end
73
+
74
+ # @label Link
75
+ # Pass a URL to the button to render an anchor tag instead of a button.
76
+ def link(color: :default, size: :md)
77
+ irelia_button(url: "#") { "Link button" }
78
+ end
79
+ end
@@ -0,0 +1,5 @@
1
+ <%= content_tag :div, html_options do %>
2
+ <div class="irelia-card__inner">
3
+ <%= content %>
4
+ </div>
5
+ <% end %>
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Irelia::Card::Component < Irelia::Component
4
+ include Irelia::Options::Width
5
+
6
+ option :padding, default: -> { true }, optional: true
7
+
8
+ def variants
9
+ class_names(
10
+ "irelia-card",
11
+ "irelia-card--default": variant == :default,
12
+ "irelia-card--no-padding": padding == false
13
+ )
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ @layer components {
2
+ .irelia-card {
3
+ @apply bg-irelia-surface rounded shadow-sm;
4
+
5
+ &:not(.irelia-card--no-padding) .irelia-card__inner {
6
+ @apply p-5;
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Irelia::Card::Preview < Irelia::ComponentPreview
4
+ # You can specify the container class for the default template
5
+ # self.container_class = "w-1/2 border border-gray-300"
6
+
7
+ def default
8
+ irelia_card do
9
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales fermentum tristique."
10
+ end
11
+ end
12
+
13
+ def no_padding
14
+ irelia_card(padding: false) do
15
+ "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales fermentum tristique."
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,55 @@
1
+ module Irelia
2
+ class Component < ViewComponentContrib::Base
3
+ extend Dry::Initializer
4
+
5
+ option :html_options, default: proc { {} }
6
+ option :variant, default: proc { :default }
7
+
8
+ def initialize(**options)
9
+ super
10
+
11
+ @component_classes = +""
12
+ add_css_classes(variants)
13
+ self.class.run_after_initialize_hooks(self)
14
+ end
15
+
16
+ def html_options
17
+ # Merge the component classes with the classes from the html_options.
18
+ @html_options.merge({ class: "#{@component_classes} #{@html_options[:class]}".strip })
19
+ end
20
+
21
+ def add_css_classes(css_class)
22
+ @component_classes += " #{css_class}"
23
+ end
24
+
25
+ def variants
26
+ end
27
+
28
+ class << self
29
+ def after_initialize(method_name = nil, &block)
30
+ @after_initialize_hooks ||= []
31
+ if method_name
32
+ @after_initialize_hooks << method_name
33
+ elsif block_given?
34
+ @after_initialize_hooks << block
35
+ end
36
+ end
37
+
38
+ def run_after_initialize_hooks(instance)
39
+ return unless @after_initialize_hooks
40
+ @after_initialize_hooks.each do |hook|
41
+ if hook.is_a?(Symbol)
42
+ instance.send(hook)
43
+ elsif hook.is_a?(Proc)
44
+ instance.instance_eval(&hook)
45
+ end
46
+ end
47
+ end
48
+
49
+ def inherited(subclass)
50
+ super
51
+ subclass.instance_variable_set(:@after_initialize_hooks, @after_initialize_hooks.dup)
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,7 @@
1
+ module Irelia
2
+ class ComponentPreview < ViewComponentContrib::Preview::Base
3
+ include Irelia::ComponentsHelper
4
+
5
+ self.abstract_class = true
6
+ end
7
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Irelia::Container::Component < Irelia::Component
4
+ include Irelia::Options::Padding
5
+
6
+ option :center, default: -> { false }, in: %i[true false]
7
+ option :size, default: -> { :full_width }, in: %i[full_width xxs xs sm md lg xl]
8
+
9
+ def variants
10
+ class_names(
11
+ "irelia-container",
12
+ "irelia-container--default": variant == :default,
13
+ "irelia-container--size-full-width": size == :full_width,
14
+ "irelia-container--size-xxl": size == :xxl,
15
+ "irelia-container--size-xl": size == :xl,
16
+ "irelia-container--size-lg": size == :lg,
17
+ "irelia-container--size-md": size == :md,
18
+ "irelia-container--size-sm": size == :sm,
19
+ "irelia-container--size-xs": size == :xs,
20
+ "irelia-container--size-xxs": size == :xxs,
21
+ "irelia-container--center": center == true
22
+ )
23
+ end
24
+
25
+ def call
26
+ content_tag :div, html_options do
27
+ content
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,45 @@
1
+ @layer components {
2
+ .irelia-container {
3
+ @apply px-10 m-0;
4
+
5
+ &.irelia-container--center {
6
+ @apply mx-auto;
7
+ }
8
+ }
9
+
10
+ .irelia-app-shell .irelia-container {
11
+ @apply px-0;
12
+ }
13
+
14
+ .irelia-container--size-full-width {
15
+ @apply w-[100%];
16
+ }
17
+
18
+ .irelia-container--size-xxl {
19
+ @apply max-w-[1536px];
20
+ }
21
+
22
+ .irelia-container--size-xl {
23
+ @apply max-w-[1280px];
24
+ }
25
+
26
+ .irelia-container--size-lg {
27
+ @apply max-w-[1024px];
28
+ }
29
+
30
+ .irelia-container--size-md {
31
+ @apply max-w-[768px];
32
+ }
33
+
34
+ .irelia-container--size-sm {
35
+ @apply max-w-[640px];
36
+ }
37
+
38
+ .irelia-container--size-xs {
39
+ @apply max-w-[448px];
40
+ }
41
+
42
+ .irelia-container--size-xxs {
43
+ @apply max-w-[320px];
44
+ }
45
+ }
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Irelia::Container::Preview < Irelia::ComponentPreview
4
+ # You can specify the container class for the default template
5
+ # self.container_class = "w-1/2 border border-gray-300"
6
+
7
+ def default
8
+ irelia_container size: :lg do
9
+ "The container class sets the max-width of an element to match the min-width of the current breakpoint. This is useful if you’d prefer to design for a fixed set of screen sizes instead of trying to accommodate a fully fluid viewport."
10
+ end
11
+ end
12
+
13
+ def centered
14
+ irelia_container size: :lg, center: true do
15
+ "The container class sets the max-width of an element to match the min-width of the current breakpoint. This is useful if you’d prefer to design for a fixed set of screen sizes instead of trying to accommodate a fully fluid viewport."
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ <%= content_tag :div, html_options do %>
2
+ <%= content %>
3
+ <% end %>
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Irelia::Div::Component < Irelia::Component
4
+ include Irelia::Options::Padding
5
+ include Irelia::Options::TextFormatting
6
+ include Irelia::Options::Width
7
+ include Irelia::Options::Fixed
8
+
9
+ def variants
10
+ class_names(
11
+ "irelia-div",
12
+ "irelia-div--default": variant == :default
13
+ )
14
+ end
15
+ end
@@ -0,0 +1,7 @@
1
+ @layer components {
2
+ .irelia-div {
3
+ }
4
+
5
+ .irelia-div--default {
6
+ }
7
+ }
@@ -0,0 +1,7 @@
1
+ <%= content_tag :div, html_options do %>
2
+ <hr>
3
+ <% if content %>
4
+ <span class="irelia-divider__inner_text"><%= content %></span>
5
+ <hr >
6
+ <% end %>
7
+ <% end %>
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Irelia::Divider::Component < Irelia::Component
4
+ def variants
5
+ class_names(
6
+ "irelia-divider",
7
+ "irelia-divider--default": variant == :default
8
+ )
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ @layer components {
2
+ .irelia-divider {
3
+ .irelia-divider__inner_text {
4
+ @apply px-5 text-sm font-bold;
5
+ }
6
+ }
7
+
8
+ .irelia-divider--default {
9
+ @apply flex items-center;
10
+
11
+ hr {
12
+ @apply flex-grow border-t border-neutral-200;
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,17 @@
1
+ <%= content_tag :span, html_options.merge({"data-controller": "irelia-dropdown", "data-irelia-dropdown-open-value": open}) do %>
2
+ <span class="irelia-dropdown__trigger">
3
+ <%= custom_trigger || trigger %>
4
+ </span>
5
+ <div
6
+ data-irelia-dropdown-target="menu"
7
+ class="irelia-dropdown__content hidden"
8
+ data-transition-enter-from="transition-closed"
9
+ data-transition-enter-to="transition-open"
10
+ data-transition-leave-from="transition-open"
11
+ data-transition-leave-to="transition-closed"
12
+ >
13
+ <% items.each do |item| %>
14
+ <%= item %>
15
+ <% end %>
16
+ </div>
17
+ <% end %>
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Irelia::Dropdown::Component < Irelia::Component
4
+ option :open, default: -> { false }
5
+ option :direction, default: -> { :down }, in: %i[down up]
6
+
7
+ renders_one :trigger, "DropdownTrigger"
8
+ renders_one :custom_trigger, "CustomDropdownTrigger"
9
+ renders_many :items, "DropdownItem"
10
+
11
+ def variants
12
+ class_names(
13
+ "irelia-dropdown",
14
+ "irelia-dropdown--default": variant == :default,
15
+ "irelia-dropdown--direction-down": direction == :down,
16
+ "irelia-dropdown--direction-up": direction == :up
17
+ )
18
+ end
19
+
20
+ def initialize(**options)
21
+ super
22
+ end
23
+
24
+ class DropdownTrigger < Irelia::Button::Component
25
+ def initialize(**options)
26
+ options[:html_options] ||= {}
27
+ options[:html_options]["data"] = { "action": "irelia-dropdown#toggle click@window->irelia-dropdown#hide" }
28
+ super(**options)
29
+ end
30
+ end
31
+
32
+ class CustomDropdownTrigger < Irelia::Component
33
+ def initialize(**options)
34
+ options[:html_options] ||= {}
35
+ options[:html_options]["data"] = { "action": "irelia-dropdown#toggle click@window->irelia-dropdown#hide" }
36
+ options[:html_options]["style"] = "display:block;width:100%"
37
+ super(**options)
38
+ end
39
+
40
+ def call
41
+ content_tag(:button, content, html_options)
42
+ end
43
+ end
44
+
45
+ class DropdownItem < Irelia::Button::Component
46
+ def initialize(**options)
47
+ options[:size] = :sm
48
+ options[:variant] = :dropdown_item
49
+ super(**options)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,14 @@
1
+ import Dropdown from "@stimulus-components/dropdown";
2
+
3
+ export default class extends Dropdown {
4
+ static values = {
5
+ open: Boolean,
6
+ };
7
+
8
+ connect() {
9
+ super.connect();
10
+ if (this.openValue) {
11
+ this.enter();
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,37 @@
1
+ @layer components {
2
+ .irelia-dropdown {
3
+ @apply relative;
4
+
5
+ &.irelia-dropdown--direction-down {
6
+ .irelia-dropdown__content {
7
+ @apply top-0 mt-10;
8
+
9
+ &.transition-closed {
10
+ @apply -translate-y-2 opacity-0;
11
+ }
12
+
13
+ &.transition-open {
14
+ @apply -translate-y-0 opacity-100;
15
+ }
16
+ }
17
+ }
18
+
19
+ &.irelia-dropdown--direction-up {
20
+ .irelia-dropdown__content {
21
+ @apply bottom-0 mb-10 mt-0;
22
+
23
+ &.transition-closed {
24
+ @apply translate-y-2 opacity-0;
25
+ }
26
+
27
+ &.transition-open {
28
+ @apply translate-y-0 opacity-100;
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ .irelia-dropdown__content {
35
+ @apply absolute duration-200 z-50 min-w-48 text-neutral-800 rounded-md border border-neutral-200/70 bg-white text-sm p-1 shadow-md -translate-x-0.5;
36
+ }
37
+ }