lookbook 1.0.7 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/lookbook/css/lookbook.css +76 -2
- data/app/assets/lookbook/js/app.js +20 -2
- data/app/{components/lookbook/params_editor/field/component.js → assets/lookbook/js/components/params_input.js} +1 -14
- data/app/assets/lookbook/js/lookbook.js +2 -1
- data/app/components/lookbook/base_component.rb +2 -3
- data/app/components/lookbook/button/component.html.erb +2 -2
- data/app/components/lookbook/button/component.rb +6 -1
- data/app/components/lookbook/button_group/component.rb +3 -4
- data/app/components/lookbook/copy_button/component.html.erb +1 -1
- data/app/components/lookbook/debug_menu/component.html.erb +51 -0
- data/app/components/lookbook/debug_menu/component.rb +18 -0
- data/app/components/lookbook/embed/component.html.erb +3 -3
- data/app/components/lookbook/header/component.html.erb +19 -44
- data/app/components/lookbook/inspector_panel/component.html.erb +5 -3
- data/app/components/lookbook/inspector_panel/component.rb +6 -18
- data/app/components/lookbook/nav/component.js +4 -0
- data/app/components/lookbook/nav/component.rb +1 -1
- data/app/components/lookbook/nav/item/component.html.erb +4 -4
- data/app/components/lookbook/nav/item/component.rb +1 -1
- data/app/components/lookbook/page_tabs/component.html.erb +4 -4
- data/app/components/lookbook/page_tabs/component.rb +1 -1
- data/app/components/lookbook/params/editor/component.html.erb +21 -0
- data/app/components/lookbook/{params_editor → params/editor}/component.js +1 -1
- data/app/components/lookbook/params/editor/component.rb +40 -0
- data/app/components/lookbook/params/field/component.css +76 -0
- data/app/components/lookbook/params/field/component.html.erb +27 -0
- data/app/components/lookbook/params/field/component.js +7 -0
- data/app/components/lookbook/params/field/component.rb +101 -0
- data/app/components/lookbook/tabs/component.html.erb +2 -2
- data/app/components/lookbook/tag_component.rb +1 -0
- data/app/components/lookbook/viewport/component.css +1 -1
- data/app/components/lookbook/viewport/component.html.erb +11 -0
- data/app/controllers/lookbook/previews_controller.rb +1 -1
- data/app/helpers/lookbook/component_helper.rb +45 -26
- data/app/helpers/lookbook/page_helper.rb +1 -1
- data/app/views/layouts/lookbook/application.html.erb +18 -4
- data/app/views/layouts/lookbook/page.html.erb +4 -4
- data/app/views/layouts/lookbook/shell.html.erb +4 -4
- data/app/views/layouts/lookbook/skeleton.html.erb +0 -6
- data/app/views/lookbook/error.html.erb +1 -1
- data/app/views/lookbook/pages/show.html.erb +2 -2
- data/app/views/lookbook/previews/inputs/_color.html.erb +5 -0
- data/app/views/lookbook/previews/inputs/_range.html.erb +15 -0
- data/app/views/lookbook/previews/inputs/_select.html.erb +5 -0
- data/app/views/lookbook/previews/inputs/_text.html.erb +5 -0
- data/app/views/lookbook/previews/inputs/_textarea.html.erb +5 -0
- data/app/views/lookbook/previews/inputs/_toggle.html.erb +20 -0
- data/app/views/lookbook/previews/panels/_content.html.erb +2 -2
- data/app/views/lookbook/previews/panels/_notes.html.erb +2 -2
- data/app/views/lookbook/previews/panels/_output.html.erb +1 -1
- data/app/views/lookbook/previews/panels/_params.html.erb +3 -3
- data/app/views/lookbook/previews/panels/_preview.html.erb +1 -1
- data/app/views/lookbook/previews/panels/_source.html.erb +2 -2
- data/app/views/lookbook/previews/show.html.erb +13 -19
- data/lib/lookbook/config.rb +17 -1
- data/lib/lookbook/engine.rb +17 -7
- data/lib/lookbook/markdown.rb +1 -1
- data/lib/lookbook/panels.rb +14 -4
- data/lib/lookbook/params.rb +66 -35
- data/lib/lookbook/parser.rb +1 -0
- data/lib/lookbook/preview.rb +10 -4
- data/lib/lookbook/preview_controller.rb +11 -5
- data/lib/lookbook/preview_example.rb +2 -2
- data/lib/lookbook/source_inspector.rb +10 -4
- data/lib/lookbook/tag.rb +13 -3
- data/lib/lookbook/tag_options.rb +111 -0
- data/lib/lookbook/tags.rb +6 -2
- data/lib/lookbook/template_parser.rb +72 -0
- data/lib/lookbook/theme.rb +1 -1
- data/lib/lookbook/utils.rb +23 -0
- data/lib/lookbook/version.rb +1 -1
- data/lib/lookbook.rb +2 -0
- data/public/lookbook-assets/css/lookbook.css +369 -126
- data/public/lookbook-assets/css/lookbook.css.map +1 -1
- data/public/lookbook-assets/js/embed.js +13 -13
- data/public/lookbook-assets/js/embed.js.map +1 -1
- data/public/lookbook-assets/js/lookbook.js +772 -687
- data/public/lookbook-assets/js/lookbook.js.map +1 -1
- metadata +42 -10
- data/app/components/lookbook/params_editor/component.html.erb +0 -3
- data/app/components/lookbook/params_editor/component.rb +0 -11
- data/app/components/lookbook/params_editor/field/component.html.erb +0 -49
- data/app/components/lookbook/params_editor/field/component.rb +0 -44
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d855b9a3a2e36fa5e18aa2388ced2c97a8b07dc8cd5b81785cd6ed1b85269bca
|
|
4
|
+
data.tar.gz: 3f54dfcf6def53543c8247634ed0b40e6a39807d6e09c59690c50f0f8a0f175d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f213eb79ea2eab3f01af6be18544c1d59d02905b50d6ff773f54f89e14e0982be43ff948c1eab32819317278a6915070cf1c8259923bb17b195d86d4932f27c5
|
|
7
|
+
data.tar.gz: 616c37c62765074f87d79c14313499e9bcec19e8722751f74ce39793693ca3058b60f55ac5e80edb406b9301022d79d55c3bb33f9601281576d3f15eb868109b
|
|
@@ -47,9 +47,83 @@
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
@layer components {
|
|
50
|
-
|
|
50
|
+
[type="text"],
|
|
51
|
+
[type="email"],
|
|
52
|
+
[type="url"],
|
|
53
|
+
[type="password"],
|
|
54
|
+
[type="number"],
|
|
55
|
+
[type="date"],
|
|
56
|
+
[type="datetime-local"],
|
|
57
|
+
[type="month"],
|
|
58
|
+
[type="search"],
|
|
59
|
+
[type="tel"],
|
|
60
|
+
[type="time"],
|
|
61
|
+
[type="week"],
|
|
62
|
+
textarea,
|
|
63
|
+
select {
|
|
51
64
|
@apply text-lookbook-input-text placeholder:text-lookbook-input-text-placeholder placeholder:italic;
|
|
52
65
|
@apply border-lookbook-input-border focus:ring-lookbook-input-border-focus focus:border-lookbook-input-border-focus;
|
|
53
|
-
@apply rounded-md text-sm w-full bg-lookbook-input-bg;
|
|
66
|
+
@apply rounded-md text-sm w-full bg-lookbook-input-bg block;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
input[type="range"] {
|
|
70
|
+
-webkit-appearance: none;
|
|
71
|
+
appearance: none;
|
|
72
|
+
background: transparent;
|
|
73
|
+
cursor: pointer;
|
|
74
|
+
width: 100%;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
input[type="range"]:focus {
|
|
78
|
+
outline: none;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
input[type="range"]::-webkit-slider-runnable-track {
|
|
82
|
+
@apply bg-lookbook-input-toggle;
|
|
83
|
+
border-radius: 0.5rem;
|
|
84
|
+
height: 0.5rem;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
input[type="range"]::-webkit-slider-thumb {
|
|
88
|
+
-webkit-appearance: none;
|
|
89
|
+
appearance: none;
|
|
90
|
+
@apply bg-lookbook-input-toggle-active;
|
|
91
|
+
margin-top: -4px;
|
|
92
|
+
border-radius: 0.5rem;
|
|
93
|
+
height: 1rem;
|
|
94
|
+
width: 1rem;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
input[type="range"]::-moz-range-track {
|
|
98
|
+
@apply bg-lookbook-input-toggle;
|
|
99
|
+
border-radius: 0.5rem;
|
|
100
|
+
height: 0.5rem;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
input[type="range"]::-moz-range-thumb {
|
|
104
|
+
@apply bg-lookbook-input-toggle-active;
|
|
105
|
+
border: none;
|
|
106
|
+
border-radius: 0.5rem;
|
|
107
|
+
height: 1rem;
|
|
108
|
+
width: 1rem;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
input[type="range"]:focus::-webkit-slider-thumb,
|
|
112
|
+
input[type="range"]:focus::-moz-range-thumb {
|
|
113
|
+
@apply outline-1 outline-lookbook-input-toggle-active outline-offset-2;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
input[type="color"] {
|
|
117
|
+
-webkit-appearance: none;
|
|
118
|
+
width: 46px;
|
|
119
|
+
@apply border border-lookbook-input-border rounded-lg cursor-pointer;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
input[type="color"]::-webkit-color-swatch-wrapper {
|
|
123
|
+
padding: 0;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
input[type="color"]::-webkit-color-swatch {
|
|
127
|
+
@apply border-0 rounded-lg;
|
|
54
128
|
}
|
|
55
129
|
}
|
|
@@ -5,10 +5,20 @@ import { isExternalLink } from "./helpers/dom";
|
|
|
5
5
|
|
|
6
6
|
export default function app() {
|
|
7
7
|
return {
|
|
8
|
+
_requestsInProgress: 0,
|
|
9
|
+
|
|
8
10
|
version: Alpine.$persist("").as("lookbook-version"),
|
|
9
11
|
|
|
10
12
|
location: window.location,
|
|
11
13
|
|
|
14
|
+
get sidebarHidden() {
|
|
15
|
+
return this.$store.layout.sidebar.hidden;
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
get loading() {
|
|
19
|
+
return this._requestsInProgress > 0;
|
|
20
|
+
},
|
|
21
|
+
|
|
12
22
|
init() {
|
|
13
23
|
if (window.SOCKET_PATH) {
|
|
14
24
|
console.log("SOCKET CREATED");
|
|
@@ -42,6 +52,7 @@ export default function app() {
|
|
|
42
52
|
async updateDOM() {
|
|
43
53
|
this.debug("Starting DOM update");
|
|
44
54
|
this.$dispatch("dom:update-start");
|
|
55
|
+
this.requestStart();
|
|
45
56
|
try {
|
|
46
57
|
const { fragment, title } = await fetchHTML(
|
|
47
58
|
window.location,
|
|
@@ -49,6 +60,7 @@ export default function app() {
|
|
|
49
60
|
);
|
|
50
61
|
morph(this.$root, fragment);
|
|
51
62
|
document.title = title;
|
|
63
|
+
this.requestEnd();
|
|
52
64
|
this.$dispatch("dom:update-complete");
|
|
53
65
|
this.debug("DOM update complete");
|
|
54
66
|
} catch (err) {
|
|
@@ -67,8 +79,14 @@ export default function app() {
|
|
|
67
79
|
}
|
|
68
80
|
},
|
|
69
81
|
|
|
70
|
-
|
|
71
|
-
|
|
82
|
+
requestStart() {
|
|
83
|
+
this._requestsInProgress += 1;
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
requestEnd() {
|
|
87
|
+
if (this._requestsInProgress > 0) {
|
|
88
|
+
this._requestsInProgress -= 1;
|
|
89
|
+
}
|
|
72
90
|
},
|
|
73
91
|
|
|
74
92
|
...Alpine.$log,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default function
|
|
1
|
+
export default function paramsInputComponent({ name, value }) {
|
|
2
2
|
return {
|
|
3
3
|
name,
|
|
4
4
|
value,
|
|
@@ -19,18 +19,5 @@ export default function paramsEditorFieldComponent({ name, value }) {
|
|
|
19
19
|
validate() {
|
|
20
20
|
return this.$root.reportValidity ? this.$root.reportValidity() : true;
|
|
21
21
|
},
|
|
22
|
-
|
|
23
|
-
get isNarrowLayout() {
|
|
24
|
-
return this.narrow || false;
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
bindings: {
|
|
28
|
-
input: {
|
|
29
|
-
[":id"]: "`param-${name}`",
|
|
30
|
-
["x-ref"]: "input",
|
|
31
|
-
["x-model.debounce.200"]: "value",
|
|
32
|
-
["@keydown.stop"]: true,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
22
|
};
|
|
36
23
|
}
|
|
@@ -19,7 +19,7 @@ import app from "./app";
|
|
|
19
19
|
// Note: A ParcelJS issue prevents loading all depths of component JS files in one glob,
|
|
20
20
|
// so need to split it up. Path aliases also do not work with the glob imports.
|
|
21
21
|
import { getComponents } from "./helpers/build";
|
|
22
|
-
import * as components from "../../../components/lookbook
|
|
22
|
+
import * as components from "../../../components/lookbook/*/*component.js";
|
|
23
23
|
import * as subComponents from "../../../components/lookbook/*/*/component.js";
|
|
24
24
|
import * as jsComponents from "./components/*.js";
|
|
25
25
|
|
|
@@ -50,6 +50,7 @@ Alpine.data("app", app);
|
|
|
50
50
|
[components, subComponents, jsComponents].forEach((scripts) => {
|
|
51
51
|
const components = getComponents(scripts);
|
|
52
52
|
Object.keys(components).forEach((name) => {
|
|
53
|
+
console.log(name);
|
|
53
54
|
Alpine.data(`${name}Component`, components[name]);
|
|
54
55
|
});
|
|
55
56
|
});
|
|
@@ -12,11 +12,10 @@ module Lookbook
|
|
|
12
12
|
merged_classes = class_names(attrs[:class], @html_attrs[:class])
|
|
13
13
|
merged_attrs = @html_attrs.except(:class).deep_merge(attrs.except(:class))
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
name: component_name,
|
|
15
|
+
lookbook_tag tag, name: component_name,
|
|
17
16
|
**merged_attrs,
|
|
18
17
|
"x-data": prepare_alpine_data(merged_attrs[:"x-data"]),
|
|
19
|
-
class: merged_classes
|
|
18
|
+
class: merged_classes, &block
|
|
20
19
|
end
|
|
21
20
|
|
|
22
21
|
def component_name
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
disabled: @disabled,
|
|
11
11
|
"@keydown.esc.stop": "hideDropdown" do %>
|
|
12
12
|
<span x-ref="icon">
|
|
13
|
-
<%= icon ||
|
|
13
|
+
<%= icon || lookbook_render(:icon, name: @icon, size: icon_size, ":class": "{'animate-spin': _spinning}") %>
|
|
14
14
|
</span>
|
|
15
15
|
<% if @tooltip %>
|
|
16
16
|
<label class="hidden" x-ref="tooltip"><%= @tooltip %></label>
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<% if content %>
|
|
19
19
|
<div x-ref="content"><%== content %></div>
|
|
20
20
|
<% end %>
|
|
21
|
-
<% if dropdown %>
|
|
21
|
+
<% if dropdown? %>
|
|
22
22
|
<div class="hidden" x-ref="dropdown">
|
|
23
23
|
<div class="bg-white divide-y divide-lookbook-divider text-left">
|
|
24
24
|
<%== dropdown %>
|
|
@@ -4,6 +4,7 @@ module Lookbook
|
|
|
4
4
|
renders_one :dropdown
|
|
5
5
|
|
|
6
6
|
ICON_SIZES = {
|
|
7
|
+
xs: 3,
|
|
7
8
|
sm: 3.5,
|
|
8
9
|
md: 4,
|
|
9
10
|
lg: 6
|
|
@@ -23,13 +24,17 @@ module Lookbook
|
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
def padding
|
|
26
|
-
|
|
27
|
+
[:xs, :sm].include?(@size) ? "p-1" : "p-2"
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
def tag_name
|
|
30
31
|
@href.present? ? :a : :button
|
|
31
32
|
end
|
|
32
33
|
|
|
34
|
+
def dropdown?
|
|
35
|
+
dropdown.present?
|
|
36
|
+
end
|
|
37
|
+
|
|
33
38
|
protected
|
|
34
39
|
|
|
35
40
|
def alpine_component
|
|
@@ -2,12 +2,11 @@ module Lookbook
|
|
|
2
2
|
class ButtonGroup::Component < Lookbook::BaseComponent
|
|
3
3
|
renders_many :buttons, ->(copy: nil, **attrs, &block) do
|
|
4
4
|
attrs[:size] = @size
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
if copy.present?
|
|
6
|
+
lookbook_render :copy_button, target: copy, **attrs, &block
|
|
7
7
|
else
|
|
8
|
-
|
|
8
|
+
lookbook_render :button, **attrs, &block
|
|
9
9
|
end
|
|
10
|
-
render instance, &block
|
|
11
10
|
end
|
|
12
11
|
|
|
13
12
|
def initialize(size: :md, **html_attrs)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<%= render_component_tag class: "divide-y divide-lookbook-divider min-w-[180px]" do %>
|
|
2
|
+
<div class="px-3 py-3">
|
|
3
|
+
<ul class="space-y-2 opacity-80">
|
|
4
|
+
<% if debug_data? %>
|
|
5
|
+
<li>
|
|
6
|
+
<a href="#"
|
|
7
|
+
class="text-xs flex items-center hover:underline"
|
|
8
|
+
x-data="clipboardComponent"
|
|
9
|
+
@click.prevent.stop="copyToClipboard('#debug-data')">
|
|
10
|
+
<span x-show="copied" x-cloak>
|
|
11
|
+
<%= icon :check, size: 2.5, class: "text-green-600" %>
|
|
12
|
+
</span>
|
|
13
|
+
<span x-show="!copied">
|
|
14
|
+
<%= icon :clipboard, size: 2.5 %>
|
|
15
|
+
</span>
|
|
16
|
+
<span class="ml-2">Copy debug data</span>
|
|
17
|
+
</a>
|
|
18
|
+
</li>
|
|
19
|
+
<% end %>
|
|
20
|
+
<li>
|
|
21
|
+
<a href="#"
|
|
22
|
+
class="text-xs flex items-center hover:underline"
|
|
23
|
+
@click.stop="localStorage.clear(); window.location.reload();">
|
|
24
|
+
<%= icon :refresh_cw, size: 2.5 %>
|
|
25
|
+
<span class="ml-2">Reset local storage</span>
|
|
26
|
+
</a>
|
|
27
|
+
</li>
|
|
28
|
+
</ul>
|
|
29
|
+
</div>
|
|
30
|
+
<div class="flex items-center text-xs px-3 py-2 bg-zinc-50">
|
|
31
|
+
<span class="opacity-70 mr-1">Lookbook</span>
|
|
32
|
+
<span class="mr-6">v<%= @version %></span>
|
|
33
|
+
<div class="flex items-center space-x-2">
|
|
34
|
+
<% if @docs_url.present? %>
|
|
35
|
+
<a href="<%= @docs_url %>" target="_blank" class="ml-auto opacity-70" title="Documentation">
|
|
36
|
+
<%= icon :book, size: 3 %>
|
|
37
|
+
</a>
|
|
38
|
+
<% end %>
|
|
39
|
+
<% if @repo_url.present? %>
|
|
40
|
+
<a href="<%= @repo_url %>" target="_blank" class="ml-auto opacity-70" title="Github">
|
|
41
|
+
<%= icon :github, size: 3 %>
|
|
42
|
+
</a>
|
|
43
|
+
<% end %>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
<% if debug_data? %>
|
|
47
|
+
<div id="debug-data" class="hidden" x-cloak>
|
|
48
|
+
<%== debug_data %>
|
|
49
|
+
</div>
|
|
50
|
+
<% end %>
|
|
51
|
+
<% end %>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Lookbook
|
|
2
|
+
class DebugMenu::Component < Lookbook::BaseComponent
|
|
3
|
+
def initialize(version: nil, docs_url: nil, repo_url: nil, **html_attrs)
|
|
4
|
+
@version = version
|
|
5
|
+
@docs_url = docs_url
|
|
6
|
+
@repo_url = repo_url
|
|
7
|
+
super(**html_attrs)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def debug_data
|
|
11
|
+
content
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def debug_data?
|
|
15
|
+
debug_data.present?
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
<% if @target.present? %>
|
|
2
2
|
<%= render_component_tag class: "not-prose border-b border-lookbook-divider rounded-sm overflow-hidden", "@navigation:start.window": "cleanup" do %>
|
|
3
3
|
|
|
4
|
-
<%=
|
|
4
|
+
<%= lookbook_render :toolbar, class: "border border-b-0 border-lookbook-divider" do |toolbar| %>
|
|
5
5
|
<% toolbar.section padded: true do %>
|
|
6
6
|
<h3>
|
|
7
7
|
<%= @target.preview.label %> (<%= @target.label %>)
|
|
8
8
|
</h3>
|
|
9
9
|
<% end %>
|
|
10
10
|
<% toolbar.section align: :right, divide: :left do %>
|
|
11
|
-
<%=
|
|
11
|
+
<%= lookbook_render :button_group do |group| %>
|
|
12
12
|
<% group.button icon: :eye,
|
|
13
13
|
href: lookbook_inspect_path(@target.path, @params),
|
|
14
14
|
tooltip: "View in Inspector" %>
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
@viewport:resize-progress="resizeIframe"
|
|
28
28
|
@viewport:resize-complete="resizeIframe"
|
|
29
29
|
@tabs:change.window="resizeIframe">
|
|
30
|
-
<%=
|
|
30
|
+
<%= lookbook_render :viewport,
|
|
31
31
|
src: lookbook_preview_path(@target.path, @params.merge(lookbook_embed: true)),
|
|
32
32
|
alpine_data: "store",
|
|
33
33
|
resize_height: false,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<%= render_component_tag :header do %>
|
|
2
|
-
<%=
|
|
2
|
+
<%= lookbook_render :toolbar, class: "!bg-lookbook-header-bg !text-lookbook-header-text !border-lookbook-header-border" do |toolbar| %>
|
|
3
3
|
<% toolbar.section padded: true do %>
|
|
4
4
|
<% if branding.present? %>
|
|
5
5
|
<a
|
|
@@ -11,57 +11,32 @@
|
|
|
11
11
|
<% end %>
|
|
12
12
|
|
|
13
13
|
<% toolbar.section padded: false, align: :right, class: "flex items-center" do %>
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
<div x-show="loading" x-cloak>
|
|
16
|
+
<svg class="animate-spin h-3.5 w-3.5 text-lookbook-header-text opacity-60" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
17
|
+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
18
|
+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
19
|
+
</svg>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<%= lookbook_render :button_group do |group| %>
|
|
15
23
|
<% if @debug_menu %>
|
|
16
|
-
<% group.button icon: :help_circle, class: "opacity-50 hover:opacity-100 transition !text-lookbook-header-text" do |button| %>
|
|
17
|
-
<%
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<a href="#"
|
|
23
|
-
class="text-xs flex items-center hover:underline"
|
|
24
|
-
x-data="clipboardComponent"
|
|
25
|
-
@click.prevent.stop="copyToClipboard('#debug-data')">
|
|
26
|
-
<span x-show="copied" x-cloak>
|
|
27
|
-
<%= icon :check, size: 2.5, class: "text-green-600" %>
|
|
28
|
-
</span>
|
|
29
|
-
<span x-show="!copied">
|
|
30
|
-
<%= icon :clipboard, size: 2.5 %>
|
|
31
|
-
</span>
|
|
32
|
-
<span class="ml-2">Copy debug data</span>
|
|
33
|
-
</a>
|
|
34
|
-
</li>
|
|
35
|
-
<li>
|
|
36
|
-
<a href="#"
|
|
37
|
-
class="text-xs flex items-center hover:underline"
|
|
38
|
-
@click.stop="localStorage.clear(); window.location.reload();">
|
|
39
|
-
<%= icon :refresh_cw, size: 2.5 %>
|
|
40
|
-
<span class="ml-2">Reset local storage</span>
|
|
41
|
-
</a>
|
|
42
|
-
</li>
|
|
43
|
-
</ul>
|
|
44
|
-
</div>
|
|
45
|
-
<div class="flex items-center text-xs px-3 py-2 bg-zinc-50">
|
|
46
|
-
<span class="opacity-70 mr-1">Lookbook</span>
|
|
47
|
-
<span class="mr-6">v<%= Lookbook::VERSION %></span>
|
|
48
|
-
<div class="flex items-center space-x-2">
|
|
49
|
-
<a href="https://lookbook.build/guide" target="_blank" class="ml-auto opacity-70" title="Documentation">
|
|
50
|
-
<%= icon :book, size: 3 %>
|
|
51
|
-
</a>
|
|
52
|
-
<a href="https://github.com/allmarkedup/lookbook" target="_blank" class="ml-auto opacity-70" title="Github">
|
|
53
|
-
<%= icon :github, size: 3 %>
|
|
54
|
-
</a>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
<% end %>
|
|
24
|
+
<% group.button icon: :help_circle, class: "opacity-50 hover:opacity-100 transition !text-lookbook-header-text", "x-show": "!loading" do |button| %>
|
|
25
|
+
<% menu = lookbook_render :debug_menu,
|
|
26
|
+
version: Lookbook::VERSION,
|
|
27
|
+
docs_url: "https://lookbook.build/guide",
|
|
28
|
+
repo_url: "https://github.com/allmarkedup/lookbook" do %>
|
|
29
|
+
<%= helpers.pretty_json(Lookbook.debug_data) %>
|
|
58
30
|
<% end %>
|
|
31
|
+
<% button.dropdown({}).with_content(menu) %>
|
|
59
32
|
<% end %>
|
|
60
33
|
<% end %>
|
|
34
|
+
|
|
61
35
|
<% group.button icon: :menu,
|
|
62
36
|
"@click.stop": "toggleSidebar",
|
|
63
37
|
"x-show": "$store.layout.mobile && sidebarHidden",
|
|
64
38
|
class: "!text-lookbook-header-text" %>
|
|
39
|
+
|
|
65
40
|
<% group.button icon: :x,
|
|
66
41
|
"@click.stop": "toggleSidebar",
|
|
67
42
|
"x-show": "$store.layout.mobile && !sidebarHidden",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<%= render_component_tag :div, class: "h-full" do %>
|
|
2
|
-
<% if panel_styles %>
|
|
3
|
-
<% content_for :panel_css do %><%= panel_styles %><% end %>
|
|
4
|
-
<% end %>
|
|
5
2
|
<%= panel_html %>
|
|
3
|
+
<% end %>
|
|
4
|
+
|
|
5
|
+
<% if panel_styles %>
|
|
6
|
+
<% content_for :user_styles do %><%= panel_styles %>
|
|
7
|
+
<% end %>
|
|
6
8
|
<% end %>
|
|
@@ -4,30 +4,18 @@ module Lookbook
|
|
|
4
4
|
class InspectorPanel::Component < Lookbook::BaseComponent
|
|
5
5
|
attr_reader :panel_styles, :panel_html, :id
|
|
6
6
|
|
|
7
|
-
def initialize(id:, name:,
|
|
7
|
+
def initialize(id:, name:, **attrs)
|
|
8
8
|
@id = id
|
|
9
9
|
@name = name
|
|
10
|
-
@system = system
|
|
11
|
-
|
|
12
|
-
@panel_styles = nil
|
|
13
|
-
super(**html_attrs)
|
|
10
|
+
@system = attrs[:system] || false
|
|
11
|
+
super(**attrs.except(:system))
|
|
14
12
|
end
|
|
15
13
|
|
|
16
14
|
def before_render
|
|
17
15
|
if @system == false
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
css_parser = ::CssParser::Parser.new
|
|
22
|
-
@panel_styles = ""
|
|
23
|
-
style_tags.each do |style_tag|
|
|
24
|
-
css_parser.load_string! style_tag.text
|
|
25
|
-
css_parser.each_selector do |selector, declarations, specificity|
|
|
26
|
-
@panel_styles += "##{id} #{selector} { #{declarations} }\n"
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
@panel_html = content.gsub(/<style(?:\s[^>]*)?>.*<\/style>/, "").html_safe
|
|
30
|
-
end
|
|
16
|
+
tpl = TemplateParser.new(content)
|
|
17
|
+
@panel_styles = tpl.styles.map { |s| "##{id} #{s}" }.join("\n")
|
|
18
|
+
@panel_html = tpl.content
|
|
31
19
|
end
|
|
32
20
|
@panel_html ||= content
|
|
33
21
|
end
|
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
"entity-type": item.type
|
|
7
7
|
},
|
|
8
8
|
cloak: true do %>
|
|
9
|
-
<%=
|
|
9
|
+
<%= lookbook_tag href.present? ? :a : :div,
|
|
10
10
|
href: href,
|
|
11
|
-
class: "flex items-center py-1 select-none cursor-pointer text-lookbook-nav-text hover:bg-lookbook-nav-item-hover",
|
|
11
|
+
class: "flex items-center py-1 select-none cursor-pointer text-lookbook-nav-text hover:bg-lookbook-nav-item-hover transition",
|
|
12
12
|
style: "padding-left: #{left_pad}px",
|
|
13
13
|
"x-bind": "bindings.#{href.present? ? "link" : "toggle"}" do %>
|
|
14
|
-
<div class="relative flex items-center">
|
|
14
|
+
<div class="relative flex items-center w-full">
|
|
15
15
|
<%= icon nil,
|
|
16
16
|
size: 3,
|
|
17
17
|
class: "mr-1 text-lookbook-nav-toggle absolute -left-4",
|
|
18
18
|
"x-effect": "iconName = open ? 'chevron-down' : 'chevron-right'" if children? %>
|
|
19
19
|
<%= icon nav_icon, size: 3.5, class: "mr-1.5 text-lookbook-nav-icon-stroke" %>
|
|
20
|
-
<span <% if @item.type == :preview %>
|
|
20
|
+
<span class="truncate <% if @item.type == :preview %>font-bold<% end %>"><%= label %></span>
|
|
21
21
|
</div>
|
|
22
22
|
<% end %>
|
|
23
23
|
|
|
@@ -45,7 +45,7 @@ module Lookbook
|
|
|
45
45
|
def children
|
|
46
46
|
@children ||= if collection? && !collapsed?
|
|
47
47
|
item.non_empty_items.map do |item|
|
|
48
|
-
|
|
48
|
+
lookbook_render Lookbook::Nav::Item::Component.new item,
|
|
49
49
|
nav_id: @nav_id,
|
|
50
50
|
depth: (@depth + 1),
|
|
51
51
|
collapse_singles: @collapse_singles
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<%= render_component_tag "x-data": "{ activeTab: null }" do %>
|
|
2
2
|
<div class="flex w-full border-b border-lookbook-divider mb-6">
|
|
3
|
-
<%=
|
|
3
|
+
<%= lookbook_render :tabs, theme: :page do |t| %>
|
|
4
4
|
<% @tabs.each do |props| %>
|
|
5
5
|
<%= t.tab **props %>
|
|
6
6
|
<% end %>
|
|
7
7
|
<% end %>
|
|
8
8
|
</div>
|
|
9
|
-
<%=
|
|
9
|
+
<%= lookbook_render :tab_panels do |t| %>
|
|
10
10
|
<% @tabs.each do |props| %>
|
|
11
11
|
<% t.panel name: props[:name] do %>
|
|
12
|
-
<%=
|
|
13
|
-
<%== props[:
|
|
12
|
+
<%= lookbook_render :prose, markdown: props[:markdown], class: "max-w-none flex-none" do %>
|
|
13
|
+
<%== props[:tab_content] %>
|
|
14
14
|
<% end %>
|
|
15
15
|
<% end %>
|
|
16
16
|
<% end %>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<%= render_component_tag class: "p-4 overflow-hidden" do %>
|
|
2
|
+
<div class="bg-white border border-lookbook-divider rounded-md overflow-x-auto">
|
|
3
|
+
<table class="border-collapse w-full" :class="narrow && 'linear'">
|
|
4
|
+
<thead>
|
|
5
|
+
<tr>
|
|
6
|
+
<th class="param-label">Param</th>
|
|
7
|
+
<th class="param-description">Description</th>
|
|
8
|
+
<th class="param-input">Input</th>
|
|
9
|
+
</tr>
|
|
10
|
+
</thead>
|
|
11
|
+
<tbody>
|
|
12
|
+
<%= safe_join(fields.compact) %>
|
|
13
|
+
</tbody>
|
|
14
|
+
</table>
|
|
15
|
+
</div>
|
|
16
|
+
<% end %>
|
|
17
|
+
|
|
18
|
+
<% if param_styles %>
|
|
19
|
+
<% content_for :user_styles do %><%= param_styles %>
|
|
20
|
+
<% end %>
|
|
21
|
+
<% end %>
|