trmnl_preview 0.27.0 → 0.28.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.
@@ -1,5 +1,6 @@
1
- # Mirrored from each Framework release's plugins.css: the screen prefixes it defines for
2
- # value--, label--, title--, description--, text-- and content-- classes, and the classes each
1
+ # Mirrored from each Framework release's plugins.css: the screen prefixes it defines for the
2
+ # value, label, title, description and content elements and their value--, label--, title--,
3
+ # description--, text-- and content-- classes, and the classes each
3
4
  # covers: every class in a family (`all`), all `except` some, or `only` some. A list holds
4
5
  # until the next release listed.
5
6
  # Refresh with `rake framework:classes` — do not edit manually.
@@ -14,6 +15,7 @@
14
15
  families:
15
16
  label:
16
17
  except:
18
+ - label
17
19
  - label--gray-out
18
20
  - label--underline-2
19
21
  text: all
@@ -23,6 +25,7 @@
23
25
  families:
24
26
  label:
25
27
  except:
28
+ - label
26
29
  - label--gray-out
27
30
  - label--underline-2
28
31
  text:
@@ -75,6 +78,7 @@
75
78
  families:
76
79
  label:
77
80
  except:
81
+ - label
78
82
  - label--gray
79
83
  - label--underline-2
80
84
  text:
@@ -95,6 +99,7 @@
95
99
  families:
96
100
  label:
97
101
  except:
102
+ - label
98
103
  - label--gray
99
104
  - label--underline-2
100
105
  text: all
@@ -105,29 +110,26 @@
105
110
  - 2bit
106
111
  - 4bit
107
112
  - landscape
108
- - lg
109
- - lg:landscape
110
- - lg:portrait
111
- - md
112
- - md:landscape
113
- - md:portrait
114
113
  - portrait
115
- - sm
116
- - sm:landscape
117
- - sm:portrait
118
114
  families:
119
115
  content:
120
116
  except:
117
+ - content
121
118
  - content--center
122
119
  - content--left
123
120
  - content--right
124
- description: all
121
+ description:
122
+ except:
123
+ - description
125
124
  label:
126
125
  except:
126
+ - label
127
127
  - label--gray-out
128
128
  - label--underline-2
129
129
  text: all
130
- title: all
130
+ title:
131
+ except:
132
+ - title
131
133
  value: all
132
134
  - prefixes:
133
135
  - 3bit
@@ -175,19 +177,54 @@
175
177
  families:
176
178
  content:
177
179
  except:
180
+ - content
178
181
  - content--center
179
182
  - content--left
180
183
  - content--right
181
- description: all
184
+ description:
185
+ except:
186
+ - description
182
187
  label:
183
188
  except:
189
+ - label
184
190
  - label--gray-out
185
191
  - label--underline-2
186
192
  text:
187
193
  except:
188
194
  - text--black
189
195
  - text--white
190
- title: all
196
+ title:
197
+ except:
198
+ - title
199
+ value: all
200
+ - prefixes:
201
+ - lg
202
+ - lg:landscape
203
+ - lg:portrait
204
+ - md
205
+ - md:landscape
206
+ - md:portrait
207
+ - sm
208
+ - sm:landscape
209
+ - sm:portrait
210
+ families:
211
+ content:
212
+ except:
213
+ - content--center
214
+ - content--left
215
+ - content--right
216
+ description:
217
+ except:
218
+ - description
219
+ label:
220
+ except:
221
+ - label
222
+ - label--gray-out
223
+ - label--underline-2
224
+ text: all
225
+ title:
226
+ except:
227
+ - title
191
228
  value: all
192
229
  3.0.0:
193
230
  - prefixes:
@@ -239,12 +276,16 @@
239
276
  families:
240
277
  content:
241
278
  except:
279
+ - content
242
280
  - content--center
243
281
  - content--left
244
282
  - content--right
245
- description: all
283
+ description:
284
+ except:
285
+ - description
246
286
  label:
247
287
  except:
288
+ - label
248
289
  - label--gray-out
249
290
  - label--inverted
250
291
  - label--underline-2
@@ -254,7 +295,9 @@
254
295
  - text--justify
255
296
  - text--left
256
297
  - text--right
257
- title: all
298
+ title:
299
+ except:
300
+ - title
258
301
  value: all
259
302
  - prefixes:
260
303
  - dark
@@ -329,13 +372,35 @@
329
372
  - text--right
330
373
  - prefixes:
331
374
  - landscape
375
+ - portrait
376
+ families:
377
+ content:
378
+ except:
379
+ - content
380
+ - content--center
381
+ - content--left
382
+ - content--right
383
+ description:
384
+ except:
385
+ - description
386
+ label:
387
+ except:
388
+ - label
389
+ - label--gray-out
390
+ - label--inverted
391
+ - label--underline-2
392
+ text: all
393
+ title:
394
+ except:
395
+ - title
396
+ value: all
397
+ - prefixes:
332
398
  - lg
333
399
  - lg:landscape
334
400
  - lg:portrait
335
401
  - md
336
402
  - md:landscape
337
403
  - md:portrait
338
- - portrait
339
404
  - sm
340
405
  - sm:landscape
341
406
  - sm:portrait
@@ -345,14 +410,19 @@
345
410
  - content--center
346
411
  - content--left
347
412
  - content--right
348
- description: all
413
+ description:
414
+ except:
415
+ - description
349
416
  label:
350
417
  except:
418
+ - label
351
419
  - label--gray-out
352
420
  - label--inverted
353
421
  - label--underline-2
354
422
  text: all
355
- title: all
423
+ title:
424
+ except:
425
+ - title
356
426
  value: all
357
427
  3.0.4:
358
428
  - prefixes:
@@ -404,12 +474,16 @@
404
474
  families:
405
475
  content:
406
476
  except:
477
+ - content
407
478
  - content--center
408
479
  - content--left
409
480
  - content--right
410
- description: all
481
+ description:
482
+ except:
483
+ - description
411
484
  label:
412
485
  except:
486
+ - label
413
487
  - label--gray-out
414
488
  - label--inverted
415
489
  - label--underline-2
@@ -429,7 +503,9 @@
429
503
  - text--xlarge
430
504
  - text--xxlarge
431
505
  - text--xxxlarge
432
- title: all
506
+ title:
507
+ except:
508
+ - title
433
509
  value: all
434
510
  - prefixes:
435
511
  - dark
@@ -515,13 +591,35 @@
515
591
  - text--right
516
592
  - prefixes:
517
593
  - landscape
594
+ - portrait
595
+ families:
596
+ content:
597
+ except:
598
+ - content
599
+ - content--center
600
+ - content--left
601
+ - content--right
602
+ description:
603
+ except:
604
+ - description
605
+ label:
606
+ except:
607
+ - label
608
+ - label--gray-out
609
+ - label--inverted
610
+ - label--underline-2
611
+ text: all
612
+ title:
613
+ except:
614
+ - title
615
+ value: all
616
+ - prefixes:
518
617
  - lg
519
618
  - lg:landscape
520
619
  - lg:portrait
521
620
  - md
522
621
  - md:landscape
523
622
  - md:portrait
524
- - portrait
525
623
  - sm
526
624
  - sm:landscape
527
625
  - sm:portrait
@@ -531,14 +629,19 @@
531
629
  - content--center
532
630
  - content--left
533
631
  - content--right
534
- description: all
632
+ description:
633
+ except:
634
+ - description
535
635
  label:
536
636
  except:
637
+ - label
537
638
  - label--gray-out
538
639
  - label--inverted
539
640
  - label--underline-2
540
641
  text: all
541
- title: all
642
+ title:
643
+ except:
644
+ - title
542
645
  value: all
543
646
  3.0.5:
544
647
  - prefixes:
@@ -590,12 +693,16 @@
590
693
  families:
591
694
  content:
592
695
  except:
696
+ - content
593
697
  - content--center
594
698
  - content--left
595
699
  - content--right
596
- description: all
700
+ description:
701
+ except:
702
+ - description
597
703
  label:
598
704
  except:
705
+ - label
599
706
  - label--gray-out
600
707
  - label--inverted
601
708
  - label--underline-2
@@ -604,7 +711,9 @@
604
711
  - text--default
605
712
  - text--inverse
606
713
  - text--muted
607
- title: all
714
+ title:
715
+ except:
716
+ - title
608
717
  value: all
609
718
  - prefixes:
610
719
  - dark
@@ -699,13 +808,35 @@
699
808
  - text--xxxlarge
700
809
  - prefixes:
701
810
  - landscape
811
+ - portrait
812
+ families:
813
+ content:
814
+ except:
815
+ - content
816
+ - content--center
817
+ - content--left
818
+ - content--right
819
+ description:
820
+ except:
821
+ - description
822
+ label:
823
+ except:
824
+ - label
825
+ - label--gray-out
826
+ - label--inverted
827
+ - label--underline-2
828
+ text: all
829
+ title:
830
+ except:
831
+ - title
832
+ value: all
833
+ - prefixes:
702
834
  - lg
703
835
  - lg:landscape
704
836
  - lg:portrait
705
837
  - md
706
838
  - md:landscape
707
839
  - md:portrait
708
- - portrait
709
840
  - sm
710
841
  - sm:landscape
711
842
  - sm:portrait
@@ -715,14 +846,19 @@
715
846
  - content--center
716
847
  - content--left
717
848
  - content--right
718
- description: all
849
+ description:
850
+ except:
851
+ - description
719
852
  label:
720
853
  except:
854
+ - label
721
855
  - label--gray-out
722
856
  - label--inverted
723
857
  - label--underline-2
724
858
  text: all
725
- title: all
859
+ title:
860
+ except:
861
+ - title
726
862
  value: all
727
863
  - prefixes:
728
864
  - lg:3bit
@@ -798,12 +934,16 @@
798
934
  families:
799
935
  content:
800
936
  except:
937
+ - content
801
938
  - content--center
802
939
  - content--left
803
940
  - content--right
804
- description: all
941
+ description:
942
+ except:
943
+ - description
805
944
  label:
806
945
  except:
946
+ - label
807
947
  - label--gray-out
808
948
  - label--inverted
809
949
  - label--underline-2
@@ -823,7 +963,9 @@
823
963
  - text--xlarge
824
964
  - text--xxlarge
825
965
  - text--xxxlarge
826
- title: all
966
+ title:
967
+ except:
968
+ - title
827
969
  value: all
828
970
  - prefixes:
829
971
  - dark
@@ -909,13 +1051,35 @@
909
1051
  - text--right
910
1052
  - prefixes:
911
1053
  - landscape
1054
+ - portrait
1055
+ families:
1056
+ content:
1057
+ except:
1058
+ - content
1059
+ - content--center
1060
+ - content--left
1061
+ - content--right
1062
+ description:
1063
+ except:
1064
+ - description
1065
+ label:
1066
+ except:
1067
+ - label
1068
+ - label--gray-out
1069
+ - label--inverted
1070
+ - label--underline-2
1071
+ text: all
1072
+ title:
1073
+ except:
1074
+ - title
1075
+ value: all
1076
+ - prefixes:
912
1077
  - lg
913
1078
  - lg:landscape
914
1079
  - lg:portrait
915
1080
  - md
916
1081
  - md:landscape
917
1082
  - md:portrait
918
- - portrait
919
1083
  - sm
920
1084
  - sm:landscape
921
1085
  - sm:portrait
@@ -925,14 +1089,19 @@
925
1089
  - content--center
926
1090
  - content--left
927
1091
  - content--right
928
- description: all
1092
+ description:
1093
+ except:
1094
+ - description
929
1095
  label:
930
1096
  except:
1097
+ - label
931
1098
  - label--gray-out
932
1099
  - label--inverted
933
1100
  - label--underline-2
934
1101
  text: all
935
- title: all
1102
+ title:
1103
+ except:
1104
+ - title
936
1105
  value: all
937
1106
  3.1.1:
938
1107
  - prefixes:
@@ -984,12 +1153,16 @@
984
1153
  families:
985
1154
  content:
986
1155
  except:
1156
+ - content
987
1157
  - content--center
988
1158
  - content--left
989
1159
  - content--right
990
- description: all
1160
+ description:
1161
+ except:
1162
+ - description
991
1163
  label:
992
1164
  except:
1165
+ - label
993
1166
  - label--gray-out
994
1167
  - label--inverted
995
1168
  - label--underline-2
@@ -998,7 +1171,9 @@
998
1171
  - text--default
999
1172
  - text--inverse
1000
1173
  - text--muted
1001
- title: all
1174
+ title:
1175
+ except:
1176
+ - title
1002
1177
  value: all
1003
1178
  - prefixes:
1004
1179
  - dark
@@ -1093,13 +1268,35 @@
1093
1268
  - text--xxxlarge
1094
1269
  - prefixes:
1095
1270
  - landscape
1271
+ - portrait
1272
+ families:
1273
+ content:
1274
+ except:
1275
+ - content
1276
+ - content--center
1277
+ - content--left
1278
+ - content--right
1279
+ description:
1280
+ except:
1281
+ - description
1282
+ label:
1283
+ except:
1284
+ - label
1285
+ - label--gray-out
1286
+ - label--inverted
1287
+ - label--underline-2
1288
+ text: all
1289
+ title:
1290
+ except:
1291
+ - title
1292
+ value: all
1293
+ - prefixes:
1096
1294
  - lg
1097
1295
  - lg:landscape
1098
1296
  - lg:portrait
1099
1297
  - md
1100
1298
  - md:landscape
1101
1299
  - md:portrait
1102
- - portrait
1103
1300
  - sm
1104
1301
  - sm:landscape
1105
1302
  - sm:portrait
@@ -1109,14 +1306,19 @@
1109
1306
  - content--center
1110
1307
  - content--left
1111
1308
  - content--right
1112
- description: all
1309
+ description:
1310
+ except:
1311
+ - description
1113
1312
  label:
1114
1313
  except:
1314
+ - label
1115
1315
  - label--gray-out
1116
1316
  - label--inverted
1117
1317
  - label--underline-2
1118
1318
  text: all
1119
- title: all
1319
+ title:
1320
+ except:
1321
+ - title
1120
1322
  value: all
1121
1323
  - prefixes:
1122
1324
  - lg:3bit
@@ -1194,13 +1396,20 @@
1194
1396
  families:
1195
1397
  content:
1196
1398
  except:
1399
+ - content
1197
1400
  - content--center
1198
1401
  - content--left
1199
1402
  - content--right
1200
- description: all
1201
- label: all
1403
+ description:
1404
+ except:
1405
+ - description
1406
+ label:
1407
+ except:
1408
+ - label
1202
1409
  text: all
1203
- title: all
1410
+ title:
1411
+ except:
1412
+ - title
1204
1413
  value: all
1205
1414
  - prefixes:
1206
1415
  - dark
@@ -9,8 +9,6 @@ module TRMNLP
9
9
  @available = Queue.new
10
10
  @mutex = Mutex.new
11
11
  @shutdown = false
12
-
13
- at_exit { shutdown }
14
12
  end
15
13
 
16
14
  def with_driver
@@ -10,10 +10,18 @@ module TRMNLP
10
10
 
11
11
  def build
12
12
  Selenium::WebDriver.for(:firefox, options:).tap do |driver|
13
+ # Exit hooks run newest first, so this quits Firefox before Selenium's hook stops geckodriver and orphans it.
14
+ at_exit { quit(driver) }
13
15
  driver.manage.window.maximize
14
16
  end
15
17
  end
16
18
 
19
+ def quit(driver)
20
+ driver.quit
21
+ rescue StandardError
22
+ nil
23
+ end
24
+
17
25
  def options
18
26
  Selenium::WebDriver::Firefox::Options.new(web_socket_url: true).tap do |opts|
19
27
  opts.add_argument('--headless')
@@ -7,7 +7,8 @@ module TRMNLP
7
7
  module Checks
8
8
  # Reports bracketed Framework classes the Framework never generates, one
9
9
  # finding per class. They match no rule, so they do nothing, and nothing
10
- # says so: `lg:w--[192px]` leaves the element at its smaller width.
10
+ # says so: `lg:w--[192px]` leaves the element at its smaller width, and
11
+ # `mt--[2px]` or `w--[40%]` leave it where it was.
11
12
  #
12
13
  # The ranges mirror the loops in the Framework's utilities/_size.scss,
13
14
  # _gap.scss and _rounded.scss, and hold for every 3.x release's
@@ -24,6 +25,11 @@ module TRMNLP
24
25
  [family, { 'px' => 128, (family.start_with?('w') ? 'cqw' : 'cqh') => 100 }]
25
26
  end.merge('gap--' => { 'px' => 50 }, 'rounded--' => { 'px' => 50 }).freeze
26
27
 
28
+ # Margin and padding come only in spacing steps (`mt--1` is 4px), never
29
+ # in brackets, in every 3.x release.
30
+ SPACING_FAMILIES = %w[m mt mr mb ml mx my p pt pr pb pl px py].map { "#{it}--" }.freeze
31
+ SPACING_LEARN_MORE = 'https://trmnl.com/framework/docs/spacing'
32
+
27
33
  # `gap--[Npx]` and `rounded--[Npx]` exist only without a screen prefix.
28
34
  PREFIXABLE = SIZE_FAMILIES
29
35
 
@@ -33,8 +39,8 @@ module TRMNLP
33
39
  PATTERN = /
34
40
  (?<![\w:-])
35
41
  (?<prefix>(?:[a-z0-9-]+:)*)
36
- (?<family>w--min-|w--max-|h--min-|h--max-|w--|h--|gap--|rounded--)
37
- \[(?<value>[\d.]+)(?<unit>[a-z]+)\]
42
+ (?<family>w--min-|w--max-|h--min-|h--max-|w--|h--|gap--|rounded--|[mp][trblxy]?--)
43
+ \[(?<value>[\d.]+)(?<unit>[a-z%]+)\]
38
44
  /x
39
45
 
40
46
  def issues
@@ -42,6 +48,8 @@ module TRMNLP
42
48
 
43
49
  source.all_markup.scan(PATTERN).uniq.filter_map do |prefix, family, value, unit|
44
50
  css_class = "#{prefix}#{family}[#{value}#{unit}]"
51
+ next spacing_issue(css_class, family) if SPACING_FAMILIES.include?(family)
52
+
45
53
  reason = problem(prefix, family, value, unit)
46
54
  { message: "'#{css_class}' has no effect: #{reason}." } if reason
47
55
  end
@@ -51,6 +59,12 @@ module TRMNLP
51
59
 
52
60
  def version = @version ||= Gem::Version.new(source.framework_version.number)
53
61
 
62
+ def spacing_issue(css_class, family)
63
+ { message: "'#{css_class}' has no effect: the Framework has no bracket values for '#{family}', " \
64
+ "only spacing steps such as '#{family}1' for 4px.",
65
+ learn_more: SPACING_LEARN_MORE }
66
+ end
67
+
54
68
  def problem(prefix, family, value, unit)
55
69
  max = RANGES.dig(family, unit)
56
70
  return "the Framework has no '#{unit}' values for '#{family}'" unless max
@@ -9,10 +9,11 @@ module TRMNLP
9
9
  module Lint
10
10
  module Checks
11
11
  # Reports a Framework class behind screen prefixes that the plugin's release does not
12
- # define for it, such as `xl:value--large` or `dark:value--large`. The class matches no
13
- # rule, so it does nothing. Classes the release lacks entirely are left to FrameworkClassesExist.
12
+ # define for it, such as `xl:value--large`, `dark:value--large` or `lg:title`. The class
13
+ # matches no rule, so it does nothing. Classes the release lacks entirely are left to
14
+ # FrameworkClassesExist.
14
15
  class FrameworkPrefixesExist < Check
15
- PREFIXED_PATTERN = /\A(?<prefix>.+):(?<name>(?:value|label|title|description|text|content)--.+)\z/
16
+ PREFIXED_PATTERN = /\A(?<prefix>.+):(?<name>(?:value|label|title|description|text|content)(?:--.+)?)\z/
16
17
  DATA_PATH = File.expand_path('../../../../db/data/framework_prefixes.yml', __dir__)
17
18
  LEARN_MORE = 'https://trmnl.com/framework/docs/responsive'
18
19
 
@@ -42,7 +43,9 @@ module TRMNLP
42
43
 
43
44
  def reason(prefix, name)
44
45
  version = "Framework v#{source.framework_version}"
45
- return "#{name} has no '#{prefix}:' variant in #{version}." if families_by_prefix.key?(prefix)
46
+ if families_by_prefix.key?(prefix)
47
+ return "#{name} has no '#{prefix}:' variant in #{version}.#{base_size_hint(prefix, name)}"
48
+ end
46
49
 
47
50
  reordered = families_by_prefix.keys.find do |known|
48
51
  known.split(':').sort == prefix.split(':').sort && covers?(known, name)
@@ -52,6 +55,13 @@ module TRMNLP
52
55
  "#{version} has no '#{prefix}:' prefix."
53
56
  end
54
57
 
58
+ # A bare element such as `title` can lack a prefix that its sizes have: `lg:title--base`
59
+ # is the base size on large screens.
60
+ def base_size_hint(prefix, name)
61
+ base = "#{name}--base"
62
+ " Use '#{prefix}:#{base}' for its base size." if !name.include?('--') && covers?(prefix, base)
63
+ end
64
+
55
65
  # A family is covered as `all` its classes, all `except` some, or `only` some.
56
66
  def covers?(prefix, name)
57
67
  coverage = families_by_prefix.dig(prefix, name.split('--').first)