polaris_view_components 0.3.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/javascripts/polaris_view_components/button_controller.js +48 -0
- data/app/assets/javascripts/polaris_view_components/index.js +11 -1
- data/app/assets/javascripts/polaris_view_components/modal_controller.js +25 -0
- data/app/assets/javascripts/polaris_view_components/polaris_controller.js +24 -0
- data/app/assets/javascripts/polaris_view_components/popover_controller.js +45 -0
- data/app/assets/javascripts/polaris_view_components/scrollable_controller.js +60 -0
- data/app/assets/javascripts/polaris_view_components/select_controller.js +6 -4
- data/app/assets/javascripts/polaris_view_components.js +1539 -5
- data/app/assets/stylesheets/polaris_view_components/custom.css +68 -0
- data/app/assets/stylesheets/polaris_view_components/shopify_navigation.css +0 -4
- data/app/assets/stylesheets/polaris_view_components/spacer_component.css +39 -0
- data/app/assets/stylesheets/polaris_view_components.css +93 -3
- data/app/assets/stylesheets/polaris_view_components.postcss.css +2 -0
- data/app/components/polaris/action.rb +3 -3
- data/app/components/polaris/action_list/item_component.html.erb +35 -0
- data/app/components/polaris/action_list/item_component.rb +41 -0
- data/app/components/polaris/action_list/section_component.html.erb +16 -0
- data/app/components/polaris/action_list/section_component.rb +26 -0
- data/app/components/polaris/action_list_component.html.erb +13 -0
- data/app/components/polaris/action_list_component.rb +25 -0
- data/app/components/polaris/application_component.rb +19 -19
- data/app/components/polaris/avatar_component.rb +1 -1
- data/app/components/polaris/badge_component.rb +1 -1
- data/app/components/polaris/banner_component.rb +6 -6
- data/app/components/polaris/base_button.rb +1 -1
- data/app/components/polaris/button_component.html.erb +13 -0
- data/app/components/polaris/button_group_component.rb +5 -5
- data/app/components/polaris/callout_card_component.rb +5 -5
- data/app/components/polaris/caption_component.rb +2 -2
- data/app/components/polaris/card/header_component.rb +1 -3
- data/app/components/polaris/card/section_component.rb +6 -2
- data/app/components/polaris/card_component.html.erb +4 -0
- data/app/components/polaris/card_component.rb +5 -6
- data/app/components/polaris/character_count.rb +10 -10
- data/app/components/polaris/checkbox_component.rb +4 -4
- data/app/components/polaris/choice_component.rb +1 -1
- data/app/components/polaris/choice_list_component.rb +4 -4
- data/app/components/polaris/data_table/cell_component.html.erb +18 -0
- data/app/components/polaris/data_table/cell_component.rb +49 -0
- data/app/components/polaris/data_table/column_component.rb +19 -0
- data/app/components/polaris/data_table_component.html.erb +77 -0
- data/app/components/polaris/data_table_component.rb +42 -0
- data/app/components/polaris/description_list_component.rb +3 -3
- data/app/components/polaris/display_text_component.rb +2 -2
- data/app/components/polaris/dropzone/component.rb +36 -38
- data/app/components/polaris/empty_state_component.html.erb +16 -11
- data/app/components/polaris/empty_state_component.rb +4 -3
- data/app/components/polaris/exception_list/item_component.rb +2 -2
- data/app/components/polaris/exception_list_component.rb +1 -1
- data/app/components/polaris/filters_component.html.erb +13 -0
- data/app/components/polaris/filters_component.rb +38 -0
- data/app/components/polaris/footer_help_component.rb +1 -1
- data/app/components/polaris/form_layout/group_component.rb +3 -3
- data/app/components/polaris/form_layout/item_component.rb +1 -1
- data/app/components/polaris/form_layout_component.rb +3 -3
- data/app/components/polaris/heading_component.rb +1 -1
- data/app/components/polaris/headless_button.html.erb +13 -0
- data/app/components/polaris/headless_button.rb +17 -5
- data/app/components/polaris/icon_component.rb +2 -2
- 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/label_component.rb +2 -2
- data/app/components/polaris/labelled_component.rb +2 -2
- data/app/components/polaris/layout/annotated_section.rb +1 -1
- data/app/components/polaris/layout/section.rb +2 -0
- data/app/components/polaris/layout_component.rb +3 -3
- data/app/components/polaris/link_component.rb +5 -3
- data/app/components/polaris/list_component.rb +3 -3
- data/app/components/polaris/modal/section_component.rb +19 -0
- data/app/components/polaris/modal_component.html.erb +79 -0
- data/app/components/polaris/modal_component.rb +98 -0
- data/app/components/polaris/page_actions_component.rb +21 -6
- data/app/components/polaris/page_component.rb +4 -4
- data/app/components/polaris/pagination_component.rb +1 -5
- data/app/components/polaris/popover/pane_component.html.erb +25 -0
- data/app/components/polaris/popover/pane_component.rb +20 -0
- data/app/components/polaris/popover/section_component.rb +19 -0
- data/app/components/polaris/popover_component.html.erb +38 -0
- data/app/components/polaris/popover_component.rb +90 -0
- data/app/components/polaris/progress_bar_component.rb +5 -5
- data/app/components/polaris/radio_button_component.rb +3 -3
- data/app/components/polaris/resource_item_component.html.erb +16 -6
- data/app/components/polaris/resource_item_component.rb +42 -9
- data/app/components/polaris/resource_list_component.html.erb +10 -0
- data/app/components/polaris/resource_list_component.rb +4 -10
- data/app/components/polaris/scrollable_component.html.erb +5 -0
- data/app/components/polaris/scrollable_component.rb +48 -0
- data/app/components/polaris/select_component.rb +10 -5
- data/app/components/polaris/setting_toggle_component.html.erb +10 -0
- data/app/components/polaris/setting_toggle_component.rb +24 -0
- data/app/components/polaris/shopify_navigation_component.rb +6 -6
- data/app/components/polaris/skeleton_body_text_component.rb +1 -1
- data/app/components/polaris/spacer_component.rb +50 -0
- data/app/components/polaris/spinner_component.rb +2 -2
- data/app/components/polaris/stack_component.rb +5 -5
- data/app/components/polaris/subheading_component.rb +1 -1
- data/app/components/polaris/tabs/tab_component.html.erb +10 -0
- data/app/components/polaris/tabs/tab_component.rb +34 -0
- data/app/components/polaris/tabs_component.html.erb +7 -0
- data/app/components/polaris/tabs_component.rb +37 -0
- data/app/components/polaris/tag_component.rb +2 -2
- data/app/components/polaris/text_container_component.rb +2 -2
- data/app/components/polaris/text_field_component.rb +8 -8
- data/app/components/polaris/text_style_component.rb +11 -2
- data/app/components/polaris/thumbnail_component.rb +2 -2
- data/app/helpers/polaris/form_builder.rb +30 -3
- data/app/helpers/polaris/url_helper.rb +3 -3
- data/app/helpers/polaris/view_helper.rb +26 -6
- data/app/validators/type_validator.rb +2 -2
- data/lib/generators/polaris_view_components/install_generator.rb +5 -5
- data/lib/polaris/view_components/engine.rb +6 -1
- data/lib/polaris/view_components/version.rb +1 -1
- data/lib/polaris_view_components.rb +1 -1
- metadata +45 -6
- data/app/components/polaris/choice_list/component.html.erb +0 -34
- data/app/components/polaris/choice_list/component.rb +0 -65
- data/app/helpers/polaris/action_helper.rb +0 -14
@@ -1,7 +1,9 @@
|
|
1
1
|
module Polaris
|
2
2
|
# Module to allow shorthand calls for Polaris components
|
3
3
|
module ViewHelper
|
4
|
-
|
4
|
+
# standard:disable Layout/HashAlignment
|
5
|
+
POLARIS_HELPERS = {
|
6
|
+
action_list: "Polaris::ActionListComponent",
|
5
7
|
avatar: "Polaris::AvatarComponent",
|
6
8
|
badge: "Polaris::BadgeComponent",
|
7
9
|
banner: "Polaris::BannerComponent",
|
@@ -10,8 +12,11 @@ module Polaris
|
|
10
12
|
callout_card: "Polaris::CalloutCardComponent",
|
11
13
|
caption: "Polaris::CaptionComponent",
|
12
14
|
card: "Polaris::CardComponent",
|
15
|
+
card_section: "Polaris::Card::SectionComponent",
|
13
16
|
checkbox: "Polaris::CheckboxComponent",
|
17
|
+
check_box: "Polaris::CheckboxComponent",
|
14
18
|
choice_list: "Polaris::ChoiceListComponent",
|
19
|
+
data_table: "Polaris::DataTableComponent",
|
15
20
|
description_list: "Polaris::DescriptionListComponent",
|
16
21
|
display_text: "Polaris::DisplayTextComponent",
|
17
22
|
dropzone: "Polaris::Dropzone::Component",
|
@@ -19,44 +24,59 @@ module Polaris
|
|
19
24
|
exception_list: "Polaris::ExceptionListComponent",
|
20
25
|
footer_help: "Polaris::FooterHelpComponent",
|
21
26
|
form_layout: "Polaris::FormLayoutComponent",
|
27
|
+
filters: "Polaris::FiltersComponent",
|
22
28
|
heading: "Polaris::HeadingComponent",
|
23
29
|
icon: "Polaris::IconComponent",
|
30
|
+
index_table: "Polaris::IndexTableComponent",
|
24
31
|
inline_error: "Polaris::InlineErrorComponent",
|
25
32
|
layout: "Polaris::LayoutComponent",
|
26
33
|
link: "Polaris::LinkComponent",
|
27
34
|
list: "Polaris::ListComponent",
|
35
|
+
modal: "Polaris::ModalComponent",
|
28
36
|
page: "Polaris::PageComponent",
|
29
37
|
page_actions: "Polaris::PageActionsComponent",
|
30
38
|
pagination: "Polaris::PaginationComponent",
|
31
39
|
progress_bar: "Polaris::ProgressBarComponent",
|
40
|
+
popover: "Polaris::PopoverComponent",
|
32
41
|
radio_button: "Polaris::RadioButtonComponent",
|
33
42
|
resource_list: "Polaris::ResourceListComponent",
|
34
43
|
resource_item: "Polaris::ResourceItemComponent",
|
35
44
|
select: "Polaris::SelectComponent",
|
45
|
+
setting_toggle: "Polaris::SettingToggleComponent",
|
36
46
|
shopify_navigation: "Polaris::ShopifyNavigationComponent",
|
37
47
|
stack: "Polaris::StackComponent",
|
38
48
|
subheading: "Polaris::SubheadingComponent",
|
49
|
+
scrollable: "Polaris::ScrollableComponent",
|
39
50
|
spinner: "Polaris::SpinnerComponent",
|
40
51
|
skeleton_body_text: "Polaris::SkeletonBodyTextComponent",
|
52
|
+
spacer: "Polaris::SpacerComponent",
|
53
|
+
tabs: "Polaris::TabsComponent",
|
41
54
|
tag: "Polaris::TagComponent",
|
42
55
|
text_container: "Polaris::TextContainerComponent",
|
43
56
|
text_field: "Polaris::TextFieldComponent",
|
44
57
|
text_style: "Polaris::TextStyleComponent",
|
45
58
|
thumbnail: "Polaris::ThumbnailComponent",
|
46
|
-
visually_hidden: "Polaris::VisuallyHiddenComponent"
|
59
|
+
visually_hidden: "Polaris::VisuallyHiddenComponent"
|
47
60
|
}.freeze
|
48
|
-
|
49
|
-
|
61
|
+
# standard:enable Layout/HashAlignment
|
62
|
+
POLARIS_HELPERS.each do |name, component|
|
50
63
|
define_method "polaris_#{name}" do |*args, **kwargs, &block|
|
51
64
|
render component.constantize.new(*args, **kwargs), &block
|
52
65
|
end
|
53
66
|
end
|
54
67
|
|
68
|
+
POLARIS_TEXT_STYLES = %i[subdued strong positive negative code].freeze
|
69
|
+
POLARIS_TEXT_STYLES.each do |name|
|
70
|
+
define_method "polaris_text_#{name}" do |**kwargs, &block|
|
71
|
+
polaris_text_style(variation: name, **kwargs, &block)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
55
75
|
def polaris_icon_source(name)
|
56
76
|
path = ViewComponents::Engine.root.join("app", "assets", "icons", "polaris", "#{name}.svg")
|
57
77
|
file = File.read(path)
|
58
78
|
doc = Nokogiri::HTML::DocumentFragment.parse(file)
|
59
|
-
svg = doc.at_css
|
79
|
+
svg = doc.at_css "svg"
|
60
80
|
svg[:class] = "Polaris-Icon__Svg"
|
61
81
|
svg[:focusable] = false
|
62
82
|
svg[:"aria-hidden"] = true
|
@@ -64,7 +84,7 @@ module Polaris
|
|
64
84
|
end
|
65
85
|
|
66
86
|
def polaris_body_styles
|
67
|
-
%
|
87
|
+
%(background-color: rgb(246, 246, 247); color: rgb(32, 34, 35); --p-background:rgba(246, 246, 247, 1); --p-background-hovered:rgba(241, 242, 243, 1); --p-background-pressed:rgba(237, 238, 239, 1); --p-background-selected:rgba(237, 238, 239, 1); --p-surface:rgba(255, 255, 255, 1); --p-surface-neutral:rgba(228, 229, 231, 1); --p-surface-neutral-hovered:rgba(219, 221, 223, 1); --p-surface-neutral-pressed:rgba(201, 204, 208, 1); --p-surface-neutral-disabled:rgba(241, 242, 243, 1); --p-surface-neutral-subdued:rgba(246, 246, 247, 1); --p-surface-subdued:rgba(250, 251, 251, 1); --p-surface-disabled:rgba(250, 251, 251, 1); --p-surface-hovered:rgba(246, 246, 247, 1); --p-surface-pressed:rgba(241, 242, 243, 1); --p-surface-depressed:rgba(237, 238, 239, 1); --p-backdrop:rgba(0, 0, 0, 0.5); --p-overlay:rgba(255, 255, 255, 0.5); --p-shadow-from-dim-light:rgba(0, 0, 0, 0.2); --p-shadow-from-ambient-light:rgba(23, 24, 24, 0.05); --p-shadow-from-direct-light:rgba(0, 0, 0, 0.15); --p-hint-from-direct-light:rgba(0, 0, 0, 0.15); --p-on-surface-background:rgba(241, 242, 243, 1); --p-border:rgba(140, 145, 150, 1); --p-border-neutral-subdued:rgba(186, 191, 195, 1); --p-border-hovered:rgba(153, 158, 164, 1); --p-border-disabled:rgba(210, 213, 216, 1); --p-border-subdued:rgba(201, 204, 207, 1); --p-border-depressed:rgba(87, 89, 89, 1); --p-border-shadow:rgba(174, 180, 185, 1); --p-border-shadow-subdued:rgba(186, 191, 196, 1); --p-divider:rgba(225, 227, 229, 1); --p-icon:rgba(92, 95, 98, 1); --p-icon-hovered:rgba(26, 28, 29, 1); --p-icon-pressed:rgba(68, 71, 74, 1); --p-icon-disabled:rgba(186, 190, 195, 1); --p-icon-subdued:rgba(140, 145, 150, 1); --p-text:rgba(32, 34, 35, 1); --p-text-disabled:rgba(140, 145, 150, 1); --p-text-subdued:rgba(109, 113, 117, 1); --p-interactive:rgba(44, 110, 203, 1); --p-interactive-disabled:rgba(189, 193, 204, 1); --p-interactive-hovered:rgba(31, 81, 153, 1); --p-interactive-pressed:rgba(16, 50, 98, 1); --p-focused:rgba(69, 143, 255, 1); --p-surface-selected:rgba(242, 247, 254, 1); --p-surface-selected-hovered:rgba(237, 244, 254, 1); --p-surface-selected-pressed:rgba(229, 239, 253, 1); --p-icon-on-interactive:rgba(255, 255, 255, 1); --p-text-on-interactive:rgba(255, 255, 255, 1); --p-action-secondary:rgba(255, 255, 255, 1); --p-action-secondary-disabled:rgba(255, 255, 255, 1); --p-action-secondary-hovered:rgba(246, 246, 247, 1); --p-action-secondary-pressed:rgba(241, 242, 243, 1); --p-action-secondary-depressed:rgba(109, 113, 117, 1); --p-action-primary:rgba(0, 128, 96, 1); --p-action-primary-disabled:rgba(241, 241, 241, 1); --p-action-primary-hovered:rgba(0, 110, 82, 1); --p-action-primary-pressed:rgba(0, 94, 70, 1); --p-action-primary-depressed:rgba(0, 61, 44, 1); --p-icon-on-primary:rgba(255, 255, 255, 1); --p-text-on-primary:rgba(255, 255, 255, 1); --p-text-primary:rgba(0, 123, 92, 1); --p-text-primary-hovered:rgba(0, 108, 80, 1); --p-text-primary-pressed:rgba(0, 92, 68, 1); --p-surface-primary-selected:rgba(241, 248, 245, 1); --p-surface-primary-selected-hovered:rgba(179, 208, 195, 1); --p-surface-primary-selected-pressed:rgba(162, 188, 176, 1); --p-border-critical:rgba(253, 87, 73, 1); --p-border-critical-subdued:rgba(224, 179, 178, 1); --p-border-critical-disabled:rgba(255, 167, 163, 1); --p-icon-critical:rgba(215, 44, 13, 1); --p-surface-critical:rgba(254, 211, 209, 1); --p-surface-critical-subdued:rgba(255, 244, 244, 1); --p-surface-critical-subdued-hovered:rgba(255, 240, 240, 1); --p-surface-critical-subdued-pressed:rgba(255, 233, 232, 1); --p-surface-critical-subdued-depressed:rgba(254, 188, 185, 1); --p-text-critical:rgba(215, 44, 13, 1); --p-action-critical:rgba(216, 44, 13, 1); --p-action-critical-disabled:rgba(241, 241, 241, 1); --p-action-critical-hovered:rgba(188, 34, 0, 1); --p-action-critical-pressed:rgba(162, 27, 0, 1); --p-action-critical-depressed:rgba(108, 15, 0, 1); --p-icon-on-critical:rgba(255, 255, 255, 1); --p-text-on-critical:rgba(255, 255, 255, 1); --p-interactive-critical:rgba(216, 44, 13, 1); --p-interactive-critical-disabled:rgba(253, 147, 141, 1); --p-interactive-critical-hovered:rgba(205, 41, 12, 1); --p-interactive-critical-pressed:rgba(103, 15, 3, 1); --p-border-warning:rgba(185, 137, 0, 1); --p-border-warning-subdued:rgba(225, 184, 120, 1); --p-icon-warning:rgba(185, 137, 0, 1); --p-surface-warning:rgba(255, 215, 157, 1); --p-surface-warning-subdued:rgba(255, 245, 234, 1); --p-surface-warning-subdued-hovered:rgba(255, 242, 226, 1); --p-surface-warning-subdued-pressed:rgba(255, 235, 211, 1); --p-text-warning:rgba(145, 106, 0, 1); --p-border-highlight:rgba(68, 157, 167, 1); --p-border-highlight-subdued:rgba(152, 198, 205, 1); --p-icon-highlight:rgba(0, 160, 172, 1); --p-surface-highlight:rgba(164, 232, 242, 1); --p-surface-highlight-subdued:rgba(235, 249, 252, 1); --p-surface-highlight-subdued-hovered:rgba(228, 247, 250, 1); --p-surface-highlight-subdued-pressed:rgba(213, 243, 248, 1); --p-text-highlight:rgba(52, 124, 132, 1); --p-border-success:rgba(0, 164, 124, 1); --p-border-success-subdued:rgba(149, 201, 180, 1); --p-icon-success:rgba(0, 127, 95, 1); --p-surface-success:rgba(174, 233, 209, 1); --p-surface-success-subdued:rgba(241, 248, 245, 1); --p-surface-success-subdued-hovered:rgba(236, 246, 241, 1); --p-surface-success-subdued-pressed:rgba(226, 241, 234, 1); --p-text-success:rgba(0, 128, 96, 1); --p-decorative-one-icon:rgba(126, 87, 0, 1); --p-decorative-one-surface:rgba(255, 201, 107, 1); --p-decorative-one-text:rgba(61, 40, 0, 1); --p-decorative-two-icon:rgba(175, 41, 78, 1); --p-decorative-two-surface:rgba(255, 196, 176, 1); --p-decorative-two-text:rgba(73, 11, 28, 1); --p-decorative-three-icon:rgba(0, 109, 65, 1); --p-decorative-three-surface:rgba(146, 230, 181, 1); --p-decorative-three-text:rgba(0, 47, 25, 1); --p-decorative-four-icon:rgba(0, 106, 104, 1); --p-decorative-four-surface:rgba(145, 224, 214, 1); --p-decorative-four-text:rgba(0, 45, 45, 1); --p-decorative-five-icon:rgba(174, 43, 76, 1); --p-decorative-five-surface:rgba(253, 201, 208, 1); --p-decorative-five-text:rgba(79, 14, 31, 1); --p-border-radius-base:0.4rem; --p-border-radius-wide:0.8rem; --p-border-radius-full:50%; --p-card-shadow:0px 0px 5px var(--p-shadow-from-ambient-light), 0px 1px 2px var(--p-shadow-from-direct-light); --p-popover-shadow:-1px 0px 20px var(--p-shadow-from-ambient-light), 0px 1px 5px var(--p-shadow-from-direct-light); --p-modal-shadow:0px 26px 80px var(--p-shadow-from-dim-light), 0px 0px 1px var(--p-shadow-from-dim-light); --p-top-bar-shadow:0 2px 2px -1px var(--p-shadow-from-direct-light); --p-button-drop-shadow:0 1px 0 rgba(0, 0, 0, 0.05); --p-button-inner-shadow:inset 0 -1px 0 rgba(0, 0, 0, 0.2); --p-button-pressed-inner-shadow:inset 0 1px 0 rgba(0, 0, 0, 0.15); --p-override-none:none; --p-override-transparent:transparent; --p-override-one:1; --p-override-visible:visible; --p-override-zero:0; --p-override-loading-z-index:514; --p-button-font-weight:500; --p-non-null-content:''; --p-choice-size:2rem; --p-icon-size:1rem; --p-choice-margin:0.1rem; --p-control-border-width:0.2rem; --p-banner-border-default:inset 0 0.1rem 0 0 var(--p-border-neutral-subdued), inset 0 0 0 0.1rem var(--p-border-neutral-subdued); --p-banner-border-success:inset 0 0.1rem 0 0 var(--p-border-success-subdued), inset 0 0 0 0.1rem var(--p-border-success-subdued); --p-banner-border-highlight:inset 0 0.1rem 0 0 var(--p-border-highlight-subdued), inset 0 0 0 0.1rem var(--p-border-highlight-subdued); --p-banner-border-warning:inset 0 0.1rem 0 0 var(--p-border-warning-subdued), inset 0 0 0 0.1rem var(--p-border-warning-subdued); --p-banner-border-critical:inset 0 0.1rem 0 0 var(--p-border-critical-subdued), inset 0 0 0 0.1rem var(--p-border-critical-subdued); --p-badge-mix-blend-mode:luminosity; --p-thin-border-subdued:0.1rem solid var(--p-border-subdued); --p-text-field-spinner-offset:0.2rem; --p-text-field-focus-ring-offset:-0.4rem; --p-text-field-focus-ring-border-radius:0.7rem; --p-button-group-item-spacing:-0.1rem; --p-duration-1-0-0:100ms; --p-duration-1-5-0:150ms; --p-ease-in:cubic-bezier(0.5, 0.1, 1, 1); --p-ease:cubic-bezier(0.4, 0.22, 0.28, 1); --p-range-slider-thumb-size-base:1.6rem; --p-range-slider-thumb-size-active:2.4rem; --p-range-slider-thumb-scale:1.5; --p-badge-font-weight:400; --p-frame-offset:0px;)
|
68
88
|
end
|
69
89
|
end
|
70
90
|
end
|
@@ -3,11 +3,11 @@ class TypeValidator < ActiveModel::EachValidator
|
|
3
3
|
required_type = options[:with]
|
4
4
|
|
5
5
|
if value.is_a?(Array)
|
6
|
-
unless value.all? { |i| i.
|
6
|
+
unless value.all? { |i| i.instance_of?(required_type) }
|
7
7
|
record.errors.add attribute, (options[:message] || "is not of class #{required_type}")
|
8
8
|
end
|
9
9
|
else
|
10
|
-
unless value.
|
10
|
+
unless value.instance_of?(required_type)
|
11
11
|
record.errors.add attribute, (options[:message] || "is not of class #{required_type}")
|
12
12
|
end
|
13
13
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "rails/generators/active_record"
|
4
4
|
|
5
5
|
module PolarisViewComponents
|
6
6
|
class InstallGenerator < Rails::Generators::Base
|
7
|
-
source_root File.expand_path(
|
7
|
+
source_root File.expand_path("templates", __dir__)
|
8
8
|
|
9
9
|
def add_npm_package
|
10
10
|
say "Adding NPM package", :green
|
@@ -14,13 +14,13 @@ module PolarisViewComponents
|
|
14
14
|
def add_to_stimulus_controller
|
15
15
|
say "Adding import to to Stimulus controller", :green
|
16
16
|
dir_path = "app/javascript/controllers"
|
17
|
-
empty_directory(
|
17
|
+
empty_directory("app/javascript")
|
18
18
|
empty_directory(dir_path)
|
19
19
|
|
20
20
|
file_path = "#{dir_path}/index.js"
|
21
21
|
|
22
22
|
unless File.exist?(file_path)
|
23
|
-
copy_file
|
23
|
+
copy_file "stimulus_index.js", file_path
|
24
24
|
end
|
25
25
|
|
26
26
|
append_to_file file_path do
|
@@ -29,7 +29,7 @@ module PolarisViewComponents
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def show_readme
|
32
|
-
readme
|
32
|
+
readme "README"
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -19,11 +19,16 @@ module Polaris
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
initializer "polaris_view_components.importmap", before: "importmap" do |app|
|
23
|
+
if app.config.respond_to?(:importmap) && app.config.importmap.has_key?(:cache_sweepers)
|
24
|
+
app.config.importmap.cache_sweepers << Engine.root.join("app/assets/javascripts")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
22
28
|
initializer "polaris_view_components.helpers" do
|
23
29
|
ActiveSupport.on_load(:action_controller_base) do
|
24
30
|
helper Polaris::ViewHelper
|
25
31
|
helper Polaris::UrlHelper
|
26
|
-
helper Polaris::ActionHelper
|
27
32
|
helper Polaris::ConditionalHelper
|
28
33
|
end
|
29
34
|
end
|
@@ -1 +1 @@
|
|
1
|
-
require
|
1
|
+
require "polaris/view_components"
|
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.6.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-
|
12
|
+
date: 2021-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -448,14 +448,27 @@ files:
|
|
448
448
|
- app/assets/icons/polaris/WholesaleMajor.svg
|
449
449
|
- app/assets/icons/polaris/WifiMajor.svg
|
450
450
|
- app/assets/javascripts/polaris_view_components.js
|
451
|
+
- app/assets/javascripts/polaris_view_components/button_controller.js
|
451
452
|
- app/assets/javascripts/polaris_view_components/index.js
|
453
|
+
- app/assets/javascripts/polaris_view_components/modal_controller.js
|
454
|
+
- app/assets/javascripts/polaris_view_components/polaris_controller.js
|
455
|
+
- app/assets/javascripts/polaris_view_components/popover_controller.js
|
452
456
|
- app/assets/javascripts/polaris_view_components/resource_item_controller.js
|
457
|
+
- app/assets/javascripts/polaris_view_components/scrollable_controller.js
|
453
458
|
- app/assets/javascripts/polaris_view_components/select_controller.js
|
454
459
|
- app/assets/javascripts/polaris_view_components/text_field_controller.js
|
455
460
|
- app/assets/stylesheets/polaris_view_components.css
|
456
461
|
- app/assets/stylesheets/polaris_view_components.postcss.css
|
462
|
+
- app/assets/stylesheets/polaris_view_components/custom.css
|
457
463
|
- app/assets/stylesheets/polaris_view_components/shopify_navigation.css
|
464
|
+
- app/assets/stylesheets/polaris_view_components/spacer_component.css
|
458
465
|
- app/components/polaris/action.rb
|
466
|
+
- app/components/polaris/action_list/item_component.html.erb
|
467
|
+
- app/components/polaris/action_list/item_component.rb
|
468
|
+
- app/components/polaris/action_list/section_component.html.erb
|
469
|
+
- app/components/polaris/action_list/section_component.rb
|
470
|
+
- app/components/polaris/action_list_component.html.erb
|
471
|
+
- app/components/polaris/action_list_component.rb
|
459
472
|
- app/components/polaris/application_component.rb
|
460
473
|
- app/components/polaris/avatar_component.html.erb
|
461
474
|
- app/components/polaris/avatar_component.rb
|
@@ -483,11 +496,14 @@ files:
|
|
483
496
|
- app/components/polaris/checkbox_component.rb
|
484
497
|
- app/components/polaris/choice_component.html.erb
|
485
498
|
- app/components/polaris/choice_component.rb
|
486
|
-
- app/components/polaris/choice_list/component.html.erb
|
487
|
-
- app/components/polaris/choice_list/component.rb
|
488
499
|
- app/components/polaris/choice_list_component.html.erb
|
489
500
|
- app/components/polaris/choice_list_component.rb
|
490
501
|
- app/components/polaris/component.rb
|
502
|
+
- app/components/polaris/data_table/cell_component.html.erb
|
503
|
+
- app/components/polaris/data_table/cell_component.rb
|
504
|
+
- app/components/polaris/data_table/column_component.rb
|
505
|
+
- app/components/polaris/data_table_component.html.erb
|
506
|
+
- app/components/polaris/data_table_component.rb
|
491
507
|
- app/components/polaris/description_list_component.html.erb
|
492
508
|
- app/components/polaris/description_list_component.rb
|
493
509
|
- app/components/polaris/display_text_component.rb
|
@@ -501,6 +517,8 @@ files:
|
|
501
517
|
- app/components/polaris/exception_list/item_component.rb
|
502
518
|
- app/components/polaris/exception_list_component.html.erb
|
503
519
|
- app/components/polaris/exception_list_component.rb
|
520
|
+
- app/components/polaris/filters_component.html.erb
|
521
|
+
- app/components/polaris/filters_component.rb
|
504
522
|
- app/components/polaris/footer_help_component.html.erb
|
505
523
|
- app/components/polaris/footer_help_component.rb
|
506
524
|
- app/components/polaris/form_layout/group_component.html.erb
|
@@ -513,6 +531,10 @@ files:
|
|
513
531
|
- app/components/polaris/headless_button.rb
|
514
532
|
- app/components/polaris/icon_component.html.erb
|
515
533
|
- app/components/polaris/icon_component.rb
|
534
|
+
- app/components/polaris/index_table/cell_component.rb
|
535
|
+
- app/components/polaris/index_table/column_component.rb
|
536
|
+
- app/components/polaris/index_table_component.html.erb
|
537
|
+
- app/components/polaris/index_table_component.rb
|
516
538
|
- app/components/polaris/inline_error_component.html.erb
|
517
539
|
- app/components/polaris/inline_error_component.rb
|
518
540
|
- app/components/polaris/label_component.html.erb
|
@@ -527,6 +549,9 @@ files:
|
|
527
549
|
- app/components/polaris/link_component.rb
|
528
550
|
- app/components/polaris/list_component.html.erb
|
529
551
|
- app/components/polaris/list_component.rb
|
552
|
+
- app/components/polaris/modal/section_component.rb
|
553
|
+
- app/components/polaris/modal_component.html.erb
|
554
|
+
- app/components/polaris/modal_component.rb
|
530
555
|
- app/components/polaris/new_component.rb
|
531
556
|
- app/components/polaris/page_actions_component.html.erb
|
532
557
|
- app/components/polaris/page_actions_component.rb
|
@@ -534,24 +559,39 @@ files:
|
|
534
559
|
- app/components/polaris/page_component.rb
|
535
560
|
- app/components/polaris/pagination_component.html.erb
|
536
561
|
- app/components/polaris/pagination_component.rb
|
562
|
+
- app/components/polaris/popover/pane_component.html.erb
|
563
|
+
- app/components/polaris/popover/pane_component.rb
|
564
|
+
- app/components/polaris/popover/section_component.rb
|
565
|
+
- app/components/polaris/popover_component.html.erb
|
566
|
+
- app/components/polaris/popover_component.rb
|
537
567
|
- app/components/polaris/progress_bar_component.html.erb
|
538
568
|
- app/components/polaris/progress_bar_component.rb
|
539
569
|
- app/components/polaris/radio_button_component.html.erb
|
540
570
|
- app/components/polaris/radio_button_component.rb
|
541
571
|
- app/components/polaris/resource_item_component.html.erb
|
542
572
|
- app/components/polaris/resource_item_component.rb
|
573
|
+
- app/components/polaris/resource_list_component.html.erb
|
543
574
|
- app/components/polaris/resource_list_component.rb
|
575
|
+
- app/components/polaris/scrollable_component.html.erb
|
576
|
+
- app/components/polaris/scrollable_component.rb
|
544
577
|
- app/components/polaris/select_component.html.erb
|
545
578
|
- app/components/polaris/select_component.rb
|
579
|
+
- app/components/polaris/setting_toggle_component.html.erb
|
580
|
+
- app/components/polaris/setting_toggle_component.rb
|
546
581
|
- app/components/polaris/shopify_navigation_component.html.erb
|
547
582
|
- app/components/polaris/shopify_navigation_component.rb
|
548
583
|
- app/components/polaris/skeleton_body_text_component.html.erb
|
549
584
|
- app/components/polaris/skeleton_body_text_component.rb
|
585
|
+
- app/components/polaris/spacer_component.rb
|
550
586
|
- app/components/polaris/spinner_component.html.erb
|
551
587
|
- app/components/polaris/spinner_component.rb
|
552
588
|
- app/components/polaris/stack_component.html.erb
|
553
589
|
- app/components/polaris/stack_component.rb
|
554
590
|
- app/components/polaris/subheading_component.rb
|
591
|
+
- app/components/polaris/tabs/tab_component.html.erb
|
592
|
+
- app/components/polaris/tabs/tab_component.rb
|
593
|
+
- app/components/polaris/tabs_component.html.erb
|
594
|
+
- app/components/polaris/tabs_component.rb
|
555
595
|
- app/components/polaris/tag_component.html.erb
|
556
596
|
- app/components/polaris/tag_component.rb
|
557
597
|
- app/components/polaris/text_container_component.rb
|
@@ -561,7 +601,6 @@ files:
|
|
561
601
|
- app/components/polaris/thumbnail_component.html.erb
|
562
602
|
- app/components/polaris/thumbnail_component.rb
|
563
603
|
- app/components/polaris/visually_hidden_component.rb
|
564
|
-
- app/helpers/polaris/action_helper.rb
|
565
604
|
- app/helpers/polaris/class_name_helper.rb
|
566
605
|
- app/helpers/polaris/conditional_helper.rb
|
567
606
|
- app/helpers/polaris/fetch_or_fallback_helper.rb
|
@@ -598,7 +637,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
598
637
|
- !ruby/object:Gem::Version
|
599
638
|
version: '0'
|
600
639
|
requirements: []
|
601
|
-
rubygems_version: 3.2.
|
640
|
+
rubygems_version: 3.2.30
|
602
641
|
signing_key:
|
603
642
|
specification_version: 4
|
604
643
|
summary: ViewComponents for Polaris Design System
|
@@ -1,34 +0,0 @@
|
|
1
|
-
<%= field_set_tag(nil, content_tag_options) do %>
|
2
|
-
<% if @title.present? %>
|
3
|
-
<%= content_tag("legend", class: "Polaris-ChoiceList__Title") do %>
|
4
|
-
<%= @title %>
|
5
|
-
<% end %>
|
6
|
-
<% end %>
|
7
|
-
|
8
|
-
<ul class="Polaris-ChoiceList__Choices">
|
9
|
-
<% choice_component = @allow_multiple ? Polaris::CheckboxComponent : Polaris::RadioButtonComponent %>
|
10
|
-
|
11
|
-
<% @choices.each do |choice| %>
|
12
|
-
<li>
|
13
|
-
<%= render choice_component.new(
|
14
|
-
form: @form,
|
15
|
-
attribute: @attribute,
|
16
|
-
name: final_name,
|
17
|
-
value: choice[:value],
|
18
|
-
label: choice[:label],
|
19
|
-
disabled: choice[:disabled] || @disabled,
|
20
|
-
checked: choice_is_selected?(choice),
|
21
|
-
help_text: choice[:help_text],
|
22
|
-
children_content: choice[:children_content],
|
23
|
-
input_attrs: @input_attrs,
|
24
|
-
) %>
|
25
|
-
</li>
|
26
|
-
<% end %>
|
27
|
-
</ul>
|
28
|
-
|
29
|
-
<% if @error.present? %>
|
30
|
-
<div class="Polaris-ChoiceList__ChoiceError">
|
31
|
-
<%= polaris_inline_error { @error } %>
|
32
|
-
</div>
|
33
|
-
<% end %>
|
34
|
-
<% end %>
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Polaris
|
4
|
-
module ChoiceList
|
5
|
-
class Component < Polaris::Component
|
6
|
-
def initialize(
|
7
|
-
choices:,
|
8
|
-
form: nil,
|
9
|
-
attribute: nil,
|
10
|
-
name: nil,
|
11
|
-
title: '',
|
12
|
-
title_hidden: false,
|
13
|
-
selected: [],
|
14
|
-
allow_multiple: false,
|
15
|
-
error: '',
|
16
|
-
disabled: false,
|
17
|
-
input_attrs: {},
|
18
|
-
**args
|
19
|
-
)
|
20
|
-
super
|
21
|
-
|
22
|
-
@choices = choices
|
23
|
-
@form = form
|
24
|
-
@attribute = attribute
|
25
|
-
|
26
|
-
@name = name
|
27
|
-
@title = title
|
28
|
-
@title_hidden = title_hidden
|
29
|
-
@selected = selected
|
30
|
-
@allow_multiple = allow_multiple
|
31
|
-
@error = error
|
32
|
-
@disabled = disabled
|
33
|
-
@input_attrs = input_attrs
|
34
|
-
end
|
35
|
-
|
36
|
-
def final_name
|
37
|
-
return nil if @name.nil?
|
38
|
-
|
39
|
-
@allow_multiple ? "#{@name}[]" : @name
|
40
|
-
end
|
41
|
-
|
42
|
-
def choice_is_selected?(choice)
|
43
|
-
@selected.include? choice[:value]
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def classes
|
49
|
-
classes = ['Polaris-ChoiceList']
|
50
|
-
|
51
|
-
classes << 'Polaris-ChoiceList--titleHidden' if @title_hidden
|
52
|
-
|
53
|
-
classes
|
54
|
-
end
|
55
|
-
|
56
|
-
def additional_aria
|
57
|
-
super
|
58
|
-
|
59
|
-
{
|
60
|
-
invalid: @error.present?
|
61
|
-
}
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Polaris
|
2
|
-
module ActionHelper
|
3
|
-
def render_plain_action(action)
|
4
|
-
case action
|
5
|
-
when Hash
|
6
|
-
action = action(**action)
|
7
|
-
end
|
8
|
-
|
9
|
-
render Polaris::ButtonComponent.new(**action.to_h.except(:content), plain: true) do
|
10
|
-
action.content
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|