rolemodel-rails 2.4.1 → 2.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab7ce13bbc4227eedf045d0ce216b341049445daab3856f6b1d435f9799ffb53
4
- data.tar.gz: 5e5ce9316bd729ad8dd3bacf21d849aa274d9c870768fd6d7866f5cb2ae093bf
3
+ metadata.gz: fede781704d5a6d3f851f7dfafe1ab6a6d3be865609e009b6eaff8610c510656
4
+ data.tar.gz: ae9be94c16906a8ccb1bca770b9e6f385ef6f7e5e8e97a8c6c830502d567b145
5
5
  SHA512:
6
- metadata.gz: 74101aeb24869c8e84b1bb645573df9b95e97dfaf79d8c0d4d5980efafe46c64f414b9afded5511a9f4ae8bf0ee2339074e841710f08ba8314d996bd27a847db
7
- data.tar.gz: 6438c65a802314259eaa3c0ebe8cdd94301e95f3dc5a1e82c1809f2285c219f731953da1b1bfe45ac5c877273a958b7ba5cd17f6052d4500dd12302590f194c4
6
+ metadata.gz: bd3700f56df8e270774d4036bdebe388d86c37bcd190fb75f39022640dee94200ae7fe7eef23474a58c2c10e5aafea2809619bc34a6b6d4e86777798287b603b
7
+ data.tar.gz: d75431fd64ce262417b5468ae9af0f60ec5125d499c3f2bdbb91b6278c60fe20bb3d312bce1a3b85dc2882aef931968cc499a91e5e457579667248795e603ec6
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Executable Best Practices for Rails apps, based on RoleModel's best approaches
4
4
 
5
+ ![title image](title_image.png)
6
+
5
7
  Attempts to solve the pain of:
6
8
 
7
9
  * Setup of a new Rails app is harder than it needs to be
@@ -324,8 +326,8 @@ e.g.
324
326
  bin/new_generator testing/fantasitic_specs 'A Fantastic Testing Framework'
325
327
  ```
326
328
 
327
- We use the embeded Rails apps (`example_rails_current` & `example_rails_legacy`) to test generators against. They reference the rolemodel-rails gem by local path,
328
- so you can navigate into one of them and run your generator for immediate feedback while developing.
329
+ We use the embeded Rails apps (`example_rails_current` & `example_rails_legacy`) to test generators against. The specs run generators against a copy of `example_rails_current`.
330
+ `example_rails_legacy` references the rolemodel-rails gem by local path, so you can navigate into it and run your generator for immediate feedback while developing.
329
331
 
330
332
  ## Testing
331
333
 
@@ -10,3 +10,10 @@ Adds icon helper for handling icon generation using the provider of your choice.
10
10
 
11
11
  Run the generator with the `-i` option to install the IconBuilders themselves in your
12
12
  application's `lib/rolemodel/optics` directory.
13
+
14
+ ## SVG icons (for example, Hugeicons)
15
+
16
+ Use `--custom`. Put each SVG in `app/assets/images/icons/`, and `icon('name')` inlines it with
17
+ Optics' `.icon--svg` modifier (Optics 2.5+), so size, weight and emphasis modifiers apply. A subfolder
18
+ works as part of the name: `icon('duotone-rounded/home-01')`. Draw the SVGs with `currentColor`
19
+ so they follow the text color.
@@ -1,6 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # CustomIconBuilder is an IconBuilder that allows for custom SVG icons to be used in the application.
4
+ # It inlines app/assets/images/icons/<name>.svg, so any SVG set works, including Hugeicons:
5
+ #
6
+ # icon('home-01') # icons/home-01.svg
7
+ # icon('duotone-rounded/home-01') # icons/duotone-rounded/home-01.svg
4
8
  class Rolemodel::Optics::CustomIconBuilder < Rolemodel::Optics::IconBuilder
5
9
  def self.flash_icons
6
10
  {
@@ -15,28 +19,28 @@ class Rolemodel::Optics::CustomIconBuilder < Rolemodel::Optics::IconBuilder
15
19
  :span
16
20
  end
17
21
 
18
- # NOTE: This does not work with propshaft and the latest asset pipeline
19
- # We will need to find a way to make this work in Rails 8 with propshaft.
20
- def tag_contents # rubocop:disable Metrics/AbcSize
22
+ def tag_contents
21
23
  # Inspired by https://blog.cloud66.com/using-svgs-in-a-rails-stack
22
- asset = Rails.application.assets_manifest.find_sources(svg_path).first
24
+ source = svg_source
25
+ return "<!-- SVG #{svg_path} not found -->".html_safe if source.nil?
23
26
 
24
- if asset
25
- file = asset.source.force_encoding('UTF-8')
26
- doc = Nokogiri::HTML::DocumentFragment.parse file
27
- svg = doc.at_css 'svg'
28
- svg['class'] = options[:class] if options[:class].present?
27
+ # These SVG files can safely be marked html_safe since we created them and they are part of this app's code.
28
+ source.dup.force_encoding('UTF-8').html_safe
29
+ end
30
+
31
+ # Propshaft and Sprockets find assets differently.
32
+ def svg_source
33
+ assets = Rails.application.assets
34
+ if assets.respond_to?(:load_path)
35
+ assets.load_path.find(svg_path)&.content
29
36
  else
30
- doc = "<!-- SVG #{svg_path} not found -->"
37
+ Rails.application.assets_manifest.find_sources(svg_path).first&.source
31
38
  end
32
-
33
- # These SVG files can safely be marked html_safe since we created them and they are part of this app's code.
34
- raw doc
35
39
  end
36
40
 
37
41
  def tag_classes
38
42
  [
39
- 'custom-icons',
43
+ 'icon--svg',
40
44
  filled ? 'icon--filled' : '',
41
45
  weight == DEFAULT_WEIGHT ? '' : "icon--weight-#{weight}",
42
46
  emphasis == DEFAULT_EMPHASIS ? '' : "icon--#{emphasis}-emphasis"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rolemodel
4
- VERSION = '2.4.1'
4
+ VERSION = '2.5.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rolemodel-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - RoleModel Software Inc
@@ -459,7 +459,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
459
459
  - !ruby/object:Gem::Version
460
460
  version: '0'
461
461
  requirements: []
462
- rubygems_version: 4.0.3
462
+ rubygems_version: 4.0.20
463
463
  specification_version: 4
464
464
  summary: The RoleModel Way of building Rails apps.
465
465
  test_files: []