optics_view_components 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -1
  3. data/Gemfile +4 -2
  4. data/Gemfile.lock +187 -1
  5. data/README.md +11 -1
  6. data/Rakefile +3 -1
  7. data/app/components/optics/application_view_component.rb +117 -0
  8. data/app/components/optics/application_view_component_preview.rb +7 -0
  9. data/app/components/optics/button/component.rb +57 -0
  10. data/app/components/optics/button/preview.rb +34 -0
  11. data/app/components/optics/icon/component.rb +59 -0
  12. data/app/components/optics/icon/preview.rb +33 -0
  13. data/demo/.ruby-version +1 -0
  14. data/demo/Gemfile +20 -0
  15. data/demo/Gemfile.lock +194 -0
  16. data/demo/Procfile.dev +2 -0
  17. data/demo/README.md +24 -0
  18. data/demo/Rakefile +8 -0
  19. data/demo/app/assets/builds/.keep +0 -0
  20. data/demo/app/assets/config/manifest.js +3 -0
  21. data/demo/app/assets/images/.keep +0 -0
  22. data/demo/app/assets/stylesheets/application.sass.scss +2 -0
  23. data/demo/app/controllers/application_controller.rb +4 -0
  24. data/demo/app/controllers/concerns/.keep +0 -0
  25. data/demo/app/controllers/home_controller.rb +5 -0
  26. data/demo/app/helpers/application_helper.rb +4 -0
  27. data/demo/app/javascript/application.js +3 -0
  28. data/demo/app/javascript/controllers/application.js +9 -0
  29. data/demo/app/javascript/controllers/index.js +11 -0
  30. data/demo/app/views/home/index.html.erb +3 -0
  31. data/demo/app/views/layouts/application.html.erb +15 -0
  32. data/demo/bin/bundle +113 -0
  33. data/demo/bin/dev +8 -0
  34. data/demo/bin/importmap +5 -0
  35. data/demo/bin/rails +6 -0
  36. data/demo/bin/rake +6 -0
  37. data/demo/bin/setup +35 -0
  38. data/demo/config/application.rb +36 -0
  39. data/demo/config/boot.rb +6 -0
  40. data/demo/config/cable.yml +10 -0
  41. data/demo/config/credentials.yml.enc +1 -0
  42. data/demo/config/database.yml +25 -0
  43. data/demo/config/environment.rb +7 -0
  44. data/demo/config/environments/development.rb +63 -0
  45. data/demo/config/environments/production.rb +89 -0
  46. data/demo/config/environments/test.rb +59 -0
  47. data/demo/config/importmap.rb +9 -0
  48. data/demo/config/initializers/assets.rb +14 -0
  49. data/demo/config/initializers/content_security_policy.rb +26 -0
  50. data/demo/config/initializers/filter_parameter_logging.rb +10 -0
  51. data/demo/config/initializers/inflections.rb +17 -0
  52. data/demo/config/initializers/permissions_policy.rb +12 -0
  53. data/demo/config/locales/en.yml +33 -0
  54. data/demo/config/puma.rb +45 -0
  55. data/demo/config/routes.rb +8 -0
  56. data/demo/config/storage.yml +34 -0
  57. data/demo/config.ru +8 -0
  58. data/demo/lib/assets/.keep +0 -0
  59. data/demo/lib/tasks/.keep +0 -0
  60. data/demo/log/.keep +0 -0
  61. data/demo/package.json +9 -0
  62. data/demo/public/404.html +67 -0
  63. data/demo/public/422.html +67 -0
  64. data/demo/public/500.html +66 -0
  65. data/demo/public/favicon.ico +0 -0
  66. data/demo/yarn.lock +157 -0
  67. data/lib/optics/view_components/engine.rb +19 -0
  68. data/lib/optics/view_components/version.rb +1 -1
  69. data/lib/optics/view_components.rb +4 -2
  70. metadata +155 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d8a939a59793e3f27065ac5cddadd809131961428f67f06d37e4be3f1e308ee
4
- data.tar.gz: d239ad7523f2e891a1659d0d5fc84b27ba01a6c46eef684196171d185bdf52d5
3
+ metadata.gz: 4a96cbd214ce4d3eb339e032c1c04ccc3435751f2618e5b41f9175114fd8e7de
4
+ data.tar.gz: 5d7edae41972ec1d189827dcdb71bdf0859cd26c7164f2de992ba282fc37df95
5
5
  SHA512:
6
- metadata.gz: 39847ffae1cc6c7c0d90625f1c247dd78b2037e6862145eb4185f34999c02028651dd44385465c521b40c207cffa8fcc260b0ef14ae4b9b72af0f15544c0c233
7
- data.tar.gz: 29b8bb26b211e60be644e7fb9e4548dff55ce39bbe4d1d9cc6aa7385421d08d39b63fbd1dd3e4fb143f46a2d9e703b7741b7f897de3d753c301d8da6bcbd3d9a
6
+ metadata.gz: 9dc9e7910cdd85f698f9080704e2b16f5b8bc38e78509ddca578d7c8a4b35f9df810b06a04d6f19fe51471a81baaad88f9518a45d2091956c074117b042eaf04
7
+ data.tar.gz: fa393926ee1c68a2e14a6795f8b01c8a815aa0f324227e55df5df030e03afda1414c0cced29f4f632e56327ab5478e3925ff3315fecb3de8bc273f706a3e6ecb
data/.rubocop.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
- TargetRubyVersion: 2.6
3
+ SuggestExtensions: false
4
+ TargetRubyVersion: 3.1
data/Gemfile CHANGED
@@ -5,8 +5,10 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in optics_view_components.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rake', '~> 13.0'
8
+ gem 'rails', '~> 7.0'
9
9
 
10
+ gem 'bootsnap', require: false
11
+ gem 'rake', '~> 13.0'
10
12
  gem 'rspec', '~> 3.0'
11
-
12
13
  gem 'rubocop', '~> 1.21'
14
+ gem 'view_component'
data/Gemfile.lock CHANGED
@@ -1,17 +1,166 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- optics_view_components (0.1.0)
4
+ optics_view_components (0.1.1)
5
+ view_component (> 2.0, < 4.0)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ actioncable (7.0.4.3)
11
+ actionpack (= 7.0.4.3)
12
+ activesupport (= 7.0.4.3)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (7.0.4.3)
16
+ actionpack (= 7.0.4.3)
17
+ activejob (= 7.0.4.3)
18
+ activerecord (= 7.0.4.3)
19
+ activestorage (= 7.0.4.3)
20
+ activesupport (= 7.0.4.3)
21
+ mail (>= 2.7.1)
22
+ net-imap
23
+ net-pop
24
+ net-smtp
25
+ actionmailer (7.0.4.3)
26
+ actionpack (= 7.0.4.3)
27
+ actionview (= 7.0.4.3)
28
+ activejob (= 7.0.4.3)
29
+ activesupport (= 7.0.4.3)
30
+ mail (~> 2.5, >= 2.5.4)
31
+ net-imap
32
+ net-pop
33
+ net-smtp
34
+ rails-dom-testing (~> 2.0)
35
+ actionpack (7.0.4.3)
36
+ actionview (= 7.0.4.3)
37
+ activesupport (= 7.0.4.3)
38
+ rack (~> 2.0, >= 2.2.0)
39
+ rack-test (>= 0.6.3)
40
+ rails-dom-testing (~> 2.0)
41
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
42
+ actiontext (7.0.4.3)
43
+ actionpack (= 7.0.4.3)
44
+ activerecord (= 7.0.4.3)
45
+ activestorage (= 7.0.4.3)
46
+ activesupport (= 7.0.4.3)
47
+ globalid (>= 0.6.0)
48
+ nokogiri (>= 1.8.5)
49
+ actionview (7.0.4.3)
50
+ activesupport (= 7.0.4.3)
51
+ builder (~> 3.1)
52
+ erubi (~> 1.4)
53
+ rails-dom-testing (~> 2.0)
54
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
55
+ activejob (7.0.4.3)
56
+ activesupport (= 7.0.4.3)
57
+ globalid (>= 0.3.6)
58
+ activemodel (7.0.4.3)
59
+ activesupport (= 7.0.4.3)
60
+ activerecord (7.0.4.3)
61
+ activemodel (= 7.0.4.3)
62
+ activesupport (= 7.0.4.3)
63
+ activestorage (7.0.4.3)
64
+ actionpack (= 7.0.4.3)
65
+ activejob (= 7.0.4.3)
66
+ activerecord (= 7.0.4.3)
67
+ activesupport (= 7.0.4.3)
68
+ marcel (~> 1.0)
69
+ mini_mime (>= 1.1.0)
70
+ activesupport (7.0.4.3)
71
+ concurrent-ruby (~> 1.0, >= 1.0.2)
72
+ i18n (>= 1.6, < 2)
73
+ minitest (>= 5.1)
74
+ tzinfo (~> 2.0)
75
+ addressable (2.8.4)
76
+ public_suffix (>= 2.0.2, < 6.0)
9
77
  ast (2.4.2)
78
+ bootsnap (1.16.0)
79
+ msgpack (~> 1.2)
80
+ builder (3.2.4)
81
+ capybara (3.39.1)
82
+ addressable
83
+ matrix
84
+ mini_mime (>= 0.1.3)
85
+ nokogiri (~> 1.8)
86
+ rack (>= 1.6.0)
87
+ rack-test (>= 0.6.3)
88
+ regexp_parser (>= 1.5, < 3.0)
89
+ xpath (~> 3.2)
90
+ coderay (1.1.3)
91
+ concurrent-ruby (1.2.2)
92
+ crass (1.0.6)
93
+ date (3.3.3)
10
94
  diff-lcs (1.5.0)
95
+ erubi (1.12.0)
96
+ globalid (1.1.0)
97
+ activesupport (>= 5.0)
98
+ i18n (1.13.0)
99
+ concurrent-ruby (~> 1.0)
11
100
  json (2.6.3)
101
+ loofah (2.21.3)
102
+ crass (~> 1.0.2)
103
+ nokogiri (>= 1.12.0)
104
+ mail (2.8.1)
105
+ mini_mime (>= 0.1.1)
106
+ net-imap
107
+ net-pop
108
+ net-smtp
109
+ marcel (1.0.2)
110
+ matrix (0.4.2)
111
+ method_source (1.0.0)
112
+ mini_mime (1.1.2)
113
+ minitest (5.18.0)
114
+ msgpack (1.7.1)
115
+ net-imap (0.3.4)
116
+ date
117
+ net-protocol
118
+ net-pop (0.1.2)
119
+ net-protocol
120
+ net-protocol (0.2.1)
121
+ timeout
122
+ net-smtp (0.3.3)
123
+ net-protocol
124
+ nio4r (2.5.9)
125
+ nokogiri (1.15.1-x86_64-linux)
126
+ racc (~> 1.4)
12
127
  parallel (1.23.0)
13
128
  parser (3.2.2.1)
14
129
  ast (~> 2.4.1)
130
+ pry (0.14.2)
131
+ coderay (~> 1.1)
132
+ method_source (~> 1.0)
133
+ public_suffix (5.0.1)
134
+ racc (1.6.2)
135
+ rack (2.2.7)
136
+ rack-test (2.1.0)
137
+ rack (>= 1.3)
138
+ rails (7.0.4.3)
139
+ actioncable (= 7.0.4.3)
140
+ actionmailbox (= 7.0.4.3)
141
+ actionmailer (= 7.0.4.3)
142
+ actionpack (= 7.0.4.3)
143
+ actiontext (= 7.0.4.3)
144
+ actionview (= 7.0.4.3)
145
+ activejob (= 7.0.4.3)
146
+ activemodel (= 7.0.4.3)
147
+ activerecord (= 7.0.4.3)
148
+ activestorage (= 7.0.4.3)
149
+ activesupport (= 7.0.4.3)
150
+ bundler (>= 1.15.0)
151
+ railties (= 7.0.4.3)
152
+ rails-dom-testing (2.0.3)
153
+ activesupport (>= 4.2.0)
154
+ nokogiri (>= 1.6)
155
+ rails-html-sanitizer (1.5.0)
156
+ loofah (~> 2.19, >= 2.19.1)
157
+ railties (7.0.4.3)
158
+ actionpack (= 7.0.4.3)
159
+ activesupport (= 7.0.4.3)
160
+ method_source
161
+ rake (>= 12.2)
162
+ thor (~> 1.0)
163
+ zeitwerk (~> 2.5)
15
164
  rainbow (3.1.1)
16
165
  rake (13.0.6)
17
166
  regexp_parser (2.8.0)
@@ -28,6 +177,14 @@ GEM
28
177
  rspec-mocks (3.12.5)
29
178
  diff-lcs (>= 1.2.0, < 2.0)
30
179
  rspec-support (~> 3.12.0)
180
+ rspec-rails (6.0.2)
181
+ actionpack (>= 6.1)
182
+ activesupport (>= 6.1)
183
+ railties (>= 6.1)
184
+ rspec-core (~> 3.12)
185
+ rspec-expectations (~> 3.12)
186
+ rspec-mocks (~> 3.12)
187
+ rspec-support (~> 3.12)
31
188
  rspec-support (3.12.0)
32
189
  rubocop (1.51.0)
33
190
  json (~> 2.3)
@@ -42,16 +199,45 @@ GEM
42
199
  rubocop-ast (1.28.1)
43
200
  parser (>= 3.2.1.0)
44
201
  ruby-progressbar (1.13.0)
202
+ sprockets (4.2.0)
203
+ concurrent-ruby (~> 1.0)
204
+ rack (>= 2.2.4, < 4)
205
+ sprockets-rails (3.4.2)
206
+ actionpack (>= 5.2)
207
+ activesupport (>= 5.2)
208
+ sprockets (>= 3.0.0)
209
+ thor (1.2.2)
210
+ timeout (0.3.2)
211
+ tzinfo (2.0.6)
212
+ concurrent-ruby (~> 1.0)
45
213
  unicode-display_width (2.4.2)
214
+ view_component (3.0.0)
215
+ activesupport (>= 5.2.0, < 8.0)
216
+ concurrent-ruby (~> 1.0)
217
+ method_source (~> 1.0)
218
+ websocket-driver (0.7.5)
219
+ websocket-extensions (>= 0.1.0)
220
+ websocket-extensions (0.1.5)
221
+ xpath (3.2.0)
222
+ nokogiri (~> 1.8)
223
+ zeitwerk (2.6.8)
46
224
 
47
225
  PLATFORMS
48
226
  x86_64-linux
49
227
 
50
228
  DEPENDENCIES
229
+ bootsnap
230
+ capybara
51
231
  optics_view_components!
232
+ pry
233
+ rails (~> 7.0)
52
234
  rake (~> 13.0)
53
235
  rspec (~> 3.0)
236
+ rspec-rails
54
237
  rubocop (~> 1.21)
238
+ sprockets
239
+ sprockets-rails
240
+ view_component
55
241
 
56
242
  BUNDLED WITH
57
243
  2.4.10
data/README.md CHANGED
@@ -14,7 +14,17 @@ If bundler is not being used to manage dependencies, install the gem by executin
14
14
 
15
15
  ## Usage
16
16
 
17
- TODO: Write usage instructions here
17
+ Add to `config/application.rb`:
18
+
19
+ ```
20
+ require 'optics/view_components'
21
+ require 'optics/view_components/engine'
22
+ ```
23
+
24
+ Use in a view:
25
+ ```
26
+ <%= render(Optics::Button::Component.new(label: 'Hello')) %>
27
+ ```
18
28
 
19
29
  ## Development
20
30
 
data/Rakefile CHANGED
@@ -7,6 +7,8 @@ RSpec::Core::RakeTask.new(:spec)
7
7
 
8
8
  require 'rubocop/rake_task'
9
9
 
10
- RuboCop::RakeTask.new
10
+ RuboCop::RakeTask.new(:rubocop) do |t|
11
+ t.options = ['--fail-level', 'warning', '--display-only-fail-level-offenses']
12
+ end
11
13
 
12
14
  task default: %i[spec rubocop]
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Optics
4
+ class ApplicationViewComponent < ViewComponent::Base
5
+ class_attribute :optional_attributes, default: {}
6
+ class_attribute :required_attributes, default: {}
7
+
8
+ class << self
9
+ # To allow DB queries, put this in the class definition:
10
+ # self.allow_db_queries = true
11
+ attr_accessor :allow_db_queries
12
+ alias allow_db_queries? allow_db_queries
13
+
14
+ def requires(parameter, default: nil)
15
+ required_attributes[parameter] = default
16
+
17
+ attr_reader parameter
18
+ end
19
+
20
+ def accepts(parameter, default: nil)
21
+ optional_attributes[parameter] = default
22
+
23
+ attr_reader parameter
24
+ end
25
+
26
+ def inherited(subclass)
27
+ subclass.optional_attributes = optional_attributes.dup
28
+ subclass.required_attributes = required_attributes.dup
29
+ super
30
+ end
31
+ end
32
+
33
+ def initialize(**attributes)
34
+ super
35
+
36
+ initialize_instance_variables(required_attributes, attributes) do |key, _default|
37
+ raise ArgumentError, "Missing keyword: :#{key}"
38
+ end
39
+
40
+ initialize_instance_variables(optional_attributes, attributes) do |key, default|
41
+ instance_variable_set("@#{key}", default)
42
+ end
43
+
44
+ @attributes = attributes.except(*optional_attributes.keys, *required_attributes.keys)
45
+ end
46
+
47
+ def class_for(name)
48
+ "c--#{identifier}--#{name}"
49
+ end
50
+
51
+ def container_class
52
+ "c--#{identifier}"
53
+ end
54
+
55
+ def class_names_for(*args)
56
+ class_names(*args).map { |name| class_for(name) }.join(' ')
57
+ end
58
+
59
+ # Inspired by https://github.com/primer/view_components/blob/v0.1.9/app/lib/primer/class_name_helper.rb#L9
60
+ def class_names(*args) # rubocop:disable Metrics/MethodLength
61
+ [].tap do |classes|
62
+ args.each do |class_name|
63
+ case class_name
64
+ when String
65
+ classes << class_name
66
+ when Hash
67
+ class_name.each do |key, val|
68
+ classes << key if val
69
+ end
70
+ end
71
+ end
72
+
73
+ classes.compact!
74
+ classes.uniq!
75
+ end
76
+ end
77
+
78
+ # Used by Stimulus. E.g. data-controller=identifier => data-controller='dynamic-form--field'
79
+ def identifier
80
+ @identifier ||= self.class.name.sub('::Component', '').underscore.gsub('_', '-').gsub('/', '--')
81
+ end
82
+
83
+ # Helper for Stimulus data attributes
84
+ def data_for(method:, target:)
85
+ data_method(method).merge(data_target(target))
86
+ end
87
+
88
+ # Helper for Stimulus controller method
89
+ def data_method(method, event: 'click')
90
+ { action: "#{event}->#{identifier}##{method}" }
91
+ end
92
+
93
+ # Helper for Stimulus controller target
94
+ def data_target(target)
95
+ { "#{identifier}": { target: } }
96
+ end
97
+
98
+ # Helper for Stimulus controller value
99
+ def data_values(values)
100
+ values.transform_keys do |key|
101
+ "#{identifier}-#{key}-value"
102
+ end
103
+ end
104
+
105
+ private
106
+
107
+ def initialize_instance_variables(configured_attributes, attributes)
108
+ configured_attributes.each do |key, default|
109
+ if attributes.key?(key)
110
+ instance_variable_set("@#{key}", attributes[key])
111
+ else
112
+ yield(key, default)
113
+ end
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Optics
4
+ class ApplicationViewComponentPreview < ViewComponent::Preview
5
+ include ApplicationHelper
6
+ end
7
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Optics
4
+ module Button
5
+ class Component < ApplicationViewComponent
6
+ SIZES = %w[small medium large].freeze
7
+ STYLES = %w[default primary secondary delete].freeze
8
+
9
+ renders_one :leading_icon, lambda { |name:, size: 'normal'|
10
+ Optics::Icon::Component.new(name:, size:)
11
+ }
12
+
13
+ accepts :label
14
+ accepts :border, default: true
15
+ accepts :icon, default: false
16
+ accepts :size, default: 'medium'
17
+ accepts :variant, default: 'default'
18
+ accepts :url
19
+
20
+ def call
21
+ build_button do
22
+ capture do
23
+ concat leading_icon
24
+ concat label
25
+ end
26
+ end
27
+ end
28
+
29
+ def build_button(&)
30
+ return link_to(url, class: classes, **@attributes, &) if url
31
+
32
+ tag.button(class: classes, **@attributes, &)
33
+ end
34
+
35
+ def button_class
36
+ return 'btn' if variant == 'default'
37
+
38
+ "btn-#{variant}"
39
+ end
40
+
41
+ def classes
42
+ class_names(
43
+ button_class,
44
+ size_class,
45
+ 'btn--icon': icon,
46
+ 'btn--no-border': !border
47
+ ).join(' ')
48
+ end
49
+
50
+ def size_class
51
+ return if size == 'medium'
52
+
53
+ "btn--#{size}"
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Optics
4
+ module Button
5
+ class Preview < ApplicationViewComponentPreview
6
+ # @param border toggle
7
+ # @param icon toggle
8
+ # @param id text
9
+ # @param label text
10
+ # @param size select {{ ::Button::Component::SIZES }}
11
+ # @param variant select {{ ::Button::Component::STYLES }}
12
+ # @param url text
13
+ def default( # rubocop:disable Metrics/ParameterLists
14
+ border: true,
15
+ icon: false,
16
+ id: nil,
17
+ label: 'Default',
18
+ size: 'normal',
19
+ variant: 'default',
20
+ url: nil
21
+ )
22
+ render(Button::Component.new(
23
+ border:,
24
+ icon:,
25
+ id:,
26
+ label:,
27
+ size:,
28
+ variant:,
29
+ url:
30
+ ))
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Optics
4
+ module Icon
5
+ class Component < ApplicationViewComponent
6
+ SIZES = %w[normal large x-large].freeze
7
+ WEIGHTS = %w[light normal semi-bold bold].freeze
8
+ EMPHASES = %w[low normal high].freeze
9
+
10
+ requires :name
11
+ accepts :data
12
+ accepts :emphasis, default: 'normal'
13
+ accepts :filled, default: false
14
+ accepts :size, default: 'normal'
15
+ accepts :title
16
+ accepts :weight, default: 'normal'
17
+
18
+ def call
19
+ content_tag(
20
+ :span,
21
+ class: classes,
22
+ 'aria-label': title,
23
+ title:,
24
+ data:
25
+ ) do
26
+ name
27
+ end
28
+ end
29
+
30
+ def classes
31
+ class_names(
32
+ 'material-symbols-outlined',
33
+ size_class,
34
+ weight_class,
35
+ emphasis_class,
36
+ 'icon--filled': filled
37
+ ).join(' ')
38
+ end
39
+
40
+ def size_class
41
+ return if size == 'normal'
42
+
43
+ "icon--#{size}"
44
+ end
45
+
46
+ def weight_class
47
+ return if weight == 'normal'
48
+
49
+ "icon--weight-#{weight}"
50
+ end
51
+
52
+ def emphasis_class
53
+ return if emphasis == 'normal'
54
+
55
+ "icon--#{emphasis}-emphasis"
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Optics
4
+ module Icon
5
+ class Preview < ViewComponent::Preview
6
+ # @param emphasis select {{ ::Icon::Component::EMPHASES }}
7
+ # @param filled toggle
8
+ # @param name
9
+ # @param size select {{ ::Icon::Component::SIZES }}
10
+ # @param title
11
+ # @param weight select {{ ::Icon::Component::WEIGHTS }}
12
+ def default( # rubocop:disable Metrics/ParameterLists
13
+ emphasis: 'normal',
14
+ filled: false,
15
+ name: 'settings',
16
+ size: 'normal',
17
+ title: nil,
18
+ weight: 'normal'
19
+ )
20
+ render(
21
+ Icon::Component.new(
22
+ emphasis:,
23
+ filled:,
24
+ name:,
25
+ size:,
26
+ title:,
27
+ weight:
28
+ )
29
+ )
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1 @@
1
+ 3.2.2
data/demo/Gemfile ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'rails', '~> 7.0.4', '>= 7.0.4.3'
6
+
7
+ gem 'bootsnap', require: false
8
+ gem 'cssbundling-rails', '~> 1.1'
9
+ gem 'puma', '~> 6.0'
10
+ gem 'sprockets-rails'
11
+
12
+ gem 'optics_view_components', path: '../'
13
+
14
+ group :development, :test do
15
+ gem 'debug', platforms: %i[mri mingw x64_mingw]
16
+ end
17
+
18
+ group :development do
19
+ gem 'web-console'
20
+ end