bigcartel-theme-fonts 1.7.0 → 1.8.1
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 +19 -0
- data/lib/bigcartel/theme/fonts/theme_fonts.yml +48 -0
- data/spec/theme_font_spec.rb +109 -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: c24d66f05033aa4200161c1f0c2e1f76b2e2d7ffc05ebf2c7362d0402c83d731
|
4
|
+
data.tar.gz: c2c5567bbd85fa600d66c62d561984d9bd16cd7c60132f6684620d63112c99b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a321d1697c53a3dba38e686faa7dff2f7425ca78f604153e209dcfccaf2cfabd551dd7866bf99ed5b7f8f02e5dfb1260afd9fca1b3ca379ebe719a62b978792
|
7
|
+
data.tar.gz: 8ecd906210fdae6fd8ea4d7a239cc520d27630a9785b7631a2a124b2110bd9d41915a3a3e94f45c9b9c4aa539427e70cebb7b00ec7d70453c42fae96d03a2118
|
@@ -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.1'
|
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,25 @@ 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_json(account_theme)
|
70
|
+
# Cosmos and Lunch Break use the secondary font for the primary text font
|
71
|
+
font_setting = if ["cosmos", "lunch break"].include?(account_theme.theme.name.downcase)
|
72
|
+
account_theme.settings["secondary_font"]
|
73
|
+
else
|
74
|
+
account_theme.settings["primary_font"] ||
|
75
|
+
account_theme.settings["text_font"] ||
|
76
|
+
account_theme.settings["font"] ||
|
77
|
+
account_theme.settings["serif_font"]
|
78
|
+
end
|
79
|
+
|
80
|
+
font = find_by_name(font_setting)
|
81
|
+
return {} if font.nil? || font.collection != 'google'
|
82
|
+
|
83
|
+
{
|
84
|
+
"primary_text_font" => "https://fonts.googleapis.com/css?family=#{font.name.gsub(' ', '+')}"
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
69
88
|
private
|
70
89
|
|
71
90
|
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,113 @@ 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_json" do
|
148
|
+
let(:theme) { double("Theme", name: "default") }
|
149
|
+
let(:account_theme) { double("AccountTheme", theme: theme, settings: {}) }
|
150
|
+
|
151
|
+
before(:each) do
|
152
|
+
stub(ThemeFont).all {[
|
153
|
+
ThemeFont.new('One Font', 'One Family', '400,700', 'google'),
|
154
|
+
ThemeFont.new('Two', 'Two Family', nil, 'default'),
|
155
|
+
ThemeFont.new('Three', 'Three Family', '300,600', 'google')
|
156
|
+
]}
|
157
|
+
end
|
158
|
+
|
159
|
+
context "with default theme" do
|
160
|
+
it "uses primary_font when present" do
|
161
|
+
stub(account_theme).settings { { "primary_font" => "One Font" } }
|
162
|
+
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
163
|
+
result.should == {
|
164
|
+
"primary_text_font" => "https://fonts.googleapis.com/css?family=One+Font"
|
165
|
+
}
|
166
|
+
end
|
167
|
+
|
168
|
+
context "font setting fallback stack" do
|
169
|
+
it "falls back to text_font when primary_font is absent" do
|
170
|
+
stub(account_theme).settings { { "text_font" => "Three" } }
|
171
|
+
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
172
|
+
result.should == {
|
173
|
+
"primary_text_font" => "https://fonts.googleapis.com/css?family=Three"
|
174
|
+
}
|
175
|
+
end
|
176
|
+
|
177
|
+
it "falls back to font when primary_font and text_font are absent" do
|
178
|
+
stub(account_theme).settings { { "font" => "One Font" } }
|
179
|
+
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
180
|
+
result.should == {
|
181
|
+
"primary_text_font" => "https://fonts.googleapis.com/css?family=One+Font"
|
182
|
+
}
|
183
|
+
end
|
184
|
+
|
185
|
+
it "falls back to serif_font when all others are absent" do
|
186
|
+
stub(account_theme).settings { { "serif_font" => "Three" } }
|
187
|
+
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
188
|
+
result.should == {
|
189
|
+
"primary_text_font" => "https://fonts.googleapis.com/css?family=Three"
|
190
|
+
}
|
191
|
+
end
|
192
|
+
|
193
|
+
it "prefers primary_font over other settings" do
|
194
|
+
stub(account_theme).settings { {
|
195
|
+
"primary_font" => "One Font",
|
196
|
+
"text_font" => "Three",
|
197
|
+
"font" => "Three",
|
198
|
+
"serif_font" => "Three"
|
199
|
+
} }
|
200
|
+
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
201
|
+
result.should == {
|
202
|
+
"primary_text_font" => "https://fonts.googleapis.com/css?family=One+Font"
|
203
|
+
}
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
it "returns empty hash for non-Google font" do
|
208
|
+
stub(account_theme).settings { { "primary_font" => "Two" } }
|
209
|
+
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
210
|
+
result.should == {}
|
211
|
+
end
|
212
|
+
|
213
|
+
it "returns empty hash for unknown font" do
|
214
|
+
stub(account_theme).settings { { "primary_font" => "Unknown" } }
|
215
|
+
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
216
|
+
result.should == {}
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
context "with Cosmos theme" do
|
221
|
+
let(:theme) { double("Theme", name: "cosmos") }
|
222
|
+
|
223
|
+
it "uses secondary_font setting" do
|
224
|
+
stub(account_theme).settings { { "secondary_font" => "Three" } }
|
225
|
+
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
226
|
+
result.should == {
|
227
|
+
"primary_text_font" => "https://fonts.googleapis.com/css?family=Three"
|
228
|
+
}
|
229
|
+
end
|
230
|
+
|
231
|
+
it "ignores primary_font when secondary_font is present" do
|
232
|
+
stub(account_theme).settings { {
|
233
|
+
"secondary_font" => "Three",
|
234
|
+
"primary_font" => "One Font"
|
235
|
+
} }
|
236
|
+
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
237
|
+
result.should == {
|
238
|
+
"primary_text_font" => "https://fonts.googleapis.com/css?family=Three"
|
239
|
+
}
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
context "with Lunch Break theme" do
|
244
|
+
let(:theme) { double("Theme", name: "lunch break") }
|
245
|
+
|
246
|
+
it "uses secondary_font setting" do
|
247
|
+
stub(account_theme).settings { { "secondary_font" => "One Font" } }
|
248
|
+
result = ThemeFont.google_font_url_for_theme_json(account_theme)
|
249
|
+
result.should == {
|
250
|
+
"primary_text_font" => "https://fonts.googleapis.com/css?family=One+Font"
|
251
|
+
}
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
146
255
|
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.1
|
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
|