ariadne_view_components 0.0.58 → 0.0.64

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +70 -0
  3. data/LICENSE.txt +661 -49
  4. data/README.md +52 -4
  5. data/app/assets/javascripts/ariadne_view_components.js +98 -7
  6. data/app/assets/javascripts/ariadne_view_components.js.map +1 -1
  7. data/app/assets/stylesheets/ariadne_view_components.css +1 -7
  8. data/app/components/ariadne/base_component.rb +79 -27
  9. data/app/components/ariadne/behaviors/tooltipable.rb +120 -0
  10. data/app/components/ariadne/conditional_wrapper.rb +21 -0
  11. data/app/components/ariadne/form/base_component.rb +74 -0
  12. data/app/components/ariadne/form/base_input_component.rb +60 -0
  13. data/app/components/ariadne/form/caption/component.html.erb +10 -0
  14. data/app/components/ariadne/form/caption/component.rb +29 -0
  15. data/app/components/ariadne/form/form_control/component.html.erb +19 -0
  16. data/app/components/ariadne/form/form_control/component.rb +27 -0
  17. data/app/components/ariadne/form/form_reference/component.html.erb +1 -0
  18. data/app/components/ariadne/form/form_reference/component.rb +18 -0
  19. data/app/components/ariadne/form/group/component.html.erb +5 -0
  20. data/app/components/ariadne/form/group/component.rb +27 -0
  21. data/app/components/ariadne/form/hidden_field/component.html.erb +1 -0
  22. data/app/components/ariadne/form/hidden_field/component.rb +15 -0
  23. data/app/components/ariadne/form/separator/component.html.erb +1 -0
  24. data/app/components/ariadne/form/separator/component.rb +8 -0
  25. data/app/components/ariadne/form/spacing_wrapper/component.html.erb +3 -0
  26. data/app/components/ariadne/form/spacing_wrapper/component.rb +8 -0
  27. data/app/components/ariadne/form/text_field/component.html.erb +25 -0
  28. data/app/components/ariadne/form/text_field/component.rb +132 -0
  29. data/app/components/ariadne/form/validation_message/component.html.erb +5 -0
  30. data/app/components/ariadne/form/validation_message/component.rb +14 -0
  31. data/app/components/ariadne/layout/narrow/component.html.erb +10 -0
  32. data/app/components/ariadne/layout/narrow/component.rb +24 -0
  33. data/app/components/ariadne/layout/nav_bar/component.css +0 -0
  34. data/app/components/ariadne/layout/nav_bar/component.html.erb +123 -0
  35. data/app/components/ariadne/layout/nav_bar/component.rb +77 -0
  36. data/app/components/ariadne/ui/button/component.html.erb +5 -0
  37. data/app/components/ariadne/ui/button/component.rb +184 -0
  38. data/app/components/ariadne/ui/clipboard_copy/component.html.erb +8 -0
  39. data/app/components/ariadne/ui/clipboard_copy/component.rb +102 -0
  40. data/app/components/ariadne/ui/clipboard_copy/component.ts +54 -0
  41. data/app/components/ariadne/ui/combobox/component.html.erb +32 -0
  42. data/app/components/ariadne/ui/combobox/component.rb +83 -0
  43. data/app/components/ariadne/ui/combobox/component.ts +119 -0
  44. data/app/components/ariadne/ui/combobox/menu_item/component.html.erb +9 -0
  45. data/app/components/ariadne/ui/combobox/menu_item/component.rb +53 -0
  46. data/app/components/ariadne/ui/combobox/option/component.html.erb +11 -0
  47. data/app/components/ariadne/ui/combobox/option/component.rb +45 -0
  48. data/app/components/ariadne/ui/heroicon/component.html.erb +3 -0
  49. data/app/components/ariadne/ui/heroicon/component.rb +141 -0
  50. data/app/components/ariadne/ui/image/component.rb +69 -0
  51. data/app/components/ariadne/ui/link/component.html.erb +3 -0
  52. data/app/components/ariadne/ui/link/component.rb +56 -0
  53. data/app/components/ariadne/ui/typography/component.html.erb +3 -0
  54. data/app/components/ariadne/ui/typography/component.rb +41 -0
  55. data/app/lib/ariadne/attributes_helper.rb +119 -0
  56. data/app/lib/ariadne/fetch_or_fallback_helper.rb +1 -1
  57. data/app/lib/ariadne/form.rb +16 -0
  58. data/app/lib/ariadne/view_helper.rb +2 -5
  59. data/app/lib/view_components_contrib/html_attrs.rb +64 -0
  60. data/app/lib/view_components_contrib/style_variants.rb +14 -0
  61. data/lib/ariadne/forms/acts_as_component.rb +125 -0
  62. data/lib/ariadne/forms/base.html.erb +8 -0
  63. data/lib/ariadne/forms/base.rb +132 -0
  64. data/lib/ariadne/forms/buffer_rewriter.rb +51 -0
  65. data/lib/ariadne/forms/builder.rb +88 -0
  66. data/lib/ariadne/forms/dsl/button_input.rb +33 -0
  67. data/lib/ariadne/forms/dsl/form_object.rb +26 -0
  68. data/lib/ariadne/forms/dsl/input.rb +322 -0
  69. data/lib/ariadne/forms/dsl/input_group.rb +34 -0
  70. data/lib/ariadne/forms/dsl/input_methods.rb +157 -0
  71. data/lib/ariadne/forms/dsl/submit_button_input.rb +36 -0
  72. data/lib/ariadne/forms/dsl/text_field_input.rb +73 -0
  73. data/lib/ariadne/forms/utils.rb +34 -0
  74. data/lib/ariadne/generate.rb +11 -0
  75. data/lib/ariadne/view_components/engine.rb +24 -7
  76. data/lib/ariadne/view_components/version.rb +1 -1
  77. data/lib/ariadne/view_components.rb +1 -1
  78. data/lib/ariadne/yard/backend.rb +24 -0
  79. data/lib/ariadne/yard/component_manifest.rb +148 -0
  80. data/lib/ariadne/yard/component_ref.rb +49 -0
  81. data/lib/ariadne/yard/docs_helper.rb +98 -0
  82. data/lib/ariadne/yard/info_arch_docs_helper.rb +31 -0
  83. data/lib/ariadne/yard/lookbook_docs_helper.rb +32 -0
  84. data/lib/ariadne/yard/lookbook_pages_backend.rb +235 -0
  85. data/lib/ariadne/yard/registry.rb +136 -0
  86. data/lib/ariadne/yard/renders_many_handler.rb +23 -0
  87. data/lib/ariadne/yard/renders_one_handler.rb +23 -0
  88. data/lib/ariadne/yard.rb +19 -0
  89. data/static/arguments.yml +141 -48
  90. data/static/audited_at.json +0 -9
  91. data/static/classes.yml +210 -209
  92. data/static/constants.json +2 -209
  93. data/static/statuses.json +0 -9
  94. metadata +125 -210
  95. data/app/assets/builds/ariadne_view_components.css +0 -2202
  96. data/app/assets/javascripts/components/ariadne/accumulator_controller/accumulator_controller.d.ts +0 -22
  97. data/app/assets/javascripts/components/ariadne/ariadne-form.d.ts +0 -22
  98. data/app/assets/javascripts/components/ariadne/ariadne.d.ts +0 -2
  99. data/app/assets/javascripts/components/ariadne/clipboard_copy_component/clipboard-copy-component.d.ts +0 -4
  100. data/app/assets/javascripts/components/ariadne/dropdown/menu_component.d.ts +0 -1
  101. data/app/assets/javascripts/components/ariadne/events_controller/events_controller.d.ts +0 -4
  102. data/app/assets/javascripts/components/ariadne/options_controller/options_controller.d.ts +0 -39
  103. data/app/assets/javascripts/components/ariadne/outlet_manager_controller/outlet_manager_controller.d.ts +0 -42
  104. data/app/assets/javascripts/components/ariadne/slideover_component/slideover-component.d.ts +0 -9
  105. data/app/assets/javascripts/components/ariadne/string_match_controller/string_match_controller.d.ts +0 -27
  106. data/app/assets/javascripts/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.d.ts +0 -48
  107. data/app/assets/javascripts/components/ariadne/tab_container_component/tab-container-component.d.ts +0 -1
  108. data/app/assets/javascripts/components/ariadne/tab_nav_component/tab-nav-component.d.ts +0 -9
  109. data/app/assets/javascripts/components/ariadne/time_ago_component/time-ago-component.d.ts +0 -1
  110. data/app/assets/javascripts/components/ariadne/toggleable_controller/toggleable_controller.d.ts +0 -34
  111. data/app/assets/javascripts/components/ariadne/tooltip_component/tooltip-component.d.ts +0 -24
  112. data/app/assets/stylesheets/dropdown.css +0 -46
  113. data/app/assets/stylesheets/prosemirror.css +0 -323
  114. data/app/assets/stylesheets/tooltip-component.css +0 -37
  115. data/app/components/ariadne/accumulator_controller/accumulator_controller.d.ts +0 -22
  116. data/app/components/ariadne/accumulator_controller/accumulator_controller.js +0 -39
  117. data/app/components/ariadne/accumulator_controller/accumulator_controller.ts +0 -48
  118. data/app/components/ariadne/action_card_component.html.erb +0 -13
  119. data/app/components/ariadne/action_card_component.rb +0 -88
  120. data/app/components/ariadne/ariadne-form.d.ts +0 -22
  121. data/app/components/ariadne/ariadne-form.js +0 -85
  122. data/app/components/ariadne/ariadne.d.ts +0 -2
  123. data/app/components/ariadne/ariadne.js +0 -24
  124. data/app/components/ariadne/ariadne.ts +0 -29
  125. data/app/components/ariadne/avatar_component.rb +0 -81
  126. data/app/components/ariadne/avatar_stack_component/avatar_stack_component.html.erb +0 -12
  127. data/app/components/ariadne/avatar_stack_component.rb +0 -75
  128. data/app/components/ariadne/base_button.rb +0 -70
  129. data/app/components/ariadne/blankslate_component/blankslate_component.html.erb +0 -26
  130. data/app/components/ariadne/blankslate_component.rb +0 -148
  131. data/app/components/ariadne/body_component.rb +0 -30
  132. data/app/components/ariadne/bottom_tab_component.html.erb +0 -4
  133. data/app/components/ariadne/bottom_tab_component.rb +0 -44
  134. data/app/components/ariadne/bottom_tab_nav_component.html.erb +0 -5
  135. data/app/components/ariadne/bottom_tab_nav_component.rb +0 -33
  136. data/app/components/ariadne/breadcrumbs_component.html.erb +0 -13
  137. data/app/components/ariadne/breadcrumbs_component.rb +0 -31
  138. data/app/components/ariadne/button_component/button_component.html.erb +0 -4
  139. data/app/components/ariadne/button_component.rb +0 -165
  140. data/app/components/ariadne/checkbox_component.html.erb +0 -5
  141. data/app/components/ariadne/checkbox_component.rb +0 -43
  142. data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.d.ts +0 -4
  143. data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.js +0 -18
  144. data/app/components/ariadne/clipboard_copy_component/clipboard-copy-component.ts +0 -19
  145. data/app/components/ariadne/clipboard_copy_component/clipboard_copy_component.html.erb +0 -9
  146. data/app/components/ariadne/clipboard_copy_component.rb +0 -90
  147. data/app/components/ariadne/close_button_component.html.erb +0 -4
  148. data/app/components/ariadne/close_button_component.rb +0 -33
  149. data/app/components/ariadne/combobox_component.html.erb +0 -14
  150. data/app/components/ariadne/combobox_component.rb +0 -76
  151. data/app/components/ariadne/component.rb +0 -127
  152. data/app/components/ariadne/container_component/container_component.html.erb +0 -3
  153. data/app/components/ariadne/container_component.rb +0 -25
  154. data/app/components/ariadne/content.rb +0 -12
  155. data/app/components/ariadne/counter_component.rb +0 -100
  156. data/app/components/ariadne/details_component/details_component.html.erb +0 -4
  157. data/app/components/ariadne/details_component.rb +0 -81
  158. data/app/components/ariadne/dropdown/menu_component.d.ts +0 -1
  159. data/app/components/ariadne/dropdown/menu_component.html.erb +0 -20
  160. data/app/components/ariadne/dropdown/menu_component.js +0 -1
  161. data/app/components/ariadne/dropdown/menu_component.rb +0 -101
  162. data/app/components/ariadne/dropdown/menu_component.ts +0 -1
  163. data/app/components/ariadne/dropdown_component/dropdown_component.html.erb +0 -8
  164. data/app/components/ariadne/dropdown_component.rb +0 -172
  165. data/app/components/ariadne/events_controller/events_controller.d.ts +0 -4
  166. data/app/components/ariadne/events_controller/events_controller.js +0 -6
  167. data/app/components/ariadne/events_controller/events_controller.ts +0 -7
  168. data/app/components/ariadne/flash_component/flash_component.html.erb +0 -31
  169. data/app/components/ariadne/flash_component.rb +0 -128
  170. data/app/components/ariadne/flex_component/flex_component.html.erb +0 -5
  171. data/app/components/ariadne/flex_component.rb +0 -56
  172. data/app/components/ariadne/footer_component/footer_component.html.erb +0 -7
  173. data/app/components/ariadne/footer_component.rb +0 -23
  174. data/app/components/ariadne/grid_component/grid_component.html.erb +0 -26
  175. data/app/components/ariadne/grid_component.rb +0 -67
  176. data/app/components/ariadne/header_component/header_component.html.erb +0 -29
  177. data/app/components/ariadne/header_component.rb +0 -111
  178. data/app/components/ariadne/heading_component.rb +0 -49
  179. data/app/components/ariadne/heroicon_component/heroicon_component.html.erb +0 -4
  180. data/app/components/ariadne/heroicon_component.rb +0 -166
  181. data/app/components/ariadne/image_component.rb +0 -53
  182. data/app/components/ariadne/inline_flex_component/inline_flex_component.html.erb +0 -6
  183. data/app/components/ariadne/inline_flex_component.rb +0 -72
  184. data/app/components/ariadne/layout_component.html.erb +0 -21
  185. data/app/components/ariadne/layout_component.rb +0 -69
  186. data/app/components/ariadne/link_component.rb +0 -65
  187. data/app/components/ariadne/list_component/list_component.html.erb +0 -3
  188. data/app/components/ariadne/list_component.rb +0 -70
  189. data/app/components/ariadne/modal_component.html.erb +0 -11
  190. data/app/components/ariadne/modal_component.rb +0 -88
  191. data/app/components/ariadne/narrow_container_component/narrow_container_component.html.erb +0 -3
  192. data/app/components/ariadne/narrow_container_component.rb +0 -30
  193. data/app/components/ariadne/options_controller/options_controller.d.ts +0 -39
  194. data/app/components/ariadne/options_controller/options_controller.js +0 -89
  195. data/app/components/ariadne/options_controller/options_controller.ts +0 -122
  196. data/app/components/ariadne/outlet_manager_controller/outlet_manager_controller.d.ts +0 -42
  197. data/app/components/ariadne/outlet_manager_controller/outlet_manager_controller.js +0 -237
  198. data/app/components/ariadne/outlet_manager_controller/outlet_manager_controller.ts +0 -278
  199. data/app/components/ariadne/panel_bar_component/panel_bar_component.html.erb +0 -20
  200. data/app/components/ariadne/panel_bar_component.rb +0 -80
  201. data/app/components/ariadne/pill_component/pill_component.html.erb +0 -3
  202. data/app/components/ariadne/pill_component.rb +0 -44
  203. data/app/components/ariadne/popover_component.html.erb +0 -10
  204. data/app/components/ariadne/popover_component.rb +0 -81
  205. data/app/components/ariadne/progress_bar_component.html.erb +0 -5
  206. data/app/components/ariadne/progress_bar_component.rb +0 -63
  207. data/app/components/ariadne/relative_time_component.html.erb +0 -3
  208. data/app/components/ariadne/relative_time_component.rb +0 -61
  209. data/app/components/ariadne/show_more_button_component.html.erb +0 -11
  210. data/app/components/ariadne/show_more_button_component.rb +0 -47
  211. data/app/components/ariadne/slideover_component/slideover-component.d.ts +0 -9
  212. data/app/components/ariadne/slideover_component/slideover-component.js +0 -11
  213. data/app/components/ariadne/slideover_component/slideover-component.ts +0 -17
  214. data/app/components/ariadne/slideover_component/slideover_component.html.erb +0 -9
  215. data/app/components/ariadne/slideover_component.rb +0 -66
  216. data/app/components/ariadne/spinner_component.html.erb +0 -16
  217. data/app/components/ariadne/spinner_component.rb +0 -45
  218. data/app/components/ariadne/string_match_controller/string_match_controller.d.ts +0 -27
  219. data/app/components/ariadne/string_match_controller/string_match_controller.js +0 -51
  220. data/app/components/ariadne/string_match_controller/string_match_controller.ts +0 -65
  221. data/app/components/ariadne/subheader_component.html.erb +0 -11
  222. data/app/components/ariadne/subheader_component.rb +0 -65
  223. data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.d.ts +0 -48
  224. data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.js +0 -207
  225. data/app/components/ariadne/synced_boolean_attributes_controller/synced_boolean_attributes_controller.ts +0 -256
  226. data/app/components/ariadne/tab_component/tab_component.html.erb +0 -3
  227. data/app/components/ariadne/tab_component.rb +0 -98
  228. data/app/components/ariadne/tab_container_component/tab-container-component.d.ts +0 -1
  229. data/app/components/ariadne/tab_container_component/tab-container-component.js +0 -23
  230. data/app/components/ariadne/tab_container_component/tab-container-component.ts +0 -24
  231. data/app/components/ariadne/tab_container_component.erb +0 -10
  232. data/app/components/ariadne/tab_container_component.rb +0 -68
  233. data/app/components/ariadne/tab_nav_component/tab-nav-component.d.ts +0 -9
  234. data/app/components/ariadne/tab_nav_component/tab-nav-component.js +0 -33
  235. data/app/components/ariadne/tab_nav_component/tab-nav-component.ts +0 -34
  236. data/app/components/ariadne/tab_nav_component/tab_nav_component.html.erb +0 -7
  237. data/app/components/ariadne/tab_nav_component.rb +0 -72
  238. data/app/components/ariadne/table_nav_component/table_nav_component.html.erb +0 -52
  239. data/app/components/ariadne/table_nav_component.rb +0 -338
  240. data/app/components/ariadne/text.rb +0 -25
  241. data/app/components/ariadne/time_ago_component/time-ago-component.d.ts +0 -1
  242. data/app/components/ariadne/time_ago_component/time-ago-component.js +0 -1
  243. data/app/components/ariadne/time_ago_component/time-ago-component.ts +0 -1
  244. data/app/components/ariadne/time_ago_component.rb +0 -56
  245. data/app/components/ariadne/timeline_component/timeline_component.html.erb +0 -19
  246. data/app/components/ariadne/timeline_component.rb +0 -34
  247. data/app/components/ariadne/toggle_component/toggle_component.html.erb +0 -15
  248. data/app/components/ariadne/toggle_component.rb +0 -95
  249. data/app/components/ariadne/toggleable_controller/toggleable_controller.d.ts +0 -34
  250. data/app/components/ariadne/toggleable_controller/toggleable_controller.js +0 -54
  251. data/app/components/ariadne/toggleable_controller/toggleable_controller.ts +0 -77
  252. data/app/components/ariadne/tooltip_component/tooltip-component.d.ts +0 -24
  253. data/app/components/ariadne/tooltip_component/tooltip-component.js +0 -43
  254. data/app/components/ariadne/tooltip_component/tooltip-component.ts +0 -57
  255. data/app/components/ariadne/tooltip_component/tooltip_component.html.erb +0 -4
  256. data/app/components/ariadne/tooltip_component.rb +0 -108
  257. data/app/lib/ariadne/action_view_extensions/form_helper.rb +0 -30
  258. data/app/lib/ariadne/audited/dsl.rb +0 -32
  259. data/app/lib/ariadne/form_builder.rb +0 -80
  260. data/app/lib/ariadne/status/dsl.rb +0 -41
  261. data/config/importmap.rb +0 -3
  262. data/exe/tailwindcss +0 -21
  263. data/lib/rubocop/cop/ariadne/base_cop.rb +0 -26
  264. data/tailwind.config.js +0 -70
@@ -1,37 +0,0 @@
1
- .ariadne-tooltip-arrow,
2
- .ariadne-tooltip-arrow::before {
3
- position: absolute;
4
- width: 8px;
5
- height: 8px;
6
- background: inherit;
7
- }
8
-
9
- .ariadne-tooltip-arrow {
10
- visibility: hidden;
11
- }
12
-
13
- tooltip[data-tooltip-show] .ariadne-tooltip-arrow::before {
14
- visibility: visible;
15
- content: '';
16
- transform: rotate(45deg);
17
- }
18
-
19
- tooltip[data-popper-placement^='top'][data-tooltip-show] > .ariadne-tooltip-arrow {
20
- bottom: -4px;
21
- }
22
-
23
- tooltip[data-popper-placement^='bottom'] > .ariadne-tooltip-arrow {
24
- top: -4px;
25
- }
26
-
27
- tooltip[data-popper-placement^='left'] > .ariadne-tooltip-arrow {
28
- right: -4px;
29
- }
30
-
31
- tooltip[data-popper-placement^='right'] > .ariadne-tooltip-arrow {
32
- left: -4px;
33
- }
34
-
35
- tooltip[data-tooltip-show] {
36
- display: block;
37
- }
@@ -1,22 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- export default class AccumulatorController extends Controller {
3
- static targets: string[];
4
- static values: {
5
- syncAttrs: {
6
- type: ArrayConstructor;
7
- default: string[];
8
- };
9
- sumAttr: {
10
- type: string;
11
- default: string;
12
- };
13
- };
14
- sumTargets: Array<HTMLElement>;
15
- accumulatorTarget?: HTMLElement;
16
- syncAttrsValue: Array<string>;
17
- sumAttrValue: string;
18
- connect(): void;
19
- accumulate(): void;
20
- setAttributesTo(sum: number): void;
21
- get accumulator(): Element;
22
- }
@@ -1,39 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- class AccumulatorController extends Controller {
3
- connect() {
4
- this.accumulate();
5
- }
6
- accumulate() {
7
- let sum = 0;
8
- for (const i in this.sumTargets) {
9
- const target = this.sumTargets[i];
10
- const value = Number(target.getAttribute(this.sumAttrValue));
11
- if (!isNaN(value)) {
12
- sum += value;
13
- }
14
- }
15
- this.setAttributesTo(sum);
16
- }
17
- setAttributesTo(sum) {
18
- for (const i in this.syncAttrsValue) {
19
- const attr = this.syncAttrsValue[i];
20
- this.accumulator.setAttribute(attr, sum.toString());
21
- }
22
- }
23
- get accumulator() {
24
- var _a;
25
- return (_a = this.accumulatorTarget) !== null && _a !== void 0 ? _a : this.element;
26
- }
27
- }
28
- AccumulatorController.targets = ['sum', 'accumulator'];
29
- AccumulatorController.values = {
30
- syncAttrs: {
31
- type: Array,
32
- default: ['aria-valuenow'],
33
- },
34
- sumAttr: {
35
- type: 'string',
36
- default: 'data-value',
37
- },
38
- };
39
- export default AccumulatorController;
@@ -1,48 +0,0 @@
1
- import {Controller} from '@hotwired/stimulus'
2
-
3
- export default class AccumulatorController extends Controller {
4
- static targets = ['sum', 'accumulator']
5
- static values = {
6
- syncAttrs: {
7
- type: Array,
8
- default: ['aria-valuenow'],
9
- },
10
- sumAttr: {
11
- type: 'string',
12
- default: 'data-value',
13
- },
14
- }
15
-
16
- declare sumTargets: Array<HTMLElement>
17
- declare accumulatorTarget?: HTMLElement
18
- declare syncAttrsValue: Array<string>
19
- declare sumAttrValue: string
20
-
21
- connect(): void {
22
- this.accumulate()
23
- }
24
-
25
- accumulate() {
26
- let sum = 0
27
- for (const i in this.sumTargets) {
28
- const target = this.sumTargets[i]
29
- const value = Number(target.getAttribute(this.sumAttrValue))
30
- if (!isNaN(value)) {
31
- sum += value
32
- }
33
- }
34
-
35
- this.setAttributesTo(sum)
36
- }
37
-
38
- setAttributesTo(sum: number) {
39
- for (const i in this.syncAttrsValue) {
40
- const attr = this.syncAttrsValue[i]
41
- this.accumulator.setAttribute(attr, sum.toString())
42
- }
43
- }
44
-
45
- get accumulator() {
46
- return this.accumulatorTarget ?? this.element
47
- }
48
- }
@@ -1,13 +0,0 @@
1
- <%= render Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes) do |component| %>
2
- <%= render Ariadne::LinkComponent.new(tag: @link_tag, href: @href, actionable: @actionable, classes: @link_classes, attributes: @link_attributes) do %>
3
- <%= icon %>
4
- <%= title %>
5
- <% end %>
6
- <% if actions? %>
7
- <div class="<%= @actions_wrapper_classes %>">
8
- <% actions.each do |action| %>
9
- <%= action %>
10
- <% end %>
11
- </div>
12
- <% end %>
13
- <% end %>
@@ -1,88 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- # Card of anchor tags (most likely) that are used to navigate around a similar idea
5
- class ActionCardComponent < Ariadne::Component
6
- DEFAULT_TAG = :div
7
- DEFAULT_TITLE_TAG = :h3
8
- DEFAULT_ICON_TAG = :svg
9
- DEFAULT_ACTION_TAG = :a
10
- TAG_OPTIONS = [DEFAULT_TAG].freeze
11
-
12
- DEFAULT_CLASSES = {
13
- wrapper: "ariadne-overflow-hidden ariadne-w-96 ariadne-rounded-lg ariadne-mr-4 [&:last]:ariadne-mr-0",
14
- actions_wrapper: "ariadne-flex ariadne-w-full",
15
- icon: "",
16
- link: "ariadne-flex ariadne-flex-col ariadne-items-center",
17
- title: "ariadne-text-center ariadne-mb-4 ariadne-text-xl ariadne-font-bold",
18
- action: "ariadne-w-full ariadne-flex ariadne-items-center ariadne-justify-center ariadne-py-6 ariadne-text-sm",
19
- }
20
-
21
- DEFAULT_ATTRIBUTES = {
22
- wrapper: {},
23
- link: {},
24
- icon: {},
25
- title: {},
26
- action: {},
27
- }
28
-
29
- renders_one :icon, lambda { |tag: DEFAULT_ICON_TAG, icon: :inbox, size: :lg, variant: HeroiconsHelper::Icon::VARIANT_OUTLINE, classes: "", attributes: {}, text_classes: "", text_attributes: {}|
30
- Ariadne::HeroiconComponent.new(
31
- tag: tag,
32
- size: size,
33
- variant: variant,
34
- classes: merge_class_names(DEFAULT_CLASSES[:icon], classes),
35
- attributes: DEFAULT_ATTRIBUTES[:icon].merge(attributes),
36
- text_classes: text_classes,
37
- text_attributes: text_attributes,
38
- icon: icon,
39
- )
40
- }
41
-
42
- renders_one :title, lambda { |tag: DEFAULT_TITLE_TAG, classes: "", attributes: {}|
43
- Ariadne::HeadingComponent.new(
44
- tag: tag,
45
- classes: merge_class_names(DEFAULT_CLASSES[:title], classes),
46
- attributes: DEFAULT_ATTRIBUTES[:title].merge(attributes),
47
- )
48
- }
49
-
50
- renders_many :actions, lambda { |tag: DEFAULT_ACTION_TAG, href:, actionable: false, classes: "", attributes: {}|
51
- Ariadne::LinkComponent.new(
52
- tag: tag,
53
- href: href,
54
- actionable: actionable,
55
- classes: merge_class_names(DEFAULT_CLASSES[:action], classes),
56
- attributes: DEFAULT_ATTRIBUTES[:action].merge(attributes),
57
- )
58
- }
59
-
60
- # @example Default
61
- #
62
- # <%= render(Ariadne::ActionCardComponent.new) { "Example" } %>
63
- #
64
- # @param tag [Symbol, String] The rendered tag name.
65
- # @param classes [String] <%= link_to_classes_docs %>
66
- # @param attributes [Hash] <%= link_to_attributes_docs %>
67
- def initialize(
68
- tag: DEFAULT_TAG,
69
- href:,
70
- classes: "",
71
- attributes: {},
72
- actions_wrapper_classes: "",
73
- actionable: false,
74
- link_classes: "",
75
- link_attributes: {}
76
- )
77
- @tag = check_incoming_tag(DEFAULT_TAG, tag)
78
- @href = href
79
- @classes = merge_class_names(DEFAULT_CLASSES[:wrapper], classes)
80
- @attributes = DEFAULT_ATTRIBUTES[:wrapper].merge(attributes)
81
- @actions_wrapper_classes = merge_class_names(DEFAULT_CLASSES[:actions_wrapper], actions_wrapper_classes)
82
-
83
- @link_classes = merge_class_names(DEFAULT_CLASSES[:link], link_classes)
84
- @link_attributes = DEFAULT_ATTRIBUTES[:link].merge(link_attributes)
85
- @actionable = actionable
86
- end
87
- end
88
- end
@@ -1,22 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- import type { TemplateResult } from 'lit-html';
3
- type HTMLFormField = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
4
- export default class AriadneFormWith extends Controller {
5
- static targets: string[];
6
- readonly formFieldTargets: [HTMLFormField];
7
- connect(): void;
8
- disconnect(): void;
9
- onBlur: (event: Event) => void;
10
- onSubmit: (event: Event) => void;
11
- validateForm(): boolean;
12
- validateField(field: HTMLFormField): boolean;
13
- shouldValidateField(field: HTMLFormField): boolean;
14
- refreshErrorForInvalidField(field: HTMLFormField, isValid: boolean): void;
15
- removeExistingErrorMessage(field: HTMLFormField): void;
16
- showErrorForInvalidField(field: HTMLFormField): void;
17
- buildFieldErrorHtml(field: HTMLFormField): string;
18
- get formFields(): HTMLFormField[];
19
- get firstInvalidField(): HTMLFormField | undefined;
20
- getRenderString: (data: TemplateResult) => string;
21
- }
22
- export {};
@@ -1,85 +0,0 @@
1
- import { Controller } from '@hotwired/stimulus';
2
- import { html } from 'lit-html';
3
- class AriadneFormWith extends Controller {
4
- constructor() {
5
- super(...arguments);
6
- this.onBlur = (event) => {
7
- this.validateField(event.target);
8
- };
9
- this.onSubmit = (event) => {
10
- var _a;
11
- if (!this.validateForm()) {
12
- event.preventDefault();
13
- (_a = this.firstInvalidField) === null || _a === void 0 ? void 0 : _a.focus();
14
- }
15
- };
16
- this.getRenderString = (data) => {
17
- const { strings, values } = data;
18
- const v = [...values, ''].map(e => (typeof e === 'object' ? this.getRenderString(e) : e));
19
- return strings.reduce((acc, s, i) => acc + s + v[i], '');
20
- };
21
- }
22
- connect() {
23
- this.element.setAttribute('novalidate', 'true');
24
- this.element.addEventListener('blur', this.onBlur, true);
25
- this.element.addEventListener('submit', this.onSubmit);
26
- this.element.addEventListener('ajax:beforeSend', this.onSubmit);
27
- }
28
- disconnect() {
29
- this.element.removeEventListener('blur', this.onBlur);
30
- this.element.removeEventListener('submit', this.onSubmit);
31
- this.element.removeEventListener('ajax:beforeSend', this.onSubmit);
32
- }
33
- validateForm() {
34
- let isValid = true;
35
- // Not using `find` because we want to validate all the fields
36
- for (const field of this.formFields) {
37
- if (this.shouldValidateField(field) && !this.validateField(field))
38
- isValid = false;
39
- }
40
- return isValid;
41
- }
42
- validateField(field) {
43
- if (!this.shouldValidateField(field))
44
- return true;
45
- const isValid = field.checkValidity();
46
- field.classList.toggle('invalid', !isValid);
47
- this.refreshErrorForInvalidField(field, isValid);
48
- return isValid;
49
- }
50
- shouldValidateField(field) {
51
- return (!field.disabled &&
52
- !field.classList.contains('ProseMirror') &&
53
- !['file', 'reset', 'submit', 'button'].includes(field.type));
54
- }
55
- refreshErrorForInvalidField(field, isValid) {
56
- this.removeExistingErrorMessage(field);
57
- if (!isValid)
58
- this.showErrorForInvalidField(field);
59
- }
60
- removeExistingErrorMessage(field) {
61
- var _a;
62
- const fieldContainer = field.closest('.field');
63
- if (!fieldContainer)
64
- return;
65
- const existingErrorMessageElement = fieldContainer.querySelector('.error');
66
- if (existingErrorMessageElement) {
67
- (_a = existingErrorMessageElement === null || existingErrorMessageElement === void 0 ? void 0 : existingErrorMessageElement.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(existingErrorMessageElement);
68
- }
69
- }
70
- showErrorForInvalidField(field) {
71
- field.insertAdjacentHTML('afterend', this.buildFieldErrorHtml(field));
72
- }
73
- buildFieldErrorHtml(field) {
74
- const data = html `<p class="error">${field.validationMessage}</p>`;
75
- return this.getRenderString(data);
76
- }
77
- get formFields() {
78
- return Array.from(this.formFieldTargets);
79
- }
80
- get firstInvalidField() {
81
- return this.formFields.find(field => !field.checkValidity());
82
- }
83
- }
84
- AriadneFormWith.targets = ['formField'];
85
- export default AriadneFormWith;
@@ -1,2 +0,0 @@
1
- import './tab_container_component/tab-container-component';
2
- import './time_ago_component/time-ago-component';
@@ -1,24 +0,0 @@
1
- import { Application } from '@hotwired/stimulus';
2
- import AriadneForm from './ariadne-form';
3
- import StringMatchController from './string_match_controller/string_match_controller';
4
- import EventsController from './events_controller/events_controller';
5
- import OptionsController from './options_controller/options_controller';
6
- import AccumulatorController from './accumulator_controller/accumulator_controller';
7
- import ToggleableController from './toggleable_controller/toggleable_controller';
8
- import ClipboardCopyComponent from './clipboard_copy_component/clipboard-copy-component';
9
- import SlideoverComponent from './slideover_component/slideover-component';
10
- import TabNavComponent from './tab_nav_component/tab-nav-component';
11
- import TooltipComponent from './tooltip_component/tooltip-component';
12
- import './tab_container_component/tab-container-component';
13
- import './time_ago_component/time-ago-component';
14
- const application = Application.start();
15
- application.register('clipboard-copy-component', ClipboardCopyComponent);
16
- application.register('ariadne-form', AriadneForm);
17
- application.register('slideover-component', SlideoverComponent);
18
- application.register('tab-nav-component', TabNavComponent);
19
- application.register('tooltip-component', TooltipComponent);
20
- application.register('toggleable', ToggleableController);
21
- application.register('accumulator', AccumulatorController);
22
- application.register('options', OptionsController);
23
- application.register('string-match', StringMatchController);
24
- application.register('events', EventsController);
@@ -1,29 +0,0 @@
1
- import {Application} from '@hotwired/stimulus'
2
-
3
- import AriadneForm from './ariadne-form'
4
-
5
- import StringMatchController from './string_match_controller/string_match_controller'
6
- import EventsController from './events_controller/events_controller'
7
- import OptionsController from './options_controller/options_controller'
8
- import AccumulatorController from './accumulator_controller/accumulator_controller'
9
- import ToggleableController from './toggleable_controller/toggleable_controller'
10
- import ClipboardCopyComponent from './clipboard_copy_component/clipboard-copy-component'
11
- import SlideoverComponent from './slideover_component/slideover-component'
12
- import TabNavComponent from './tab_nav_component/tab-nav-component'
13
- import TooltipComponent from './tooltip_component/tooltip-component'
14
-
15
- import './tab_container_component/tab-container-component'
16
- import './time_ago_component/time-ago-component'
17
-
18
- const application = Application.start()
19
-
20
- application.register('clipboard-copy-component', ClipboardCopyComponent)
21
- application.register('ariadne-form', AriadneForm)
22
- application.register('slideover-component', SlideoverComponent)
23
- application.register('tab-nav-component', TabNavComponent)
24
- application.register('tooltip-component', TooltipComponent)
25
- application.register('toggleable', ToggleableController)
26
- application.register('accumulator', AccumulatorController)
27
- application.register('options', OptionsController)
28
- application.register('string-match', StringMatchController)
29
- application.register('events', EventsController)
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- # `Avatar` can be used to represent users.
5
- #
6
- # - Use the default circle avatar for users, and the square shape
7
- # for or any other non-human avatars.
8
- # - By default, `Avatar` will render a static `<img>`. To have `Avatar` function as a link, set the `href` which will wrap the `<img>` in a `<a>`.
9
- # - Set `size` to update the height and width of the `Avatar` in pixels.
10
- # - To stack multiple avatars together, use <%= link_to_component(Ariadne::AvatarStackComponent) %>.
11
- #
12
- # @accessibility
13
- # Images should have text alternatives that describe the information or function represented.
14
- # If the avatar functions as a link, provide alt text that helps convey the function. For instance,
15
- # if `Avatar` is a link to a user profile, the alt attribute should be `@kittenuser profile`
16
- # rather than `@kittenuser`.
17
- # [Learn more about best image practices (WAI Images)](https://www.w3.org/WAI/tutorials/images/)
18
- class AvatarComponent < Ariadne::Component
19
- DEFAULT_SIZE = 20
20
- SMALL_THRESHOLD = 24
21
-
22
- DEFAULT_SHAPE = :circle
23
- SHAPE_OPTIONS = [DEFAULT_SHAPE, :square].freeze
24
-
25
- SIZE_OPTIONS = [16, DEFAULT_SIZE, SMALL_THRESHOLD, 32, 40, 48, 80].freeze
26
-
27
- DEFAULT_CLASSES = "ariadne-inline-block ariadne-rounded-full ariadne-ring-2 ariadne-ring-white"
28
-
29
- # @example Default
30
- # <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser")) %>
31
- #
32
- # @example Square
33
- # <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", shape: :square)) %>
34
- #
35
- # @example Link
36
- # <%= render(Ariadne::AvatarComponent.new(href: "#", src: "http://placekitten.com/200/200", alt: "@kittenuser profile")) %>
37
- #
38
- # @example With size
39
- # <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 16)) %>
40
- # <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 20)) %>
41
- # <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 24)) %>
42
- # <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 32)) %>
43
- # <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 40)) %>
44
- # <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 48)) %>
45
- # <%= render(Ariadne::AvatarComponent.new(src: "http://placekitten.com/200/200", alt: "@kittenuser", size: 80)) %>
46
- #
47
- # @param src [String] The source url of the avatar image.
48
- # @param alt [String] Passed through to alt on img tag.
49
- # @param size [Integer] <%= one_of(Ariadne::AvatarComponent::SIZE_OPTIONS) %>
50
- # @param shape [Symbol] Shape of the avatar. <%= one_of(Ariadne::AvatarComponent::SHAPE_OPTIONS) %>
51
- # @param href [String] The URL to link to. If used, component will be wrapped by an `<a>` tag.
52
- # @param classes [String] <%= link_to_classes_docs %>
53
- # @param attributes [Hash] <%= link_to_attributes_docs %>
54
- def initialize(src:, alt:, size: DEFAULT_SIZE, shape: DEFAULT_SHAPE, href: nil, classes: "", attributes: {})
55
- @tag = :img
56
- @href = href
57
-
58
- @classes = merge_class_names(
59
- DEFAULT_CLASSES,
60
- classes,
61
- )
62
-
63
- @attributes = attributes
64
- @attributes[:src] = src
65
- @attributes[:alt] = alt
66
- @attributes[:size] = fetch_or_raise(SIZE_OPTIONS, size)
67
- @attributes[:height] = @attributes[:size]
68
- @attributes[:width] = @attributes[:size]
69
- end
70
-
71
- def call
72
- if @href
73
- render(Ariadne::LinkComponent.new(href: @href, classes: @classes, attributes: @attributes)) do
74
- render(Ariadne::BaseComponent.new(tag: @tag)) { content }
75
- end
76
- else
77
- render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) { content }
78
- end
79
- end
80
- end
81
- end
@@ -1,12 +0,0 @@
1
- <%= render Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes) do %>
2
- <% if tooltipped? %>
3
- <%= tooltip.to_s %>
4
- <% avatars.each_with_index do |avatar, i| %>
5
- <%= avatar %>
6
- <% end %>
7
- <% else %>
8
- <% avatars.each_with_index do |avatar, i| %>
9
- <%= avatar %>
10
- <% end %>
11
- <% end %>
12
- <% end %>
@@ -1,75 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- # Use `AvatarStack` to stack multiple avatars together.
5
- class AvatarStackComponent < Ariadne::Component
6
- ALIGN_DEFAULT = :left
7
- ALIGN_OPTIONS = [ALIGN_DEFAULT, :right].freeze
8
-
9
- DEFAULT_TAG = :div
10
- TAG_OPTIONS = [DEFAULT_TAG, :span].freeze
11
-
12
- DEFAULT_BODY_TAG = :div
13
- BODY_TAG_OPTIONS = [DEFAULT_BODY_TAG, :span].freeze
14
-
15
- # `Tooltip` that appears on mouse hover or keyboard focus over the stack.
16
- #
17
- # @param tag [Symbol, String] The rendered tag name
18
- # @param text [String] The text content of the tooltip. This should be brief and no longer than a sentence.
19
- # @param direction [Symbol] <%= one_of(Ariadne::TooltipComponent::VALID_PLACEMENTS) %>
20
- # @param classes [String] <%= link_to_classes_docs %>
21
- # @param attributes [Hash] Same arguments as <%= link_to_component(Ariadne::TooltipComponent) %>.
22
- renders_one :tooltip, lambda { |tag: Ariadne::TooltipComponent::DEFAULT_TAG, text:, direction: Ariadne::TooltipComponent::DEFAULT_PLACEMENT, classes: "", attributes: {}|
23
- raise ArgumentError, "Avatar stacks with a tooltip must have a unique `id` set." if @id.blank?
24
-
25
- Ariadne::TooltipComponent.new(for_id: @id, tag: tag, text: text, direction: direction, type: :label, classes: classes, attributes: attributes)
26
- }
27
-
28
- # Required list of stacked avatars.
29
- #
30
- # @param classes [String] <%= link_to_classes_docs %>
31
- # @param attributes [Hash] <%= link_to_attributes_docs %>
32
- renders_many :avatars, "Ariadne::AvatarComponent"
33
-
34
- DEFAULT_CLASSES = "ariadne-flex ariadne--space-x-2 ariadne-overflow-hidden"
35
-
36
- # @example Default
37
- # <%= render(Ariadne::AvatarStackComponent.new) do |c| %>
38
- # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
39
- # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
40
- # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
41
- # <% end %>
42
- #
43
- # @example Align right
44
- # <%= render(Ariadne::AvatarStackComponent.new(align: :right)) do |c| %>
45
- # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
46
- # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
47
- # <% c.with_avatar(src: "http://placekitten.com/200/200", alt: "@kittenuser") %>
48
- # <% end %>
49
- #
50
- # @param tag [Symbol] <%= one_of(Ariadne::AvatarStackComponent::TAG_OPTIONS) %>
51
- # @param align [Symbol] <%= one_of(Ariadne::AvatarStackComponent::ALIGN_OPTIONS) %>
52
- # @param classes [String] <%= link_to_classes_docs %>
53
- # @param attributes [Hash] <%= link_to_attributes_docs %>
54
- def initialize(tag: DEFAULT_TAG, align: ALIGN_DEFAULT, classes: "", attributes: {})
55
- @tag = check_incoming_tag(DEFAULT_TAG, tag)
56
- @align = fetch_or_raise(ALIGN_OPTIONS, align)
57
- @classes = merge_class_names(
58
- DEFAULT_CLASSES,
59
- classes,
60
- )
61
-
62
- @attributes = attributes
63
- @attributes[:id] ||= "avatar-stack-#{SecureRandom.hex(4)}"
64
- @id = @attributes[:id]
65
- end
66
-
67
- def render?
68
- avatars.any?
69
- end
70
-
71
- def tooltipped?
72
- tooltip.present?
73
- end
74
- end
75
- end
@@ -1,70 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Ariadne
4
- # Use `BaseButton` to render an unstyled `<button>` tag that can be customized.
5
- class BaseButton < Ariadne::Component
6
- DEFAULT_TAG = :button
7
- TAG_OPTIONS = [DEFAULT_TAG, :a, :summary].freeze
8
-
9
- DEFAULT_TYPE = :button
10
- TYPE_SUBMIT = :submit
11
- VALID_TYPES = [DEFAULT_TYPE, :reset, TYPE_SUBMIT].freeze
12
-
13
- SIZE_CLASS_MAPPINGS = {
14
- xs: "ariadne-px-2.5 ariadne-py-1.5 ariadne-text-xs ariadne-font-medium ariadne-rounded",
15
- sm: "ariadne-px-3 ariadne-py-2 ariadne-text-sm ariadne-leading-4 ariadne-font-medium ariadne-rounded-m",
16
- md: "ariadne-px-4 ariadne-py-2 ariadne-text-sm ariadne-font-medium ariadne-rounded-md",
17
- lg: "ariadne-px-4 ariadne-py-2 ariadne-text-base ariadne-font-medium ariadne-rounded-md",
18
- xl: "ariadne-px-6 ariadne-py-3 ariadne-text-base ariadne-font-medium ariadne-rounded-md",
19
- }.freeze
20
- VALID_SIZES = SIZE_CLASS_MAPPINGS.keys.freeze
21
-
22
- DEFAULT_CLASSES = "ariadne-items-center ariadne-border ariadne-shadow-sm focus:ariadne-outline-none focus:ariadne-ring-2 focus:ariadne-ring-offset-2"
23
- DEFAULT_NUDE_CLASSES = "focus:ariadne-outline-none focus:ariadne-ring-2 focus:ariadne-ring-offset-2"
24
-
25
- DEFAULT_SIZE = :md
26
-
27
- # @example Setting the size
28
- # <%= render(Ariadne::BaseButton.new(size: :xs)) { "I am an extra small button!" } %>
29
- # <%= render(Ariadne::BaseButton.new(size: :sm)) { "I am a small button!" } %>
30
- # <%= render(Ariadne::BaseButton.new(size: :md)) { "I am a medium button!" } %>
31
- # <%= render(Ariadne::BaseButton.new(size: :lg)) { "I am a large button!" } %>
32
- # <%= render(Ariadne::BaseButton.new(size: :xl)) { "I am an extra large button!" } %>
33
- #
34
- # @param tag [Symbol] <%= one_of(Ariadne::BaseButton::TAG_OPTIONS) %>
35
- # @param type [Symbol] <%= one_of(Ariadne::BaseButton::VALID_TYPES) %>
36
- # @param size [Symbol] <%= one_of(Ariadne::BaseButton::VALID_SIZES) %>
37
- # @param classes [String] <%= link_to_classes_docs %>
38
- # @param attributes [Hash] <%= link_to_attributes_docs %>
39
- def initialize(
40
- tag: DEFAULT_TAG,
41
- type: DEFAULT_TYPE,
42
- size: DEFAULT_SIZE,
43
- classes: "",
44
- attributes: {}
45
- )
46
- @attributes = attributes
47
- @tag = fetch_or_raise(TAG_OPTIONS, tag)
48
- @size = fetch_or_raise(VALID_SIZES, size)
49
-
50
- if button?
51
- @attributes[:type] = fetch_or_raise(VALID_TYPES, type)
52
- @classes = merge_class_names(DEFAULT_CLASSES, SIZE_CLASS_MAPPINGS[@size], classes)
53
- else
54
- @classes = merge_class_names(DEFAULT_NUDE_CLASSES, SIZE_CLASS_MAPPINGS[@size], classes)
55
- end
56
- end
57
-
58
- def call
59
- render(Ariadne::BaseComponent.new(tag: @tag, classes: @classes, attributes: @attributes)) { content }
60
- end
61
-
62
- private def link?(type)
63
- type == :link
64
- end
65
-
66
- private def button?
67
- @tag == :button
68
- end
69
- end
70
- end