primer_view_components 0.0.61 → 0.0.65

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +746 -613
  3. data/app/components/primer/alpha/border_box/header.rb +1 -2
  4. data/app/components/primer/alpha/button_marketing.rb +4 -4
  5. data/app/components/primer/alpha/tab_nav.rb +1 -1
  6. data/app/components/primer/alpha/tab_panels.rb +2 -2
  7. data/app/components/primer/alpha/underline_nav.rb +2 -1
  8. data/app/components/primer/alpha/underline_panels.rb +2 -2
  9. data/app/components/primer/base_component.rb +8 -36
  10. data/app/components/primer/beta/auto_complete/item.rb +1 -1
  11. data/app/components/primer/beta/auto_complete.rb +4 -2
  12. data/app/components/primer/beta/avatar.rb +1 -1
  13. data/app/components/primer/beta/blankslate.html.erb +2 -2
  14. data/app/components/primer/beta/blankslate.rb +7 -6
  15. data/app/components/primer/beta/breadcrumbs.rb +2 -2
  16. data/app/components/primer/beta/text.rb +1 -1
  17. data/app/components/primer/border_box_component.rb +1 -1
  18. data/app/components/primer/box_component.rb +3 -2
  19. data/app/components/primer/button_component.html.erb +3 -9
  20. data/app/components/primer/button_component.rb +61 -28
  21. data/app/components/primer/button_group.rb +9 -15
  22. data/app/components/primer/clipboard_copy.rb +1 -1
  23. data/app/components/primer/close_button.rb +1 -1
  24. data/app/components/primer/component.rb +77 -0
  25. data/app/components/primer/counter_component.rb +1 -1
  26. data/app/components/primer/details_component.rb +1 -1
  27. data/app/components/primer/dropdown/menu.rb +1 -1
  28. data/app/components/primer/dropdown.html.erb +0 -1
  29. data/app/components/primer/dropdown.rb +2 -1
  30. data/app/components/primer/dropdown_menu_component.rb +1 -1
  31. data/app/components/primer/flash_component.rb +3 -2
  32. data/app/components/primer/flex_component.rb +16 -16
  33. data/app/components/primer/flex_item_component.rb +1 -1
  34. data/app/components/primer/hellip_button.rb +1 -1
  35. data/app/components/primer/hidden_text_expander.rb +1 -1
  36. data/app/components/primer/image.rb +3 -3
  37. data/app/components/primer/image_crop.rb +2 -1
  38. data/app/components/primer/label_component.rb +23 -13
  39. data/app/components/primer/layout_component.rb +1 -0
  40. data/app/components/primer/local_time.rb +1 -1
  41. data/app/components/primer/markdown.rb +1 -1
  42. data/app/components/primer/menu_component.rb +2 -1
  43. data/app/components/primer/navigation/tab_component.rb +1 -0
  44. data/app/components/primer/octicon_component.rb +4 -2
  45. data/app/components/primer/octicon_symbols_component.rb +2 -2
  46. data/app/components/primer/popover_component.rb +3 -3
  47. data/app/components/primer/progress_bar_component.rb +7 -6
  48. data/app/components/primer/spinner_component.html.erb +4 -7
  49. data/app/components/primer/spinner_component.rb +1 -1
  50. data/app/components/primer/subhead_component.rb +3 -1
  51. data/app/components/primer/tab_container_component.rb +1 -1
  52. data/app/components/primer/time_ago_component.rb +1 -1
  53. data/app/components/primer/timeline_item_component.rb +4 -3
  54. data/app/components/primer/tooltip.rb +1 -0
  55. data/app/lib/primer/octicon/cache.rb +4 -10
  56. data/lib/primer/classify/utilities.rb +17 -44
  57. data/lib/primer/classify/utilities.yml +298 -68
  58. data/lib/primer/classify.rb +92 -178
  59. data/lib/primer/view_components/engine.rb +1 -0
  60. data/lib/primer/view_components/linters/argument_mappers/button.rb +4 -4
  61. data/lib/primer/view_components/linters/blankslate_api_migration.rb +11 -5
  62. data/lib/primer/view_components/version.rb +1 -1
  63. data/lib/rubocop/cop/primer/deprecated_arguments.rb +1 -1
  64. data/lib/rubocop/cop/primer/deprecated_button_arguments.rb +51 -0
  65. data/lib/rubocop/cop/primer/deprecated_label_schemes.rb +68 -0
  66. data/lib/rubocop/cop/primer/deprecated_layout_component.rb +30 -0
  67. data/lib/rubocop/cop/primer/primer_octicon.rb +1 -3
  68. data/lib/tasks/custom_utilities.yml +298 -0
  69. data/lib/tasks/docs.rake +1 -1
  70. data/lib/tasks/utilities.rake +21 -4
  71. data/static/arguments.yml +16 -7
  72. data/static/classes.yml +19 -18
  73. data/static/constants.json +25 -15
  74. metadata +10 -12
  75. data/app/components/primer/auto_complete/auto_complete.d.ts +0 -1
  76. data/app/components/primer/auto_complete/auto_complete.js +0 -1
  77. data/app/components/primer/auto_complete/auto_component.d.ts +0 -1
  78. data/app/components/primer/auto_complete/auto_component.js +0 -1
  79. data/lib/primer/classify/cache.rb +0 -109
  80. data/lib/primer/classify/flex.rb +0 -111
@@ -9,9 +9,10 @@ module Primer
9
9
  PRELOADED_ICONS = [:alert, :check, :"chevron-down", :paste, :clock, :"dot-fill", :info, :"kebab-horizontal", :link, :lock, :mail, :pencil, :plus, :question, :repo, :search, :"shield-lock", :star, :trash, :x].freeze
10
10
 
11
11
  class << self
12
- def get_key(**kwargs)
13
- correct_key_args?(**kwargs)
14
- kwargs.hash
12
+ def get_key(symbol:, size:, width: nil, height: nil)
13
+ attrs = { symbol: symbol, size: size, width: width, height: height }
14
+ attrs.compact!
15
+ attrs.hash
15
16
  end
16
17
 
17
18
  def read(key)
@@ -37,13 +38,6 @@ module Primer
37
38
  def preload!
38
39
  PRELOADED_ICONS.each { |icon| Primer::OcticonComponent.new(icon: icon) }
39
40
  end
40
-
41
- private
42
-
43
- def correct_key_args?(symbol:, size:, width: nil, height: nil)
44
- # This method does nothing but will raise an ArgumentError if the
45
- # wrong args are passed.
46
- end
47
41
  end
48
42
  end
49
43
  end
@@ -16,21 +16,8 @@ module Primer
16
16
  )
17
17
  ).freeze
18
18
  # rubocop:enable Security/YAMLLoad
19
- BREAKPOINTS = ["", "-sm", "-md", "-lg", "-xl"].freeze
20
19
 
21
- # Replacements for some classnames that end up being a different argument key
22
- REPLACEMENT_KEYS = {
23
- "^anim" => "animation",
24
- "^v-align" => "vertical_align",
25
- "^d" => "display",
26
- "^wb" => "word_break",
27
- "^v" => "visibility",
28
- "^width" => "w",
29
- "^height" => "h",
30
- "^color-bg" => "bg",
31
- "^color-border" => "border_color",
32
- "^color-fg" => "color"
33
- }.freeze
20
+ BREAKPOINTS = ["", "-sm", "-md", "-lg", "-xl"].freeze
34
21
 
35
22
  SUPPORTED_KEY_CACHE = Hash.new { |h, k| h[k] = !UTILITIES[k].nil? }
36
23
  BREAKPOINT_INDEX_CACHE = Hash.new { |h, k| h[k] = BREAKPOINTS.index(k) }
@@ -145,36 +132,6 @@ module Primer
145
132
  end.join(", ")
146
133
  end
147
134
 
148
- private
149
-
150
- def find_selector(selector)
151
- key = infer_selector_key(selector)
152
- value_hash = UTILITIES[key]
153
-
154
- return nil if value_hash.blank?
155
-
156
- # Each value hash will also contain an array of classnames for breakpoints
157
- # Key argument `0`, classes `[ "mr-0", "mr-sm-0", "mr-md-0", "mr-lg-0", "mr-xl-0" ]`
158
- value_hash.each do |key_argument, classnames|
159
- # Skip each value hash until we get one with the selector
160
- next unless classnames.include?(selector)
161
-
162
- # Return [:mr, 0, 1]
163
- # has index of classname, so we can match it up with responsvie array `mr: [nil, 0]`
164
- return [key, key_argument, classnames.index(selector)]
165
- end
166
-
167
- nil
168
- end
169
-
170
- def infer_selector_key(selector)
171
- REPLACEMENT_KEYS.each do |k, v|
172
- return v.to_sym if selector.match?(Regexp.new(k))
173
- end
174
-
175
- selector.split("-").first.to_sym
176
- end
177
-
178
135
  def validate(key, val, breakpoint)
179
136
  unless supported_key?(key)
180
137
  raise ArgumentError, "#{key} is not a valid Primer utility key" if validate_class_names?
@@ -191,11 +148,27 @@ module Primer
191
148
  unless supported_value?(key, val)
192
149
  raise ArgumentError, "#{val} is not a valid value for :#{key}. Use one of #{mappings(key)}" if validate_class_names?
193
150
 
151
+ return nil if [true, false].include?(val)
152
+
194
153
  return "#{key.to_s.dasherize}-#{val.to_s.dasherize}"
195
154
  end
196
155
 
197
156
  nil
198
157
  end
158
+
159
+ private
160
+
161
+ def find_selector(selector)
162
+ # Build hash indexed on the selector for fast lookup.
163
+ @selector_cache ||= UTILITIES.each_with_object({}) do |(keyword, argument_w_selectors), dict|
164
+ argument_w_selectors.each do |argument, selectors|
165
+ selectors.each_with_index do |css_selector, index|
166
+ dict[css_selector] = [keyword, argument, index]
167
+ end
168
+ end
169
+ end
170
+ @selector_cache[selector]
171
+ end
199
172
  end
200
173
  end
201
174
  end
@@ -47,38 +47,6 @@
47
47
  - color-fg-on-emphasis
48
48
  :inherit:
49
49
  - color-fg-inherit
50
- :text_primary:
51
- - color-text-primary
52
- :text_secondary:
53
- - color-text-secondary
54
- :text_tertiary:
55
- - color-text-tertiary
56
- :text_link:
57
- - color-text-link
58
- :text_success:
59
- - color-text-success
60
- :text_warning:
61
- - color-text-warning
62
- :text_danger:
63
- - color-text-danger
64
- :text_inverse:
65
- - color-text-inverse
66
- :text_white:
67
- - color-text-white
68
- :icon_primary:
69
- - color-icon-primary
70
- :icon_secondary:
71
- - color-icon-secondary
72
- :icon_tertiary:
73
- - color-icon-tertiary
74
- :icon_info:
75
- - color-icon-info
76
- :icon_danger:
77
- - color-icon-danger
78
- :icon_success:
79
- - color-icon-success
80
- :icon_warning:
81
- - color-icon-warning
82
50
  :bg:
83
51
  :default:
84
52
  - color-bg-default
@@ -118,30 +86,6 @@
118
86
  - color-bg-sponsors
119
87
  :sponsors_emphasis:
120
88
  - color-bg-sponsors-emphasis
121
- :canvas:
122
- - color-bg-canvas
123
- :canvas_inverse:
124
- - color-bg-canvas-inverse
125
- :canvas_inset:
126
- - color-bg-canvas-inset
127
- :primary:
128
- - color-bg-primary
129
- :secondary:
130
- - color-bg-secondary
131
- :tertiary:
132
- - color-bg-tertiary
133
- :info:
134
- - color-bg-info
135
- :info_inverse:
136
- - color-bg-info-inverse
137
- :danger_inverse:
138
- - color-bg-danger-inverse
139
- :success_inverse:
140
- - color-bg-success-inverse
141
- :warning:
142
- - color-bg-warning
143
- :warning_inverse:
144
- - color-bg-warning-inverse
145
89
  :border_color:
146
90
  :default:
147
91
  - color-border-default
@@ -177,18 +121,6 @@
177
121
  - color-border-sponsors
178
122
  :sponsors_emphasis:
179
123
  - color-border-sponsors-emphasis
180
- :primary:
181
- - color-border-primary
182
- :secondary:
183
- - color-border-secondary
184
- :tertiary:
185
- - color-border-tertiary
186
- :inverse:
187
- - color-border-inverse
188
- :info:
189
- - color-border-info
190
- :warning:
191
- - color-border-warning
192
124
  :position:
193
125
  :static:
194
126
  - position-static
@@ -1545,3 +1477,301 @@
1545
1477
  - col-md-12
1546
1478
  - col-lg-12
1547
1479
  - col-xl-12
1480
+ :font_size:
1481
+ '00':
1482
+ - f00
1483
+ 1:
1484
+ - f1
1485
+ 2:
1486
+ - f2
1487
+ 3:
1488
+ - f3
1489
+ 4:
1490
+ - f4
1491
+ 5:
1492
+ - f5
1493
+ 6:
1494
+ - f6
1495
+ :small:
1496
+ - text-small
1497
+ :normal:
1498
+ - text-normal
1499
+ :top:
1500
+ 0:
1501
+ - top-0
1502
+ false:
1503
+ - top-0
1504
+ :bottom:
1505
+ 0:
1506
+ - bottom-0
1507
+ false:
1508
+ - bottom-0
1509
+ :left:
1510
+ 0:
1511
+ - left-0
1512
+ false:
1513
+ - left-0
1514
+ :right:
1515
+ 0:
1516
+ - right-0
1517
+ false:
1518
+ - right-0
1519
+ :underline:
1520
+ true:
1521
+ - text-underline
1522
+ false:
1523
+ - no-underline
1524
+ :font_family:
1525
+ :mono:
1526
+ - text-mono
1527
+ :font_style:
1528
+ :italic:
1529
+ - text-italic
1530
+ :text_transform:
1531
+ :uppercase:
1532
+ - text-uppercase
1533
+ :text_align:
1534
+ :right:
1535
+ - text-right
1536
+ :left:
1537
+ - text-left
1538
+ :center:
1539
+ - text-center
1540
+ :font_weight:
1541
+ :light:
1542
+ - text-light
1543
+ :normal:
1544
+ - text-normal
1545
+ :bold:
1546
+ - text-bold
1547
+ :semibold:
1548
+ - text-semibold
1549
+ :emphasized:
1550
+ - text-emphasized
1551
+ :box_shadow:
1552
+ true:
1553
+ - color-shadow-small
1554
+ :small:
1555
+ - color-shadow-small
1556
+ :medium:
1557
+ - color-shadow-medium
1558
+ :large:
1559
+ - color-shadow-large
1560
+ :extra_large:
1561
+ - color-shadow-extra-large
1562
+ :none:
1563
+ - box-shadow-none
1564
+ false:
1565
+ - box-shadow-none
1566
+ :border:
1567
+ :left:
1568
+ - border-left
1569
+ :top:
1570
+ - border-top
1571
+ :bottom:
1572
+ - border-bottom
1573
+ :right:
1574
+ - border-right
1575
+ :y:
1576
+ - border-y
1577
+ :x:
1578
+ - border-x
1579
+ true:
1580
+ - border
1581
+ 0:
1582
+ - border-0
1583
+ false:
1584
+ - border-0
1585
+ :dashed:
1586
+ - border-dashed
1587
+ :border_top:
1588
+ 0:
1589
+ - border-top-0
1590
+ :border_bottom:
1591
+ 0:
1592
+ - border-bottom-0
1593
+ :border_left:
1594
+ 0:
1595
+ - border-left-0
1596
+ :border_right:
1597
+ 0:
1598
+ - border-right-0
1599
+ :border_radius:
1600
+ 0:
1601
+ - rounded-0
1602
+ 1:
1603
+ - rounded-1
1604
+ 2:
1605
+ - rounded-2
1606
+ 3:
1607
+ - rounded-3
1608
+ :justify_content:
1609
+ :flex_start:
1610
+ - flex-justify-start
1611
+ - flex-sm-justify-start
1612
+ - flex-md-justify-start
1613
+ - flex-lg-justify-start
1614
+ - flex-xl-justify-start
1615
+ :flex_end:
1616
+ - flex-justify-end
1617
+ - flex-sm-justify-end
1618
+ - flex-md-justify-end
1619
+ - flex-lg-justify-end
1620
+ - flex-xl-justify-end
1621
+ :center:
1622
+ - flex-justify-center
1623
+ - flex-sm-justify-center
1624
+ - flex-md-justify-center
1625
+ - flex-lg-justify-center
1626
+ - flex-xl-justify-center
1627
+ :space_between:
1628
+ - flex-justify-between
1629
+ - flex-sm-justify-between
1630
+ - flex-md-justify-between
1631
+ - flex-lg-justify-between
1632
+ - flex-xl-justify-between
1633
+ :space_around:
1634
+ - flex-justify-around
1635
+ - flex-sm-justify-around
1636
+ - flex-md-justify-around
1637
+ - flex-lg-justify-around
1638
+ - flex-xl-justify-around
1639
+ :align_items:
1640
+ :flex_start:
1641
+ - flex-items-start
1642
+ - flex-sm-items-start
1643
+ - flex-md-items-start
1644
+ - flex-lg-items-start
1645
+ - flex-xl-items-start
1646
+ :flex_end:
1647
+ - flex-items-end
1648
+ - flex-sm-items-end
1649
+ - flex-md-items-end
1650
+ - flex-lg-items-end
1651
+ - flex-xl-items-end
1652
+ :center:
1653
+ - flex-items-center
1654
+ - flex-sm-items-center
1655
+ - flex-md-items-center
1656
+ - flex-lg-items-center
1657
+ - flex-xl-items-center
1658
+ :baseline:
1659
+ - flex-items-baseline
1660
+ - flex-sm-items-baseline
1661
+ - flex-md-items-baseline
1662
+ - flex-lg-items-baseline
1663
+ - flex-xl-items-baseline
1664
+ :stretch:
1665
+ - flex-items-stretch
1666
+ - flex-sm-items-stretch
1667
+ - flex-md-items-stretch
1668
+ - flex-lg-items-stretch
1669
+ - flex-xl-items-stretch
1670
+ :flex_wrap:
1671
+ :wrap:
1672
+ - flex-wrap
1673
+ - flex-sm-wrap
1674
+ - flex-md-wrap
1675
+ - flex-lg-wrap
1676
+ - flex-xl-wrap
1677
+ :nowrap:
1678
+ - flex-nowrap
1679
+ - flex-sm-nowrap
1680
+ - flex-md-nowrap
1681
+ - flex-lg-nowrap
1682
+ - flex-xl-nowrap
1683
+ :reverse:
1684
+ - flex-wrap-reverse
1685
+ - flex-sm-wrap-reverse
1686
+ - flex-md-wrap-reverse
1687
+ - flex-lg-wrap-reverse
1688
+ - flex-xl-wrap-reverse
1689
+ :direction:
1690
+ :column:
1691
+ - flex-column
1692
+ - flex-sm-column
1693
+ - flex-md-column
1694
+ - flex-lg-column
1695
+ - flex-xl-column
1696
+ :column_reverse:
1697
+ - flex-column-reverse
1698
+ - flex-sm-column-reverse
1699
+ - flex-md-column-reverse
1700
+ - flex-lg-column-reverse
1701
+ - flex-xl-column-reverse
1702
+ :row:
1703
+ - flex-row
1704
+ - flex-sm-row
1705
+ - flex-md-row
1706
+ - flex-lg-row
1707
+ - flex-xl-row
1708
+ :row_reverse:
1709
+ - flex-row-reverse
1710
+ - flex-sm-row-reverse
1711
+ - flex-md-row-reverse
1712
+ - flex-lg-row-reverse
1713
+ - flex-xl-row-reverse
1714
+ :flex:
1715
+ 1:
1716
+ - flex-1
1717
+ - flex-sm-1
1718
+ - flex-md-1
1719
+ - flex-lg-1
1720
+ - flex-xl-1
1721
+ :auto:
1722
+ - flex-auto
1723
+ - flex-sm-auto
1724
+ - flex-md-auto
1725
+ - flex-lg-auto
1726
+ - flex-xl-auto
1727
+ :align_self:
1728
+ :auto:
1729
+ - flex-self-auto
1730
+ - flex-sm-self-auto
1731
+ - flex-md-self-auto
1732
+ - flex-lg-self-auto
1733
+ - flex-xl-self-auto
1734
+ :start:
1735
+ - flex-self-start
1736
+ - flex-sm-self-start
1737
+ - flex-md-self-start
1738
+ - flex-lg-self-start
1739
+ - flex-xl-self-start
1740
+ :end:
1741
+ - flex-self-end
1742
+ - flex-sm-self-end
1743
+ - flex-md-self-end
1744
+ - flex-lg-self-end
1745
+ - flex-xl-self-end
1746
+ :center:
1747
+ - flex-self-center
1748
+ - flex-sm-self-center
1749
+ - flex-md-self-center
1750
+ - flex-lg-self-center
1751
+ - flex-xl-self-center
1752
+ :baseline:
1753
+ - flex-self-baseline
1754
+ - flex-sm-self-baseline
1755
+ - flex-md-self-baseline
1756
+ - flex-lg-self-baseline
1757
+ - flex-xl-self-baseline
1758
+ :stretch:
1759
+ - flex-self-stretch
1760
+ - flex-sm-self-stretch
1761
+ - flex-md-self-stretch
1762
+ - flex-lg-self-stretch
1763
+ - flex-xl-self-stretch
1764
+ :flex_grow:
1765
+ 0:
1766
+ - flex-grow-0
1767
+ - flex-sm-grow-0
1768
+ - flex-md-grow-0
1769
+ - flex-lg-grow-0
1770
+ - flex-xl-grow-0
1771
+ :flex_shrink:
1772
+ 0:
1773
+ - flex-shrink-0
1774
+ - flex-sm-shrink-0
1775
+ - flex-md-shrink-0
1776
+ - flex-lg-shrink-0
1777
+ - flex-xl-shrink-0