primer_view_components 0.35.2 → 0.36.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/app/assets/javascripts/primer_view_components.js +1 -1
- data/app/assets/javascripts/primer_view_components.js.map +1 -1
- data/app/assets/styles/primer_view_components.css +1 -1
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_bar.rb +2 -2
- data/app/components/primer/alpha/action_bar_element.js +0 -7
- data/app/components/primer/alpha/action_bar_element.ts +0 -8
- data/app/components/primer/base_component.rb +4 -1
- data/app/components/primer/beta/auto_complete.rb +1 -0
- data/app/components/primer/beta/button.rb +0 -11
- data/app/components/primer/beta/link.css +1 -1
- data/app/components/primer/beta/link.css.json +2 -1
- data/app/components/primer/beta/link.css.map +1 -1
- data/app/components/primer/beta/link.html.erb +18 -0
- data/app/components/primer/beta/link.pcss +9 -0
- data/app/components/primer/beta/link.rb +26 -14
- data/app/components/primer/button_component.rb +0 -11
- data/app/components/primer/component.rb +7 -0
- data/app/components/primer/conditional_wrapper.rb +5 -2
- data/app/forms/horizontal_form.rb +2 -0
- data/app/lib/primer/forms/auto_complete.rb +2 -1
- data/app/lib/primer/forms/dsl/hidden_input.rb +4 -0
- data/app/lib/primer/forms/group.rb +4 -1
- data/lib/primer/classify/utilities.yml +63 -0
- data/lib/primer/classify.rb +1 -26
- data/lib/primer/static/generate_form_previews.rb +44 -0
- data/lib/primer/static.rb +8 -0
- data/lib/primer/view_components/version.rb +2 -2
- data/lib/tasks/custom_utilities.yml +63 -0
- data/previews/primer/beta/link_preview.rb +24 -2
- data/previews/primer/forms_preview.rb +21 -0
- data/static/classes.json +3 -0
- data/static/form_previews.json +113 -0
- metadata +5 -2
@@ -88,9 +88,9 @@ module Primer
|
|
88
88
|
def before_render
|
89
89
|
@system_arguments[:tag] = render_overflow_menu? ? :"action-bar" : :div
|
90
90
|
@system_arguments[:classes] = class_names(
|
91
|
-
@system_arguments[:classes]
|
92
|
-
"overflow-visible": !render_overflow_menu?
|
91
|
+
@system_arguments[:classes]
|
93
92
|
)
|
93
|
+
@system_arguments[:overflow] = :visible if render_overflow_menu?
|
94
94
|
content
|
95
95
|
end
|
96
96
|
end
|
@@ -47,13 +47,6 @@ let ActionBarElement = class ActionBarElement extends HTMLElement {
|
|
47
47
|
_ActionBarElement_focusZoneAbortController.set(this, null);
|
48
48
|
}
|
49
49
|
connectedCallback() {
|
50
|
-
// Calculate the width of all the items before hiding anything
|
51
|
-
for (const item of this.items) {
|
52
|
-
const width = item.getBoundingClientRect().width;
|
53
|
-
const marginLeft = parseInt(window.getComputedStyle(item)?.marginLeft, 10);
|
54
|
-
const marginRight = parseInt(window.getComputedStyle(item)?.marginRight, 10);
|
55
|
-
item.setAttribute('data-offset-width', `${width + marginLeft + marginRight}`);
|
56
|
-
}
|
57
50
|
resizeObserver.observe(this);
|
58
51
|
instersectionObserver.observe(this);
|
59
52
|
requestAnimationFrame(() => {
|
@@ -36,14 +36,6 @@ class ActionBarElement extends HTMLElement {
|
|
36
36
|
#focusZoneAbortController: AbortController | null = null
|
37
37
|
|
38
38
|
connectedCallback() {
|
39
|
-
// Calculate the width of all the items before hiding anything
|
40
|
-
for (const item of this.items) {
|
41
|
-
const width = item.getBoundingClientRect().width
|
42
|
-
const marginLeft = parseInt(window.getComputedStyle(item)?.marginLeft, 10)
|
43
|
-
const marginRight = parseInt(window.getComputedStyle(item)?.marginRight, 10)
|
44
|
-
item.setAttribute('data-offset-width', `${width + marginLeft + marginRight}`)
|
45
|
-
}
|
46
|
-
|
47
39
|
resizeObserver.observe(this)
|
48
40
|
instersectionObserver.observe(this)
|
49
41
|
|
@@ -151,6 +151,7 @@ module Primer
|
|
151
151
|
# | :- | :- | :- |
|
152
152
|
# | classes | String | CSS class name value to be concatenated with generated Primer CSS classes. |
|
153
153
|
# | test_selector | String | Adds `data-test-selector='given value'` in non-Production environments for testing purposes. |
|
154
|
+
# | trim | Boolean | Calls `strip` on the content to remove trailing and leading white spaces. |
|
154
155
|
def initialize(tag:, classes: nil, **system_arguments)
|
155
156
|
@tag = tag
|
156
157
|
|
@@ -158,6 +159,8 @@ module Primer
|
|
158
159
|
|
159
160
|
@result = Primer::Classify.call(**@system_arguments.merge(classes: classes))
|
160
161
|
|
162
|
+
@trim = !!@system_arguments.delete(:trim)
|
163
|
+
|
161
164
|
@system_arguments[:"data-view-component"] = true
|
162
165
|
# Filter out Primer keys so they don't get assigned as HTML attributes
|
163
166
|
@content_tag_args = add_test_selector(@system_arguments).except(*Primer::Classify::Utilities::UTILITIES.keys)
|
@@ -167,7 +170,7 @@ module Primer
|
|
167
170
|
if SELF_CLOSING_TAGS.include?(@tag)
|
168
171
|
tag(@tag, @content_tag_args.merge(@result))
|
169
172
|
else
|
170
|
-
content_tag(@tag, content, @content_tag_args.merge(@result))
|
173
|
+
content_tag(@tag, @trim ? trimmed_content : content, @content_tag_args.merge(@result))
|
171
174
|
end
|
172
175
|
end
|
173
176
|
end
|
@@ -44,6 +44,7 @@ module Primer
|
|
44
44
|
system_arguments[:"allow-out-of-bounds"] = ""
|
45
45
|
system_arguments[:id] = @list_id
|
46
46
|
system_arguments[:popover] = ""
|
47
|
+
system_arguments[:overflow_y] = :auto
|
47
48
|
system_arguments[:classes] = class_names(
|
48
49
|
"ActionListWrap ActionListWrap--inset",
|
49
50
|
@overlay_classes,
|
@@ -159,17 +159,6 @@ module Primer
|
|
159
159
|
"Button--invisible-noVisuals"
|
160
160
|
)
|
161
161
|
end
|
162
|
-
|
163
|
-
def trimmed_content
|
164
|
-
return if content.blank?
|
165
|
-
|
166
|
-
trimmed_content = content.strip
|
167
|
-
|
168
|
-
return trimmed_content unless content.html_safe?
|
169
|
-
|
170
|
-
# strip unsets `html_safe`, so we have to set it back again to guarantee that HTML blocks won't break
|
171
|
-
trimmed_content.html_safe # rubocop:disable Rails/OutputSafety
|
172
|
-
end
|
173
162
|
end
|
174
163
|
end
|
175
164
|
end
|
@@ -1 +1 @@
|
|
1
|
-
.Link{color:var(--fgColor-accent);-webkit-text-decoration:none;text-decoration:none}.Link:hover{cursor:pointer}.Link:focus,.Link:hover{-webkit-text-decoration:underline;text-decoration:underline}.Link:focus,.Link:focus-visible{outline-offset:0}.Link--underline{-webkit-text-decoration:underline;text-decoration:underline}.Link--primary{color:var(--fgColor-default)!important}.Link--primary:hover{color:var(--fgColor-accent)!important}.Link--secondary{color:var(--fgColor-muted)!important}.Link--secondary:hover{color:var(--fgColor-accent)!important}.Link--muted{color:var(--fgColor-muted)!important}.Link--muted:hover{color:var(--fgColor-accent)!important;-webkit-text-decoration:none;text-decoration:none}.Link--onHover:hover{color:var(--fgColor-accent)!important;cursor:pointer;-webkit-text-decoration:underline;text-decoration:underline}:is(.Link--secondary,.Link--primary,.Link--muted):hover [class*=color-fg]{color:inherit!important}
|
1
|
+
.Link{color:var(--fgColor-accent);-webkit-text-decoration:none;text-decoration:none}.Link:hover{cursor:pointer}.Link:focus,.Link:hover{-webkit-text-decoration:underline;text-decoration:underline}.Link:focus,.Link:focus-visible{outline-offset:0}.Link--underline{-webkit-text-decoration:underline;text-decoration:underline}.Link--primary{color:var(--fgColor-default)!important}.Link--primary:hover{color:var(--fgColor-accent)!important}.Link--secondary{color:var(--fgColor-muted)!important}.Link--secondary:hover{color:var(--fgColor-accent)!important}.Link--muted{color:var(--fgColor-muted)!important}.Link--muted:hover{color:var(--fgColor-accent)!important;-webkit-text-decoration:none;text-decoration:none}.Link--onHover:hover{color:var(--fgColor-accent)!important;cursor:pointer;-webkit-text-decoration:underline;text-decoration:underline}:is(.Link--secondary,.Link--primary,.Link--muted):hover [class*=color-fg]{color:inherit!important}.Link-content{align-items:center;display:inline-flex;gap:var(--base-size-4);line-height:normal;text-decoration:inherit}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["link.pcss"],"names":[],"mappings":"AAEA,MACE,2BAA4B,CAC5B,4BAAqB,CAArB,oBAeF,CAbE,YAEE,cACF,CAEA,wBAJE,iCAA0B,CAA1B,yBAMF,CAEA,gCAEE,gBACF,CAGF,iBACE,iCAA0B,CAA1B,yBACF,CAEA,eACE,sCAKF,CAHE,qBACE,qCACF,CAGF,iBACE,oCAKF,CAHE,uBACE,qCACF,CAGF,aACE,oCAMF,CAJE,mBACE,qCAAuC,CACvC,4BAAqB,CAArB,oBACF,CAMA,qBACE,qCAAuC,CAEvC,cAAe,CADf,iCAA0B,CAA1B,yBAEF,CAQA,0EACE,uBACF","file":"link.css","sourcesContent":["/* Links */\n\n.Link {\n color: var(--fgColor-accent);\n text-decoration: none;\n\n &:hover {\n text-decoration: underline;\n cursor: pointer;\n }\n\n &:focus {\n text-decoration: underline;\n }\n\n &:focus,\n &:focus-visible {\n outline-offset: 0;\n }\n}\n\n.Link--underline {\n text-decoration: underline;\n}\n\n.Link--primary {\n color: var(--fgColor-default) !important;\n\n &:hover {\n color: var(--fgColor-accent) !important;\n }\n}\n\n.Link--secondary {\n color: var(--fgColor-muted) !important;\n\n &:hover {\n color: var(--fgColor-accent) !important;\n }\n}\n\n.Link--muted {\n color: var(--fgColor-muted) !important;\n\n &:hover {\n color: var(--fgColor-accent) !important;\n text-decoration: none;\n }\n}\n\n/* Set the link color only on hover\n Useful when you want only part of a link to turn blue on hover */\n.Link--onHover {\n &:hover {\n color: var(--fgColor-accent) !important;\n text-decoration: underline;\n cursor: pointer;\n }\n}\n\n/* When using a color utility class inside of a link class\n color should change with link on hover. */\n.Link--secondary,\n.Link--primary,\n.Link--muted {\n &:hover [class*='color-fg'] {\n color: inherit !important;\n }\n}\n"]}
|
1
|
+
{"version":3,"sources":["link.pcss"],"names":[],"mappings":"AAEA,MACE,2BAA4B,CAC5B,4BAAqB,CAArB,oBAeF,CAbE,YAEE,cACF,CAEA,wBAJE,iCAA0B,CAA1B,yBAMF,CAEA,gCAEE,gBACF,CAGF,iBACE,iCAA0B,CAA1B,yBACF,CAEA,eACE,sCAKF,CAHE,qBACE,qCACF,CAGF,iBACE,oCAKF,CAHE,uBACE,qCACF,CAGF,aACE,oCAMF,CAJE,mBACE,qCAAuC,CACvC,4BAAqB,CAArB,oBACF,CAMA,qBACE,qCAAuC,CAEvC,cAAe,CADf,iCAA0B,CAA1B,yBAEF,CAQA,0EACE,uBACF,CAGF,cAEE,kBAAmB,CADnB,mBAAoB,CAIpB,sBAAuB,CADvB,kBAAmB,CAEnB,uBACF","file":"link.css","sourcesContent":["/* Links */\n\n.Link {\n color: var(--fgColor-accent);\n text-decoration: none;\n\n &:hover {\n text-decoration: underline;\n cursor: pointer;\n }\n\n &:focus {\n text-decoration: underline;\n }\n\n &:focus,\n &:focus-visible {\n outline-offset: 0;\n }\n}\n\n.Link--underline {\n text-decoration: underline;\n}\n\n.Link--primary {\n color: var(--fgColor-default) !important;\n\n &:hover {\n color: var(--fgColor-accent) !important;\n }\n}\n\n.Link--secondary {\n color: var(--fgColor-muted) !important;\n\n &:hover {\n color: var(--fgColor-accent) !important;\n }\n}\n\n.Link--muted {\n color: var(--fgColor-muted) !important;\n\n &:hover {\n color: var(--fgColor-accent) !important;\n text-decoration: none;\n }\n}\n\n/* Set the link color only on hover\n Useful when you want only part of a link to turn blue on hover */\n.Link--onHover {\n &:hover {\n color: var(--fgColor-accent) !important;\n text-decoration: underline;\n cursor: pointer;\n }\n}\n\n/* When using a color utility class inside of a link class\n color should change with link on hover. */\n.Link--secondary,\n.Link--primary,\n.Link--muted {\n &:hover [class*='color-fg'] {\n color: inherit !important;\n }\n}\n\n.Link-content {\n display: inline-flex;\n align-items: center;\n /* stylelint-disable-next-line primer/typography */\n line-height: normal;\n gap: var(--base-size-4);\n text-decoration: inherit;\n}\n"]}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<%= render Primer::ConditionalWrapper.new(condition: tooltip?, trim: true, tag: :span, position: :relative) do %>
|
2
|
+
<%= render(Primer::BaseComponent.new(trim: true, **@system_arguments)) do %>
|
3
|
+
<% if leading_visual || trailing_visual %>
|
4
|
+
<%= render(Primer::BaseComponent.new(tag: :span, classes: "Link-content", trim: true)) do %>
|
5
|
+
<% if leading_visual %>
|
6
|
+
<%= leading_visual %>
|
7
|
+
<% end %>
|
8
|
+
<%= content %>
|
9
|
+
<% if trailing_visual %>
|
10
|
+
<%= trailing_visual %>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
<% else %>
|
14
|
+
<%= content %>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
17
|
+
<%= tooltip if tooltip? %>
|
18
|
+
<% end %>
|
@@ -30,6 +30,32 @@ module Primer
|
|
30
30
|
Primer::Alpha::Tooltip.new(**system_arguments)
|
31
31
|
}
|
32
32
|
|
33
|
+
# Leading visuals appear to the left of the link text.
|
34
|
+
#
|
35
|
+
# Use:
|
36
|
+
#
|
37
|
+
# - `leading_visual_icon` which accepts the arguments accepted by <%= link_to_component(Primer::Beta::Octicon) %>.
|
38
|
+
#
|
39
|
+
# @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::Beta::Octicon) %>.
|
40
|
+
renders_one :leading_visual, types: {
|
41
|
+
icon: lambda { |**system_arguments|
|
42
|
+
Primer::Beta::Octicon.new(**system_arguments)
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
# Trailing visuals appear to the right of the link text.
|
47
|
+
#
|
48
|
+
# Use:
|
49
|
+
#
|
50
|
+
# - `trailing_visual_icon` which accepts the arguments accepted by <%= link_to_component(Primer::Beta::Octicon) %>.
|
51
|
+
#
|
52
|
+
# @param system_arguments [Hash] Same arguments as <%= link_to_component(Primer::Beta::Octicon) %>.
|
53
|
+
renders_one :trailing_visual, types: {
|
54
|
+
icon: lambda { |**system_arguments|
|
55
|
+
Primer::Beta::Octicon.new(**system_arguments)
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
33
59
|
# @param href [String] URL to be used for the Link. Required. If the requirements are not met an error will be raised in non production environments. In production, an empty link element will be rendered.
|
34
60
|
# @param scheme [Symbol] <%= one_of(Primer::Beta::Link::SCHEME_MAPPINGS.keys) %>
|
35
61
|
# @param muted [Boolean] Uses light gray for Link color, and blue on hover.
|
@@ -54,20 +80,6 @@ module Primer
|
|
54
80
|
def before_render
|
55
81
|
raise ArgumentError, "href is required" if @system_arguments[:href].nil? && !Rails.env.production?
|
56
82
|
end
|
57
|
-
|
58
|
-
def call
|
59
|
-
if tooltip.present?
|
60
|
-
render Primer::BaseComponent.new(tag: :span, position: :relative) do
|
61
|
-
render(Primer::BaseComponent.new(**@system_arguments)) do
|
62
|
-
content
|
63
|
-
end.to_s + tooltip.to_s
|
64
|
-
end
|
65
|
-
else
|
66
|
-
render(Primer::BaseComponent.new(**@system_arguments)) do
|
67
|
-
content
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
83
|
end
|
72
84
|
end
|
73
85
|
end
|
@@ -111,16 +111,5 @@ module Primer
|
|
111
111
|
def link?
|
112
112
|
@scheme == LINK_SCHEME
|
113
113
|
end
|
114
|
-
|
115
|
-
def trimmed_content
|
116
|
-
return if content.blank?
|
117
|
-
|
118
|
-
trimmed_content = content.strip
|
119
|
-
|
120
|
-
return trimmed_content unless content.html_safe?
|
121
|
-
|
122
|
-
# strip unsets `html_safe`, so we have to set it back again to guarantee that HTML blocks won't break
|
123
|
-
trimmed_content.html_safe # rubocop:disable Rails/OutputSafety
|
124
|
-
end
|
125
114
|
end
|
126
115
|
end
|
@@ -148,5 +148,12 @@ module Primer
|
|
148
148
|
def should_raise_aria_error?
|
149
149
|
!Rails.env.production? && raise_on_invalid_aria? && !ENV["PRIMER_WARNINGS_DISABLED"]
|
150
150
|
end
|
151
|
+
|
152
|
+
def trimmed_content
|
153
|
+
return content unless content.present?
|
154
|
+
|
155
|
+
# strip unsets `html_safe`, so we have to set it back again to guarantee that HTML blocks won't break
|
156
|
+
content.html_safe? ? content.strip.html_safe : content.strip # rubocop:disable Rails/OutputSafety
|
157
|
+
end
|
151
158
|
end
|
152
159
|
end
|
@@ -10,12 +10,15 @@ module Primer
|
|
10
10
|
def initialize(condition:, **base_component_arguments)
|
11
11
|
@condition = condition
|
12
12
|
@base_component_arguments = base_component_arguments
|
13
|
+
@trim = !!@base_component_arguments.delete(:trim)
|
13
14
|
end
|
14
15
|
|
15
16
|
def call
|
16
|
-
|
17
|
+
unless @condition
|
18
|
+
return @trim ? trimmed_content : content
|
19
|
+
end
|
17
20
|
|
18
|
-
BaseComponent.new(**@base_component_arguments).render_in(self) { content }
|
21
|
+
BaseComponent.new(trim: @trim, **@base_component_arguments).render_in(self) { content }
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
@@ -18,9 +18,12 @@ module Primer
|
|
18
18
|
@layout = layout
|
19
19
|
@system_arguments = system_arguments
|
20
20
|
|
21
|
+
@system_arguments[:display] = :none if inputs.all?(&:hidden?)
|
22
|
+
|
21
23
|
@system_arguments[:classes] = class_names(
|
22
24
|
@system_arguments.delete(:classes),
|
23
|
-
"FormControl-horizontalGroup" => horizontal
|
25
|
+
"FormControl-horizontalGroup" => horizontal?,
|
26
|
+
"FormControl-spacingWrapper" => !horizontal? && inputs.size > 1
|
24
27
|
)
|
25
28
|
end
|
26
29
|
|
@@ -1877,3 +1877,66 @@
|
|
1877
1877
|
- flex-md-shrink-0
|
1878
1878
|
- flex-lg-shrink-0
|
1879
1879
|
- flex-xl-shrink-0
|
1880
|
+
:overflow:
|
1881
|
+
:auto:
|
1882
|
+
- overflow-auto
|
1883
|
+
- overflow-sm-auto
|
1884
|
+
- overflow-lg-auto
|
1885
|
+
- overflow-xl-auto
|
1886
|
+
:hidden:
|
1887
|
+
- overflow-hidden
|
1888
|
+
- overflow-sm-hidden
|
1889
|
+
- overflow-lg-hidden
|
1890
|
+
- overflow-xl-hidden
|
1891
|
+
:scroll:
|
1892
|
+
- overflow-scroll
|
1893
|
+
- overflow-sm-scroll
|
1894
|
+
- overflow-lg-scroll
|
1895
|
+
- overflow-xl-scroll
|
1896
|
+
:visible:
|
1897
|
+
- overflow-visible
|
1898
|
+
- overflow-sm-visible
|
1899
|
+
- overflow-lg-visible
|
1900
|
+
- overflow-xl-visible
|
1901
|
+
:overflow_x:
|
1902
|
+
:auto:
|
1903
|
+
- overflow-x-auto
|
1904
|
+
- overflow-sm-x-auto
|
1905
|
+
- overflow-lg-x-auto
|
1906
|
+
- overflow-xl-x-auto
|
1907
|
+
:hidden:
|
1908
|
+
- overflow-x-hidden
|
1909
|
+
- overflow-sm-x-hidden
|
1910
|
+
- overflow-lg-x-hidden
|
1911
|
+
- overflow-xl-x-hidden
|
1912
|
+
:scroll:
|
1913
|
+
- overflow-x-scroll
|
1914
|
+
- overflow-sm-x-scroll
|
1915
|
+
- overflow-lg-x-scroll
|
1916
|
+
- overflow-xl-x-scroll
|
1917
|
+
:visible:
|
1918
|
+
- overflow-x-visible
|
1919
|
+
- overflow-sm-x-visible
|
1920
|
+
- overflow-lg-x-visible
|
1921
|
+
- overflow-xl-x-visible
|
1922
|
+
:overflow_y:
|
1923
|
+
:auto:
|
1924
|
+
- overflow-y-auto
|
1925
|
+
- overflow-sm-y-auto
|
1926
|
+
- overflow-lg-y-auto
|
1927
|
+
- overflow-xl-y-auto
|
1928
|
+
:hidden:
|
1929
|
+
- overflow-y-hidden
|
1930
|
+
- overflow-sm-y-hidden
|
1931
|
+
- overflow-lg-y-hidden
|
1932
|
+
- overflow-xl-y-hidden
|
1933
|
+
:scroll:
|
1934
|
+
- overflow-y-scroll
|
1935
|
+
- overflow-sm-y-scroll
|
1936
|
+
- overflow-lg-y-scroll
|
1937
|
+
- overflow-xl-y-scroll
|
1938
|
+
:visible:
|
1939
|
+
- overflow-y-visible
|
1940
|
+
- overflow-sm-y-visible
|
1941
|
+
- overflow-lg-y-visible
|
1942
|
+
- overflow-xl-y-visible
|
data/lib/primer/classify.rb
CHANGED
@@ -49,9 +49,7 @@ module Primer
|
|
49
49
|
case key
|
50
50
|
when :classes
|
51
51
|
# insert :classes first to avoid huge doc diffs
|
52
|
-
|
53
|
-
result.unshift(class_names)
|
54
|
-
end
|
52
|
+
result.unshift(val)
|
55
53
|
next
|
56
54
|
when :style
|
57
55
|
style = val
|
@@ -105,29 +103,6 @@ module Primer
|
|
105
103
|
brk_str = Primer::Classify::Utilities::BREAKPOINTS[brk]
|
106
104
|
Primer::Classify::Utilities.validate(key, val, brk_str)
|
107
105
|
end
|
108
|
-
|
109
|
-
def validated_class_names(classes)
|
110
|
-
return if classes.blank?
|
111
|
-
|
112
|
-
if raise_on_invalid_options? && !ENV["PRIMER_WARNINGS_DISABLED"]
|
113
|
-
invalid_class_names =
|
114
|
-
classes.split.each_with_object([]) do |class_name, memo|
|
115
|
-
memo << class_name if Primer::Classify::Validation.invalid?(class_name)
|
116
|
-
end
|
117
|
-
|
118
|
-
if invalid_class_names.any?
|
119
|
-
raise ArgumentError, "Use System Arguments (https://primer.style/view-components/system-arguments) "\
|
120
|
-
"instead of Primer CSS class #{'name'.pluralize(invalid_class_names.length)} #{invalid_class_names.to_sentence}. "\
|
121
|
-
"This warning will not be raised in production. Set PRIMER_WARNINGS_DISABLED=1 to disable this warning."
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
classes
|
126
|
-
end
|
127
|
-
|
128
|
-
def raise_on_invalid_options?
|
129
|
-
Rails.application.config.primer_view_components.raise_on_invalid_options
|
130
|
-
end
|
131
106
|
end
|
132
107
|
end
|
133
108
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :nocov:
|
4
|
+
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
module Primer
|
8
|
+
module Static
|
9
|
+
# :nodoc:
|
10
|
+
module GenerateFormPreviews
|
11
|
+
class << self
|
12
|
+
def call
|
13
|
+
Lookbook.previews.filter_map do |preview|
|
14
|
+
next unless preview.preview_class == Primer::FormsPreview
|
15
|
+
|
16
|
+
{
|
17
|
+
name: preview.name,
|
18
|
+
lookup_path: preview.lookup_path,
|
19
|
+
examples: preview.scenarios.flat_map do |parent_scenario|
|
20
|
+
scenarios = parent_scenario.type == :scenario_group ? parent_scenario.scenarios : [parent_scenario]
|
21
|
+
|
22
|
+
scenarios.map do |scenario|
|
23
|
+
snapshot_tag = scenario.tags.find { |tag| tag.tag_name == "snapshot" }
|
24
|
+
snapshot = if snapshot_tag.nil?
|
25
|
+
"false"
|
26
|
+
elsif snapshot_tag.text.blank?
|
27
|
+
"true"
|
28
|
+
else
|
29
|
+
snapshot_tag.text
|
30
|
+
end
|
31
|
+
{
|
32
|
+
preview_path: scenario.lookup_path,
|
33
|
+
name: scenario.name,
|
34
|
+
snapshot: snapshot
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/primer/static.rb
CHANGED
@@ -15,6 +15,7 @@ module Primer
|
|
15
15
|
audited_at: "audited_at.json",
|
16
16
|
arguments: "arguments.json",
|
17
17
|
previews: "previews.json",
|
18
|
+
form_previews: "form_previews.json",
|
18
19
|
info_arch: "info_arch.json"
|
19
20
|
}.freeze
|
20
21
|
|
@@ -50,6 +51,13 @@ module Primer
|
|
50
51
|
Static::GeneratePreviews.call
|
51
52
|
end
|
52
53
|
|
54
|
+
# Returns an array of hashes, one per example form, that contains some metadata and
|
55
|
+
# an array of all the form's previews. The preview data contains the Lookbook URL
|
56
|
+
# to each preview and its name.
|
57
|
+
def self.generate_form_previews
|
58
|
+
Static::GenerateFormPreviews.call
|
59
|
+
end
|
60
|
+
|
53
61
|
# Returns an array of hashes, one per Primer component, that contains all the data needed
|
54
62
|
# for the new primer.style docsite.
|
55
63
|
def self.generate_info_arch
|
@@ -370,3 +370,66 @@
|
|
370
370
|
- flex-md-shrink-0
|
371
371
|
- flex-lg-shrink-0
|
372
372
|
- flex-xl-shrink-0
|
373
|
+
:overflow:
|
374
|
+
:auto:
|
375
|
+
- overflow-auto
|
376
|
+
- overflow-sm-auto
|
377
|
+
- overflow-lg-auto
|
378
|
+
- overflow-xl-auto
|
379
|
+
:hidden:
|
380
|
+
- overflow-hidden
|
381
|
+
- overflow-sm-hidden
|
382
|
+
- overflow-lg-hidden
|
383
|
+
- overflow-xl-hidden
|
384
|
+
:scroll:
|
385
|
+
- overflow-scroll
|
386
|
+
- overflow-sm-scroll
|
387
|
+
- overflow-lg-scroll
|
388
|
+
- overflow-xl-scroll
|
389
|
+
:visible:
|
390
|
+
- overflow-visible
|
391
|
+
- overflow-sm-visible
|
392
|
+
- overflow-lg-visible
|
393
|
+
- overflow-xl-visible
|
394
|
+
:overflow_x:
|
395
|
+
:auto:
|
396
|
+
- overflow-x-auto
|
397
|
+
- overflow-sm-x-auto
|
398
|
+
- overflow-lg-x-auto
|
399
|
+
- overflow-xl-x-auto
|
400
|
+
:hidden:
|
401
|
+
- overflow-x-hidden
|
402
|
+
- overflow-sm-x-hidden
|
403
|
+
- overflow-lg-x-hidden
|
404
|
+
- overflow-xl-x-hidden
|
405
|
+
:scroll:
|
406
|
+
- overflow-x-scroll
|
407
|
+
- overflow-sm-x-scroll
|
408
|
+
- overflow-lg-x-scroll
|
409
|
+
- overflow-xl-x-scroll
|
410
|
+
:visible:
|
411
|
+
- overflow-x-visible
|
412
|
+
- overflow-sm-x-visible
|
413
|
+
- overflow-lg-x-visible
|
414
|
+
- overflow-xl-x-visible
|
415
|
+
:overflow_y:
|
416
|
+
:auto:
|
417
|
+
- overflow-y-auto
|
418
|
+
- overflow-sm-y-auto
|
419
|
+
- overflow-lg-y-auto
|
420
|
+
- overflow-xl-y-auto
|
421
|
+
:hidden:
|
422
|
+
- overflow-y-hidden
|
423
|
+
- overflow-sm-y-hidden
|
424
|
+
- overflow-lg-y-hidden
|
425
|
+
- overflow-xl-y-hidden
|
426
|
+
:scroll:
|
427
|
+
- overflow-y-scroll
|
428
|
+
- overflow-sm-y-scroll
|
429
|
+
- overflow-lg-y-scroll
|
430
|
+
- overflow-xl-y-scroll
|
431
|
+
:visible:
|
432
|
+
- overflow-y-visible
|
433
|
+
- overflow-sm-y-visible
|
434
|
+
- overflow-lg-y-visible
|
435
|
+
- overflow-xl-y-visible
|
@@ -9,8 +9,14 @@ module Primer
|
|
9
9
|
# @param underline [Boolean]
|
10
10
|
# @param muted [Boolean]
|
11
11
|
# @param scheme [Symbol] select [default, primary, secondary]
|
12
|
-
|
13
|
-
|
12
|
+
# @param leading_visual_icon [Symbol] octicon
|
13
|
+
# @param trailing_visual_icon [Symbol] octicon
|
14
|
+
def playground(scheme: :default, muted: false, underline: true, leading_visual_icon: nil, trailing_visual_icon: nil)
|
15
|
+
render(Primer::Beta::Link.new(href: "#", scheme: scheme, muted: muted, underline: underline)) do |link|
|
16
|
+
link.with_leading_visual_icon(icon: leading_visual_icon) if leading_visual_icon && leading_visual_icon != :none
|
17
|
+
link.with_trailing_visual_icon(icon: trailing_visual_icon) if trailing_visual_icon && trailing_visual_icon != :none
|
18
|
+
"This is a link!"
|
19
|
+
end
|
14
20
|
end
|
15
21
|
|
16
22
|
# @label Default Options
|
@@ -66,6 +72,22 @@ module Primer
|
|
66
72
|
render(Primer::Beta::Link.new(href: "#", scheme: :secondary, muted: true)) { "This is a muted secondary link color." }
|
67
73
|
end
|
68
74
|
# @!endgroup
|
75
|
+
|
76
|
+
# @label With leading icon
|
77
|
+
def with_leading_icon
|
78
|
+
render(Primer::Beta::Link.new(href: "#")) do |component|
|
79
|
+
component.with_leading_visual_icon(icon: :"mark-github")
|
80
|
+
"Link with leading icon"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# @label With trailing icon
|
85
|
+
def with_trailing_icon
|
86
|
+
render(Primer::Beta::Link.new(href: "#")) do |component|
|
87
|
+
component.with_trailing_visual_icon(icon: :"link-external")
|
88
|
+
"Link with trailing icon"
|
89
|
+
end
|
90
|
+
end
|
69
91
|
end
|
70
92
|
end
|
71
93
|
end
|