lookbook 1.0.0.rc.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 74c62e76c265b02970bc86ad242fb43c347ccf0ad141b512148f3ef1e3eb2ae9
4
- data.tar.gz: d389ed323fa6918a5919865414e6c4b17e23870a27d398ba92af055ffa958bf4
3
+ metadata.gz: 5617d397419ae8b9e95fa6c53ceb94dd3a7dffe83ea1fae0f643f17f6c15b995
4
+ data.tar.gz: 1fb037740def1192fa5aa9d0c076419dc06ed629996e7cc82ed741e7aefa000f
5
5
  SHA512:
6
- metadata.gz: a64d8542e71251f52b36d88548dfe5fbd0347c1d6a52ff6e0f6bbe8e1e256d93a5761089f7594b95453c7865bf619822483efa229fe011474d2f2818d9bcd96c
7
- data.tar.gz: 2360d8e4a06cf428dd10c7ea3d39d9d17b4bea377fa98861e9f3848026d3b9ed60da882df07005bd9547891fd63b88a8368da4a15dedc076de759a1418a06385
6
+ metadata.gz: a5710f8a40f7594bc4d9ac3347ca8c04102f708b50c21d96d1695b26ab4d6ccc23436e1288cea7d43516264260c31f091530cb15d3ea144707d2ae280442c333
7
+ data.tar.gz: 1bfdcf6ce5bb68e2af399b5920ec821a73057e77aaf4732216da498b1745c5c8eb15b220ce56115dd8c14d757febe75315c2620c6c6c929b3e973d001a5b7797
data/README.md CHANGED
@@ -1,83 +1,52 @@
1
- # Lookbook v1.0
1
+ # Lookbook
2
2
 
3
3
  <div>
4
4
  <a href="https://rubygems.org/gems/lookbook"><img src="https://img.shields.io/gem/v/lookbook?include_prereleases" alt="Gem version"></a>
5
- <img src="https://github.com/allmarkedup/lookbook/actions/workflows/ci.yml/badge.svg?branch=v1.0-beta" alt="CI status">
5
+ <a href="https://github.com/allmarkedup/lookbook/actions/workflows/ci.yml"><img src="https://github.com/allmarkedup/lookbook/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI status"></a>
6
6
  </div>
7
7
  <br>
8
8
 
9
- > **This is the Lookbook v1.0 BETA development branch.**<br>
10
- >_For code and documentation for the current stable release see the [main branch](https://github.com/allmarkedup/lookbook/tree/main)._
9
+ A tool to help develop, test and document [ViewComponents](https://viewcomponent.org/) in isolation.
11
10
 
11
+ ## Documentation
12
12
 
13
- ## Get started
13
+ **Lookbook (v1.x)** documentation: **[https://lookbook.build](https://lookbook.build)**
14
14
 
15
- If you are already using Lookbook in your project, just update the Lookbook gem to the latest beta release and then head over to the [beta documentation site](https://beta.lookbook.build/) to read more about the new features.
15
+ > _Looking for v0.9.x docs? [Head over here](https://github.com/allmarkedup/lookbook/tree/0.9.x)._
16
16
 
17
- ```ruby
18
- gem "lookbook", ">= 1.0.0.beta.8"
19
- ```
20
17
 
21
- If you are **new to Lookbook** then check out the <a href="https://beta.lookbook.build/guide/quick-start/">v1.0 quick start guide</a> for more detailed instructions on installing Lookbook in your project
22
-
23
-
24
- <h4>Useful Resources</h4>
25
-
26
- * 👉 <a href="https://beta.lookbook.build/">v1.0 docs</a>
27
- * 👉 <a href="https://lookbook-demo-app-v1-0-beta.herokuapp.com/lookbook">v1.0 demo app</a> <em>(The repo for the demo <a href="https://github.com/allmarkedup/lookbook-demo/tree/v1.0-beta">is here</a> if you want to dig in further)</em>
28
-
29
-
30
-
31
- ## Changes and new features in v1.0
32
-
33
- Lookbook v1.0 includes a completely re-written UI, many under-the hood improvements and a some exciting new customisation options.
34
-
35
- ### Frontend changes:
36
-
37
- * Completely re-written UI - now built with ViewComponents
38
- * New [UI themes and customisation options](https://beta.lookbook.build/guide/themes/)
39
- * Improved small-screen/mobile view
40
- * Debug menu
41
- * ...and many other small visual and usability improvements
42
-
43
- ### New options for extending Lookbook:
44
-
45
- * Define [custom tags](https://beta.lookbook.build/guide/extend/tags/) for preview file annotations
46
- * Create [your own tab panels](https://beta.lookbook.build/guide/extend/panels/) - with complete control over content/layout and access to all Lookbook data
47
- * Use [lifecycle hooks](https://beta.lookbook.build/guide/extend/hooks/) to run your own code when Lookbook starts up, when files change or at shutdown
48
-
49
- ### Other changes
50
-
51
- * 'Workbench' app for developing Lookbook's UI components in Lookbook
52
- * New Rspec-based test suite and dummy app
53
- * All new documentation site built using [Bridgetown](https://www.bridgetownrb.com/)
18
+ ## Demo
54
19
 
20
+ **Online Demo:** [https://lookbook-demo-app-v1-0-beta.herokuapp.com/lookbook](https://lookbook-demo-app-v1-0-beta.herokuapp.com/lookbook)
55
21
 
56
22
  [![Lookbook UI](.github/assets/lookbook_screenshot_v1.0_beta.png)](https://lookbook-demo-app-v1-0-beta.herokuapp.com/lookbook/)
57
23
 
58
- ## Workbench
59
24
 
60
- 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:
25
+ ## Development
26
+
27
+ Lookbook's UI is itself built using ViewComponents. To preview these components in a Lookbook instance you can run the included `workbench` app:
61
28
 
62
29
  1. Clone this repo
63
30
  2. Install dependencies: `bundle install & npm install`
64
- 3. Start the Workbench: `foreman start`
65
- 4. Open http://localhost:4545 in your browser to view the Workbench
31
+ 3. Start the app: `bin/workbench`
32
+ 4. Visit http://localhost:4545/lookbook to view the Lookbook instance
33
+
34
+ The `workbench` app will be started in development mode and any changes to Lookbook's views or assets will immediately be reflected in the UI.
66
35
 
67
- This will start the Workbench app in development mode and any changes to Lookbooks views or assets will immediately be visible in the UI.
36
+ ### Docs site
68
37
 
38
+ The [Lookbook docs site](https://lookbook.build) is built using [Bridgetown](https://www.bridgetownrb.com/) and the source files can be found in the `./docs` directory.
69
39
 
70
- ## Running tests
40
+ To see a local version of the site run `bin/docs` from the root of this repo and then visit http://localhost:4000 in your browser.
71
41
 
72
- The test suite is in the process of being completely overhauled.
42
+ ### Testing
73
43
 
74
- Tests are now written using RSpec and the system now uses [Combustion](https://github.com/pat/combustion) under the hood.
44
+ Lookbook uses RSpec for testing.
75
45
 
76
- - Tests can be run using the `rake lookbook:test` or `bundle exec rspec` commands.
77
- - 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
46
+ Tests can be run using the `rake spec` or `bundle exec rspec` commands.
78
47
 
48
+ The dummy app that the tests are being run against can be viewed by running the `bin/dummy` command and then browsing to http://localhost:9292/lookbook
79
49
 
80
- ---
81
50
 
82
51
  ## License
83
52
 
@@ -19,7 +19,7 @@ function initClipboard(context = {}) {
19
19
  return false;
20
20
  }
21
21
 
22
- const content = decodeEntities(targetEl.innerText.trim());
22
+ const content = decodeEntities(targetEl.innerHTML.trim());
23
23
 
24
24
  await window.navigator.clipboard.writeText(content);
25
25
  this.copied = true;
@@ -35,7 +35,7 @@ module Lookbook
35
35
  alpine_component_name = x_data || @html_attrs&.dig(:"x-data") || alpine_component
36
36
  if alpine_component_name.present?
37
37
  args = Array.wrap(alpine_data)
38
- args.any? ? "#{alpine_component_name}(#{safe_join(args).gsub("&quot;", "'").tr("\"", "'")})" : alpine_component_name
38
+ args.any? ? "#{alpine_component_name}(#{safe_join(args)})" : alpine_component_name
39
39
  end
40
40
  end
41
41
  end
@@ -13,7 +13,7 @@
13
13
  href: lookbook_inspect_path(@example.path, @params),
14
14
  tooltip: "View in Inspector" %>
15
15
  <% group.button icon: :external_link,
16
- href: lookbook_inspect_path(@example.path, @params),
16
+ href: lookbook_preview_path(@example.path, @params),
17
17
  tooltip: "Open in new window",
18
18
  target: "_blank" %>
19
19
  <% end %>
@@ -1,7 +1,7 @@
1
1
  <%= render_component_tag class: "px-4 py-3" do %>
2
2
  <div class="flex items-start max-w-[800px]" :class="isNarrowLayout && '!block'">
3
3
  <label
4
- for="param-<%= @name %>"
4
+ for="param-<%= name %>"
5
5
  class="block font-bold cursor-pointer flex-none py-2 w-[140px] truncate pr-2">
6
6
  <%= label %>
7
7
  </label>
@@ -27,12 +27,12 @@
27
27
  <select
28
28
  class="form-input"
29
29
  x-bind="bindings.input || {}"
30
- x-model="value">
30
+ x-model="value"
31
+ name="<%= name %>">
31
32
  <%= options_for_select(@options || [], value) %>
32
33
  </select>
33
34
 
34
35
  <% elsif field_type == "toggle" %>
35
-
36
36
  <button type="button"
37
37
  class="<%= value == true ? "bg-lookbook-input-toggle-active" : "bg-lookbook-input-toggle" %> relative inline-flex flex-shrink-0 h-6 w-11 border-2 border-transparent rounded-full cursor-pointer transition-colors ease-in-out duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-input-border-focus"
38
38
  role="switch"
@@ -42,7 +42,6 @@
42
42
  class="<%= value == true ? "translate-x-5" : "translate-x-0" %> pointer-events-none inline-block h-5 w-5 rounded-full bg-white shadow ring-0 transition ease-in-out duration-200"
43
43
  ></span>
44
44
  </button>
45
-
46
45
  <% end %>
47
46
  </div>
48
47
  </div>
@@ -1,5 +1,7 @@
1
1
  module Lookbook
2
2
  class ParamsEditor::Field::Component < Lookbook::BaseComponent
3
+ attr_reader :name
4
+
3
5
  def initialize(input:, name:, default: nil, value: nil, input_type: nil, type: nil, options: nil, **html_attrs)
4
6
  @input = input
5
7
  @name = name
@@ -12,7 +14,7 @@ module Lookbook
12
14
  end
13
15
 
14
16
  def label
15
- @name.titleize
17
+ name.titleize
16
18
  end
17
19
 
18
20
  def value
@@ -31,8 +33,8 @@ module Lookbook
31
33
  protected
32
34
 
33
35
  def alpine_data
34
- escaped_value = value.is_a?(String) ? helpers.j(value) : value
35
- "{name: '#{@name}', value: '#{escaped_value}'}"
36
+ escaped_value = helpers.raw json_escape(value.to_json)
37
+ "{name: '#{name}', value: #{escaped_value}}"
36
38
  end
37
39
 
38
40
  def alpine_component
@@ -1,5 +1,6 @@
1
1
  module Lookbook
2
2
  class ApplicationController < ActionController::Base
3
+ content_security_policy false, if: -> { Rails.env.development? }
3
4
  protect_from_forgery with: :exception
4
5
 
5
6
  helper Lookbook::ApplicationHelper
@@ -1,4 +1,3 @@
1
- require "rails"
2
1
  require "view_component"
3
2
  require "action_cable/engine"
4
3
  require "listen"
@@ -14,7 +14,7 @@ module Lookbook
14
14
  render html: render_to_string(template, **opts)
15
15
  end
16
16
 
17
- def render_in_layout_to_string(template, locals, **opts)
17
+ def render_in_layout_to_string(template, locals, opts = {})
18
18
  append_view_path Lookbook::Engine.root.join("app/views")
19
19
  html = render_to_string(template, locals: locals, **determine_layout(opts[:layout]))
20
20
  if opts[:append_html].present?
@@ -1,3 +1,3 @@
1
1
  module Lookbook
2
- VERSION = "1.0.0.rc.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -1,18 +1,6 @@
1
1
  require_relative "../lookbook"
2
2
 
3
3
  namespace :lookbook do
4
- desc "Run the rspec tests"
5
- task :test do
6
- sh "bundle exec rspec"
7
- end
8
-
9
- namespace :test do
10
- desc "Start a server to view the test app"
11
- task :serve do
12
- sh "bundle exec rackup"
13
- end
14
- end
15
-
16
4
  namespace :previews do
17
5
  desc "Preparse the previews"
18
6
  task preparse: :environment do
@@ -20,21 +8,4 @@ namespace :lookbook do
20
8
  puts "Lookbook preview parsing complete"
21
9
  end
22
10
  end
23
-
24
- namespace :release do
25
- desc "Bump the Lookbook engine version number"
26
- task :bump_version, [:version] do |t, args|
27
- filename = Lookbook::Engine.root.join("lib/lookbook/version.rb")
28
- current_version = Lookbook::VERSION.to_s
29
- new_version = args[:version].sub("v", "").tr("-", ".")
30
- file = File.open(filename)
31
- contents = file.read
32
- File.write(filename, contents.gsub(current_version, new_version))
33
- end
34
-
35
- desc "Build Gem and push to RubyGems"
36
- task :build_and_push do
37
- sh("rake build && gem push pkg/lookbook-#{Lookbook::VERSION}.gem")
38
- end
39
- end
40
11
  end
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA","sources":["app/assets/lookbook/css/themes/zinc.css"],"sourcesContent":[":root {\n --lookbook-white: theme(\"colors.white\");\n --lookbook-accent-50: theme(\"colors.zinc.50\");\n --lookbook-accent-100: theme(\"colors.zinc.100\");\n --lookbook-accent-200: theme(\"colors.zinc.200\");\n --lookbook-accent-300: theme(\"colors.zinc.300\");\n --lookbook-accent-400: theme(\"colors.zinc.400\");\n --lookbook-accent-500: theme(\"colors.zinc.500\");\n --lookbook-accent-600: theme(\"colors.zinc.600\");\n --lookbook-accent-700: theme(\"colors.zinc.700\");\n --lookbook-accent-800: theme(\"colors.zinc.800\");\n --lookbook-accent-900: theme(\"colors.zinc.900\");\n --lookbook-base-50: theme(\"colors.zinc.50\");\n --lookbook-base-100: theme(\"colors.zinc.100\");\n --lookbook-base-200: theme(\"colors.zinc.200\");\n --lookbook-base-300: theme(\"colors.zinc.300\");\n --lookbook-base-400: theme(\"colors.zinc.400\");\n --lookbook-base-500: theme(\"colors.zinc.500\");\n --lookbook-base-600: theme(\"colors.zinc.600\");\n --lookbook-base-700: theme(\"colors.zinc.700\");\n --lookbook-base-800: theme(\"colors.zinc.800\");\n --lookbook-base-900: theme(\"colors.zinc.900\");\n --lookbook-text: var(--lookbook-base-800);\n --lookbook-divider: var(--lookbook-base-300);\n --lookbook-icon-button-stroke: var(--lookbook-base-400);\n --lookbook-icon-button-stroke-hover: var(--lookbook-accent-600);\n --lookbook-tooltip-bg: var(--lookbook-accent-500);\n --lookbook-tooltip-text: var(--lookbook-white);\n --lookbook-scrollbar: var(--lookbook-base-200);\n --lookbook-scrollbar-hover: var(--lookbook-base-300);\n --lookbook-toolbar-bg: var(--lookbook-white);\n --lookbook-toolbar-divider: var(--lookbook-divider);\n --lookbook-nav-text: var(--lookbook-text);\n --lookbook-nav-toggle: var(--lookbook-base-500);\n --lookbook-nav-icon-stroke: var(--lookbook-accent-500);\n --lookbook-nav-item-hover: var(--lookbook-base-100);\n --lookbook-nav-item-active: var(--lookbook-accent-50);\n --lookbook-input-bg: var(--lookbook-white);\n --lookbook-input-border: var(--lookbook-base-300);\n --lookbook-input-border-focus: var(--lookbook-accent-200);\n --lookbook-input-text: var(--lookbook-base-600);\n --lookbook-input-text-placeholder: var(--lookbook-base-400);\n --lookbook-input-toggle: var(--lookbook-base-300);\n --lookbook-input-toggle-active: var(--lookbook-accent-500);\n --lookbook-prose-bg: var(--lookbook-white);\n --lookbook-prose-text: var(--lookbook-base-600);\n --lookbook-prose-link: var(--lookbook-accent-900);\n --lookbook-tabs-text: var(--lookbook-base-500);\n --lookbook-tabs-text-hover: var(--lookbook-base-700);\n --lookbook-tabs-text-disabled: var(--lookbook-base-300);\n --lookbook-tabs-border-active: var(--lookbook-accent-400);\n --lookbook-viewport-handle: var(--lookbook-white);\n --lookbook-viewport-handle-icon-stroke: var(--lookbook-base-300);\n --lookbook-viewport-handle-icon-stroke-hover: var(--lookbook-base-700);\n --lookbook-sidebar-bg: var(--lookbook-base-50);\n --lookbook-page-bg: var(--lookbook-white);\n --lookbook-drawer-bg: var(--lookbook-base-50);\n --lookbook-header-bg: var(--lookbook-accent-600);\n --lookbook-header-text: var(--lookbook-white);\n --lookbook-header-border: var(--lookbook-accent-700);\n --lookbook-blank-slate-title: var(--lookbook-accent-600);\n --lookbook-branding-text: var(--lookbook-header-text);\n --lookbook-draggable-hint: rgb(224 231 255 / 0.2);\n}\n"],"names":[],"version":3,"file":"zinc.css.map","sourceRoot":"../../../../"}
File without changes
@@ -11421,7 +11421,7 @@ function $122263eab94cad08$export$c6684e6159b21de3(context = {}) {
11421
11421
  this.warn("Could not find copy target");
11422
11422
  return false;
11423
11423
  }
11424
- const content = (0, $7ae6ae39c2ec9059$export$6cb344a21ca18aec)(targetEl.innerText.trim());
11424
+ const content = (0, $7ae6ae39c2ec9059$export$6cb344a21ca18aec)(targetEl.innerHTML.trim());
11425
11425
  await window.navigator.clipboard.writeText(content);
11426
11426
  this.copied = true;
11427
11427
  if (copyTimeout) clearTimeout(copyTimeout);