primer_view_components 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/app/components/primer/layout_component.html.erb +3 -3
- data/app/components/primer/layout_component.rb +10 -3
- data/lib/primer/classify.rb +3 -3
- data/lib/primer/fetch_or_fallback_helper.rb +1 -1
- data/lib/primer/view_components/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be0c09210143e8465e55e213978714a4b27a19d2ddb690e3dfc378e4e3123e3b
|
4
|
+
data.tar.gz: '0862e8437eff534e74fc1275f99c53f0445285de2cd409cd9ea4f20e54349ec0'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b0511a3995c27d1d0b7bb8979c53a1b72e6ae1ea73bff636278ccb590a386d96e46393d871e3993c613604c6e10dbc386cc1a1de6f6ebeebccbf3f973965326
|
7
|
+
data.tar.gz: 20ba7273f5b2d655c5ebb6c283ea2d36e34e2417fd51f6bd4698dc7187985baa1944b4f548a3756622f7c697742f3388bec5dd3f3d00d1e7a12936e011dea440
|
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
<%= render(Primer::FlexComponent.new(**@kwargs)) do %>
|
2
2
|
<% if @side == :left %>
|
3
|
-
<%= render Primer::BaseComponent.new(tag: :div, classes: "flex-shrink-0", col: (@responsive ? [12, nil,
|
3
|
+
<%= render Primer::BaseComponent.new(tag: :div, classes: "flex-shrink-0", col: (@responsive ? [12, nil, @sidebar_col] : @sidebar_col), mb: (@responsive ? [4, nil, 0] : nil)) do %>
|
4
4
|
<%= sidebar %>
|
5
5
|
<% end %>
|
6
6
|
<% end %>
|
7
7
|
|
8
|
-
<%= render Primer::BaseComponent.new(tag: :div, classes: "flex-shrink-0", col: (@responsive ? [12, nil,
|
8
|
+
<%= render Primer::BaseComponent.new(tag: :div, classes: "flex-shrink-0", col: (@responsive ? [12, nil, @main_col] : @main_col), mb: (@responsive ? [4, nil, 0] : nil)) do %>
|
9
9
|
<%= main %>
|
10
10
|
<% end %>
|
11
11
|
|
12
12
|
<% if @side == :right %>
|
13
|
-
<%= render Primer::BaseComponent.new(tag: :div, classes: "flex-shrink-0", col: (@responsive ? [12, nil,
|
13
|
+
<%= render Primer::BaseComponent.new(tag: :div, classes: "flex-shrink-0", col: (@responsive ? [12, nil, @sidebar_col] : @sidebar_col)) do %>
|
14
14
|
<%= sidebar %>
|
15
15
|
<% end %>
|
16
16
|
<% end %>
|
@@ -5,17 +5,24 @@ module Primer
|
|
5
5
|
with_content_areas :main, :sidebar
|
6
6
|
|
7
7
|
DEFAULT_SIDE = :right
|
8
|
-
ALLOWED_SIDES = [DEFAULT_SIDE, :left]
|
8
|
+
ALLOWED_SIDES = [DEFAULT_SIDE, :left].freeze
|
9
9
|
|
10
|
-
|
10
|
+
MAX_COL = 12
|
11
|
+
DEFAULT_SIDEBAR_COL = 3
|
12
|
+
ALLOWED_SIDEBAR_COLS = (1..(MAX_COL - 1)).to_a.freeze
|
13
|
+
|
14
|
+
def initialize(responsive: false, side: DEFAULT_SIDE, sidebar_col: DEFAULT_SIDEBAR_COL, **kwargs)
|
11
15
|
@kwargs = kwargs
|
12
|
-
@side = fetch_or_fallback(ALLOWED_SIDES, side, DEFAULT_SIDE)
|
16
|
+
@side = fetch_or_fallback(ALLOWED_SIDES, side.to_sym, DEFAULT_SIDE)
|
13
17
|
@responsive = responsive
|
14
18
|
@kwargs[:classes] = class_names(
|
15
19
|
"gutter-condensed gutter-lg",
|
16
20
|
@kwargs[:classes]
|
17
21
|
)
|
18
22
|
@kwargs[:direction] = responsive ? [:column, nil, :row] : nil
|
23
|
+
|
24
|
+
@sidebar_col = fetch_or_fallback(ALLOWED_SIDEBAR_COLS, sidebar_col, DEFAULT_SIDEBAR_COL)
|
25
|
+
@main_col = MAX_COL - @sidebar_col
|
19
26
|
end
|
20
27
|
end
|
21
28
|
end
|
data/lib/primer/classify.rb
CHANGED
@@ -161,9 +161,9 @@ module Primer
|
|
161
161
|
|
162
162
|
if SPACING_KEYS.include?(key)
|
163
163
|
if MARGIN_DIRECTION_KEYS.include?(key)
|
164
|
-
raise ArgumentError, "value must be between -6 and 6" if (val < -6 || val > 6)
|
165
|
-
|
166
|
-
raise ArgumentError, "value must be between 0 and 6" if (val < 0 || val > 6)
|
164
|
+
raise ArgumentError, "value of #{key} must be between -6 and 6" if (val < -6 || val > 6)
|
165
|
+
elsif !((key == :mx || key == :my) && val == :auto)
|
166
|
+
raise ArgumentError, "value of #{key} must be between 0 and 6" if (val < 0 || val > 6)
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
@@ -23,7 +23,7 @@ module Primer
|
|
23
23
|
if allowed_values.include?(given_value)
|
24
24
|
given_value
|
25
25
|
else
|
26
|
-
if fallback_raises && ENV["RAILS_ENV"] != "production"
|
26
|
+
if fallback_raises && ENV["RAILS_ENV"] != "production" && ENV["STORYBOOK"] != "true"
|
27
27
|
raise InvalidValueError, <<~MSG
|
28
28
|
fetch_or_fallback was called with an invalid value.
|
29
29
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: primer_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitHub Open Source
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|