lookbook 1.0.0.beta.2 → 1.0.0.beta.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +180 -40
- data/app/components/lookbook/{component.rb → base_component.rb} +1 -1
- data/app/components/lookbook/button/component.rb +1 -1
- data/app/components/lookbook/button_group/component.rb +1 -1
- data/app/components/lookbook/code/component.rb +1 -1
- data/app/components/lookbook/copy_button/component.html.erb +1 -1
- data/app/components/lookbook/copy_button/component.rb +1 -1
- data/app/components/lookbook/dimensions_display/component.rb +1 -1
- data/app/components/lookbook/embed/component.html.erb +3 -2
- data/app/components/lookbook/embed/component.rb +1 -1
- data/app/components/lookbook/filter/component.html.erb +1 -1
- data/app/components/lookbook/filter/component.rb +1 -1
- data/app/components/lookbook/header/component.html.erb +5 -10
- data/app/components/lookbook/header/component.rb +1 -1
- data/app/components/lookbook/icon/component.rb +1 -1
- data/app/components/lookbook/nav/component.rb +1 -1
- data/app/components/lookbook/nav/item/component.html.erb +2 -2
- data/app/components/lookbook/nav/item/component.rb +1 -1
- data/app/components/lookbook/page_tabs/component.rb +1 -1
- data/app/components/lookbook/params_editor/component.rb +1 -1
- data/app/components/lookbook/params_editor/field/component.rb +1 -1
- data/app/components/lookbook/prose/component.rb +1 -1
- data/app/components/lookbook/split_layout/component.rb +1 -1
- data/app/components/lookbook/tab_panels/component.rb +1 -1
- data/app/components/lookbook/tab_panels/panel/component.rb +2 -2
- data/app/components/lookbook/tabs/component.js +6 -6
- data/app/components/lookbook/tabs/component.rb +1 -1
- data/app/components/lookbook/tabs/dropdown_tab/component.rb +1 -1
- data/app/components/lookbook/tabs/tab/component.rb +1 -1
- data/app/components/lookbook/toolbar/component.rb +1 -1
- data/app/components/lookbook/viewport/component.rb +1 -1
- data/app/controllers/lookbook/previews_controller.rb +24 -29
- data/app/helpers/lookbook/application_helper.rb +6 -0
- data/app/helpers/lookbook/component_helper.rb +4 -0
- data/app/helpers/lookbook/page_helper.rb +1 -1
- data/app/views/layouts/lookbook/application.html.erb +1 -1
- data/app/views/layouts/lookbook/shell.html.erb +1 -1
- data/app/views/layouts/lookbook/skeleton.html.erb +7 -1
- data/app/views/lookbook/404.html.erb +1 -1
- data/app/views/lookbook/index.html.erb +1 -1
- data/app/views/lookbook/pages/show.html.erb +2 -2
- data/app/views/lookbook/previews/panels/_notes.html.erb +1 -1
- data/app/views/lookbook/previews/show.html.erb +3 -3
- data/lib/lookbook/collection.rb +1 -1
- data/lib/lookbook/component.rb +31 -0
- data/lib/lookbook/config.rb +54 -9
- data/lib/lookbook/engine.rb +72 -12
- data/lib/lookbook/page.rb +2 -2
- data/lib/lookbook/parser.rb +1 -4
- data/lib/lookbook/preview.rb +24 -7
- data/lib/lookbook/preview_example.rb +1 -1
- data/lib/lookbook/source_inspector.rb +10 -0
- data/lib/lookbook/utils.rb +2 -2
- data/lib/lookbook/version.rb +1 -1
- data/lib/lookbook.rb +1 -12
- data/public/lookbook-assets/js/lookbook.js +105 -104
- data/public/lookbook-assets/js/lookbook.js.map +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ad3d5561ec7db31b1681dfb07bd3c4233baf75ab4865ad58de9c5bd48ae327e
|
4
|
+
data.tar.gz: 52e1363d495943316286f41d564ef19d29f2ac525b10988079c0cbb57db7d88e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c726d88df050f17317a9e9ec849ddf47c6650d244ae0e11b4627365d283f3a8acf10c15fa6d930ec6e48d64954b84f559ec984f5fb8981e5c37ac4d256029b02
|
7
|
+
data.tar.gz: ea985b9135c8c7f1422edc2aa20122685947d786737f6532842c677a11d9afc40a9d08f3f3db04cdb0d7051dc8194d62c0dad21faa5e9870931f0fe0ba2bf2a4
|
data/README.md
CHANGED
@@ -11,6 +11,7 @@ The main goals of the v1.0 release are:
|
|
11
11
|
- [x] Rebuild app UI using ViewComponent components
|
12
12
|
- [x] Improve usability of the small screen/mobile layout
|
13
13
|
- [x] Add support for some limited UI color theme customisation
|
14
|
+
- [x] Add support for custom inspector panels
|
14
15
|
- [x] Remove the `experimental` flag from the [Pages](https://github.com/allmarkedup/lookbook#pages)
|
15
16
|
- [x] Improve the development/debugging setup, and allow previewing Lookbook's own components in Lookbook :-)
|
16
17
|
- [ ] Improve the test setup and test coverage, switch to RSpec **[in progress]**
|
@@ -29,25 +30,21 @@ The bulk of the v1.0 'new feature' development work is now mostly complete, alth
|
|
29
30
|
|
30
31
|
**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.
|
31
32
|
|
32
|
-
### Main areas/points for testing:
|
33
|
+
### Main areas/points for testing/feedback:
|
33
34
|
|
34
35
|
- Existing Lookbook setups should continue to work **with no changes required**
|
35
|
-
-
|
36
|
-
-
|
37
|
-
- It's now possible to pick from one of a small set of pre-defined UI themes (finer-grained customisation coming soon!). [See below](#ui-theming) for details. Any thoughts on this?
|
36
|
+
- It's now possible to pick from one of a small set of pre-defined **UI themes** (plus finer-grained customisation coming soon). [See below](#ui-theming) for details.
|
37
|
+
- You can now [extend Lookbook](#extending-lookbook) to more closely customise it to your needs - testing and feedback around this area would be a great help!
|
38
38
|
|
39
|
-
>
|
39
|
+
> Any thoughts, comments or bug reports (even if unrelated to the specific areas above) would be much appreciated!
|
40
40
|
|
41
|
-
## New features
|
42
41
|
|
43
|
-
|
42
|
+
## UI theming
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
Lookbook now ships with a small set of pre-defined UI themes, which can be set using the `ui_theme` config option:
|
44
|
+
Lookbook v1.0 ships with a small set of pre-defined UI themes, which can be set using the `ui_theme` config option:
|
48
45
|
|
49
46
|
```ruby
|
50
|
-
# config/application.rb
|
47
|
+
# config/application.rb
|
51
48
|
config.lookbook.ui_theme = "blue"
|
52
49
|
```
|
53
50
|
|
@@ -59,25 +56,174 @@ Currently available themes are:
|
|
59
56
|
|
60
57
|
> More themes and finer-grained customisation of theme colours is coming soon!
|
61
58
|
|
62
|
-
|
59
|
+
## Extending Lookbook
|
60
|
+
|
61
|
+
> Opening up Lookbook to more in-depth customisation is a work in progress and any feedback or use-case examples would be greatly appreciated!
|
62
|
+
|
63
|
+
* [Lifecycle Hooks](#lifecycle-hooks)
|
64
|
+
* [Adding inspector panels](#adding-inspector-panels)
|
65
|
+
* [Removing inspector panels](#removing-inspector-panels)
|
66
|
+
|
67
|
+
### Lifecycle hooks
|
68
|
+
|
69
|
+
A number of lifecycle hooks are available for use in triggering actions outside of Lookbook.
|
70
|
+
|
71
|
+
All hook callback blocks are yielded a `Lookbook` instance as the first argument. Some hooks additionally supply other arguments, see below for details.
|
72
|
+
|
73
|
+
#### `:after_initialize`
|
74
|
+
|
75
|
+
This is run once Lookbook has been set up and the initial parsing of files has been completed.
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
Lookbook.after_initialize do |app|
|
79
|
+
puts "Lookbook version #{app.version} has started"
|
80
|
+
puts "There are #{app.previews.size} previews and #{app.pages.size} pages"
|
81
|
+
# other code here...
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
85
|
+
#### `:after_change`
|
86
|
+
|
87
|
+
Run each time a change is detected to a file that Lookbook is watching, unless listening for changes has been disabled in the config.
|
88
|
+
|
89
|
+
Receives a hash as the second argument with `:modified`, `:added`, and `:removed` properties, each of which is an array of affected file paths.
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
Lookbook.after_change do |app, changes|
|
93
|
+
puts "Modified files: #{changes.modified.join("\n")}"
|
94
|
+
puts "Added files: #{changes.added.join("\n")}"
|
95
|
+
puts "Removed files: #{changes.removed.join("\n")}"
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
99
|
+
#### `:before_exit`
|
100
|
+
|
101
|
+
Run when the current process exits, after Lookbook has stopped any listeners.
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
Lookbook.after_initialize do |app|
|
105
|
+
puts "Shutting down..."
|
106
|
+
end
|
107
|
+
```
|
108
|
+
|
109
|
+
### Adding inspector panels
|
110
|
+
|
111
|
+
It's now possible to add custom inspector panels/tabs to Lookbook using the `:define_panel` method:
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
Lookbook.define_panel(<name>, <opts>)
|
115
|
+
```
|
116
|
+
|
117
|
+
* `<name>`: A unique name for the panel
|
118
|
+
* `<opts>`: A `Hash` of options (see below for details)
|
119
|
+
|
120
|
+
For example, a very simple 'info' panel could be created as follows:
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
# config/application.rb
|
124
|
+
Lookbook.define_panel(:info, {
|
125
|
+
label: "Extra Info",
|
126
|
+
partial: "panels/info"
|
127
|
+
})
|
128
|
+
```
|
129
|
+
|
130
|
+
```erb
|
131
|
+
<!-- views/panels/_info.html.erb -->
|
132
|
+
<div>
|
133
|
+
<h2>Some information</h2>
|
134
|
+
<ul>
|
135
|
+
<li>You are looking at the '<%= preview.label %>' preview</li>
|
136
|
+
<li>The preview file path is: '<%= preview.full_path %>'<li>
|
137
|
+
<li>There are <%= examples.size %> examples in this preview<li>
|
138
|
+
</ul>
|
139
|
+
</div>
|
140
|
+
```
|
141
|
+
|
142
|
+
#### Panel templates
|
143
|
+
|
144
|
+
The panel partial template will have access to any `locals` defined in the [panel options](#panel-options), plus the following variables:
|
145
|
+
|
146
|
+
#### `panel`
|
147
|
+
|
148
|
+
The resolved panel options object (see below for details)
|
149
|
+
|
150
|
+
```erb
|
151
|
+
<h2><%= panel.label =></h2>
|
152
|
+
```
|
153
|
+
|
154
|
+
#### `preview`
|
155
|
+
|
156
|
+
An object representing the current preview:
|
157
|
+
|
158
|
+
* `preview.id`
|
159
|
+
* `preview.label`
|
160
|
+
* `preview.full_path`
|
161
|
+
* `preview.url_path`
|
162
|
+
* ...
|
163
|
+
|
164
|
+
#### `examples`
|
165
|
+
|
166
|
+
An array of objects representing the individual examples being rendered in the current preview. (For non-grouped previews, this array will always only have one item.)
|
167
|
+
|
168
|
+
Each example has the following properties:
|
169
|
+
|
170
|
+
* `example.output` - the rendered preview example output (String)
|
171
|
+
* `example.source` - the example source code (String)
|
172
|
+
* `example.source_lang` - a hash of information about the source language (Ruby or HTML/ERB, depending on whether the example uses a preview template)
|
173
|
+
* `example.id`
|
174
|
+
* `example.label`
|
175
|
+
* `example.full_path`
|
176
|
+
* `example.url_path`
|
177
|
+
* ...
|
178
|
+
|
179
|
+
|
180
|
+
#### `components`
|
181
|
+
|
182
|
+
An array of objects representing the components that are rendered in the preview. The components are 'guessed' from the Preview class name but if that doesn't work then they can be manually specified via annotations.
|
183
|
+
|
184
|
+
Each component object has the following properties:
|
63
185
|
|
64
|
-
|
186
|
+
* `component.name`
|
187
|
+
* `component.full_path`
|
188
|
+
* `component.dir_path`
|
189
|
+
* `component.template_path`
|
190
|
+
* `component.inline?`
|
65
191
|
|
66
|
-
|
192
|
+
To manually specify one or more components in the preview class, you can use the `@component` tag at the class level:
|
67
193
|
|
68
|
-
|
69
|
-
|
194
|
+
```ruby
|
195
|
+
# @component Elements::BigDangerButton
|
196
|
+
class ButtonComponentPreview < ViewComponent::Preview
|
197
|
+
|
198
|
+
def default
|
199
|
+
render Elements::BigDangerButton.new do
|
200
|
+
"Click here"
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
```
|
206
|
+
|
207
|
+
#### `context`
|
208
|
+
|
209
|
+
An object containing data about the request context:
|
210
|
+
|
211
|
+
* `context.preview_params`
|
212
|
+
* `context.path`
|
213
|
+
|
214
|
+
#### `app`
|
70
215
|
|
71
|
-
|
216
|
+
The main `Lookbook` app instance.
|
72
217
|
|
73
|
-
|
218
|
+
* `app.previews` - Array of preview objects
|
219
|
+
* `app.pages` - Array of page objects
|
220
|
+
* `app.logger` - Logger instance
|
74
221
|
|
75
|
-
|
222
|
+
#### Panel options
|
76
223
|
|
77
224
|
```ruby
|
78
225
|
{
|
79
226
|
label: "New Panel",
|
80
|
-
pane: :drawer,
|
81
227
|
position: 1,
|
82
228
|
partial: "path/to/view_partial",
|
83
229
|
content: "Some **markdown** content",
|
@@ -85,11 +231,11 @@ Panels are defined as a hash with the following properties (all of which are act
|
|
85
231
|
disabled: false,
|
86
232
|
show: true,
|
87
233
|
copy: "Content to be copied",
|
234
|
+
locals: {}
|
88
235
|
}
|
89
236
|
```
|
90
237
|
|
91
238
|
* `label`: the text to be displayed in the tab
|
92
|
-
* `pane`: the panel location, either `:drawer` or `:main` (`:drawer` is the default)
|
93
239
|
* `position`: used for ordering the tabs
|
94
240
|
* `partial`: the path to the view template partial used to render the panel
|
95
241
|
* `content`: the default partial renders and displays the contents of this (markdown supported)
|
@@ -99,7 +245,8 @@ Panels are defined as a hash with the following properties (all of which are act
|
|
99
245
|
* `copy`: if present, the panel will display a copy button that copies the value of this property to the clipboard when clicked
|
100
246
|
* `locals`: a `Hash` of local variables that will be made available to the partial when rendering the panel
|
101
247
|
|
102
|
-
|
248
|
+
|
249
|
+
All panel option values can be provided either as a **simple static value** or as a **lambda function** which will receive a hash of data relating to the currently active preview/example. For example:
|
103
250
|
|
104
251
|
```ruby
|
105
252
|
{
|
@@ -108,32 +255,25 @@ All panel config values can be provided either as a **simple static value** or a
|
|
108
255
|
}
|
109
256
|
```
|
110
257
|
|
111
|
-
|
258
|
+
The `data` hash contains the same set of objects that are passed to the panel partial template:
|
112
259
|
|
113
|
-
|
260
|
+
* `data.preview`
|
261
|
+
* `data.examples`
|
262
|
+
* `data.components`
|
263
|
+
* `data.context`
|
264
|
+
* `data.app`
|
114
265
|
|
115
|
-
|
266
|
+
**See the [panel templates section above]((#panel-templates)) for more details.**
|
116
267
|
|
117
|
-
|
118
|
-
config.lookbook.inspector_panels.notes = false # remove the notes panel
|
119
|
-
```
|
268
|
+
### Removing inspector panels
|
120
269
|
|
121
|
-
|
122
|
-
|
123
|
-
Existing panel configuration can be amended as needed. For example, to change the label on one of the default panels:
|
270
|
+
To remove a panel entirely from the UI you can use the `Lookbook.remove_panel` method:
|
124
271
|
|
125
272
|
```ruby
|
126
|
-
config.
|
127
|
-
|
128
|
-
# or use block-style config
|
129
|
-
config.lookbook.inspector_panels do |panels|
|
130
|
-
panels.notes.label = "Instructions"
|
131
|
-
end
|
273
|
+
# config/application.rb
|
274
|
+
Lookbook.remove_panel(:notes)
|
132
275
|
```
|
133
276
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
277
|
## 🛠 Workbench
|
138
278
|
|
139
279
|
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:
|
@@ -4,7 +4,7 @@
|
|
4
4
|
x_data: prepare_alpine_data,
|
5
5
|
"@click.prevent": "copyToClipboard" do |button| %>
|
6
6
|
<% button.icon name: @icon, size: icon_size, x_show: "!copied", cloak: true %>
|
7
|
-
<%=
|
7
|
+
<%= icon :check, size: icon_size, class: "text-green-500", x_show: "copied", cloak: true %>
|
8
8
|
<% if content %>
|
9
9
|
<div x-ref="copyTarget" class="hidden"><%== content %></div>
|
10
10
|
<% end %>
|
@@ -25,7 +25,8 @@
|
|
25
25
|
@viewport:loaded="loadResizer"
|
26
26
|
@dom:update-complete="loadResizer"
|
27
27
|
@viewport:resize-progress="resizeIframe"
|
28
|
-
@viewport:resize-complete="resizeIframe"
|
28
|
+
@viewport:resize-complete="resizeIframe"
|
29
|
+
@tabs:change.window="resizeIframe">
|
29
30
|
<%= render_component :viewport,
|
30
31
|
src: helpers.lookbook_preview_path(@example.path, @params.merge(lookbook_embed: true)),
|
31
32
|
alpine_data: "store",
|
@@ -38,7 +39,7 @@
|
|
38
39
|
<% else %>
|
39
40
|
<%= render_component_tag class: "bg-white flex flex-col items-center justify-center border-2 border-dashed border-gray-200 p-6 rounded-md not-prose" do %>
|
40
41
|
<div class="px-4 text-center">
|
41
|
-
<%=
|
42
|
+
<%= icon :alert_triangle, size: 6, class: "text-red-300 mx-auto" %>
|
42
43
|
<div class="mt-2 max-w-xs">
|
43
44
|
<h5 class="text-base">Preview not found</h5>
|
44
45
|
<p class="mt-1 opacity-50 text-sm">
|
@@ -11,7 +11,7 @@
|
|
11
11
|
@keydown.f.stop.prevent.window="focus"
|
12
12
|
@keydown.stop>
|
13
13
|
<button class="text-lookbook-button-text hover:text-lookbook-button-text-hover focus:ring-0 focus:outline-none absolute top-1/2 right-3 -translate-y-1/2" @click="clear" :class="{hidden: !active}">
|
14
|
-
<%=
|
14
|
+
<%= icon :x, size: 3 %>
|
15
15
|
</button>
|
16
16
|
</div>
|
17
17
|
<% end %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Lookbook
|
2
|
-
class Filter::Component < Lookbook::
|
2
|
+
class Filter::Component < Lookbook::BaseComponent
|
3
3
|
def initialize(store: nil, placeholder: "Type to filter…", **html_attrs)
|
4
4
|
@model = store.nil? ? "{}" : "#{store}.raw"
|
5
5
|
@placeholder = placeholder
|
@@ -24,15 +24,10 @@
|
|
24
24
|
x-data="clipboardComponent"
|
25
25
|
@click.prevent.stop="copyToClipboard('#debug-data')">
|
26
26
|
<span x-show="copied" x-cloak>
|
27
|
-
<%=
|
28
|
-
name: :check,
|
29
|
-
size: 2.5,
|
30
|
-
class: "text-green-600" %>
|
27
|
+
<%= icon :check, size: 2.5, class: "text-green-600" %>
|
31
28
|
</span>
|
32
29
|
<span x-show="!copied">
|
33
|
-
<%=
|
34
|
-
name: :clipboard,
|
35
|
-
size: 2.5 %>
|
30
|
+
<%= icon :clipboard, size: 2.5 %>
|
36
31
|
</span>
|
37
32
|
<span class="ml-2">Copy debug data</span>
|
38
33
|
</a>
|
@@ -41,7 +36,7 @@
|
|
41
36
|
<a href="#"
|
42
37
|
class="text-xs flex items-center hover:underline"
|
43
38
|
@click.stop="localStorage.clear(); window.location.reload();">
|
44
|
-
<%=
|
39
|
+
<%= icon :refresh_cw, size: 2.5 %>
|
45
40
|
<span class="ml-2">Reset local storage</span>
|
46
41
|
</a>
|
47
42
|
</li>
|
@@ -52,10 +47,10 @@
|
|
52
47
|
<span class="mr-6">v<%= Lookbook::VERSION %></span>
|
53
48
|
<div class="flex items-center space-x-2">
|
54
49
|
<!-- a href="https://github.com/allmarkedup/lookbook" target="_blank" class="ml-auto opacity-70" title="Documentation">
|
55
|
-
<%=
|
50
|
+
<%= icon :book, size: 3 %>
|
56
51
|
</a -->
|
57
52
|
<a href="https://github.com/allmarkedup/lookbook" target="_blank" class="ml-auto opacity-70" title="Github">
|
58
|
-
<%=
|
53
|
+
<%= icon :github, size: 3 %>
|
59
54
|
</a>
|
60
55
|
</div>
|
61
56
|
</div>
|
@@ -6,11 +6,11 @@
|
|
6
6
|
style: "padding-left: #{left_pad}px",
|
7
7
|
x_bind: "bindings.#{href.present? ? "link" : "toggle"}" do %>
|
8
8
|
<div class="relative flex items-center">
|
9
|
-
<%=
|
9
|
+
<%= icon nil,
|
10
10
|
size: 3,
|
11
11
|
class: "mr-1 text-lookbook-nav-toggle absolute -left-4",
|
12
12
|
x_effect: "iconName = open ? 'chevron-down' : 'chevron-right'" if children? %>
|
13
|
-
<%=
|
13
|
+
<%= icon nav_icon(@item), size: 3.5, class: "mr-1.5 text-lookbook-nav-icon" %>
|
14
14
|
<span><%= label %></span>
|
15
15
|
</div>
|
16
16
|
<% end %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Lookbook
|
2
|
-
class ParamsEditor::Field::Component < Lookbook::
|
2
|
+
class ParamsEditor::Field::Component < Lookbook::BaseComponent
|
3
3
|
def initialize(input:, name:, default: nil, value: nil, input_type: nil, type: nil, options: nil, **html_attrs)
|
4
4
|
@input = input
|
5
5
|
@name = name
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Lookbook
|
2
|
-
class TabPanels::Panel::Component < Lookbook::
|
2
|
+
class TabPanels::Panel::Component < Lookbook::BaseComponent
|
3
3
|
def initialize(name:, id: nil, **html_attrs)
|
4
4
|
@name = name
|
5
|
-
@id = id || name
|
5
|
+
@id = "#{id || "panel-#{name}"}"
|
6
6
|
super(**html_attrs)
|
7
7
|
end
|
8
8
|
end
|
@@ -16,7 +16,7 @@ export default function tabsComponent(store) {
|
|
16
16
|
},
|
17
17
|
|
18
18
|
get tabs() {
|
19
|
-
return Array.from(this.$refs.tabs.children);
|
19
|
+
return this.$refs.tabs ? Array.from(this.$refs.tabs.children) : [];
|
20
20
|
},
|
21
21
|
|
22
22
|
get dropdownTabs() {
|
@@ -45,7 +45,7 @@ export default function tabsComponent(store) {
|
|
45
45
|
const initialTab = initial
|
46
46
|
? this.tabs.find((t) => this._getRef(t) === initial)
|
47
47
|
: this.tabs[0];
|
48
|
-
this.selectTab(initialTab);
|
48
|
+
this.selectTab(initialTab, true);
|
49
49
|
|
50
50
|
this.parentObserver = observeSize(
|
51
51
|
this.$root.parentElement,
|
@@ -64,13 +64,10 @@ export default function tabsComponent(store) {
|
|
64
64
|
}
|
65
65
|
|
66
66
|
if (width === this.$root.offsetWidth) {
|
67
|
-
console.log("uep");
|
68
67
|
this.visibleTabsCount = this.tabs.length;
|
69
68
|
return;
|
70
69
|
}
|
71
70
|
|
72
|
-
console.log(width);
|
73
|
-
|
74
71
|
let sumTabWidths = 60;
|
75
72
|
let triggerLeft = 20;
|
76
73
|
let visibleTabsCount = 0;
|
@@ -87,9 +84,12 @@ export default function tabsComponent(store) {
|
|
87
84
|
this._lastMeasuredWidth = width;
|
88
85
|
},
|
89
86
|
|
90
|
-
selectTab(el) {
|
87
|
+
selectTab(el, initial = false) {
|
91
88
|
this.store.activeTab = this._getRef(el);
|
92
89
|
dropdown.hide();
|
90
|
+
if (!initial) {
|
91
|
+
this.$dispatch("tabs:change", { tabs: this });
|
92
|
+
}
|
93
93
|
},
|
94
94
|
|
95
95
|
isSelected(el) {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Lookbook
|
2
|
-
class Tabs::DropdownTab::Component < Lookbook::
|
2
|
+
class Tabs::DropdownTab::Component < Lookbook::BaseComponent
|
3
3
|
def initialize(name:, label: nil, hotkey: nil, disabled: nil, position: 0, theme: :toolbar, **html_attrs)
|
4
4
|
@name = name
|
5
5
|
@label = label
|