fontawesome_subsetter 0.1.8 → 0.1.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee1a96f695d2d8ba25bf3ef9cbc67a1904b7e1b2dc8253725e3a2a908e488fc4
4
- data.tar.gz: 3077455250275b5fffefa855d18339689f6858a1ace1f862cd60b490cda58c2b
3
+ metadata.gz: 33c3b2edc76b53a04844718df0b26cee93aed21d85db538f25f52fafe6453287
4
+ data.tar.gz: 963351cb3b73e82827ab710e27ceed76d3a4c034ef966025f6df386a13d6bb37
5
5
  SHA512:
6
- metadata.gz: c4f0c881d6cc89e17990f9e02c367e1028f4abdc7196bba424dfa2e417556744769d4fdb1000b4de9db05555352c2967d715db0fe555761df054bec6477de511
7
- data.tar.gz: 61bd9c7daad6fd89ce9d7e5dfec870868e6228e4153a47011e1d80bbac7558f4d1aeb3ab0173b8f98cec02455440b7cc79142ae4c229f1382f25ec76671fe689
6
+ metadata.gz: 0f503ad4e00f742e74a499341fde0cd4c837589ad95a57845f24a8a8723589ea44f7147d37df4179dbf3dc164badc382f84fb7fae3dddd0eeb40faa492ae4cdf
7
+ data.tar.gz: d4a51a28bd5bdd8a5c1499683def9dc88091a8bbd88b1668aa643e76fcdf318dcdde3216c3f67ebcb3a765d34d7d8aa371fe59008989cd288a0b9c937fdb2924
data/README.md CHANGED
@@ -103,6 +103,18 @@ FontawesomeSubsetter.configure do | config |
103
103
 
104
104
  # Custom SCSS template (optional — receives @styles hash, must return SCSS string)
105
105
  # config.scss_template = ->(styles) { "..." }
106
+
107
+ # Additional SCSS variables to inject into the `@use "variables" with (...)` block.
108
+ # Keys may be symbols/strings (with or without leading `$`). Values are raw SCSS.
109
+ # config.variables = {
110
+ # "fa-font-display" => "swap",
111
+ # "fa-css-prefix" => '"fa"'
112
+ # }
113
+
114
+ # Optional presentational FontAwesome SCSS partials to include. Defaults to `:all`.
115
+ # Available: "sizing", "widths", "list", "bordered", "animated", "rotated-flipped", "stacked"
116
+ # (Core partials — functions, mixins, core, icons — are always included.)
117
+ # config.features = ["animated"]
106
118
  end
107
119
  ```
108
120
 
@@ -234,28 +234,32 @@ module FontawesomeSubsetter
234
234
  private
235
235
 
236
236
  def default_scss_template(styles)
237
- <<-SCSS
237
+ extra_vars = FontawesomeSubsetter.configuration.variables || {}
238
+ extra_lines = extra_vars.map { | name, value | " #{ name.to_s.start_with?('$') ? name : "$#{ name }" }: #{ value }," }.join("\n")
238
239
 
240
+ icons = @styles.except("brands").values.reduce(Set.new) { | all_icons, style | all_icons.merge(style[:sass_icon_cache]) }.join(", ")
241
+ brand_icons = @styles["brands"][:sass_icon_cache].to_a.join(", ")
242
+ style_uses = styles.map { | s | "@use \"./vendor/fontawesome/scss/#{ s[:name] }.scss\";" }.join("\n")
243
+
244
+ features = FontawesomeSubsetter.configuration.features
245
+ enabled_features = features == :all ? Configuration::AVAILABLE_FEATURES : Array(features).map(&:to_s)
246
+ feature_uses = enabled_features.map { | f | "@use \"./vendor/fontawesome/scss/#{ f }\";" }.join("\n")
247
+
248
+ <<~SCSS
239
249
  // The custom importer strips populated $icons/$brand-icons maps from variables.scss in memory.
240
250
  @use "./vendor/fontawesome/scss/variables" with (
241
251
  $font-path: "webfonts",
242
- $icons: (#{ @styles.except("brands").values.reduce(Set.new) { | all_icons, style | all_icons.merge(style[:sass_icon_cache]) }.join(", ") }),
243
- $brand-icons: (#{ @styles["brands"][:sass_icon_cache].to_a.join(", ") }));
252
+ #{ extra_lines }
253
+ $icons: (#{ icons }),
254
+ $brand-icons: (#{ brand_icons }));
244
255
 
245
256
  @use "./vendor/fontawesome/scss/functions";
246
257
  @use "./vendor/fontawesome/scss/mixins";
247
258
  @use "./vendor/fontawesome/scss/core";
248
- // @use "./vendor/fontawesome/scss/sizing";
249
- // @use "./vendor/fontawesome/scss/widths";
250
- // @use "./vendor/fontawesome/scss/list";
251
- // @use "./vendor/fontawesome/scss/bordered";
252
- @use "./vendor/fontawesome/scss/animated";
253
- // @use "./vendor/fontawesome/scss/rotated-flipped";
254
- // @use "./vendor/fontawesome/scss/stacked";
259
+ #{ feature_uses }
255
260
  @use "./vendor/fontawesome/scss/icons";
256
261
 
257
- #{ styles.map { "@use \"./vendor/fontawesome/scss/#{ it[:name] }.scss\";" }.join("\n") }
258
-
262
+ #{ style_uses }
259
263
  SCSS
260
264
  end
261
265
 
@@ -1,5 +1,5 @@
1
1
  module FontawesomeSubsetter
2
2
 
3
- VERSION = "0.1.8"
3
+ VERSION = "0.1.9"
4
4
 
5
5
  end
@@ -22,12 +22,19 @@ module FontawesomeSubsetter
22
22
  class Configuration
23
23
 
24
24
  attr_accessor :meta_path, :fonts_dir, :build_dir, :scan_globs, :watch_paths,
25
- :watch_file_type_regex, :icon_regex, :scss_template, :styles
25
+ :watch_file_type_regex, :icon_regex, :scss_template, :styles,
26
+ :variables, :features
27
+
28
+ # Optional presentational FontAwesome SCSS partials.
29
+ # Core partials (functions, mixins, core, icons) are always included.
30
+ AVAILABLE_FEATURES = ["sizing", "widths", "list", "bordered", "animated", "rotated-flipped", "stacked"].freeze
26
31
 
27
32
  def initialize
28
33
  @scan_globs = ["app/views/**/*.slim", "app/helpers/**/*.rb"]
29
34
  @watch_file_type_regex = /\.(slim|rb)$/
30
35
  @icon_regex = /icon\(\s*:(?<prefix>fas|far|fab|fad|fal|fat)\s*,\s*:(?<icon>[\w_\-]+)\b/
36
+ @variables = {}
37
+ @features = :all
31
38
  end
32
39
 
33
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fontawesome_subsetter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - 16554289+optimuspwnius@users.noreply.github.com