optics_view_components 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a96cbd214ce4d3eb339e032c1c04ccc3435751f2618e5b41f9175114fd8e7de
4
- data.tar.gz: 5d7edae41972ec1d189827dcdb71bdf0859cd26c7164f2de992ba282fc37df95
3
+ metadata.gz: c7e868dbff72f35b8979429a0a6ab9cb6690f1ed46ff5d4ca3d658aaec5fcd68
4
+ data.tar.gz: 5200729a15f3672e8afb161e7437909f8ec55b8d6c4e189ba9d44349e5e58111
5
5
  SHA512:
6
- metadata.gz: 9dc9e7910cdd85f698f9080704e2b16f5b8bc38e78509ddca578d7c8a4b35f9df810b06a04d6f19fe51471a81baaad88f9518a45d2091956c074117b042eaf04
7
- data.tar.gz: fa393926ee1c68a2e14a6795f8b01c8a815aa0f324227e55df5df030e03afda1414c0cced29f4f632e56327ab5478e3925ff3315fecb3de8bc273f706a3e6ecb
6
+ metadata.gz: 21c5922dabf1c062f5b184d8650ac9b0616df298770d519a87abbd577ba237ff039d0fa1759df5172cc8a39e21018a2013ac6f65a97fb7eeceeaa64edf779f20
7
+ data.tar.gz: '06913b6c9d7d9718ec86f6d9f81f648fa0a9ed2bc19e1a73eef0c614c0995f958c105bcf29a8074358ee221c153e2af12fda0d991a7dadc66bcbb98f81e52299'
data/Gemfile CHANGED
@@ -8,6 +8,7 @@ gemspec
8
8
  gem 'rails', '~> 7.0'
9
9
 
10
10
  gem 'bootsnap', require: false
11
+ gem 'lookbook'
11
12
  gem 'rake', '~> 13.0'
12
13
  gem 'rspec', '~> 3.0'
13
14
  gem 'rubocop', '~> 1.21'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- optics_view_components (0.1.1)
4
+ optics_view_components (0.1.3)
5
5
  view_component (> 2.0, < 4.0)
6
6
 
7
7
  GEM
@@ -90,17 +90,33 @@ GEM
90
90
  coderay (1.1.3)
91
91
  concurrent-ruby (1.2.2)
92
92
  crass (1.0.6)
93
+ css_parser (1.14.0)
94
+ addressable
93
95
  date (3.3.3)
94
96
  diff-lcs (1.5.0)
95
97
  erubi (1.12.0)
96
98
  globalid (1.1.0)
97
99
  activesupport (>= 5.0)
100
+ htmlbeautifier (1.4.2)
101
+ htmlentities (4.3.4)
98
102
  i18n (1.13.0)
99
103
  concurrent-ruby (~> 1.0)
100
104
  json (2.6.3)
101
105
  loofah (2.21.3)
102
106
  crass (~> 1.0.2)
103
107
  nokogiri (>= 1.12.0)
108
+ lookbook (2.0.3)
109
+ activemodel
110
+ css_parser
111
+ htmlbeautifier (~> 1.3)
112
+ htmlentities (~> 4.3.4)
113
+ marcel (~> 1.0)
114
+ railties (>= 5.0)
115
+ redcarpet (~> 3.5)
116
+ rouge (>= 3.26, < 5.0)
117
+ view_component (>= 2.0)
118
+ yard (~> 0.9.25)
119
+ zeitwerk (~> 2.5)
104
120
  mail (2.8.1)
105
121
  mini_mime (>= 0.1.1)
106
122
  net-imap
@@ -163,8 +179,10 @@ GEM
163
179
  zeitwerk (~> 2.5)
164
180
  rainbow (3.1.1)
165
181
  rake (13.0.6)
182
+ redcarpet (3.6.0)
166
183
  regexp_parser (2.8.0)
167
184
  rexml (3.2.5)
185
+ rouge (4.1.1)
168
186
  rspec (3.12.0)
169
187
  rspec-core (~> 3.12.0)
170
188
  rspec-expectations (~> 3.12.0)
@@ -220,6 +238,7 @@ GEM
220
238
  websocket-extensions (0.1.5)
221
239
  xpath (3.2.0)
222
240
  nokogiri (~> 1.8)
241
+ yard (0.9.34)
223
242
  zeitwerk (2.6.8)
224
243
 
225
244
  PLATFORMS
@@ -228,6 +247,7 @@ PLATFORMS
228
247
  DEPENDENCIES
229
248
  bootsnap
230
249
  capybara
250
+ lookbook
231
251
  optics_view_components!
232
252
  pry
233
253
  rails (~> 7.0)
data/README.md CHANGED
@@ -17,7 +17,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
17
17
  Add to `config/application.rb`:
18
18
 
19
19
  ```
20
- require 'optics/view_components'
20
+ require 'view_component'
21
21
  require 'optics/view_components/engine'
22
22
  ```
23
23
 
@@ -26,6 +26,15 @@ Use in a view:
26
26
  <%= render(Optics::Button::Component.new(label: 'Hello')) %>
27
27
  ```
28
28
 
29
+ ### Add previews to your application's [Lookbook](https://github.com/ViewComponent/lookbook)
30
+
31
+ Add to `config/application.rb`:
32
+
33
+ ```
34
+ config.lookbook.component_paths << Optics::ViewComponents::Engine.root.join('app/components/optics')
35
+ config.view_component.preview_paths << Optics::ViewComponents::Engine.root.join('previews')
36
+ ```
37
+
29
38
  ## Development
30
39
 
31
40
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/demo/Gemfile CHANGED
@@ -9,6 +9,7 @@ gem 'cssbundling-rails', '~> 1.1'
9
9
  gem 'puma', '~> 6.0'
10
10
  gem 'sprockets-rails'
11
11
 
12
+ gem 'lookbook'
12
13
  gem 'optics_view_components', path: '../'
13
14
 
14
15
  group :development, :test do
data/demo/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- optics_view_components (0.1.1)
4
+ optics_view_components (0.1.3)
5
5
  view_component (> 2.0, < 4.0)
6
6
 
7
7
  GEM
@@ -72,12 +72,16 @@ GEM
72
72
  i18n (>= 1.6, < 2)
73
73
  minitest (>= 5.1)
74
74
  tzinfo (~> 2.0)
75
+ addressable (2.8.4)
76
+ public_suffix (>= 2.0.2, < 6.0)
75
77
  bindex (0.8.1)
76
78
  bootsnap (1.16.0)
77
79
  msgpack (~> 1.2)
78
80
  builder (3.2.4)
79
81
  concurrent-ruby (1.2.2)
80
82
  crass (1.0.6)
83
+ css_parser (1.14.0)
84
+ addressable
81
85
  cssbundling-rails (1.1.2)
82
86
  railties (>= 6.0.0)
83
87
  date (3.3.3)
@@ -87,6 +91,8 @@ GEM
87
91
  erubi (1.12.0)
88
92
  globalid (1.1.0)
89
93
  activesupport (>= 5.0)
94
+ htmlbeautifier (1.4.2)
95
+ htmlentities (4.3.4)
90
96
  i18n (1.13.0)
91
97
  concurrent-ruby (~> 1.0)
92
98
  io-console (0.6.0)
@@ -95,6 +101,18 @@ GEM
95
101
  loofah (2.21.3)
96
102
  crass (~> 1.0.2)
97
103
  nokogiri (>= 1.12.0)
104
+ lookbook (2.0.3)
105
+ activemodel
106
+ css_parser
107
+ htmlbeautifier (~> 1.3)
108
+ htmlentities (~> 4.3.4)
109
+ marcel (~> 1.0)
110
+ railties (>= 5.0)
111
+ redcarpet (~> 3.5)
112
+ rouge (>= 3.26, < 5.0)
113
+ view_component (>= 2.0)
114
+ yard (~> 0.9.25)
115
+ zeitwerk (~> 2.5)
98
116
  mail (2.8.1)
99
117
  mini_mime (>= 0.1.1)
100
118
  net-imap
@@ -117,6 +135,7 @@ GEM
117
135
  nio4r (2.5.9)
118
136
  nokogiri (1.15.1-x86_64-linux)
119
137
  racc (~> 1.4)
138
+ public_suffix (5.0.1)
120
139
  puma (6.2.2)
121
140
  nio4r (~> 2.0)
122
141
  racc (1.6.2)
@@ -150,8 +169,10 @@ GEM
150
169
  thor (~> 1.0)
151
170
  zeitwerk (~> 2.5)
152
171
  rake (13.0.6)
172
+ redcarpet (3.6.0)
153
173
  reline (0.3.3)
154
174
  io-console (~> 0.5)
175
+ rouge (4.1.1)
155
176
  sprockets (4.2.0)
156
177
  concurrent-ruby (~> 1.0)
157
178
  rack (>= 2.2.4, < 4)
@@ -175,6 +196,7 @@ GEM
175
196
  websocket-driver (0.7.5)
176
197
  websocket-extensions (>= 0.1.0)
177
198
  websocket-extensions (0.1.5)
199
+ yard (0.9.34)
178
200
  zeitwerk (2.6.8)
179
201
 
180
202
  PLATFORMS
@@ -184,6 +206,7 @@ DEPENDENCIES
184
206
  bootsnap
185
207
  cssbundling-rails (~> 1.1)
186
208
  debug
209
+ lookbook
187
210
  optics_view_components!
188
211
  puma (~> 6.0)
189
212
  rails (~> 7.0.4, >= 7.0.4.3)
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Component Preview</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <%= csrf_meta_tags %>
7
+ <%= csp_meta_tag %>
8
+ <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
9
+ </head>
10
+
11
+ <body style="padding: var(--op-space-medium);">
12
+ <%= yield %>
13
+ </body>
14
+ </html>
@@ -22,15 +22,11 @@ Bundler.require(*Rails.groups)
22
22
 
23
23
  module Demo
24
24
  class Application < Rails::Application
25
- # Initialize configuration defaults for originally generated Rails version.
26
25
  config.load_defaults 7.0
27
26
 
28
- # Configuration for the application, engines, and railties goes here.
29
- #
30
- # These settings can be overridden in specific environments using the files
31
- # in config/environments, which are processed later.
32
- #
33
- # config.time_zone = "Central Time (US & Canada)"
34
- # config.eager_load_paths << Rails.root.join("extras")
27
+ config.view_component.default_preview_layout = 'preview'
28
+ config.view_component.preview_paths << Rails.root.join('..', 'previews')
29
+ config.lookbook.project_name = "Optics ViewComponents v#{Optics::ViewComponents::VERSION}"
30
+ config.lookbook.component_paths = [Optics::ViewComponents::Engine.root.join('app', 'components')]
35
31
  end
36
32
  end
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Rails.application.routes.draw do
4
- # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
5
-
6
- # Defines the root path route ("/")
4
+ get '/', to: redirect('/lookbook/')
5
+ mount Lookbook::Engine, at: '/lookbook'
7
6
  root 'home#index'
8
7
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Optics
4
4
  module ViewComponents
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.3'
6
6
  end
7
7
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Optics
4
+ class ButtonPreview < ViewComponent::Preview
5
+ # @param border toggle
6
+ # @param icon toggle
7
+ # @param id text
8
+ # @param label text
9
+ # @param size select {{ Optics::Button::Component::SIZES }}
10
+ # @param variant select {{ Optics::Button::Component::STYLES }}
11
+ # @param url text
12
+ def default( # rubocop:disable Metrics/ParameterLists
13
+ border: true,
14
+ icon: false,
15
+ id: nil,
16
+ label: 'Default',
17
+ size: 'normal',
18
+ variant: 'default',
19
+ url: nil
20
+ )
21
+ render(Optics::Button::Component.new(
22
+ border:,
23
+ icon:,
24
+ id:,
25
+ label:,
26
+ size:,
27
+ variant:,
28
+ url:
29
+ ))
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Optics
4
+ class IconPreview < ViewComponent::Preview
5
+ # @param emphasis select {{ Optics::Icon::Component::EMPHASES }}
6
+ # @param filled toggle
7
+ # @param name
8
+ # @param size select {{ Optics::Icon::Component::SIZES }}
9
+ # @param title
10
+ # @param weight select {{ Optics::Icon::Component::WEIGHTS }}
11
+ def default( # rubocop:disable Metrics/ParameterLists
12
+ emphasis: 'normal',
13
+ filled: false,
14
+ name: 'settings',
15
+ size: 'normal',
16
+ title: nil,
17
+ weight: 'normal'
18
+ )
19
+ render(
20
+ Optics::Icon::Component.new(
21
+ emphasis:,
22
+ filled:,
23
+ name:,
24
+ size:,
25
+ title:,
26
+ weight:
27
+ )
28
+ )
29
+ end
30
+ end
31
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: optics_view_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reed Law
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-22 00:00:00.000000000 Z
11
+ date: 2023-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: view_component
@@ -118,9 +118,7 @@ files:
118
118
  - app/components/optics/application_view_component.rb
119
119
  - app/components/optics/application_view_component_preview.rb
120
120
  - app/components/optics/button/component.rb
121
- - app/components/optics/button/preview.rb
122
121
  - app/components/optics/icon/component.rb
123
- - app/components/optics/icon/preview.rb
124
122
  - demo/.ruby-version
125
123
  - demo/Gemfile
126
124
  - demo/Gemfile.lock
@@ -140,6 +138,7 @@ files:
140
138
  - demo/app/javascript/controllers/index.js
141
139
  - demo/app/views/home/index.html.erb
142
140
  - demo/app/views/layouts/application.html.erb
141
+ - demo/app/views/layouts/preview.html.erb
143
142
  - demo/bin/bundle
144
143
  - demo/bin/dev
145
144
  - demo/bin/importmap
@@ -178,6 +177,8 @@ files:
178
177
  - lib/optics/view_components.rb
179
178
  - lib/optics/view_components/engine.rb
180
179
  - lib/optics/view_components/version.rb
180
+ - previews/optics/button_preview.rb
181
+ - previews/optics/icon_preview.rb
181
182
  - sig/optics_view_components.rbs
182
183
  homepage: https://github.com/RoleModel/optics_view_components
183
184
  licenses:
@@ -1,34 +0,0 @@
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
@@ -1,33 +0,0 @@
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