polaris_view_components 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/polaris_view_components/select_controller.js +6 -4
- data/app/assets/javascripts/polaris_view_components.js +6 -4
- data/app/assets/stylesheets/polaris_view_components/custom.css +25 -0
- data/app/assets/stylesheets/polaris_view_components/shopify_navigation.css +0 -4
- data/app/assets/stylesheets/polaris_view_components.css +20 -3
- data/app/components/polaris/card/section_component.rb +5 -1
- data/app/components/polaris/filters_component.html.erb +13 -0
- data/app/components/polaris/filters_component.rb +38 -0
- data/app/components/polaris/index_table/cell_component.rb +22 -0
- data/app/components/polaris/index_table/column_component.rb +13 -0
- data/app/components/polaris/index_table_component.html.erb +28 -0
- data/app/components/polaris/index_table_component.rb +25 -0
- data/app/components/polaris/inline_error_component.html.erb +2 -2
- data/app/components/polaris/inline_error_component.rb +7 -1
- data/app/components/polaris/page_actions_component.rb +15 -1
- data/app/components/polaris/resource_list_component.html.erb +10 -0
- data/app/components/polaris/resource_list_component.rb +2 -8
- data/app/components/polaris/select_component.rb +7 -2
- data/app/components/polaris/text_style_component.rb +9 -0
- data/app/helpers/polaris/form_builder.rb +27 -2
- data/app/helpers/polaris/view_helper.rb +13 -3
- data/lib/polaris/view_components/version.rb +1 -1
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4ecf6c373c0c3a1188d677df7da49034a9094392ce74b0bac9e72780b1a851a
|
4
|
+
data.tar.gz: 836ebef4a9e97c359d4bf36e4ae497d673a6579de232c0a82f6cf12d4f33e3d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: add02e909f36a997d49d261b3960ad41636001dbb4a6beea5f1652a7bfadab94d9bb2e07cefc5618f652bbdd431934ceb11da59388d0523d75686bbdddc7723e
|
7
|
+
data.tar.gz: cdd86e17c2a970aae8e5fec22cb296eae4cd1df572dee371978d0b02450cf6185c30c5a891db0943b62f1f114b593a2a3e890840362c1c1efc9da6087c663dd7
|
@@ -1,12 +1,14 @@
|
|
1
1
|
import { Controller } from "@hotwired/stimulus"
|
2
2
|
|
3
3
|
export default class extends Controller {
|
4
|
-
static targets = [
|
4
|
+
static targets = ["select", "selectedOption"]
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
connect() {
|
7
|
+
this.update()
|
8
|
+
}
|
9
9
|
|
10
|
+
update() {
|
11
|
+
const option = this.selectTarget.options[this.selectTarget.selectedIndex]
|
10
12
|
this.selectedOptionTarget.innerText = option.text
|
11
13
|
}
|
12
14
|
}
|
@@ -13,10 +13,12 @@ class ResourceItem extends Controller {
|
|
13
13
|
}
|
14
14
|
|
15
15
|
class Select extends Controller {
|
16
|
-
static targets=[ "selectedOption" ];
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
static targets=[ "select", "selectedOption" ];
|
17
|
+
connect() {
|
18
|
+
this.update();
|
19
|
+
}
|
20
|
+
update() {
|
21
|
+
const option = this.selectTarget.options[this.selectTarget.selectedIndex];
|
20
22
|
this.selectedOptionTarget.innerText = option.text;
|
21
23
|
}
|
22
24
|
}
|
@@ -16,3 +16,28 @@ a.Polaris-Tag__Button {
|
|
16
16
|
.Polaris-DataTable__Cell--sortable a {
|
17
17
|
text-decoration: none;
|
18
18
|
}
|
19
|
+
|
20
|
+
/* CardSection borders */
|
21
|
+
.Polaris-Card__Section--borderTop {
|
22
|
+
border-top: 0.1rem solid var(--p-divider);
|
23
|
+
}
|
24
|
+
.Polaris-Card__Section--borderBottom {
|
25
|
+
border-bottom: 0.1rem solid var(--p-divider);
|
26
|
+
}
|
27
|
+
|
28
|
+
/* IndexTable */
|
29
|
+
|
30
|
+
/* TODO: Remove after upgrade to Polaris 7.0.0 */
|
31
|
+
.Polaris-IndexTable__TableRow.Polaris-IndexTable__TableRow--unclickable {
|
32
|
+
cursor: auto;
|
33
|
+
}
|
34
|
+
|
35
|
+
/* TestStyle sizes */
|
36
|
+
.Polaris-TextStyle--sizeSmall {
|
37
|
+
font-size: 1.25rem;
|
38
|
+
}
|
39
|
+
|
40
|
+
/* Remove box-shadow from buttons and links */
|
41
|
+
.Polaris-Button::after, .Polaris-Button:focus::after, .Polaris-Breadcrumbs__Breadcrumb::after {
|
42
|
+
box-shadow: none !important;
|
43
|
+
}
|
@@ -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)
|
@@ -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)
|
@@ -2195,3 +2192,23 @@ a.Polaris-Tag__Button {
|
|
2195
2192
|
.Polaris-DataTable__Cell--sortable a {
|
2196
2193
|
text-decoration: none;
|
2197
2194
|
}
|
2195
|
+
/* CardSection borders */
|
2196
|
+
.Polaris-Card__Section--borderTop {
|
2197
|
+
border-top: 0.1rem solid var(--p-divider);
|
2198
|
+
}
|
2199
|
+
.Polaris-Card__Section--borderBottom {
|
2200
|
+
border-bottom: 0.1rem solid var(--p-divider);
|
2201
|
+
}
|
2202
|
+
/* IndexTable */
|
2203
|
+
/* TODO: Remove after upgrade to Polaris 7.0.0 */
|
2204
|
+
.Polaris-IndexTable__TableRow.Polaris-IndexTable__TableRow--unclickable {
|
2205
|
+
cursor: auto;
|
2206
|
+
}
|
2207
|
+
/* TestStyle sizes */
|
2208
|
+
.Polaris-TextStyle--sizeSmall {
|
2209
|
+
font-size: 1.25rem;
|
2210
|
+
}
|
2211
|
+
/* Remove box-shadow from buttons and links */
|
2212
|
+
.Polaris-Button::after, .Polaris-Button:focus::after, .Polaris-Breadcrumbs__Breadcrumb::after {
|
2213
|
+
box-shadow: none !important;
|
2214
|
+
}
|
@@ -7,6 +7,8 @@ class Polaris::Card::SectionComponent < Polaris::NewComponent
|
|
7
7
|
flush: false,
|
8
8
|
full_width: false,
|
9
9
|
unstyled: false,
|
10
|
+
border_top: false,
|
11
|
+
border_bottom: false,
|
10
12
|
actions: [],
|
11
13
|
**system_arguments
|
12
14
|
)
|
@@ -14,10 +16,12 @@ class Polaris::Card::SectionComponent < Polaris::NewComponent
|
|
14
16
|
@system_arguments[:tag] = :div
|
15
17
|
@system_arguments[:classes] = class_names(
|
16
18
|
@system_arguments[:classes],
|
19
|
+
"Polaris-Card__Section": !unstyled,
|
17
20
|
"Polaris-Card__Section--flush": flush,
|
18
21
|
"Polaris-Card__Section--subdued": subdued,
|
19
22
|
"Polaris-Card__Section--fullWidth": full_width,
|
20
|
-
"Polaris-Card__Section":
|
23
|
+
"Polaris-Card__Section--borderTop": border_top,
|
24
|
+
"Polaris-Card__Section--borderBottom": border_bottom,
|
21
25
|
)
|
22
26
|
|
23
27
|
@title = title
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%= render Polaris::BaseComponent.new(**system_arguments) do %>
|
2
|
+
<div class="Polaris-Filters-ConnectedFilterControl__Wrapper">
|
3
|
+
<div class="Polaris-Filters-ConnectedFilterControl Polaris-Filters-ConnectedFilterControl--right">
|
4
|
+
<% if query.present? %>
|
5
|
+
<div class="Polaris-Filters-ConnectedFilterControl__CenterContainer">
|
6
|
+
<div class="Polaris-Filters-ConnectedFilterControl__Item">
|
7
|
+
<%= query %>
|
8
|
+
</div>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Polaris
|
4
|
+
class FiltersComponent < Polaris::NewComponent
|
5
|
+
renders_one :query, "QueryComponent"
|
6
|
+
|
7
|
+
def initialize(**system_arguments)
|
8
|
+
@system_arguments = system_arguments
|
9
|
+
end
|
10
|
+
|
11
|
+
def system_arguments
|
12
|
+
@system_arguments.tap do |opts|
|
13
|
+
opts[:tag] = "div"
|
14
|
+
opts[:classes] = class_names(
|
15
|
+
@system_arguments[:classes],
|
16
|
+
"Polaris-Filters",
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class QueryComponent < Polaris::NewComponent
|
22
|
+
def initialize(clear_button: true, **system_arguments)
|
23
|
+
@system_arguments = system_arguments.merge(
|
24
|
+
label_hidden: true,
|
25
|
+
clear_button: clear_button,
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
def call
|
30
|
+
polaris_text_field(**@system_arguments) do |text_field|
|
31
|
+
text_field.prefix do
|
32
|
+
polaris_icon(name: "SearchMinor")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Polaris::IndexTable::CellComponent < Polaris::NewComponent
|
2
|
+
def initialize(flush: false, **system_arguments)
|
3
|
+
@flush = flush
|
4
|
+
@system_arguments = system_arguments
|
5
|
+
end
|
6
|
+
|
7
|
+
def system_arguments
|
8
|
+
{ tag: "td" }.deep_merge(@system_arguments).tap do |args|
|
9
|
+
args[:classes] = class_names(
|
10
|
+
args[:classes],
|
11
|
+
"Polaris-IndexTable__TableCell",
|
12
|
+
"Polaris-IndexTable__TableCell--flush": @flush,
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def call
|
18
|
+
render(Polaris::BaseComponent.new(**system_arguments)) do
|
19
|
+
content
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Polaris::IndexTable::ColumnComponent < Polaris::NewComponent
|
2
|
+
attr_reader :title, :flush
|
3
|
+
|
4
|
+
def initialize(title, flush: false, **system_arguments, &block)
|
5
|
+
@title = title
|
6
|
+
@flush = flush
|
7
|
+
@block = block
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(row)
|
11
|
+
@block.call(row)
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%= render Polaris::BaseComponent.new(**system_arguments) do %>
|
2
|
+
<div class="Polaris-IndexTable-ScrollContainer">
|
3
|
+
<table class="Polaris-IndexTable__Table">
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<% columns.each_with_index do |column, index| %>
|
7
|
+
<th class="Polaris-IndexTable__TableHeading">
|
8
|
+
<%= column.title %>
|
9
|
+
</th>
|
10
|
+
<% end %>
|
11
|
+
</tr>
|
12
|
+
</thead>
|
13
|
+
<tbody>
|
14
|
+
<% @data.each do |row| %>
|
15
|
+
<tr class="Polaris-IndexTable__TableRow Polaris-IndexTable__TableRow--unclickable">
|
16
|
+
<% columns.each_with_index do |column, index| %>
|
17
|
+
<%= render_cell(
|
18
|
+
flush: column.flush,
|
19
|
+
) do %>
|
20
|
+
<%= column.call(row) %>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
23
|
+
</tr>
|
24
|
+
<% end %>
|
25
|
+
</tbody>
|
26
|
+
</table>
|
27
|
+
</div>
|
28
|
+
<% end %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Polaris
|
2
|
+
class IndexTableComponent < Polaris::NewComponent
|
3
|
+
renders_many :columns, -> (title, **system_arguments, &block) do
|
4
|
+
IndexTable::ColumnComponent.new(title, **system_arguments, &block)
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(data, **system_arguments)
|
8
|
+
@data = data
|
9
|
+
@system_arguments = system_arguments
|
10
|
+
end
|
11
|
+
|
12
|
+
def system_arguments
|
13
|
+
{ tag: "div" }.deep_merge(@system_arguments).tap do |args|
|
14
|
+
args[:classes] = class_names(
|
15
|
+
args[:classes],
|
16
|
+
"Polaris-IndexTable",
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def render_cell(**arguments, &block)
|
22
|
+
render(IndexTable::CellComponent.new(**arguments), &block)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -2,7 +2,13 @@
|
|
2
2
|
|
3
3
|
module Polaris
|
4
4
|
class InlineErrorComponent < Polaris::NewComponent
|
5
|
-
def initialize
|
5
|
+
def initialize(**system_arguments)
|
6
|
+
@system_arguments = system_arguments
|
7
|
+
@system_arguments[:tag] = "div"
|
8
|
+
@system_arguments[:classes] = class_names(
|
9
|
+
@system_arguments[:classes],
|
10
|
+
"Polaris-InlineError",
|
11
|
+
)
|
6
12
|
end
|
7
13
|
|
8
14
|
def renders?
|
@@ -2,12 +2,24 @@
|
|
2
2
|
|
3
3
|
module Polaris
|
4
4
|
class PageActionsComponent < Polaris::NewComponent
|
5
|
+
DISTRIBUTION_DEFAULT = nil
|
6
|
+
DISTRIBUTION_OPTIONS = [
|
7
|
+
DISTRIBUTION_DEFAULT,
|
8
|
+
:equal_spacing,
|
9
|
+
:leading,
|
10
|
+
:trailing,
|
11
|
+
:center,
|
12
|
+
:fill,
|
13
|
+
:fill_evenly,
|
14
|
+
]
|
15
|
+
|
5
16
|
renders_one :primary_action, -> (primary: true, **system_arguments) do
|
6
17
|
Polaris::ButtonComponent.new(primary: primary, **system_arguments)
|
7
18
|
end
|
8
19
|
renders_many :secondary_actions, Polaris::ButtonComponent
|
9
20
|
|
10
|
-
def initialize(**system_arguments)
|
21
|
+
def initialize(distribution: DISTRIBUTION_DEFAULT, **system_arguments)
|
22
|
+
@distribution = fetch_or_fallback(DISTRIBUTION_OPTIONS, distribution, DISTRIBUTION_DEFAULT)
|
11
23
|
@system_arguments = system_arguments
|
12
24
|
@system_arguments[:tag] = "div"
|
13
25
|
@system_arguments[:classes] = class_names(
|
@@ -18,6 +30,8 @@ module Polaris
|
|
18
30
|
|
19
31
|
private
|
20
32
|
def stack_distribution
|
33
|
+
return @distribution if @distribution.present?
|
34
|
+
|
21
35
|
(primary_action.present? && secondary_actions.any?) ? :equal_spacing : :trailing
|
22
36
|
end
|
23
37
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<%= render(Polaris::BaseComponent.new(**@wrapper_arguments)) do %>
|
2
|
+
<% if filters.present? %>
|
3
|
+
<div class="Polaris-ResourceList__FiltersWrapper">
|
4
|
+
<%= filters %>
|
5
|
+
</div>
|
6
|
+
<% end %>
|
7
|
+
<%= render(Polaris::BaseComponent.new(**@system_arguments)) do %>
|
8
|
+
<%= content %>
|
9
|
+
<% end %>
|
10
|
+
<% end %>
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module Polaris
|
4
4
|
class ResourceListComponent < Polaris::NewComponent
|
5
|
+
renders_one :filters, Polaris::FiltersComponent
|
6
|
+
|
5
7
|
def initialize(
|
6
8
|
wrapper_arguments: {},
|
7
9
|
**system_arguments
|
@@ -20,13 +22,5 @@ module Polaris
|
|
20
22
|
"Polaris-ResourceList",
|
21
23
|
)
|
22
24
|
end
|
23
|
-
|
24
|
-
def call
|
25
|
-
render(Polaris::BaseComponent.new(**@wrapper_arguments)) do
|
26
|
-
render(Polaris::BaseComponent.new(**@system_arguments)) do
|
27
|
-
content
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
25
|
end
|
32
26
|
end
|
@@ -37,6 +37,7 @@ module Polaris
|
|
37
37
|
@system_arguments[:tag] = "div"
|
38
38
|
@system_arguments[:data] ||= {}
|
39
39
|
prepend_option(@system_arguments[:data], :controller, "polaris-select")
|
40
|
+
prepend_option(@system_arguments[:data], :selected_value, @selected)
|
40
41
|
@system_arguments[:classes] = class_names(
|
41
42
|
@system_arguments[:classes],
|
42
43
|
"Polaris-Select",
|
@@ -56,12 +57,14 @@ module Polaris
|
|
56
57
|
error: error,
|
57
58
|
}.merge(wrapper_arguments)
|
58
59
|
|
59
|
-
@select_options =
|
60
|
+
@select_options = select_options
|
60
61
|
|
61
62
|
@input_options = input_options
|
63
|
+
@input_options.deep_merge!(select_options) unless @form
|
62
64
|
@input_options[:class] = class_names(@input_options[:classes], "Polaris-Select__Input")
|
63
65
|
@input_options[:disabled] = disabled
|
64
66
|
@input_options[:data] ||= {}
|
67
|
+
prepend_option(@input_options[:data], :polaris_select_target, "select")
|
65
68
|
prepend_option(@input_options[:data], :action, "polaris-select#update")
|
66
69
|
end
|
67
70
|
|
@@ -71,7 +74,9 @@ module Polaris
|
|
71
74
|
|
72
75
|
def selected_option
|
73
76
|
option = @options.to_a.find { |i| i.last.to_s == @selected.to_s }
|
74
|
-
|
77
|
+
return unless option
|
78
|
+
|
79
|
+
option.first
|
75
80
|
end
|
76
81
|
end
|
77
82
|
end
|
@@ -13,8 +13,16 @@ module Polaris
|
|
13
13
|
}
|
14
14
|
VARIATION_OPTIONS = VARIATION_MAPPINGS.keys
|
15
15
|
|
16
|
+
SIZE_DEFAULT = :default
|
17
|
+
SIZE_MAPPINGS = {
|
18
|
+
SIZE_DEFAULT => "",
|
19
|
+
small: "Polaris-TextStyle--sizeSmall",
|
20
|
+
}
|
21
|
+
SIZE_OPTIONS = SIZE_MAPPINGS.keys
|
22
|
+
|
16
23
|
def initialize(
|
17
24
|
variation: VARIATION_DEFAULT,
|
25
|
+
size: SIZE_DEFAULT,
|
18
26
|
**system_arguments
|
19
27
|
)
|
20
28
|
@system_arguments = system_arguments
|
@@ -22,6 +30,7 @@ module Polaris
|
|
22
30
|
@system_arguments[:classes] = class_names(
|
23
31
|
@system_arguments[:classes],
|
24
32
|
VARIATION_MAPPINGS[fetch_or_fallback(VARIATION_OPTIONS, variation, VARIATION_DEFAULT)],
|
33
|
+
SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)],
|
25
34
|
)
|
26
35
|
end
|
27
36
|
|
@@ -16,7 +16,7 @@ module Polaris
|
|
16
16
|
) do
|
17
17
|
render(Polaris::ListComponent.new) do |list|
|
18
18
|
object.errors.each do |error|
|
19
|
-
list.item { error.full_message }
|
19
|
+
list.item { error.full_message.html_safe }
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -26,7 +26,16 @@ module Polaris
|
|
26
26
|
return if object.blank?
|
27
27
|
return unless object.errors.key?(method)
|
28
28
|
|
29
|
-
object.errors.full_messages_for(method)&.first
|
29
|
+
object.errors.full_messages_for(method)&.first.html_safe
|
30
|
+
end
|
31
|
+
|
32
|
+
def polaris_inline_error_for(method, **options, &block)
|
33
|
+
error_message = error_for(method)
|
34
|
+
return unless error_message
|
35
|
+
|
36
|
+
render(Polaris::InlineErrorComponent.new(**options, &block)) do
|
37
|
+
error_message
|
38
|
+
end
|
30
39
|
end
|
31
40
|
|
32
41
|
def polaris_text_field(method, **options, &block)
|
@@ -48,5 +57,21 @@ module Polaris
|
|
48
57
|
end
|
49
58
|
render Polaris::SelectComponent.new(form: self, attribute: method, **options, &block)
|
50
59
|
end
|
60
|
+
|
61
|
+
def polaris_check_box(method, **options, &block)
|
62
|
+
options[:error] ||= error_for(method)
|
63
|
+
if options[:error_hidden] && options[:error]
|
64
|
+
options[:error] = !!options[:error]
|
65
|
+
end
|
66
|
+
render Polaris::CheckboxComponent.new(form: self, attribute: method, **options, &block)
|
67
|
+
end
|
68
|
+
|
69
|
+
def polaris_radio_button(method, **options, &block)
|
70
|
+
options[:error] ||= error_for(method)
|
71
|
+
if options[:error_hidden] && options[:error]
|
72
|
+
options[:error] = !!options[:error]
|
73
|
+
end
|
74
|
+
render Polaris::RadioButtonComponent.new(form: self, attribute: method, **options, &block)
|
75
|
+
end
|
51
76
|
end
|
52
77
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Polaris
|
2
2
|
# Module to allow shorthand calls for Polaris components
|
3
3
|
module ViewHelper
|
4
|
-
|
4
|
+
POLARIS_HELPERS = {
|
5
5
|
avatar: "Polaris::AvatarComponent",
|
6
6
|
badge: "Polaris::BadgeComponent",
|
7
7
|
banner: "Polaris::BannerComponent",
|
@@ -10,7 +10,9 @@ module Polaris
|
|
10
10
|
callout_card: "Polaris::CalloutCardComponent",
|
11
11
|
caption: "Polaris::CaptionComponent",
|
12
12
|
card: "Polaris::CardComponent",
|
13
|
+
card_section: "Polaris::Card::SectionComponent",
|
13
14
|
checkbox: "Polaris::CheckboxComponent",
|
15
|
+
check_box: "Polaris::CheckboxComponent",
|
14
16
|
choice_list: "Polaris::ChoiceListComponent",
|
15
17
|
data_table: "Polaris::DataTableComponent",
|
16
18
|
description_list: "Polaris::DescriptionListComponent",
|
@@ -20,8 +22,10 @@ module Polaris
|
|
20
22
|
exception_list: "Polaris::ExceptionListComponent",
|
21
23
|
footer_help: "Polaris::FooterHelpComponent",
|
22
24
|
form_layout: "Polaris::FormLayoutComponent",
|
25
|
+
filters: "Polaris::FiltersComponent",
|
23
26
|
heading: "Polaris::HeadingComponent",
|
24
27
|
icon: "Polaris::IconComponent",
|
28
|
+
index_table: "Polaris::IndexTableComponent",
|
25
29
|
inline_error: "Polaris::InlineErrorComponent",
|
26
30
|
layout: "Polaris::LayoutComponent",
|
27
31
|
link: "Polaris::LinkComponent",
|
@@ -47,13 +51,19 @@ module Polaris
|
|
47
51
|
thumbnail: "Polaris::ThumbnailComponent",
|
48
52
|
visually_hidden: "Polaris::VisuallyHiddenComponent",
|
49
53
|
}.freeze
|
50
|
-
|
51
|
-
HELPERS.each do |name, component|
|
54
|
+
POLARIS_HELPERS.each do |name, component|
|
52
55
|
define_method "polaris_#{name}" do |*args, **kwargs, &block|
|
53
56
|
render component.constantize.new(*args, **kwargs), &block
|
54
57
|
end
|
55
58
|
end
|
56
59
|
|
60
|
+
POLARIS_TEXT_STYLES = %i[subdued strong positive negative code].freeze
|
61
|
+
POLARIS_TEXT_STYLES.each do |name|
|
62
|
+
define_method "polaris_text_#{name}" do |**kwargs, &block|
|
63
|
+
polaris_text_style(variation: name, **kwargs, &block)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
57
67
|
def polaris_icon_source(name)
|
58
68
|
path = ViewComponents::Engine.root.join("app", "assets", "icons", "polaris", "#{name}.svg")
|
59
69
|
file = File.read(path)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polaris_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Gamble
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-10-
|
12
|
+
date: 2021-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -506,6 +506,8 @@ files:
|
|
506
506
|
- app/components/polaris/exception_list/item_component.rb
|
507
507
|
- app/components/polaris/exception_list_component.html.erb
|
508
508
|
- app/components/polaris/exception_list_component.rb
|
509
|
+
- app/components/polaris/filters_component.html.erb
|
510
|
+
- app/components/polaris/filters_component.rb
|
509
511
|
- app/components/polaris/footer_help_component.html.erb
|
510
512
|
- app/components/polaris/footer_help_component.rb
|
511
513
|
- app/components/polaris/form_layout/group_component.html.erb
|
@@ -518,6 +520,10 @@ files:
|
|
518
520
|
- app/components/polaris/headless_button.rb
|
519
521
|
- app/components/polaris/icon_component.html.erb
|
520
522
|
- app/components/polaris/icon_component.rb
|
523
|
+
- app/components/polaris/index_table/cell_component.rb
|
524
|
+
- app/components/polaris/index_table/column_component.rb
|
525
|
+
- app/components/polaris/index_table_component.html.erb
|
526
|
+
- app/components/polaris/index_table_component.rb
|
521
527
|
- app/components/polaris/inline_error_component.html.erb
|
522
528
|
- app/components/polaris/inline_error_component.rb
|
523
529
|
- app/components/polaris/label_component.html.erb
|
@@ -545,6 +551,7 @@ files:
|
|
545
551
|
- app/components/polaris/radio_button_component.rb
|
546
552
|
- app/components/polaris/resource_item_component.html.erb
|
547
553
|
- app/components/polaris/resource_item_component.rb
|
554
|
+
- app/components/polaris/resource_list_component.html.erb
|
548
555
|
- app/components/polaris/resource_list_component.rb
|
549
556
|
- app/components/polaris/select_component.html.erb
|
550
557
|
- app/components/polaris/select_component.rb
|