lookbook 0.9.8 → 1.0.0.beta.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +43 -849
  3. data/app/assets/lookbook/css/lookbook.css +55 -0
  4. data/app/assets/lookbook/css/themes/blue.css +42 -0
  5. data/app/assets/lookbook/css/themes/indigo.css +42 -0
  6. data/app/assets/lookbook/css/themes/zinc.css +42 -0
  7. data/app/assets/lookbook/css/{tooltip_theme.css → tooltip.css} +14 -8
  8. data/app/assets/lookbook/js/app.js +64 -63
  9. data/app/assets/lookbook/js/components/clipboard.js +47 -0
  10. data/app/assets/lookbook/js/components/tooltip.js +30 -0
  11. data/app/assets/lookbook/js/config.js +7 -4
  12. data/app/assets/lookbook/js/helpers/build.js +22 -0
  13. data/app/assets/lookbook/js/helpers/dom.js +45 -0
  14. data/app/assets/lookbook/js/helpers/layout.js +21 -0
  15. data/app/assets/lookbook/js/helpers/request.js +16 -0
  16. data/app/assets/lookbook/js/helpers/string.js +11 -0
  17. data/app/assets/lookbook/js/lib/socket.js +4 -3
  18. data/app/assets/lookbook/js/lib/tippy.js +8 -0
  19. data/app/assets/lookbook/js/lookbook.js +61 -0
  20. data/app/assets/lookbook/js/plugins/logger.js +39 -0
  21. data/app/assets/lookbook/js/stores/filter.js +2 -2
  22. data/app/assets/lookbook/js/stores/inspector.js +22 -16
  23. data/app/assets/lookbook/js/stores/layout.js +101 -5
  24. data/app/assets/lookbook/js/stores/nav.js +17 -16
  25. data/app/assets/lookbook/js/stores/pages.js +4 -2
  26. data/app/assets/lookbook/js/stores/settings.js +7 -0
  27. data/app/assets/lookbook/js/stores/workbench.js +29 -0
  28. data/app/components/lookbook/button/component.html.erb +28 -0
  29. data/app/components/lookbook/button/component.js +55 -0
  30. data/app/components/lookbook/button/component.rb +39 -0
  31. data/app/components/lookbook/button_group/component.html.erb +3 -0
  32. data/app/components/lookbook/button_group/component.rb +18 -0
  33. data/app/components/lookbook/code/component.css +57 -0
  34. data/app/components/lookbook/code/component.html.erb +10 -0
  35. data/app/components/lookbook/code/component.js +3 -0
  36. data/app/components/lookbook/code/component.rb +56 -0
  37. data/app/components/lookbook/code/highlight_github_light.css +217 -0
  38. data/app/components/lookbook/component.rb +41 -0
  39. data/app/components/lookbook/copy_button/component.html.erb +11 -0
  40. data/app/components/lookbook/copy_button/component.js +16 -0
  41. data/app/components/lookbook/copy_button/component.rb +23 -0
  42. data/app/components/lookbook/dimensions_display/component.html.erb +10 -0
  43. data/app/components/lookbook/dimensions_display/component.js +30 -0
  44. data/app/components/lookbook/dimensions_display/component.rb +18 -0
  45. data/app/components/lookbook/embed/component.html.erb +50 -0
  46. data/app/components/lookbook/embed/component.js +39 -0
  47. data/app/components/lookbook/embed/component.rb +22 -0
  48. data/app/components/lookbook/filter/component.html.erb +17 -0
  49. data/app/components/lookbook/filter/component.js +21 -0
  50. data/app/components/lookbook/filter/component.rb +15 -0
  51. data/app/components/lookbook/header/component.html.erb +79 -0
  52. data/app/components/lookbook/header/component.rb +9 -0
  53. data/app/components/lookbook/icon/component.css +11 -0
  54. data/app/components/lookbook/icon/component.html.erb +5 -0
  55. data/app/components/lookbook/icon/component.js +5 -0
  56. data/app/components/lookbook/icon/component.rb +23 -0
  57. data/app/components/lookbook/nav/component.html.erb +33 -0
  58. data/app/components/lookbook/nav/component.js +52 -0
  59. data/app/components/lookbook/nav/component.rb +37 -0
  60. data/app/components/lookbook/nav/item/component.html.erb +23 -0
  61. data/app/components/lookbook/nav/item/component.js +66 -0
  62. data/app/components/lookbook/nav/item/component.rb +84 -0
  63. data/app/components/lookbook/params_editor/component.html.erb +3 -0
  64. data/app/components/lookbook/params_editor/component.js +12 -0
  65. data/app/components/lookbook/params_editor/component.rb +11 -0
  66. data/app/components/lookbook/params_editor/field/component.html.erb +50 -0
  67. data/app/components/lookbook/params_editor/field/component.js +36 -0
  68. data/app/components/lookbook/params_editor/field/component.rb +41 -0
  69. data/app/components/lookbook/prose/component.css +12 -0
  70. data/app/components/lookbook/prose/component.html.erb +3 -0
  71. data/app/components/lookbook/prose/component.rb +26 -0
  72. data/app/components/lookbook/split_layout/component.html.erb +13 -0
  73. data/app/components/lookbook/split_layout/component.js +151 -0
  74. data/app/components/lookbook/split_layout/component.rb +11 -0
  75. data/app/components/lookbook/tabbed_content/component.html.erb +5 -0
  76. data/app/components/lookbook/tabbed_content/component.js +21 -0
  77. data/app/components/lookbook/tabbed_content/component.rb +20 -0
  78. data/app/components/lookbook/tabbed_content/section/component.html.erb +8 -0
  79. data/app/components/lookbook/tabbed_content/section/component.rb +9 -0
  80. data/app/components/lookbook/tabs/component.css +8 -0
  81. data/app/components/lookbook/tabs/component.html.erb +14 -0
  82. data/app/components/lookbook/tabs/component.js +107 -0
  83. data/app/components/lookbook/tabs/component.rb +30 -0
  84. data/app/components/lookbook/tabs/dropdown_tab/component.html.erb +14 -0
  85. data/app/components/lookbook/tabs/dropdown_tab/component.rb +16 -0
  86. data/app/components/lookbook/tabs/tab/component.html.erb +18 -0
  87. data/app/components/lookbook/tabs/tab/component.rb +16 -0
  88. data/app/components/lookbook/tag_component.rb +29 -0
  89. data/app/components/lookbook/toolbar/component.css +16 -0
  90. data/app/components/lookbook/toolbar/component.html.erb +5 -0
  91. data/app/components/lookbook/toolbar/component.rb +26 -0
  92. data/app/components/lookbook/viewport/component.css +11 -0
  93. data/app/components/lookbook/viewport/component.html.erb +57 -0
  94. data/app/{assets/lookbook/js/components/preview-window.js → components/lookbook/viewport/component.js} +57 -14
  95. data/app/components/lookbook/viewport/component.rb +21 -0
  96. data/app/controllers/lookbook/application_controller.rb +16 -9
  97. data/app/controllers/lookbook/pages_controller.rb +18 -11
  98. data/app/controllers/lookbook/previews_controller.rb +62 -25
  99. data/app/helpers/lookbook/application_helper.rb +7 -3
  100. data/app/helpers/lookbook/component_helper.rb +22 -10
  101. data/app/helpers/lookbook/output_helper.rb +8 -4
  102. data/app/helpers/lookbook/page_helper.rb +13 -21
  103. data/app/views/layouts/lookbook/application.html.erb +76 -28
  104. data/app/views/layouts/lookbook/inspector.html.erb +7 -0
  105. data/app/views/layouts/lookbook/page.html.erb +53 -0
  106. data/app/views/layouts/lookbook/shell.html.erb +64 -0
  107. data/app/views/layouts/lookbook/skeleton.html.erb +27 -10
  108. data/app/views/layouts/lookbook/standalone.html.erb +5 -0
  109. data/app/views/lookbook/404.html.erb +15 -0
  110. data/app/views/lookbook/error.html.erb +34 -34
  111. data/app/views/lookbook/index.html.erb +11 -6
  112. data/app/views/lookbook/pages/show.html.erb +29 -93
  113. data/app/views/{layouts/lookbook → lookbook}/preview.html.erb +3 -5
  114. data/app/views/lookbook/previews/panels/_notes.html.erb +19 -25
  115. data/app/views/lookbook/previews/panels/_output.html.erb +7 -18
  116. data/app/views/lookbook/previews/panels/_params.html.erb +13 -15
  117. data/app/views/lookbook/previews/panels/_preview.html.erb +6 -52
  118. data/app/views/lookbook/previews/panels/_source.html.erb +7 -16
  119. data/app/views/lookbook/previews/show.html.erb +130 -24
  120. data/config/routes.rb +7 -7
  121. data/lib/lookbook/code_formatter.rb +37 -13
  122. data/lib/lookbook/collection.rb +19 -16
  123. data/lib/lookbook/config.rb +125 -0
  124. data/lib/lookbook/engine.rb +74 -87
  125. data/lib/lookbook/entity.rb +47 -0
  126. data/lib/lookbook/error.rb +1 -2
  127. data/lib/lookbook/features.rb +1 -1
  128. data/lib/lookbook/markdown.rb +3 -5
  129. data/lib/lookbook/page.rb +26 -43
  130. data/lib/lookbook/page_collection.rb +8 -0
  131. data/lib/lookbook/params.rb +14 -15
  132. data/lib/lookbook/parser.rb +4 -0
  133. data/lib/lookbook/preview.rb +16 -7
  134. data/lib/lookbook/preview_collection.rb +8 -0
  135. data/lib/lookbook/preview_controller.rb +6 -2
  136. data/lib/lookbook/preview_example.rb +5 -6
  137. data/lib/lookbook/preview_group.rb +4 -9
  138. data/lib/lookbook/{code_inspector.rb → source_inspector.rb} +2 -2
  139. data/lib/lookbook/theme.rb +22 -0
  140. data/lib/lookbook/utils.rb +11 -3
  141. data/lib/lookbook/version.rb +1 -1
  142. data/lib/lookbook.rb +4 -1
  143. data/lib/tasks/lookbook_tasks.rake +13 -1
  144. data/public/lookbook-assets/css/app.css +2340 -1
  145. data/public/lookbook-assets/css/app.css.map +11 -1
  146. data/public/lookbook-assets/css/lookbook.css +3040 -0
  147. data/public/lookbook-assets/css/lookbook.css.map +1 -0
  148. data/public/lookbook-assets/css/themes/blue.css +44 -0
  149. data/public/lookbook-assets/css/themes/blue.css.map +1 -0
  150. data/public/lookbook-assets/css/themes/indigo.css +44 -0
  151. data/public/lookbook-assets/css/themes/indigo.css.map +1 -0
  152. data/public/lookbook-assets/css/themes/zinc.css +44 -0
  153. data/public/lookbook-assets/css/themes/zinc.css.map +1 -0
  154. data/public/lookbook-assets/js/app.js +10861 -1
  155. data/public/lookbook-assets/js/app.js.map +2571 -1
  156. data/public/lookbook-assets/js/embed.js +895 -1
  157. data/public/lookbook-assets/js/embed.js.map +1 -1
  158. data/public/lookbook-assets/js/lookbook.js +13529 -0
  159. data/public/lookbook-assets/js/lookbook.js.map +1 -0
  160. metadata +128 -116
  161. data/app/assets/lookbook/css/app.css +0 -161
  162. data/app/assets/lookbook/css/code_theme.css +0 -214
  163. data/app/assets/lookbook/js/components/app.js +0 -55
  164. data/app/assets/lookbook/js/components/code.js +0 -5
  165. data/app/assets/lookbook/js/components/copy.js +0 -20
  166. data/app/assets/lookbook/js/components/embed.js +0 -89
  167. data/app/assets/lookbook/js/components/filter.js +0 -35
  168. data/app/assets/lookbook/js/components/inspector.js +0 -66
  169. data/app/assets/lookbook/js/components/nav-group.js +0 -47
  170. data/app/assets/lookbook/js/components/nav-item.js +0 -29
  171. data/app/assets/lookbook/js/components/nav.js +0 -28
  172. data/app/assets/lookbook/js/components/page-tabs.js +0 -9
  173. data/app/assets/lookbook/js/components/page.js +0 -25
  174. data/app/assets/lookbook/js/components/param.js +0 -34
  175. data/app/assets/lookbook/js/components/sidebar.js +0 -18
  176. data/app/assets/lookbook/js/components/sizes.js +0 -16
  177. data/app/assets/lookbook/js/components/splitter.js +0 -25
  178. data/app/assets/lookbook/js/components/tabs.js +0 -52
  179. data/app/assets/lookbook/js/lib/split.js +0 -15
  180. data/app/assets/lookbook/js/stores/sidebar.js +0 -26
  181. data/app/views/layouts/lookbook/basic.html.erb +0 -7
  182. data/app/views/lookbook/components/_branding.html.erb +0 -8
  183. data/app/views/lookbook/components/_code.html.erb +0 -17
  184. data/app/views/lookbook/components/_copy_button.html.erb +0 -11
  185. data/app/views/lookbook/components/_drawer.html.erb +0 -112
  186. data/app/views/lookbook/components/_embed.html.erb +0 -39
  187. data/app/views/lookbook/components/_errors.html.erb +0 -13
  188. data/app/views/lookbook/components/_filter.html.erb +0 -18
  189. data/app/views/lookbook/components/_header.html.erb +0 -6
  190. data/app/views/lookbook/components/_icon.html.erb +0 -5
  191. data/app/views/lookbook/components/_nav.html.erb +0 -16
  192. data/app/views/lookbook/components/_nav_collection.html.erb +0 -5
  193. data/app/views/lookbook/components/_nav_group.html.erb +0 -14
  194. data/app/views/lookbook/components/_nav_item.html.erb +0 -24
  195. data/app/views/lookbook/components/_nav_page.html.erb +0 -22
  196. data/app/views/lookbook/components/_nav_preview.html.erb +0 -13
  197. data/app/views/lookbook/components/_not_found.html.erb +0 -11
  198. data/app/views/lookbook/components/_param.html.erb +0 -21
  199. data/app/views/lookbook/components/_preview.html.erb +0 -77
  200. data/app/views/lookbook/components/_sidebar.html.erb +0 -69
  201. data/app/views/lookbook/pages/not_found.html.erb +0 -15
  202. data/app/views/lookbook/previews/error.html.erb +0 -1
  203. data/app/views/lookbook/previews/inputs/_select.html.erb +0 -7
  204. data/app/views/lookbook/previews/inputs/_text.html.erb +0 -8
  205. data/app/views/lookbook/previews/inputs/_textarea.html.erb +0 -8
  206. data/app/views/lookbook/previews/inputs/_toggle.html.erb +0 -13
  207. data/app/views/lookbook/previews/not_found.html.erb +0 -23
data/README.md CHANGED
@@ -1,887 +1,81 @@
1
- <div align="center">
2
- <h1>Lookbook</h1>
1
+ # Lookbook v1.0 [beta]
3
2
 
4
- <h3>🚨 These are legacy docs for Lookbook v0.9.x releases! 🚨</h3>
5
- <p>For docs on the <strong>latest Lookbook v1.x</strong> releases see the <a href="https://lookbook.build">Lookbook docs site</a> or the <a href="https://github.com/allmarkedup/lookbook">main branch</a> of this repo.</p>
6
- </div>
3
+ This is the **beta development** branch for Lookbook v1.0.
7
4
 
8
- ---
9
-
10
- <div align="center">
11
-
12
- <p><a href="#installing">Installing</a> • <a href="#previews">Previews</a> • <a href="#pages">Pages</a> • <a href="#deployment">Deployment</a> • <a href="#config">Config</a></p>
13
- </div>
14
-
15
- ---
16
-
17
- **Lookbook gives [ViewComponent](http://viewcomponent.org/)-based projects a _ready-to-go_ development UI for navigating, inspecting and interacting with component previews.**
18
-
19
- It uses (and extends) the native [ViewComponent preview functionality](https://viewcomponent.org/guide/previews.html), so you don't need to learn a new DSL or create any extra files to get up and running.
20
-
21
- Lookbook uses [RDoc/Yard-style comment tags](#annotating-preview-files) to extend the capabilities of ViewComponent's previews whilst maintaining compatability with the standard preview class format, so you can add or remove Lookbook at any time without having to rework your code.
22
-
23
- ![Lookbook UI](.github/assets/lookbook_screenshot.png)
24
-
25
-
26
-
27
-
28
- ## Installing
29
-
30
- ### 1. Add as a dependency
31
-
32
- Add Lookbook to your `Gemfile` somewhere **after** the ViewComponent gem. For example:
33
-
34
- ```ruby
35
- gem "view_component"
36
- gem "lookbook", "~> 0.9.7"
37
- ```
38
-
39
- ### 2. Mount the Lookbook engine
40
-
41
- You then need to mount the Lookbook engine (at a path of your choosing) in your `routes.rb` file:
42
-
43
- ```ruby
44
- Rails.application.routes.draw do
45
- if Rails.env.development?
46
- mount Lookbook::Engine, at: "/lookbook"
47
- end
48
- end
49
- ```
50
-
51
- The `at` property determines the root URL that the Lookbook UI will be served at.
52
-
53
- Then you can start your app as normal and navigate to `http://localhost:3000/lookbook` (or whatever mount path you specified) to view your component previews in the Lookbook UI.
54
-
55
-
56
- <h2 id="previews">Previews</h2>
57
-
58
- You don't need to do anything special to see your ViewComponent previews and examples in Lookbook - just create them as normal and they'll automatically appear in the Lookbook UI. Preview templates, custom layouts and even bespoke [preview controllers](https://viewcomponent.org/guide/previews.html#configuring-preview-controller) should all work as you would expect.
59
-
60
- > If you are new to ViewComponent development, checkout the ViewComponent [documentation](https://viewcomponent.org/guide/) on how to get started developing your components and [creating previews](https://viewcomponent.org/guide/previews.html).
61
-
62
- ### Annotating preview files
63
-
64
- Lookbook parses [Yard-style comment tags](https://rubydoc.info/gems/yard/file/docs/Tags.md) in your preview classes to customise and extend the standard ViewComponent preview experience:
65
-
66
- ```ruby
67
- # @label Basic Button
68
- # @display bg_color "#fff"
69
- class ButtonComponentPreview < ViewComponent::Preview
70
-
71
- # Primary button
72
- # ---------------
73
- # This is the button style you should use for most things.
74
- #
75
- # @label Primary
76
- def default
77
- render ButtonComponent.new do
78
- "Click me"
79
- end
80
- end
81
-
82
- # Button with icon
83
- # ----------------
84
- # This example uses dynamic preview parameters
85
- # which can be edited live in the Lookbook UI
86
- #
87
- # @param text
88
- # @param icon select [heart, cog, alert]
89
- def icon(text: "Spread the love", icon: "heart")
90
- render ButtonComponent.new(icon: icon) do
91
- text
92
- end
93
- end
94
-
95
- # Inverted button
96
- # ---------------
97
- # For light-on-dark screens
98
- #
99
- # @display bg_color "#000"
100
- def secondary
101
- render ButtonComponent.new(style: :inverted) do
102
- "Click me"
103
- end
104
- end
105
-
106
- # Unicorn button
107
- # ---------------
108
- # This button style is still a **work in progress**.
109
- #
110
- # @hidden
111
- def secondary
112
- render ButtonComponent.new do
113
- "Click me"
114
- end
115
- end
116
-
117
- # @!group More examples
118
-
119
- def short_text
120
- render ButtonComponent.new do
121
- "Go"
122
- end
123
- end
124
-
125
- def long_text
126
- render ButtonComponent.new do
127
- "Click here to do this thing because it's the best way to do it"
128
- end
129
- end
130
-
131
- def emoji_text
132
- render ButtonComponent.new do
133
- "👀📗"
134
- end
135
- end
136
-
137
- # @!endgroup
138
-
139
- end
140
- ```
141
-
142
- **Tags** are just strings identified by their `@` prefix - for example `@hidden`. Tags are always placed in a comment above the relevant preview class or example method.
143
-
144
- The following Lookbook-specific tags are available for use:
145
-
146
- * [`@label`](#label-tag)
147
- * [`@display`](#display-tag)
148
- * [`@!group ... @!endgroup`](#group-tag)
149
- * [`@hidden`](#hidden-tag)
150
- * [`@param`](#param-tag)
151
-
152
- <h3 id="label-tag">🏷 @label</h3>
153
-
154
- Used to replace the auto-generated navigation label for the item with `<text>`.
155
-
156
- ```ruby
157
- @label <text>
158
- ```
159
-
160
- > Available for preview classes & example methods.
161
-
162
- ```ruby
163
- # @label Preview Label
164
- class FooComponentPreview < ViewComponent::Preview
165
-
166
- # @label Example Label
167
- def default
168
- end
169
- end
170
- ```
171
-
172
- <h3 id="display-tag">🏷 @display</h3>
173
-
174
- The `@display` tag lets you pass custom parameters to your preview layout so that the component preview can be customised on a per-example basis.
175
-
176
- ```ruby
177
- # @display bg_color "#eee"
178
- class FooComponentPreview < ViewComponent::Preview
179
-
180
- # @display max_width 500px
181
- # @display wrapper true
182
- def default
183
- end
184
- end
185
- ```
186
-
187
- The `@display` tag can be applied at the preview (class) or at the example (method) level, and takes the following format:
188
-
189
- ```ruby
190
- @display <key> <value>
191
- ```
192
-
193
- - `<key>` must be a valid Ruby hash key name, without quotes or spaces
194
- - `<value>` will be parsed using the [Ruby YAML parser](https://yaml.org/YAML_for_ruby.html) to resolve the value
195
-
196
- > Note: Ruby YAML does not (generally) require quoting of string values. However in some cases it _is_ required due to the presence of [indicator characters](https://yaml.org/YAML_for_ruby.html#indicators_in_strings) (such as `#`, `:` etc) - hence why the hex color code in the example above is surrounded by quotes. It's perfectly ok to quote all string values if you prefer.
197
-
198
- These display parameters can then be accessed via the `params` hash in your preview layout using `params[:lookbook][:display][<key>]`:
199
-
200
- ```html
201
- <!DOCTYPE html>
202
- <html style="background-color: <%= params[:lookbook][:display][:bg_color] %>">
203
- <head>
204
- <title>Preview Layout</title>
205
- </head>
206
- <body>
207
- <div style="max-width: <%= params[:lookbook][:display][:max_width] || '100%' %>">
208
- <% if params[:lookbook][:display][:wrapper] == true %>
209
- <div class="wrapper"><%= yield %></div>
210
- <% else %>
211
- <%= yield %>
212
- <% end %>
213
- </div>
214
- </body>
215
- </html>
216
- ```
217
-
218
- > By default ViewComponent will use your default application layout for displaying the rendered example. However it's often better to create a seperate layout that you can customise and use specifically for previewing your components. See the ViewComponent [preview docs](https://viewcomponent.org/guide/previews.html) for instructions on how to set that up.
219
-
220
- Any `@display` params set at the preview (class) level with be merged with those set on individual example methods.
221
-
222
- #### Global display params
223
-
224
- Global (fallback) display params can be defined via a configuration option:
225
-
226
- ```ruby
227
- # config/application.rb
228
- config.lookbook.preview_display_params = {
229
- bg_color: "#fff",
230
- max_width: "100%"
231
- }
232
- ```
233
-
234
- Globally defined display params will be available to all previews. Any preview or example-level `@display` values with the same name will take precedence and override a globally-set one.
235
-
236
- <h3 id="group-tag">🔖 `@!group ... @!endgroup`</h3>
237
-
238
- For smaller components, it can often make sense to render a set of preview examples in a single window, rather than representing them as individual items in the navigation which can start to look a bit cluttered.
239
-
240
- You can group a set of examples by wrapping them in `@!group <name>` / `@!endgroup` tags within your preview file:
241
-
242
- ```ruby
243
- class HeaderComponentPreview < ViewComponent::Preview
244
-
245
- def standard
246
- render Elements::HeaderComponent.new do
247
- "Standard header"
248
- end
249
- end
250
-
251
- # @!group Sizes
252
-
253
- def small
254
- render Elements::HeaderComponent.new(size: 12) do
255
- "Small header"
256
- end
257
- end
258
-
259
- def medium
260
- render Elements::HeaderComponent.new(size: 16) do
261
- "Small header"
262
- end
263
- end
264
-
265
- def big
266
- render Elements::HeaderComponent.new(size: 24) do
267
- "Small header"
268
- end
269
- end
270
-
271
- # @!endgroup
272
-
273
- end
274
- ```
275
-
276
- The example above would display the `Sizes` examples grouped together on a single page, rather than as indiviual items in the navigation:
277
-
278
- <img src=".github/assets/nav_group.png">
279
-
280
- You can have as many groups as you like within a single preview class, but each example can only belong to one group.
281
-
282
- <h3 id="hidden-tag">🏷 `@hidden`</h3>
283
-
284
- Used to temporarily exclude an item from the Lookbook navigation. The item will still be accessible via it's URL.
285
-
286
- Can be useful when a component (or a variant of a component) is still in development and is not ready to be shared with the wider team.
287
-
288
- > Available for both preview classes & example methods.
289
-
290
- ```ruby
291
- # @hidden
292
- class FooComponentPreview < ViewComponent::Preview
293
-
294
- # @hidden
295
- def default
296
- end
297
- end
298
- ```
299
-
300
- <h3 id="param-tag">@param</h3>
301
-
302
- The `@param` tag provides the ability to specify **editable preview parameters** which can be changed in the Lookbook UI in order to customise the rendered output on the fly, much like the [Controls (knobs) addon](https://storybook.js.org/addons/@storybook/addon-controls) for Storybook.
303
-
304
- Each `@param` will have an associated form field generated for it. The values for each field will be handled as [dynamic preview params](https://viewcomponent.org/guide/previews.html#:~:text=It%E2%80%99s%20also%20possible%20to%20set%20dynamic%20values%20from%20the%20params%20by%20setting%20them%20as%20arguments%3A) when rendering the example.
305
-
306
- The `@param` tag takes the following format:
307
-
308
- ```ruby
309
- @param <name> <input_type> <opts?>
310
- ```
311
-
312
- - `<name>` - name of the dynamic preview param
313
- - `<input_type>` - input field type to generate in the UI
314
- - `<opts?>` - YAML-encoded field options, used for some field types
315
-
316
- #### Input types
317
-
318
- The following **input field types** are available for use:
319
-
320
- 📝 **Text-style inputs** - Single line fields, useful for short strings of text or numbers.
321
-
322
- ```ruby
323
- @param <name> text
324
- @param <name> date
325
- @param <name> datetime-local
326
- @param <name> email
327
- @param <name> number
328
- @param <name> url
329
- @param <name> tel
330
- ```
331
-
332
- > The above types only differ in the validation constraints they impose on the input field.
333
-
334
- 📝 **Textarea** - Multi-line textarea field for longer-form content.
335
-
336
- ```ruby
337
- @param <name> textarea
338
- ```
339
-
340
- 📝 **Select box** - Dropdown select field for selecting from a list of known options.
341
-
342
- ```ruby
343
- @param <name> select <options>
344
- ```
345
-
346
- `<options>` should be a [YAML array](https://yaml.org/YAML_for_ruby.html#simple_inline_array) of options which must be formatted in the same style as the input for Rails' [`options_for_select`](https://apidock.com/rails/v6.0.0/ActionView/Helpers/FormOptionsHelper/options_for_select) helper:
347
-
348
- ```ruby
349
- # Basic options:
350
- # @param theme select [primary, secondary, danger]
351
-
352
- # With custom labels (each item itself an array of [label, value]):
353
- # @param theme select [[Primary theme, primary], [Secondary theme, secondary], [Danger theme, danger]]
354
-
355
- # With empty option (`~` in YAML)
356
- # @param theme select [~, primary, secondary, danger]
357
- ```
358
-
359
- > **Note**: In most cases YAML does not require quoting of strings, however if you are running into issues check out the [Ruby YAML docs](https://yaml.org/YAML_for_ruby.html) for a complete syntax reference.
360
-
361
- 📝 **Toggle** - On/off switch for toggling boolean values.
362
-
363
- ```ruby
364
- @param <name> toggle
365
- ```
366
-
367
- #### Default values
368
-
369
- Default values are specified as part of the preview example method parameters in the usual Ruby way:
370
-
371
- ```ruby
372
- def button(content: "Click me", theme: "primary", arrow: false)
373
- # ...
374
- end
375
- ```
376
-
377
- These will be used as the default values for the param fields.
378
-
379
- > Note that the default values are **not** evaluated at runtime, so you cannot use method calls to generate the defaults. Only static default values are supported.
380
-
381
- #### Type casting values
382
-
383
- Most dynamic param values are passed to the example method as strings, with the following exceptions:
384
-
385
- - `toggle` input - values are cast to booleans
386
- - `number` input - values are cast to integers
387
-
388
- In some cases, you may want to type cast the parameter value to something else (for example a `Symbol`) before using it when initializing the component.
389
-
390
- To help with this, a `type` option can be specified in the `@param` definition to automatically cast the dynamic value to a different type:
391
-
392
- ```ruby
393
- # @param <name> [<type>] <input_type> <opts?>
394
- ```
395
-
396
- In the example below, the value of the `theme` param (by default a string) will be automatically cast to a Symbol, ready for use in instantiating the component.
397
-
398
- ```ruby
399
- # @param theme [Symbol] select [primary, secondary, danger]
400
- def default(theme: :primary)
401
- render Elements::ButtonComponent.new(theme: theme) do
402
- "Click me"
403
- end
404
- end
405
- ```
406
-
407
- The supported types to cast to are:
408
-
409
- - `String` - *default for all except `toggle` inputs*
410
- - `Boolean` - *default for `toggle` inputs*
411
- - `Symbol`
412
- - `Date`
413
- - `DateTime`
414
- - `Integer`
415
- - `Float`
416
-
417
- The following structured types are also available but should be considered **experimental** - you may run into bugs!
418
-
419
- - `Hash` - *value string converted to Hash using the Ruby YAML parser*
420
- - `Array` - *value string converted to Array using the Ruby YAML parser*
421
-
422
- #### Full example:
423
-
424
- ```ruby
425
- class ButtonComponentPreview < ViewComponent::Preview
426
-
427
- # The params defined below will be editable in the UI:
428
- #
429
- # @param content text
430
- # @param theme select [primary, secondary, danger]
431
- # @param arrow toggle
432
- def default(content: "Click me", theme: "primary", arrow: true)
433
- render Elements::ButtonComponent.new(theme: theme, arrow: arrow) do
434
- content
435
- end
436
- end
437
-
438
- end
439
- ```
440
-
441
- <img src=".github/assets/dynamic_params.png">
442
-
443
- ### Adding notes
444
-
445
- All comment text other than tags will be treated as markdown and rendered in the **Notes** panel for that example in the Lookbook UI.
446
-
447
- ```ruby
448
- # @hidden
449
- class ProfileCardComponentPreview < ViewComponent::Preview
450
-
451
- # Profile Card
452
- # ------------
453
- # Use the default profile card component whenever you need to represent a user.
454
- def default
455
- end
456
- end
457
- ```
458
-
459
- ---
460
-
461
- <h2 id="pages">🚧 Documentation Pages [experimental]</h2>
462
-
463
- If you need to add more long-form documentation to live alongside your component previews you can do so using Lookbook's markdown-powered `pages` system.
464
-
465
- > ⚠️ This feature is currently flagged as an **experimental** feature which requires [feature opt-in](#experimental-features) to use. Its API and implementation may change before it is released.
466
- >
467
- > To enable support for pages in your project, add `config.lookbook.experimental_features = [:pages]` into your application configuration file.
468
-
469
- ### Pages demo
470
-
471
- For an example of some pages in Lookbook, check out the [example pages](https://lookbook-demo-app.herokuapp.com/lookbook) in the Lookbook demo app and the associated [page files](https://github.com/allmarkedup/lookbook-demo/tree/main/test/components/docs) in the demo repo.
472
-
473
- ### Usage
474
-
475
- By default, pages should be placed in the `test/components/docs` directory (although this can be customised) and can be nested in directories as deeply as required.
5
+ > See the [main branch](https://github.com/allmarkedup/lookbook/tree/main) for code and documentation for the current stable release.
476
6
 
477
- Pages must have either a `.html.erb` or a `.md.erb` file extension. All pages are rendered as ERB templates but `.md.erb` files will also additionally be run through a markdown parser.
7
+ ## 🚀 Release focus
478
8
 
479
- Pages can optionally make use of a **YAML frontmatter block** to customise the behaviour and content of the page itself.
9
+ The main goals of the v1.0 release are:
480
10
 
481
- An example page might look like this:
11
+ - [x] Rebuild app UI using ViewComponent components
12
+ - [x] Improve usability of the small screen/mobile layout
13
+ - [x] Add support for some limited UI color theme customisation
14
+ - [x] Remove the `experimental` flag from the [Pages](https://github.com/allmarkedup/lookbook#pages)
15
+ - [x] Improve the development/debugging setup, and allow previewing Lookbook's own components in Lookbook :-)
16
+ - [ ] Improve the test setup and test coverage, switch to RSpec **[in progress]**
482
17
 
483
- ```markdown
484
- ---
485
- title: An example page
486
- label: Nice example
487
- ---
488
-
489
- This is an example page. If it has a `.md.erb` file extension its
490
- contents will be run through a Markdown parser/renderer before display.
18
+ **No breaking changes** are planned for user-facing features, although the app UI will include some minor visual updates and usability improvements.
491
19
 
492
- Fenced code blocks are fully supported and will be highlighted appropriately.
20
+ ![Lookbook UI](.github/assets/lookbook_screenshot_v1.0_beta.png)
493
21
 
494
- ERB can be used in here.
495
- The template will be rendered **before** being parsed as Markdown.
22
+ ## 👋 Testing and feedback - help wanted!
496
23
 
497
- You can can access data about the page using the `@page` variable.
498
- The title of this page is "<%= @page.title %>".
499
- ```
24
+ The bulk of the v1.0 'new feature' development work is now mostly complete, although testing and bug fixing is ongoing.
500
25
 
501
- ### YAML Frontmatter
26
+ **If you are an existing Lookbook user** I'd greatly appreciate if you can kick the tyres on the v1.0 beta and open an issue with any bug reports, suggestions or feedback you might have.
502
27
 
503
- Pages can use an optional YAML frontmatter block to configure the behaviour of the page and to provide custom data, if required.
28
+ ### Main areas/points for testing:
504
29
 
505
- The following page options can be customised via frontmatter:
30
+ - Existing Lookbook setups should continue to work **with no changes required**
31
+ - There have been a number of small UI changes - do any of them negatively affect your experience of using Lookbook?
32
+ - The Pages feature should work without opting in to any experimental features.
33
+ - It's now possible to pick from one of a small set of pre-defined UI themes (finer-grained customisation coming soon!). See below for details. Any thoughts on this?
506
34
 
507
- * `id` - a custom page ID that can be used for linking to it from other pages
508
- * `label` - The name of the page that will be displayed in the navigation (auto-generated from the file name if not set)
509
- * `title` - The main page title displayed on the page (defaults to the label value if not set).
510
- * `hidden` - If `false` the page will not appear in the navigation but will still be accessible at it's URL (useful for pages that are still in development) [default: `true`]
511
- * `landing` - Set to `true` to use the page as the Lookbook landing page [default: `false`]
512
- * `header` - Set to `false` to hide the page header containing the page title [default: `true`]
513
- * `footer` - Set to `false` to hide the page footer containing the previous/next page links [default: `true`]
514
- * `data` - Optional hash of custom data to make available for use in the page - see info on [page variables](#page-variables) below. [default: `{}`]
35
+ > However absolutely any thoughts, comments or bug reports (even if unrelated to the specific areas above) would be much appreciated!
515
36
 
516
- #### Frontmatter defaults
37
+ ### UI theming
517
38
 
518
- You can set global default values for page options in the application configuration:
39
+ Lookbook now ships with a small set of pre-defined UI themes, which can be set using the `ui_theme` config option:
519
40
 
520
41
  ```ruby
521
- # config/application.rb
522
- config.lookbook.page_options = {
523
- footer: false,
524
- data: {
525
- brand_colors: {
526
- red: "#ff0000"
527
- }
528
- }
529
- }
42
+ # config/application.rb (or similar)
43
+ config.lookbook.ui_theme = "blue"
530
44
  ```
531
45
 
532
- These will be merged with any page-level frontmatter data. Options set in the frontmatter will override those set at the global level (apart from `data`, which will be deep-merged with the any globally defined data).
46
+ Currently available themes are:
533
47
 
534
- ### Page variables
48
+ - `indigo` (default)
49
+ - `blue`
50
+ - `zinc`
535
51
 
536
- All pages have the following variables available for use in the page template:
52
+ > More themes and finer-grained customisation of theme colours is coming soon!
537
53
 
538
- * `@page` - The current page object
539
- * `@next_page` - The next page object (if available)
540
- * `@previous_page` - The previous page object (if available)
541
- * `@pages` - Collection of all pages
542
54
 
543
- Page objects have access to frontmatter variables:
55
+ ## 🛠 Workbench
544
56
 
545
- ```ruby
546
- The page title is <%= @page.title %>
57
+ As of this release, Lookbook's UI is itself built using ViewComponent components. To help with development it is possible to preview these components (in a Lookbook instance!) by running the included 'Workbench" app, as follows:
547
58
 
548
- Our brand color hex value is <%= @page.data[:brand_colors][:red] %>
549
- ```
59
+ 1. Clone this repo
60
+ 2. Install dependencies: `bundle install & npm install`
61
+ 3. Start the Workbench: `foreman start`
62
+ 4. Open http://localhost:4545 in your browser to view the Workbench
550
63
 
551
- ### Ordering pages and directories
64
+ This will start the Workbench app in development mode and any changes to Lookbooks views or assets will immediately be visible in the UI.
552
65
 
553
- If you want to enforce a specific order for pages and directories in the Lookbook navigation you can prefix the file/directory basename with an 'order number' integer value followed by an underscore or hyphen.
554
66
 
555
- For example: `01_example_page.md.erb` will be displayed first in the navigation (`01`) within the directory it is in.
556
-
557
- The integer value will be parsed out from the filename so that it doesn't appear in navigation labels or URLs, and the value itself will be used as a 'position' number when sorting the navigation items.
558
-
559
- For example, an ordered directory of pages might look like:
560
-
561
- ```
562
- test/components/docs/
563
- ├── 01_overview.md.erb
564
- ├── 02_implementation_notes/
565
- │ ├── 01_slots.md.erb
566
- │ └── 02_html_attributes.md.erb
567
- └── 03_helpful_examples/
568
- ├── 01_basic_components.md.erb
569
- └── 02_complex_components.md.erb
570
- ```
67
+ ## 🚦 Running tests
571
68
 
572
- Without the number prefixes on the file names the pages may not have appeared in the navigation in the desired order.
69
+ The test suite is in the process of being completely overhauled.
573
70
 
574
- ### Linking to other pages
71
+ Tests are now written using RSpec and the system now uses [Combustion](https://github.com/pat/combustion) under the hood.
575
72
 
576
- You can get the path to a page using the `page_path` helper. This accepts a page `id` (as a `Symbol`) or a page object:
73
+ - Tests can be run using the `rake lookbook:test` or `bundle exec rspec` commands.
74
+ - The dummy app that the tests are being run against can be viewed by running the `rake lookbook:test:serve` command and then browsing to http://localhost:9292/lookbook
577
75
 
578
- ```markdown
579
- Visit the [about page](<%= page_path :about %>)
580
76
 
581
- Go to the [next page](<%= page_path @next_page %>)
582
- ```
583
-
584
- Page ids can be set in the YAML frontmatter block for that page:
585
-
586
- ```
587
- ---
588
- id: about
589
77
  ---
590
78
 
591
- This is the about page.
592
- ```
593
-
594
- ### Embedding previews
595
-
596
- You can embed preview examples from your project directly into the documentation pages using the `embed` helper, which renders an iframe with the rendered preview in it at any point in your document.
597
-
598
- The output looks like this:
599
-
600
- <img src=".github/assets/preview_embed.png">
601
-
602
- To specify which preview example to render, the helper accepts a preview class and a method name (as a symbol), like this:
603
-
604
- ```erb
605
- <%= embed Elements:ButtonComponentPreview, :default %>
606
- ```
607
-
608
- #### Preview params
609
-
610
- If you have configured your examples to accept preview params (see the [`@param`](#param-tag) docs), then you can supply values for those params when rendering the embedded preview:
611
-
612
- ```erb
613
- <%= embed Elements:ButtonComponentPreview, :default, params: {
614
- icon: "plus",
615
- text: "Add new"
616
- } %>
617
- ```
618
-
619
- ### Displaying code
620
-
621
- You can use language-scoped [fenced code blocks](https://www.markdownguide.org/extended-syntax/#fenced-code-blocks) in the markdown file to render nicely highlighted code examples.
622
-
623
- However, if you are not using Markdown, or need a little more control, you can use the `code` helper instead:
624
-
625
- ```erb
626
- <%= code do %>
627
- # code goes here
628
- <% end %>
629
- ```
630
-
631
- The default language is `ruby`. To highlight a different language you need to specify it's name as an argument:
632
-
633
- ```erb
634
- <%= code :html do %>
635
- <!-- code goes here -->
636
- <% end %>
637
- ```
638
-
639
- > Lookbook uses [Rouge](https://github.com/rouge-ruby/rouge) for syntax highlighting. You can find a [full list of supported languages here](https://github.com/rouge-ruby/rouge/blob/master/docs/Languages.md).
640
-
641
- ### Tabs
642
-
643
- You can break up your page's content into tabs. If your avatar page is named `01_avatar.md.erb`, by declaring a page named `01_avatar[web].md.erb` it will create a **web** tab on the page. Tabs like normal Pages can contain embedded previews and code examples.
644
-
645
- ```
646
- test/components/docs/
647
- ├── 01_avatar.md.erb
648
- ├── 01_avatar[design].md.erb
649
- ├── 01_avatar[mobile].md.erb
650
- ├── 01_avatar[web].md.erb
651
- ```
652
-
653
- By declaring the `label` frontmatter you can change the label shown on the tab:
654
-
655
- ```
656
- ---
657
- label: Website
658
- ---
659
- ```
660
-
661
- If you want the tabs in a different order, you can use the `position` frontmatter:
662
-
663
- ```
664
- ---
665
- label: Web
666
- position: 1
667
- ---
668
- ```
669
-
670
- ---
671
-
672
- ### Pages configuration
673
-
674
- These options can be set in your application configuration files to customise the pages behaviour.
675
-
676
- #### `page_paths`
677
-
678
- An array of directories to look for pages in.
679
- Default: `["test/previews/docs"]`
680
-
681
- ```ruby
682
- config.lookbook.page_paths = ["path/to/my/pages"]
683
- ```
684
-
685
- #### `page_route`
686
-
687
- The URL segment used to prefix page routes.
688
- Default: `pages`
689
-
690
- ```ruby
691
- config.lookbook.page_route = `docs`
692
- ```
693
-
694
- <h2 id="deployment">Deploying in Production</h2>
695
-
696
- Lookbook is intended to be a tool for aiding the ViewComponent development process, and so is usually restricted to running only when the app is in `development` mode.
697
-
698
- However, it is possible to run Lookbook in a production environment if you wish.
699
-
700
- ### Differences between development and production
701
-
702
- By default, Lookbook will behave a little differently in production than it does in development:
703
-
704
- 1. Watching files for changes is disabled
705
- 2. Parsing preview files for annotations does **not** happen at runtime. Instead the preview files must be pre-parsed via a Rake task before starting the app (much like asset precompilation).
706
-
707
- ### Pre-parsing preview files
708
-
709
- Run the following command to pre-parse the preview files annotations:
710
-
711
- ```
712
- rake lookbook:previews:preparse
713
- ```
714
-
715
- If you wish to run this as part of your existing assets precompilation step, you can add the following into your app's `Rakefile`:
716
-
717
- ```ruby
718
- if Rails.env.production?
719
- Rake::Task['assets:precompile'].enhance do
720
- Rake::Task["lookbook:previews:preparse"].invoke
721
- end
722
- end
723
- ```
724
-
725
- The pre-parsing of preview files will then take place every time `rake assets:precompile` is called and so will not need to be run separately.
726
-
727
- ### Configuration changes for production
728
-
729
- You will also need to make sure that the following configuration changes have been made when deploying to production:
730
-
731
- 1. Make sure ViewComponent is [configured to show previews in production](https://viewcomponent.org/api.html#show_previews) (by default it is disabled when not in development):
732
-
733
- ```ruby
734
- # config/environments/production.rb
735
- config.view_component.show_previews = true
736
- ```
737
-
738
- 2. Remove any environment checking from around the Lookbook mounting declaration (if added as per install instructions):
739
-
740
- ```ruby
741
- # config/routes.rb
742
- Rails.application.routes.draw do
743
- # if Rails.env.development? <- remove
744
- mount Lookbook::Engine, at: "/lookbook"
745
- # end
746
- end
747
- ```
748
-
749
- ### Overriding production default behaviours
750
-
751
- If for some reason you wish to enable file watching or runtime preview annotation parsing in production, you can always override the default behaviour using thie following config options:
752
-
753
- ```ruby
754
- # config/environments/production.rb
755
-
756
- # enable file-change listening
757
- config.lookbook.listen = true
758
-
759
- # enable runtime preview parsing
760
- config.lookbook.runtime_parsing = true
761
- ```
762
-
763
- <h2 id="config">General Configuration</h2>
764
-
765
- Lookbook will use the ViewComponent [configuration](https://viewcomponent.org/api.html#configuration) for your project to find and render your previews so you generally you won't need to configure much else separately.
766
-
767
- However the following Lookbook-specific configuration options are also available:
768
-
769
- ### UI auto-refresh
770
-
771
- > ⚠️ UI auto-refresh is only supported in Rails v6.0+
772
-
773
- Disable/enable the auto-updating of the Lookbook UI when files change. Enabled by default.
774
-
775
- ```ruby
776
- config.lookbook.auto_refresh = false # default is true
777
- ```
778
-
779
- By default Lookbook will listen for changes in any [preview directories](https://viewcomponent.org/api.html#preview_paths) as well as in the [components directory](config.view_component.preview_paths) itself.
780
-
781
- If you wish to add additional paths to listen for changes in, you can use the `listen_paths` option:
782
-
783
- ```ruby
784
- config.lookbook.listen_paths << Rails.root.join('app/other/directory')
785
- ```
786
-
787
- By default Lookbook listens for changes to files with the extensions `rb` and `html.*` (i.e. `.html.erb`).
788
-
789
- You can add additional extensions by using the `listen_extensions` option:
790
-
791
- ```ruby
792
- config.lookbook.listen_extensions = ['js', 'scss'] # Will not overwrite default extensions
793
- ```
794
-
795
- ### Custom favicon
796
-
797
- If you want to change the favicon used by the Lookbook UI, you can provide a path to your own (or a data-uri string) using the `ui_favicon` option:
798
-
799
- ```ruby
800
- config.lookbook.ui_favicon = "/path/to/my/favicon.png"
801
- ```
802
-
803
- > To disable the favicon entirely, set the value to `false`.
804
-
805
- ### Project name
806
-
807
- Specify a project name to display in the top left of the UI (instead of the default "Lookbook"):
808
-
809
- ```ruby
810
- config.lookbook.project_name = "My Project"
811
- ```
812
-
813
- > If you don't want to display a project name at all, set the value to `false`.
814
-
815
-
816
- <h3 id="experimental-features">Experimental features opt-in</h3>
817
-
818
- Some features may occasionally be released behind a 'experimental' feature flag while they are being tested and refined, to allow people to try them out and provide feedback.
819
-
820
- > ⚠️ **Please note:** Experimental features should be considered to be **subject to extensive change** and breaking changes to them may be made within point releases - these features are **not** considered to be covered by [semver](https://semver.org/) whilst flagged as 'experimental'. ⚠️
821
-
822
- #### Opting into specific features (recommended)
823
-
824
- To opt into individual experimental features, include the name of the feature in the `experimental_features` config option:
825
-
826
- ```ruby
827
- config.lookbook.experimental_features = ["feature_name"]
828
- ```
829
-
830
- The current experimental features that can be opted into are:
831
-
832
- - `pages`: Markdown-powered documentation pages with embeddable previews
833
-
834
-
835
- #### Opting into all experimental features (not recommended!)
836
-
837
- If you want to live life on the bleeding-edge you can opt-in to all current **and future** experimental features (usual caveats apply):
838
-
839
- ```ruby
840
- config.lookbook.experimental_features = true
841
- ```
842
-
843
-
844
- ## Keyboard shortcuts
845
-
846
- Lookbook provides a few keyboard shortcuts to help you quickly move around the UI.
847
-
848
- - `f` - move focus to the nav filter box
849
- - `Esc` [when focus is in nav filter box] - Clear contents if text is present, or return focus to the UI if the box is already empty
850
- - `s` - Switch to Source tab in the drawer
851
- - `n` - Switch to Notes tab in the drawer
852
- - `v` - Switch to the rendered preview
853
- - `o` - Switch to the code preview
854
- - `r` - Refresh the preview (useful if using something like Faker to generate randomised data for the preview)
855
- - `w` - Open the standalone rendered preview in a new window
856
-
857
- ## Contributing
858
-
859
- Lookbook is very much a small hobby/side project at the moment. I'd love to hear from anyone who is interested in contributing but I'm terrible at replying to emails or messages, so don't be surprised if I take forever to get back to you. It's not personal 😜
860
-
861
- ### Developing on a local version of Lookbook
862
-
863
- The quickest way to get a development version of Lookbook up and running is to use the [lookbook-demo](https://github.com/allmarkedup/lookbook-demo) app and link it to a local version of the Lookbook gem:
864
-
865
- #### Initial setup:
866
-
867
- 1. Clone this repository somewhere on your machine - `git clone git@github.com:allmarkedup/lookbook.git`
868
- 2. Also pull down the [lookbook-demo](https://github.com/allmarkedup/lookbook-demo) repository to your machine
869
- 3. In the `Gemfile` of the `lookbook-demo` repository, replace `gem "lookbook", '>= 0.1', git: "https://github.com/allmarkedup/lookbook", branch: "main"` with `gem "lookbook", path: "../path/to/lookbook"` (use the path to your local copy of lookbook)
870
- 4. Install dependencies - from the root of the parent project run `bundle install`
871
-
872
- #### Starting development
873
-
874
- 1. From within the `lookbook` root directory run the comand `npm run dev` (this will make sure the CSS/JS is recompiled if/when you make changes to the UI)
875
- 2. From within the `lookbook-demo` root directory run `npm run start` - this will start a server and build the demo assets
876
-
877
- Point your browser to http://localhost:3000/lookbook to see the UI. You can then make and test changes to the Lookbook code in your local copy of lookbook repo. PRs are welcome if you add anything useful :-)
878
-
879
- > Note that changes to files in the Lookbook `lib/` directory will require a server restart in order to have them applied.
880
-
881
- #### Tests
882
-
883
- You can run the tests from within the `lookbook` root directory with the `rake test` command.
884
-
885
79
  ## License
886
80
 
887
81
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).