bigcartel-theme-fonts 1.7.0 → 1.8.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/bigcartel-theme-fonts.gemspec +1 -1
- data/lib/bigcartel/theme/fonts/theme_font.rb +27 -0
- data/lib/bigcartel/theme/fonts/theme_fonts.yml +48 -0
- data/spec/theme_font_spec.rb +79 -0
- 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: eda02a423d5ecebee3afd0f6ed53186cb01e1e8322073844ae90749f5ece7d73
|
4
|
+
data.tar.gz: c903ea89b42f88293a8d31f1f951fa4694586b63da3b44de22bd7c09235ef18f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdce3702961befcddfab26283c15993d791ac1a2f35c39ff5eec44f2909b01544b2f5022c1c2c45e14fb9e02a1ce39275696b7f562bdcdab3c17c293ac608869
|
7
|
+
data.tar.gz: 4f32a6003308f29b986e63d43fcc03cf1522176c730a2a6d98ac52714295485bf05c1fb05ceda4dde40c725f8f064f113553c28c21b22cd9032fa47ba38b4a7e
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'bigcartel-theme-fonts'
|
7
|
-
spec.version = '1.
|
7
|
+
spec.version = '1.8.0'
|
8
8
|
spec.authors = ['Big Cartel']
|
9
9
|
spec.email = ['dev@bigcartel.com']
|
10
10
|
spec.description = %q{A simple class for working with Big Cartel's supported theme fonts.}
|
@@ -66,6 +66,33 @@ class ThemeFont < Struct.new(:name, :family, :weights, :collection)
|
|
66
66
|
google_fonts.empty? ? nil : google_font_url_for_fonts(google_fonts)
|
67
67
|
end
|
68
68
|
|
69
|
+
def google_font_url_for_theme_array(fonts, settings, options = {})
|
70
|
+
defaults = {
|
71
|
+
include_protocol: false,
|
72
|
+
include_weights: true
|
73
|
+
}
|
74
|
+
opts = defaults.merge(options)
|
75
|
+
|
76
|
+
google_fonts = fonts.keys.map { |key| settings[key] }.compact
|
77
|
+
.map { |font_name| find_by_name(font_name) }
|
78
|
+
.compact
|
79
|
+
.select { |font| font.collection == 'google' }
|
80
|
+
.sort_by { |font| font.name }
|
81
|
+
|
82
|
+
return [] if google_fonts.empty?
|
83
|
+
|
84
|
+
base_url = opts[:include_protocol] ? "https://fonts.googleapis.com/css?family=" : "//fonts.googleapis.com/css?family="
|
85
|
+
|
86
|
+
google_fonts.map do |font|
|
87
|
+
font_string = if opts[:include_weights] && font.weights
|
88
|
+
"#{font.name}:#{font.weights}"
|
89
|
+
else
|
90
|
+
font.name
|
91
|
+
end
|
92
|
+
"#{base_url}#{font_string.gsub(' ', '+')}&display=swap"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
69
96
|
private
|
70
97
|
|
71
98
|
def source
|
@@ -57,6 +57,10 @@ google:
|
|
57
57
|
name: Abril Fatface
|
58
58
|
family: '"Abril Fatface", cursive'
|
59
59
|
|
60
|
+
alumni_sans_pinstripe:
|
61
|
+
name: Alumni Sans Pinstripe
|
62
|
+
family: '"Alumni Sans Pinstripe", sans-serif'
|
63
|
+
|
60
64
|
amaranth:
|
61
65
|
name: Amaranth
|
62
66
|
family: '"Amaranth", serif'
|
@@ -76,6 +80,15 @@ google:
|
|
76
80
|
name: Asap
|
77
81
|
family: '"Asap", sans-serif'
|
78
82
|
|
83
|
+
atkinson_hyperlegible_next:
|
84
|
+
name: Atkinson Hyperlegible Next
|
85
|
+
family: '"Atkinson Hyperlegible Next", sans-serif'
|
86
|
+
weights: "200,300,400,500,600,700,800"
|
87
|
+
|
88
|
+
atma:
|
89
|
+
name: Atma
|
90
|
+
family: 'Atma, sans-serif'
|
91
|
+
|
79
92
|
bevan:
|
80
93
|
name: Bevan
|
81
94
|
family: '"Bevan", cursive'
|
@@ -103,6 +116,10 @@ google:
|
|
103
116
|
family: '"Chivo", sans-serif'
|
104
117
|
weights: "400,700"
|
105
118
|
|
119
|
+
coiny:
|
120
|
+
name: Coiny
|
121
|
+
family: '"Coiny", cursive'
|
122
|
+
|
106
123
|
concert_one:
|
107
124
|
name: Concert One
|
108
125
|
family: '"Concert One", cursive'
|
@@ -120,6 +137,10 @@ google:
|
|
120
137
|
name: Cutive Mono
|
121
138
|
family: '"Cutive Mono", serif'
|
122
139
|
|
140
|
+
dekko:
|
141
|
+
name: Dekko
|
142
|
+
family: 'Dekko, sans-serif'
|
143
|
+
|
123
144
|
delius:
|
124
145
|
name: Delius
|
125
146
|
family: '"Delius", cursive'
|
@@ -172,6 +193,11 @@ google:
|
|
172
193
|
family: '"Glegoo", serif'
|
173
194
|
weights: "400,700"
|
174
195
|
|
196
|
+
gorditas:
|
197
|
+
name: Gorditas
|
198
|
+
family: '"Gorditas", sans-serif'
|
199
|
+
weights: "400,700"
|
200
|
+
|
175
201
|
goudy_bookletter_1911:
|
176
202
|
name: Goudy Bookletter 1911
|
177
203
|
family: '"Goudy Bookletter 1911", serif'
|
@@ -181,6 +207,10 @@ google:
|
|
181
207
|
family: '"Hahmlet", serif'
|
182
208
|
weights: "400,700"
|
183
209
|
|
210
|
+
honk:
|
211
|
+
name: Honk
|
212
|
+
family: 'Honk, sans-serif'
|
213
|
+
|
184
214
|
inconsolata:
|
185
215
|
name: Inconsolata
|
186
216
|
family: '"Inconsolata", sans-serif'
|
@@ -201,6 +231,10 @@ google:
|
|
201
231
|
family: '"Karla", sans-serif'
|
202
232
|
weights: "300,400,500,700"
|
203
233
|
|
234
|
+
langar:
|
235
|
+
name: Langar
|
236
|
+
family: '"Langar", cursive'
|
237
|
+
|
204
238
|
lato:
|
205
239
|
name: Lato
|
206
240
|
family: '"Lato", sans-serif'
|
@@ -299,6 +333,10 @@ google:
|
|
299
333
|
family: '"ParkinSans", sans-serif'
|
300
334
|
weights: "300,400,500,700"
|
301
335
|
|
336
|
+
permanent_marker:
|
337
|
+
name: Permanent Marker
|
338
|
+
family: '"Permanent Marker", cursive'
|
339
|
+
|
302
340
|
playfair_display:
|
303
341
|
name: Playfair Display
|
304
342
|
family: '"Playfair Display", serif'
|
@@ -352,6 +390,16 @@ google:
|
|
352
390
|
family: '"Raleway", sans-serif'
|
353
391
|
weights: "400,700"
|
354
392
|
|
393
|
+
radio_canada:
|
394
|
+
name: Radio Canada
|
395
|
+
family: '"Radio Canada", sans-serif'
|
396
|
+
weights: "300,400,500,600,700"
|
397
|
+
|
398
|
+
reddit_sans:
|
399
|
+
name: Reddit Sans
|
400
|
+
family: '"Reddit Sans", sans-serif'
|
401
|
+
weights: "200,300,400,500,600,700,800"
|
402
|
+
|
355
403
|
roboto:
|
356
404
|
name: Roboto
|
357
405
|
family: '"Roboto", sans-serif'
|
data/spec/theme_font_spec.rb
CHANGED
@@ -143,4 +143,83 @@ describe ThemeFont do
|
|
143
143
|
ThemeFont.google_font_url_for_theme(fonts, settings).should be_nil
|
144
144
|
end
|
145
145
|
end
|
146
|
+
|
147
|
+
describe ".google_font_url_for_theme_array" do
|
148
|
+
let(:fonts) {{ :header_font => {}, :body_font => {}, :paragraph_font => {} }}
|
149
|
+
|
150
|
+
before(:each) do
|
151
|
+
stub(ThemeFont).all {[
|
152
|
+
ThemeFont.new('One Font', 'One Family', '400,700', 'google'),
|
153
|
+
ThemeFont.new('Two', 'Two Family', nil, 'default'),
|
154
|
+
ThemeFont.new('Three', 'Three Family', '300,600', 'google')
|
155
|
+
]}
|
156
|
+
end
|
157
|
+
|
158
|
+
context "with default options" do
|
159
|
+
it "returns an array of URLs with weights and no protocol" do
|
160
|
+
settings = { :header_font => 'One Font', :body_font => 'Two', :paragraph_font => 'Three' }
|
161
|
+
result = ThemeFont.google_font_url_for_theme_array(fonts, settings)
|
162
|
+
result.should == [
|
163
|
+
"//fonts.googleapis.com/css?family=One+Font:400,700&display=swap",
|
164
|
+
"//fonts.googleapis.com/css?family=Three:300,600&display=swap"
|
165
|
+
]
|
166
|
+
end
|
167
|
+
|
168
|
+
it "returns a single URL in array when only one Google font" do
|
169
|
+
settings = { :header_font => 'One Font', :body_font => 'Two' }
|
170
|
+
result = ThemeFont.google_font_url_for_theme_array(fonts, settings)
|
171
|
+
result.should == ["//fonts.googleapis.com/css?family=One+Font:400,700&display=swap"]
|
172
|
+
end
|
173
|
+
|
174
|
+
it "returns empty array when no Google fonts" do
|
175
|
+
settings = { :body_font => 'Two' }
|
176
|
+
result = ThemeFont.google_font_url_for_theme_array(fonts, settings)
|
177
|
+
result.should == []
|
178
|
+
end
|
179
|
+
|
180
|
+
it "deduplicates identical fonts" do
|
181
|
+
settings = { :header_font => 'One Font', :body_font => 'One Font' }
|
182
|
+
result = ThemeFont.google_font_url_for_theme_array(fonts, settings)
|
183
|
+
result.should == ["//fonts.googleapis.com/css?family=One+Font:400,700&display=swap"]
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
context "with include_protocol: true" do
|
188
|
+
it "returns URLs with https protocol" do
|
189
|
+
settings = { :header_font => 'One Font', :paragraph_font => 'Three' }
|
190
|
+
result = ThemeFont.google_font_url_for_theme_array(fonts, settings, include_protocol: true)
|
191
|
+
result.should == [
|
192
|
+
"https://fonts.googleapis.com/css?family=One+Font:400,700&display=swap",
|
193
|
+
"https://fonts.googleapis.com/css?family=Three:300,600&display=swap"
|
194
|
+
]
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
context "with include_weights: false" do
|
199
|
+
it "returns URLs without weights" do
|
200
|
+
settings = { :header_font => 'One Font', :paragraph_font => 'Three' }
|
201
|
+
result = ThemeFont.google_font_url_for_theme_array(fonts, settings, include_weights: false)
|
202
|
+
result.should == [
|
203
|
+
"//fonts.googleapis.com/css?family=One+Font&display=swap",
|
204
|
+
"//fonts.googleapis.com/css?family=Three&display=swap"
|
205
|
+
]
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
context "with both options customized" do
|
210
|
+
it "returns URLs with protocol and no weights" do
|
211
|
+
settings = { :header_font => 'One Font', :paragraph_font => 'Three' }
|
212
|
+
result = ThemeFont.google_font_url_for_theme_array(
|
213
|
+
fonts,
|
214
|
+
settings,
|
215
|
+
include_protocol: true,
|
216
|
+
include_weights: false
|
217
|
+
)
|
218
|
+
result.should == [
|
219
|
+
"https://fonts.googleapis.com/css?family=One+Font&display=swap",
|
220
|
+
"https://fonts.googleapis.com/css?family=Three&display=swap"
|
221
|
+
]
|
222
|
+
end
|
223
|
+
end
|
224
|
+
end
|
146
225
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bigcartel-theme-fonts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Big Cartel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|