lookbook 0.8.2 → 1.0.0.beta.0

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