polaris_view_components 0.3.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -3
  3. data/app/assets/javascripts/polaris_view_components/autocomplete_controller.js +119 -0
  4. data/app/assets/javascripts/polaris_view_components/button_controller.js +47 -0
  5. data/app/assets/javascripts/polaris_view_components/frame_controller.js +41 -0
  6. data/app/assets/javascripts/polaris_view_components/index.js +19 -1
  7. data/app/assets/javascripts/polaris_view_components/modal_controller.js +25 -0
  8. data/app/assets/javascripts/polaris_view_components/option_list_controller.js +41 -0
  9. data/app/assets/javascripts/polaris_view_components/polaris_controller.js +28 -0
  10. data/app/assets/javascripts/polaris_view_components/popover_controller.js +49 -0
  11. data/app/assets/javascripts/polaris_view_components/scrollable_controller.js +60 -0
  12. data/app/assets/javascripts/polaris_view_components/select_controller.js +6 -4
  13. data/app/assets/javascripts/polaris_view_components/text_field_controller.js +4 -0
  14. data/app/assets/javascripts/polaris_view_components/toast_controller.js +68 -0
  15. data/app/assets/javascripts/polaris_view_components.js +1936 -5
  16. data/app/assets/stylesheets/polaris_view_components/custom.css +109 -0
  17. data/app/assets/stylesheets/polaris_view_components/shopify_navigation.css +0 -4
  18. data/app/assets/stylesheets/polaris_view_components/spacer_component.css +39 -0
  19. data/app/assets/stylesheets/polaris_view_components.css +118 -3
  20. data/app/assets/stylesheets/polaris_view_components.postcss.css +2 -0
  21. data/app/components/polaris/action.rb +3 -3
  22. data/app/components/polaris/action_list/item_component.html.erb +35 -0
  23. data/app/components/polaris/action_list/item_component.rb +41 -0
  24. data/app/components/polaris/action_list/section_component.html.erb +16 -0
  25. data/app/components/polaris/action_list/section_component.rb +26 -0
  26. data/app/components/polaris/action_list_component.html.erb +13 -0
  27. data/app/components/polaris/action_list_component.rb +25 -0
  28. data/app/components/polaris/application_component.rb +19 -19
  29. data/app/components/polaris/autocomplete/action_component.rb +7 -0
  30. data/app/components/polaris/autocomplete/option_component.rb +35 -0
  31. data/app/components/polaris/autocomplete/section_component.html.erb +9 -0
  32. data/app/components/polaris/autocomplete/section_component.rb +12 -0
  33. data/app/components/polaris/autocomplete_component.html.erb +30 -0
  34. data/app/components/polaris/autocomplete_component.rb +58 -0
  35. data/app/components/polaris/avatar_component.rb +1 -1
  36. data/app/components/polaris/badge_component.rb +1 -1
  37. data/app/components/polaris/banner_component.rb +6 -6
  38. data/app/components/polaris/base_button.rb +1 -1
  39. data/app/components/polaris/base_checkbox.rb +48 -0
  40. data/app/components/polaris/base_radio_button.rb +38 -0
  41. data/app/components/polaris/button_component.html.erb +13 -0
  42. data/app/components/polaris/button_group_component.rb +5 -5
  43. data/app/components/polaris/callout_card_component.rb +5 -5
  44. data/app/components/polaris/caption_component.rb +2 -2
  45. data/app/components/polaris/card/header_component.rb +1 -3
  46. data/app/components/polaris/card/section_component.rb +6 -2
  47. data/app/components/polaris/card_component.html.erb +4 -0
  48. data/app/components/polaris/card_component.rb +5 -6
  49. data/app/components/polaris/character_count.rb +10 -10
  50. data/app/components/polaris/checkbox_component.html.erb +1 -5
  51. data/app/components/polaris/checkbox_component.rb +19 -12
  52. data/app/components/polaris/choice_component.rb +1 -1
  53. data/app/components/polaris/choice_list_component.rb +5 -5
  54. data/app/components/polaris/data_table/cell_component.html.erb +18 -0
  55. data/app/components/polaris/data_table/cell_component.rb +49 -0
  56. data/app/components/polaris/data_table/column_component.rb +19 -0
  57. data/app/components/polaris/data_table_component.html.erb +77 -0
  58. data/app/components/polaris/data_table_component.rb +42 -0
  59. data/app/components/polaris/description_list_component.rb +3 -3
  60. data/app/components/polaris/display_text_component.rb +2 -2
  61. data/app/components/polaris/dropzone/component.rb +36 -38
  62. data/app/components/polaris/empty_state_component.html.erb +16 -11
  63. data/app/components/polaris/empty_state_component.rb +4 -3
  64. data/app/components/polaris/exception_list/item_component.rb +2 -2
  65. data/app/components/polaris/exception_list_component.rb +1 -1
  66. data/app/components/polaris/filters_component.html.erb +35 -0
  67. data/app/components/polaris/filters_component.rb +91 -0
  68. data/app/components/polaris/footer_help_component.rb +1 -1
  69. data/app/components/polaris/form_layout/group_component.rb +3 -3
  70. data/app/components/polaris/form_layout/item_component.rb +1 -1
  71. data/app/components/polaris/form_layout_component.rb +3 -3
  72. data/app/components/polaris/frame/save_bar_component.html.erb +23 -0
  73. data/app/components/polaris/frame/save_bar_component.rb +31 -0
  74. data/app/components/polaris/frame/top_bar_component.html.erb +30 -0
  75. data/app/components/polaris/frame/top_bar_component.rb +18 -0
  76. data/app/components/polaris/frame_component.html.erb +44 -0
  77. data/app/components/polaris/frame_component.rb +33 -0
  78. data/app/components/polaris/heading_component.rb +1 -1
  79. data/app/components/polaris/headless_button.html.erb +13 -0
  80. data/app/components/polaris/headless_button.rb +17 -5
  81. data/app/components/polaris/icon_component.rb +2 -2
  82. data/app/components/polaris/index_table/cell_component.rb +22 -0
  83. data/app/components/polaris/index_table/column_component.rb +13 -0
  84. data/app/components/polaris/index_table_component.html.erb +28 -0
  85. data/app/components/polaris/index_table_component.rb +25 -0
  86. data/app/components/polaris/inline_error_component.html.erb +2 -2
  87. data/app/components/polaris/inline_error_component.rb +7 -1
  88. data/app/components/polaris/label_component.rb +2 -2
  89. data/app/components/polaris/labelled_component.rb +2 -2
  90. data/app/components/polaris/layout/annotated_section.rb +1 -1
  91. data/app/components/polaris/layout/section.rb +2 -0
  92. data/app/components/polaris/layout_component.rb +3 -3
  93. data/app/components/polaris/link_component.rb +5 -3
  94. data/app/components/polaris/list_component.rb +3 -3
  95. data/app/components/polaris/logo.rb +13 -0
  96. data/app/components/polaris/modal/section_component.rb +19 -0
  97. data/app/components/polaris/modal_component.html.erb +79 -0
  98. data/app/components/polaris/modal_component.rb +98 -0
  99. data/app/components/polaris/navigation/item_component.html.erb +31 -0
  100. data/app/components/polaris/navigation/item_component.rb +85 -0
  101. data/app/components/polaris/navigation/section_component.html.erb +17 -0
  102. data/app/components/polaris/navigation/section_component.rb +64 -0
  103. data/app/components/polaris/navigation_component.html.erb +29 -0
  104. data/app/components/polaris/navigation_component.rb +15 -0
  105. data/app/components/polaris/option_list/checkbox_component.html.erb +14 -0
  106. data/app/components/polaris/option_list/checkbox_component.rb +37 -0
  107. data/app/components/polaris/option_list/option_component.rb +24 -0
  108. data/app/components/polaris/option_list/radio_button_component.rb +54 -0
  109. data/app/components/polaris/option_list/section_component.html.erb +14 -0
  110. data/app/components/polaris/option_list/section_component.rb +53 -0
  111. data/app/components/polaris/option_list_component.html.erb +15 -0
  112. data/app/components/polaris/option_list_component.rb +67 -0
  113. data/app/components/polaris/page_actions_component.rb +21 -6
  114. data/app/components/polaris/page_component.rb +4 -4
  115. data/app/components/polaris/pagination_component.rb +1 -5
  116. data/app/components/polaris/popover/pane_component.html.erb +25 -0
  117. data/app/components/polaris/popover/pane_component.rb +20 -0
  118. data/app/components/polaris/popover/section_component.rb +19 -0
  119. data/app/components/polaris/popover_component.html.erb +31 -0
  120. data/app/components/polaris/popover_component.rb +107 -0
  121. data/app/components/polaris/progress_bar_component.rb +5 -5
  122. data/app/components/polaris/radio_button_component.html.erb +1 -6
  123. data/app/components/polaris/radio_button_component.rb +17 -7
  124. data/app/components/polaris/resource_item_component.html.erb +16 -6
  125. data/app/components/polaris/resource_item_component.rb +42 -9
  126. data/app/components/polaris/resource_list_component.html.erb +10 -0
  127. data/app/components/polaris/resource_list_component.rb +4 -10
  128. data/app/components/polaris/scrollable_component.html.erb +5 -0
  129. data/app/components/polaris/scrollable_component.rb +48 -0
  130. data/app/components/polaris/select_component.rb +10 -5
  131. data/app/components/polaris/setting_toggle_component.html.erb +10 -0
  132. data/app/components/polaris/setting_toggle_component.rb +24 -0
  133. data/app/components/polaris/shopify_navigation_component.rb +6 -6
  134. data/app/components/polaris/skeleton_body_text_component.rb +1 -1
  135. data/app/components/polaris/spacer_component.rb +50 -0
  136. data/app/components/polaris/spinner_component.rb +2 -2
  137. data/app/components/polaris/stack_component.rb +5 -5
  138. data/app/components/polaris/subheading_component.rb +1 -1
  139. data/app/components/polaris/tabs/tab_component.html.erb +10 -0
  140. data/app/components/polaris/tabs/tab_component.rb +34 -0
  141. data/app/components/polaris/tabs_component.html.erb +7 -0
  142. data/app/components/polaris/tabs_component.rb +37 -0
  143. data/app/components/polaris/tag_component.rb +2 -2
  144. data/app/components/polaris/text_container_component.rb +2 -2
  145. data/app/components/polaris/text_field_component.rb +24 -10
  146. data/app/components/polaris/text_style_component.rb +11 -2
  147. data/app/components/polaris/thumbnail_component.rb +2 -2
  148. data/app/components/polaris/toast_component.html.erb +21 -0
  149. data/app/components/polaris/toast_component.rb +40 -0
  150. data/app/components/polaris/top_bar/user_menu_component.html.erb +19 -0
  151. data/app/components/polaris/top_bar/user_menu_component.rb +9 -0
  152. data/app/helpers/polaris/form_builder.rb +31 -4
  153. data/app/helpers/polaris/url_helper.rb +3 -3
  154. data/app/helpers/polaris/view_helper.rb +37 -6
  155. data/app/validators/type_validator.rb +2 -2
  156. data/lib/generators/polaris_view_components/install_generator.rb +5 -5
  157. data/lib/polaris/view_components/engine.rb +11 -2
  158. data/lib/polaris/view_components/version.rb +1 -1
  159. data/lib/polaris_view_components.rb +1 -1
  160. metadata +88 -12
  161. data/app/components/polaris/choice_list/component.html.erb +0 -34
  162. data/app/components/polaris/choice_list/component.rb +0 -65
  163. data/app/helpers/polaris/action_helper.rb +0 -14
@@ -0,0 +1,109 @@
1
+ .Polaris--hidden {
2
+ display: none;
3
+ }
4
+
5
+ /* Add missing 1/4 section for layout */
6
+ @media (min-width: 30.625em) {
7
+ .Polaris-Layout__Section--oneFourth {
8
+ flex: 1 1 20rem;
9
+ min-width: 0;
10
+ }
11
+ }
12
+
13
+ /* Fix Tag removal link */
14
+ a.Polaris-Tag__Button {
15
+ height: auto;
16
+ }
17
+
18
+ /* Remove underline for sort link */
19
+
20
+ .Polaris-DataTable__Cell--sortable a {
21
+ text-decoration: none;
22
+ }
23
+
24
+ /* CardSection borders */
25
+ .Polaris-Card__Section--borderTop {
26
+ border-top: 0.1rem solid var(--p-divider);
27
+ }
28
+ .Polaris-Card__Section--borderBottom {
29
+ border-bottom: 0.1rem solid var(--p-divider);
30
+ }
31
+
32
+ /* IndexTable */
33
+
34
+ /* TODO: Remove after upgrade to Polaris 7.0.0 */
35
+ .Polaris-IndexTable__TableRow.Polaris-IndexTable__TableRow--unclickable {
36
+ cursor: auto;
37
+ }
38
+
39
+ /* TestStyle sizes */
40
+ .Polaris-TextStyle--sizeSmall {
41
+ font-size: 1.25rem;
42
+ }
43
+
44
+ /* Remove box-shadow from buttons and links */
45
+ .Polaris-Button::after,
46
+ .Polaris-Button:focus::after,
47
+ .Polaris-Breadcrumbs__Breadcrumb::after {
48
+ box-shadow: none !important;
49
+ }
50
+
51
+ .Polaris-Tabs__Tab:focus > .Polaris-Tabs__Title::after {
52
+ box-shadow: none !important;
53
+ }
54
+
55
+ /* ResourceItem */
56
+ .Polaris-ResourceItem__Owned--offset {
57
+ padding-left: 2rem;
58
+ }
59
+
60
+ /* Popover */
61
+ .Polaris-Popover {
62
+ margin: 0;
63
+ }
64
+
65
+ .Polaris-Popover__PopoverOverlay--closed {
66
+ visibility: hidden;
67
+ pointer-events: none;
68
+ }
69
+
70
+ /* Filters */
71
+
72
+ .Polaris-Filters-ConnectedFilterControl__RightContainer {
73
+ .Polaris-Filters-ConnectedFilterControl__Item {
74
+ & > div > div > button {
75
+ margin-right: var(--p-button-group-item-spacing);
76
+ border-radius: 0;
77
+ }
78
+
79
+ &:first-of-type > div > div > button {
80
+ border-top-left-radius: var(--p-border-radius-base);
81
+ border-bottom-left-radius: var(--p-border-radius-base);
82
+ }
83
+ }
84
+
85
+ &.Polaris-Filters-ConnectedFilterControl--queryFieldHidden {
86
+ .Polaris-Filters-ConnectedFilterControl__Item:first-of-type > div > div > button {
87
+ border-top-left-radius: var(--p-border-radius-base);
88
+ border-bottom-left-radius: var(--p-border-radius-base);
89
+ }
90
+ }
91
+ }
92
+
93
+ .Polaris-Filters-ConnectedFilterControl__RightContainerWithoutMoreFilters {
94
+ .Polaris-Filters-ConnectedFilterControl__Item:last-child > div > div > button {
95
+ border-top-right-radius: var(--p-border-radius-base);
96
+ border-bottom-right-radius: var(--p-border-radius-base);
97
+ }
98
+ }
99
+
100
+ /* Toast */
101
+ .Polaris-Frame-ToastManager {
102
+ bottom: 0;
103
+ }
104
+
105
+ /* Autocomplete */
106
+
107
+ .Polaris-Autocomplete__EmptyState {
108
+ padding: 0.8rem 1.6rem;
109
+ }
@@ -106,10 +106,6 @@
106
106
  border-bottom: .3rem solid var(--p-action-primary)
107
107
  }
108
108
 
109
- .shp-Navigation_Link:focus {
110
- box-shadow: inset 0 0 2px 0 rgba(92, 106, 196, .8), 0 0 2px 0 rgba(92, 106, 196, .8)
111
- }
112
-
113
109
  .shp-Navigation_Link:focus .shp-Navigation_LinkText {
114
110
  font-weight: 400;
115
111
  color: var(--p-text)
@@ -0,0 +1,39 @@
1
+ /* Vertical */
2
+ .Polaris-Spacer--verticalSpacingExtraTight {
3
+ height: 4px;
4
+ }
5
+ .Polaris-Spacer--verticalSpacingTight {
6
+ height: 8px;
7
+ }
8
+ .Polaris-Spacer--verticalSpacingBaseTight {
9
+ height: 12px;
10
+ }
11
+ .Polaris-Spacer--verticalSpacingBase {
12
+ height: 16px;
13
+ }
14
+ .Polaris-Spacer--verticalSpacingLoose {
15
+ height: 20px;
16
+ }
17
+ .Polaris-Spacer--verticalSpacingExtraLoose {
18
+ height: 32px;
19
+ }
20
+
21
+ /* Horizontal */
22
+ .Polaris-Spacer--horizontalSpacingExtraTight {
23
+ width: 4px;
24
+ }
25
+ .Polaris-Spacer--horizontalSpacingTight {
26
+ width: 8px;
27
+ }
28
+ .Polaris-Spacer--horizontalSpacingBaseTight {
29
+ width: 12px;
30
+ }
31
+ .Polaris-Spacer--horizontalSpacingBase {
32
+ width: 16px;
33
+ }
34
+ .Polaris-Spacer--horizontalSpacingLoose {
35
+ width: 20px;
36
+ }
37
+ .Polaris-Spacer--horizontalSpacingExtraLoose {
38
+ width: 32px;
39
+ }
@@ -2119,9 +2119,6 @@ html, body{ min-height:100%; height:100%; }
2119
2119
  text-decoration: none;
2120
2120
  border-bottom: .3rem solid var(--p-action-primary)
2121
2121
  }
2122
- .shp-Navigation_Link:focus {
2123
- box-shadow: inset 0 0 2px 0 rgba(92, 106, 196, .8), 0 0 2px 0 rgba(92, 106, 196, .8)
2124
- }
2125
2122
  .shp-Navigation_Link:focus .shp-Navigation_LinkText {
2126
2123
  font-weight: 400;
2127
2124
  color: var(--p-text)
@@ -2142,3 +2139,121 @@ html, body{ min-height:100%; height:100%; }
2142
2139
  color: var(--p-action-primary);
2143
2140
  border-bottom: .3rem solid var(--p-action-primary)
2144
2141
  }
2142
+ /* Vertical */
2143
+ .Polaris-Spacer--verticalSpacingExtraTight {
2144
+ height: 4px;
2145
+ }
2146
+ .Polaris-Spacer--verticalSpacingTight {
2147
+ height: 8px;
2148
+ }
2149
+ .Polaris-Spacer--verticalSpacingBaseTight {
2150
+ height: 12px;
2151
+ }
2152
+ .Polaris-Spacer--verticalSpacingBase {
2153
+ height: 16px;
2154
+ }
2155
+ .Polaris-Spacer--verticalSpacingLoose {
2156
+ height: 20px;
2157
+ }
2158
+ .Polaris-Spacer--verticalSpacingExtraLoose {
2159
+ height: 32px;
2160
+ }
2161
+ /* Horizontal */
2162
+ .Polaris-Spacer--horizontalSpacingExtraTight {
2163
+ width: 4px;
2164
+ }
2165
+ .Polaris-Spacer--horizontalSpacingTight {
2166
+ width: 8px;
2167
+ }
2168
+ .Polaris-Spacer--horizontalSpacingBaseTight {
2169
+ width: 12px;
2170
+ }
2171
+ .Polaris-Spacer--horizontalSpacingBase {
2172
+ width: 16px;
2173
+ }
2174
+ .Polaris-Spacer--horizontalSpacingLoose {
2175
+ width: 20px;
2176
+ }
2177
+ .Polaris-Spacer--horizontalSpacingExtraLoose {
2178
+ width: 32px;
2179
+ }
2180
+ .Polaris--hidden {
2181
+ display: none;
2182
+ }
2183
+ /* Add missing 1/4 section for layout */
2184
+ @media (min-width: 30.625em) {
2185
+ .Polaris-Layout__Section--oneFourth {
2186
+ flex: 1 1 20rem;
2187
+ min-width: 0;
2188
+ }
2189
+ }
2190
+ /* Fix Tag removal link */
2191
+ a.Polaris-Tag__Button {
2192
+ height: auto;
2193
+ }
2194
+ /* Remove underline for sort link */
2195
+ .Polaris-DataTable__Cell--sortable a {
2196
+ text-decoration: none;
2197
+ }
2198
+ /* CardSection borders */
2199
+ .Polaris-Card__Section--borderTop {
2200
+ border-top: 0.1rem solid var(--p-divider);
2201
+ }
2202
+ .Polaris-Card__Section--borderBottom {
2203
+ border-bottom: 0.1rem solid var(--p-divider);
2204
+ }
2205
+ /* IndexTable */
2206
+ /* TODO: Remove after upgrade to Polaris 7.0.0 */
2207
+ .Polaris-IndexTable__TableRow.Polaris-IndexTable__TableRow--unclickable {
2208
+ cursor: auto;
2209
+ }
2210
+ /* TestStyle sizes */
2211
+ .Polaris-TextStyle--sizeSmall {
2212
+ font-size: 1.25rem;
2213
+ }
2214
+ /* Remove box-shadow from buttons and links */
2215
+ .Polaris-Button::after,
2216
+ .Polaris-Button:focus::after,
2217
+ .Polaris-Breadcrumbs__Breadcrumb::after {
2218
+ box-shadow: none !important;
2219
+ }
2220
+ .Polaris-Tabs__Tab:focus > .Polaris-Tabs__Title::after {
2221
+ box-shadow: none !important;
2222
+ }
2223
+ /* ResourceItem */
2224
+ .Polaris-ResourceItem__Owned--offset {
2225
+ padding-left: 2rem;
2226
+ }
2227
+ /* Popover */
2228
+ .Polaris-Popover {
2229
+ margin: 0;
2230
+ }
2231
+ .Polaris-Popover__PopoverOverlay--closed {
2232
+ visibility: hidden;
2233
+ pointer-events: none;
2234
+ }
2235
+ /* Filters */
2236
+ .Polaris-Filters-ConnectedFilterControl__RightContainer .Polaris-Filters-ConnectedFilterControl__Item > div > div > button {
2237
+ margin-right: var(--p-button-group-item-spacing);
2238
+ border-radius: 0;
2239
+ }
2240
+ .Polaris-Filters-ConnectedFilterControl__RightContainer .Polaris-Filters-ConnectedFilterControl__Item:first-of-type > div > div > button {
2241
+ border-top-left-radius: var(--p-border-radius-base);
2242
+ border-bottom-left-radius: var(--p-border-radius-base);
2243
+ }
2244
+ .Polaris-Filters-ConnectedFilterControl__RightContainer.Polaris-Filters-ConnectedFilterControl--queryFieldHidden .Polaris-Filters-ConnectedFilterControl__Item:first-of-type > div > div > button {
2245
+ border-top-left-radius: var(--p-border-radius-base);
2246
+ border-bottom-left-radius: var(--p-border-radius-base);
2247
+ }
2248
+ .Polaris-Filters-ConnectedFilterControl__RightContainerWithoutMoreFilters .Polaris-Filters-ConnectedFilterControl__Item:last-child > div > div > button {
2249
+ border-top-right-radius: var(--p-border-radius-base);
2250
+ border-bottom-right-radius: var(--p-border-radius-base);
2251
+ }
2252
+ /* Toast */
2253
+ .Polaris-Frame-ToastManager {
2254
+ bottom: 0;
2255
+ }
2256
+ /* Autocomplete */
2257
+ .Polaris-Autocomplete__EmptyState {
2258
+ padding: 0.8rem 1.6rem;
2259
+ }
@@ -1,2 +1,4 @@
1
1
  @import "@shopify/polaris/dist/styles.css";
2
2
  @import "./polaris_view_components/shopify_navigation.css";
3
+ @import "./polaris_view_components/spacer_component.css";
4
+ @import "./polaris_view_components/custom.css";
@@ -5,9 +5,9 @@ module Polaris
5
5
  def initialize(
6
6
  content:,
7
7
  url:,
8
- accessibility_label: '',
8
+ accessibility_label: "",
9
9
  external: false,
10
- id: '',
10
+ id: "",
11
11
  data: {}
12
12
  )
13
13
  @content = content
@@ -25,7 +25,7 @@ module Polaris
25
25
  external: @external,
26
26
  id: @id,
27
27
  url: @url,
28
- data: @data,
28
+ data: @data
29
29
  }
30
30
  end
31
31
  end
@@ -0,0 +1,35 @@
1
+ <li>
2
+ <%= render Polaris::BaseComponent.new(**system_arguments) do %>
3
+ <div class="Polaris-ActionList__Content">
4
+ <% if @icon.present? %>
5
+ <span class="Polaris-ActionList__Prefix">
6
+ <%= polaris_icon(name: @icon) %>
7
+ </span>
8
+ <% end %>
9
+ <% if prefix.present? %>
10
+ <span class="Polaris-ActionList__Prefix">
11
+ <%= prefix %>
12
+ </span>
13
+ <% end %>
14
+
15
+ <span class="Polaris-ActionList__Text">
16
+ <% if @help_text.present? %>
17
+ <span class="Polaris-ActionList__ContentBlock">
18
+ <span class="Polaris-ActionList__ContentBlockInner">
19
+ <%= content %>
20
+ </span>
21
+ <%= polaris_text_subdued { @help_text } %>
22
+ </span>
23
+ <% else %>
24
+ <%= content %>
25
+ <% end %>
26
+ </span>
27
+
28
+ <% if suffix.present? %>
29
+ <span class="Polaris-ActionList__Suffix">
30
+ <%= suffix %>
31
+ </span>
32
+ <% end %>
33
+ </div>
34
+ <% end %>
35
+ </li>
@@ -0,0 +1,41 @@
1
+ class Polaris::ActionList::ItemComponent < Polaris::NewComponent
2
+ renders_one :prefix
3
+ renders_one :suffix
4
+
5
+ def initialize(
6
+ url: nil,
7
+ icon: nil,
8
+ help_text: nil,
9
+ active: false,
10
+ destructive: false,
11
+ external: false,
12
+ **system_arguments
13
+ )
14
+ @url = url
15
+ @icon = icon
16
+ @help_text = help_text
17
+ @active = active
18
+ @destructive = destructive
19
+ @external = external
20
+ @system_arguments = system_arguments
21
+ end
22
+
23
+ def system_arguments
24
+ @system_arguments.tap do |opts|
25
+ if @url.present?
26
+ opts[:tag] = "a"
27
+ opts[:href] = @url
28
+ opts[:target] = "_blank" if @external
29
+ else
30
+ opts[:tag] = "button"
31
+ opts[:type] = "button"
32
+ end
33
+ opts[:classes] = class_names(
34
+ @system_arguments[:classes],
35
+ "Polaris-ActionList__Item",
36
+ "Polaris-ActionList--active": @active,
37
+ "Polaris-ActionList--destructive": @destructive
38
+ )
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,16 @@
1
+ <%= render Polaris::BaseComponent.new(**system_arguments) do %>
2
+ <% if @title.present? %>
3
+ <p class="<%= title_classes %>">
4
+ <%= @title %>
5
+ </p>
6
+ <% end %>
7
+ <ul class="Polaris-ActionList__Actions">
8
+ <% if items.present? %>
9
+ <% items.each do |item| %>
10
+ <%= item %>
11
+ <% end %>
12
+ <% else %>
13
+ <%= content %>
14
+ <% end %>
15
+ </ul>
16
+ <% end %>
@@ -0,0 +1,26 @@
1
+ class Polaris::ActionList::SectionComponent < Polaris::NewComponent
2
+ renders_many :items, Polaris::ActionList::ItemComponent
3
+
4
+ def initialize(position: 1, title: nil, **system_arguments)
5
+ @position = position
6
+ @title = title
7
+ @system_arguments = system_arguments
8
+ end
9
+
10
+ def system_arguments
11
+ @system_arguments.tap do |opts|
12
+ opts[:tag] = "div"
13
+ opts[:classes] = class_names(
14
+ @system_arguments[:classes],
15
+ "Polaris-ActionList__Section--withoutTitle": @title.blank?
16
+ )
17
+ end
18
+ end
19
+
20
+ def title_classes
21
+ class_names(
22
+ "Polaris-ActionList__Title",
23
+ "Polaris-ActionList--firstSectionWithTitle": @position == 1
24
+ )
25
+ end
26
+ end
@@ -0,0 +1,13 @@
1
+ <%= render Polaris::BaseComponent.new(**system_arguments) do %>
2
+ <% if sections.present? %>
3
+ <% sections.each do |section| %>
4
+ <%= section %>
5
+ <% end %>
6
+ <% else %>
7
+ <%= render Polaris::ActionList::SectionComponent.new do %>
8
+ <% items.each do |item| %>
9
+ <%= item %>
10
+ <% end %>
11
+ <% end %>
12
+ <% end %>
13
+ <% end %>
@@ -0,0 +1,25 @@
1
+ module Polaris
2
+ class ActionListComponent < Polaris::NewComponent
3
+ renders_many :items, Polaris::ActionList::ItemComponent
4
+ renders_many :sections, ->(**system_arguments) do
5
+ @counter += 1
6
+
7
+ Polaris::ActionList::SectionComponent.new(position: @counter, **system_arguments)
8
+ end
9
+
10
+ def initialize(**system_arguments)
11
+ @counter = 0
12
+ @system_arguments = system_arguments
13
+ end
14
+
15
+ def system_arguments
16
+ @system_arguments.tap do |opts|
17
+ opts[:tag] = "div"
18
+ opts[:classes] = class_names(
19
+ @system_arguments[:classes],
20
+ "Polaris-ActionList"
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
@@ -9,27 +9,27 @@ class Polaris::ApplicationComponent < ViewComponent::Base
9
9
 
10
10
  private
11
11
 
12
- def classes
13
- []
14
- end
12
+ def classes
13
+ []
14
+ end
15
15
 
16
- def additional_data
17
- {}
18
- end
16
+ def additional_data
17
+ {}
18
+ end
19
19
 
20
- def additional_aria
21
- {}
22
- end
20
+ def additional_aria
21
+ {}
22
+ end
23
23
 
24
- def content_tag_options
25
- {
26
- class: classes.compact,
27
- data: @data.merge(additional_data),
28
- aria: @aria.merge(additional_aria)
29
- }.merge(@html_options)
30
- end
24
+ def content_tag_options
25
+ {
26
+ class: classes.compact,
27
+ data: @data.merge(additional_data),
28
+ aria: @aria.merge(additional_aria)
29
+ }.merge(@html_options)
30
+ end
31
31
 
32
- def before_render
33
- validate!
34
- end
32
+ def before_render
33
+ validate!
34
+ end
35
35
  end
@@ -0,0 +1,7 @@
1
+ module Polaris
2
+ class Autocomplete::ActionComponent < NewComponent
3
+ def initialize(**system_arguments)
4
+ @system_arguments = system_arguments
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,35 @@
1
+ module Polaris
2
+ class Autocomplete::OptionComponent < NewComponent
3
+ def initialize(
4
+ label:,
5
+ multiple: false,
6
+ **system_arguments
7
+ )
8
+ @label = label
9
+ @multiple = multiple
10
+ @system_arguments = system_arguments
11
+ end
12
+
13
+ def system_arguments
14
+ @system_arguments.tap do |args|
15
+ args[:label] = @label
16
+
17
+ args[:wrapper_arguments] ||= {}
18
+ args[:wrapper_arguments][:data] ||= {}
19
+ args[:wrapper_arguments][:data][:polaris_autocomplete_target] = "option"
20
+ args[:wrapper_arguments][:data][:label] = @label
21
+
22
+ args[:data] ||= {}
23
+ prepend_option(args[:data], :action, "polaris-autocomplete#select")
24
+ end
25
+ end
26
+
27
+ def call
28
+ if @multiple
29
+ render OptionList::CheckboxComponent.new(**system_arguments)
30
+ else
31
+ render OptionList::RadioButtonComponent.new(**system_arguments)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,9 @@
1
+ <%= render(Polaris::OptionList::SectionComponent.new(**@system_arguments)) do %>
2
+ <% if options.present? %>
3
+ <% options.each do |option| %>
4
+ <%= option %>
5
+ <% end %>
6
+ <% else %>
7
+ <%= content %>
8
+ <% end %>
9
+ <% end %>
@@ -0,0 +1,12 @@
1
+ module Polaris
2
+ class Autocomplete::SectionComponent < NewComponent
3
+ renders_many :options, ->(**system_arguments) do
4
+ Autocomplete::OptionComponent.new(multiple: @multiple, **system_arguments)
5
+ end
6
+
7
+ def initialize(multiple: false, **system_arguments)
8
+ @multiple = multiple
9
+ @system_arguments = system_arguments
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,30 @@
1
+ <%= render(Polaris::BaseComponent.new(**system_arguments)) do %>
2
+ <%= render(Polaris::PopoverComponent.new(**popover_arguments)) do |popover| %>
3
+ <% popover.activator do %>
4
+ <%= text_field %>
5
+ <% end %>
6
+
7
+ <% if empty_state.present? %>
8
+ <div
9
+ data-polaris-autocomplete-target="emptyState"
10
+ class="Polaris-Autocomplete__EmptyState Polaris--hidden"
11
+ >
12
+ <%= empty_state %>
13
+ </div>
14
+ <% end %>
15
+
16
+ <%= polaris_option_list(**option_list_arguments) do |list| %>
17
+ <% if sections.present? %>
18
+ <% sections.each do |section| %>
19
+ <%= section %>
20
+ <% end %>
21
+ <% elsif options.present? %>
22
+ <% options.each do |option| %>
23
+ <%= option %>
24
+ <% end %>
25
+ <% else %>
26
+ <%= content %>
27
+ <% end %>
28
+ <% end %>
29
+ <% end %>
30
+ <% end %>
@@ -0,0 +1,58 @@
1
+ module Polaris
2
+ class AutocompleteComponent < NewComponent
3
+ renders_one :text_field, ->(**system_arguments) do
4
+ system_arguments[:data] ||= {}
5
+ prepend_option(system_arguments[:data], :action, %w[
6
+ click->polaris-autocomplete#toggle
7
+ click@window->polaris-popover#hide
8
+ ])
9
+
10
+ system_arguments[:input_options] ||= {}
11
+ system_arguments[:input_options][:data] ||= {}
12
+ system_arguments[:input_options][:data][:polaris_autocomplete_target] = "input"
13
+
14
+ TextFieldComponent.new(**system_arguments)
15
+ end
16
+ renders_many :sections, ->(**system_arguments) do
17
+ Autocomplete::SectionComponent.new(multiple: @multiple, **system_arguments)
18
+ end
19
+ renders_many :options, ->(**system_arguments) do
20
+ Autocomplete::OptionComponent.new(multiple: @multiple, **system_arguments)
21
+ end
22
+ renders_one :empty_state
23
+
24
+ def initialize(multiple: false, url: nil, **system_arguments)
25
+ @multiple = multiple
26
+ @url = url
27
+ @system_arguments = system_arguments
28
+ end
29
+
30
+ def system_arguments
31
+ @system_arguments.tap do |opts|
32
+ opts[:tag] = "div"
33
+ opts[:data] ||= {}
34
+ opts[:data][:controller] = "polaris-autocomplete"
35
+ if @url.present?
36
+ opts[:data][:polaris_autocomplete_url_value] = @url
37
+ end
38
+ end
39
+ end
40
+
41
+ def popover_arguments
42
+ {
43
+ alignment: :left,
44
+ full_width: true,
45
+ inline: false,
46
+ wrapper_arguments: {
47
+ data: {polaris_autocomplete_target: "popover"}
48
+ }
49
+ }
50
+ end
51
+
52
+ def option_list_arguments
53
+ {
54
+ data: {polaris_autocomplete_target: "results"}
55
+ }
56
+ end
57
+ end
58
+ end