Skip to content

Commit

Permalink
Merge branch 'ui'
Browse files Browse the repository at this point in the history
* ui:
  breadcrumbs: default props, and better mobile view
  feat(playground): Home page placeholder and UI WIP
  chore: Moved playground to ./playground to keep it independent of tests
  fix(Breadcrumbs): Rename class_name option to class
  Setup UI playground in dummy app
  Create mixin for breadcrumbs CSS
  Refactored stimulus-loading
  feat: Add /proscenium/ui alias to /proscenium/lib/proscenium/ui
  feat: UI::Breadcrumbs
  • Loading branch information
joelmoss committed Mar 28, 2024
2 parents 1f75899 + af93872 commit e150467
Show file tree
Hide file tree
Showing 155 changed files with 1,985 additions and 273 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
# Ignore the default SQLite database.
/fixtures/dummy/db/*.sqlite3
/fixtures/dummy/db/*.sqlite3-*
/playground/db/*.sqlite3
/playground/db/*.sqlite3-*

# Ignore all logfiles and tempfiles.
/fixtures/dummy/log/*
/fixtures/dummy/tmp/*
!/fixtures/dummy/log/.keep
!/fixtures/dummy/tmp/.keep
/playground/log/*
/playground/tmp/*
!/playground/log/.keep
!/playground/tmp/.keep

# Ignore pidfiles, but keep the directory.
/fixtures/dummy/tmp/pids/*
!/fixtures/dummy/tmp/pids/
!/fixtures/dummy/tmp/pids/.keep
/playground/tmp/pids/*
!/playground/tmp/pids/
!/playground/tmp/pids/.keep

# Ignore uploaded files in development.
/fixtures/dummy/storage/*
!/fixtures/dummy/storage/.keep
/playground/storage/*
!/playground/storage/.keep

/fixtures/dummy/public/assets
/playground/public/assets

/.bundle/
/.yardoc
Expand Down
3 changes: 2 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ AllCops:
NewCops: enable
SuggestExtensions: false
Exclude:
- "fixtures/dummy/**/*"
- "fixtures/dummy/node_modules/**/*"
- "fixtures/dummy/vendor/**/*"
- "fixtures/external/**/*"

Layout/LineLength:
Expand Down
10 changes: 6 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@ source 'https://rubygems.org'
# Specify your gem's dependencies in proscenium.gemspec
gemspec

gem 'puma'
gem 'phlex-rails'
gem 'rails', '~> 7.0'
gem 'sqlite3'

group :development do
gem 'benchmark-ips'
gem 'debug'
gem 'puma'
gem 'rubocop'
gem 'rubocop-packaging'
gem 'rubocop-performance'
gem 'rubocop-rake'
gem 'sqlite3'
gem 'web-console'
end

group :test do
gem 'view_component', '~> 3.6.0'
gem 'capybara'
gem 'cuprite'
gem 'dry-initializer'
Expand All @@ -26,8 +30,6 @@ group :test do
gem 'gem2', path: './fixtures/external/gem2'
gem 'gem3', path: './fixtures/dummy/vendor/gem3'
gem 'gem4', path: './fixtures/external/gem4'
gem 'phlex-rails'
gem 'phlex-testing-capybara'
gem 'sus'
gem 'view_component', '~> 3.6.0'
end
28 changes: 28 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ PATH
specs:
proscenium (0.15.0.beta.4)
activesupport (>= 6.1.0, < 8.0)
dry-initializer (~> 3.1)
dry-types (~> 1.7)
ffi (~> 1.16.3)
oj (~> 3.13)
railties (>= 6.1.0, < 8.0)
Expand Down Expand Up @@ -115,6 +117,7 @@ GEM
base64 (0.2.0)
benchmark-ips (2.13.0)
bigdecimal (3.1.7)
bindex (0.8.1)
builder (3.2.4)
capybara (3.40.0)
addressable
Expand All @@ -133,9 +136,27 @@ GEM
capybara (~> 3.0)
ferrum (~> 0.14.0)
date (3.3.4)
debug (1.9.1)
irb (~> 1.10)
reline (>= 0.3.8)
diff-lcs (1.5.1)
drb (2.2.1)
dry-core (1.0.1)
concurrent-ruby (~> 1.0)
zeitwerk (~> 2.6)
dry-inflector (1.0.0)
dry-initializer (3.1.1)
dry-logic (1.5.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0, < 2)
zeitwerk (~> 2.6)
dry-types (1.7.2)
bigdecimal (~> 3.0)
concurrent-ruby (~> 1.0)
dry-core (~> 1.0)
dry-inflector (~> 1.0)
dry-logic (~> 1.4)
zeitwerk (~> 2.6)
erb (4.0.4)
cgi (>= 0.3.3)
erubi (1.12.0)
Expand Down Expand Up @@ -300,6 +321,11 @@ GEM
activesupport (>= 5.2.0, < 8.0)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webrick (1.8.1)
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
Expand All @@ -317,6 +343,7 @@ DEPENDENCIES
benchmark-ips
capybara
cuprite
debug
dry-initializer
fakefs
gem1!
Expand All @@ -335,6 +362,7 @@ DEPENDENCIES
sqlite3
sus
view_component (~> 3.6.0)
web-console

BUNDLED WITH
2.4.1
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'bundler/setup'

APP_RAKEFILE = File.expand_path('fixtures/dummy/Rakefile', __dir__)
APP_RAKEFILE = File.expand_path('playground/Rakefile', __dir__)
load 'rails/tasks/engine.rake'

require 'bundler/gem_tasks'
Expand Down
2 changes: 1 addition & 1 deletion bin/rails
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

ENGINE_ROOT = File.expand_path('..', __dir__)
APP_PATH = File.expand_path('../fixtures/dummy/config/application', __dir__)
APP_PATH = File.expand_path('../playground/config/application', __dir__)

# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
Expand Down
4 changes: 3 additions & 1 deletion fixtures/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative "config/application"
require_relative 'config/application'

Rails.application.load_tasks
4 changes: 0 additions & 4 deletions fixtures/dummy/app/channels/application_cable/channel.rb

This file was deleted.

4 changes: 0 additions & 4 deletions fixtures/dummy/app/channels/application_cable/connection.rb

This file was deleted.

12 changes: 12 additions & 0 deletions fixtures/dummy/app/components/application_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class ApplicationComponent < Proscenium::Phlex
include Phlex::Rails::Helpers::Routes

if Rails.env.development?
def before_template
comment { "Before #{self.class.name}" }
super
end
end
end
2 changes: 1 addition & 1 deletion fixtures/dummy/app/components/phlex/father.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ class Phlex::Father < Phlex::Grandfather
# def template
# h1(class: :@grandfather) { 'Grandfather' }
# end
end
end
2 changes: 1 addition & 1 deletion fixtures/dummy/app/components/phlex/grandfather.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ class Phlex::Grandfather < Proscenium::Phlex
def template
h1(class: :@grandfather) { 'Grandfather' }
end
end
end
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Phlex::React::ForwardChildren::Component < Proscenium::Phlex::ReactComponent
self.forward_children = true
end
2 changes: 2 additions & 0 deletions fixtures/dummy/app/components/phlex/react/lazy/component.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class Phlex::React::Lazy::Component < Proscenium::Phlex::ReactComponent
self.lazy = true
end
2 changes: 2 additions & 0 deletions fixtures/dummy/app/components/phlex/react/one/component.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

class Phlex::React::One::Component < Proscenium::Phlex::ReactComponent
end
4 changes: 3 additions & 1 deletion fixtures/dummy/app/components/phlex/react/three/component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

class Phlex::React::Three::Component < Proscenium::Phlex::ReactComponent
def template
super class: :foo
super(class: :foo)
end
end
4 changes: 3 additions & 1 deletion fixtures/dummy/app/components/phlex/react/two/component.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

class Phlex::React::Two::Component < Proscenium::Phlex::ReactComponent
def template
super class: :@foo
super(class: :@foo)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

class ViewComponent::CssModule::Component < Proscenium::ViewComponent
def call
tag.h1('Hello', class: [:foo, :@hello]) + tag.h2('World', class: '@world')
tag.h1('Hello', class: %i[foo @hello]) + tag.h2('World', class: '@world')
end
end
1 change: 1 addition & 0 deletions fixtures/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

class ApplicationController < ActionController::Base
layout -> { ApplicationLayout }
end
24 changes: 11 additions & 13 deletions fixtures/dummy/app/controllers/bare_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,23 @@ class BarePagesController < ApplicationController

private

def normalize_sideload_assets_params
[:sideload_view_assets, :sideload_layout_assets,
:sideload_partial_assets, :sideload_partial_layout_assets].each do |key|
def normalize_sideload_assets_params # rubocop:disable Metrics/AbcSize
%i[sideload_view_assets sideload_layout_assets
sideload_partial_assets sideload_partial_layout_assets].each do |key|
next unless params[key]

if params[key] == 'false'
params[key] = false
elsif params[key] == 'true'
params[key] = true
else
if params[key][:css] == 'false'
params[key][:css] = false
elsif params[key][:css] == 'true'
params[key][:css] = true
elsif params[key][:js] == 'false'
params[key][:js] = false
elsif params[key][:js] == 'true'
params[key][:js] = true
end
elsif params[key][:css] == 'false'
params[key][:css] = false
elsif params[key][:css] == 'true'
params[key][:css] = true
elsif params[key][:js] == 'false'
params[key][:js] = false
elsif params[key][:js] == 'true'
params[key][:js] = true
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion fixtures/dummy/app/controllers/phlex/react_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

class Phlex::ReactController < ApplicationController
def forward_children
render Phlex::React::ForwardChildren::Component.new { 'hello' }
render(Phlex::React::ForwardChildren::Component.new { 'hello' })
end
end
4 changes: 2 additions & 2 deletions fixtures/dummy/app/controllers/phlex_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class PhlexController < ApplicationController
sideload_assets false

def basic
render Views::Phlex::Basic.new
render Phlex::BasicView.new
end

def include_assets
render Views::Phlex::IncludeAssets.new
render Phlex::IncludeAssetsView.new
end
end
2 changes: 0 additions & 2 deletions fixtures/dummy/app/helpers/application_helper.rb

This file was deleted.

7 changes: 0 additions & 7 deletions fixtures/dummy/app/jobs/application_job.rb

This file was deleted.

2 changes: 2 additions & 0 deletions fixtures/dummy/app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
9 changes: 9 additions & 0 deletions fixtures/dummy/app/views/application_view.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class ApplicationView < ApplicationComponent
# The ApplicationView is an abstract class for all your views.

# By default, it inherits from `ApplicationComponent`, but you
# can change that to `Phlex::HTML` if you want to keep views and
# components independent.
end
23 changes: 23 additions & 0 deletions fixtures/dummy/app/views/layouts/application_layout.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

class ApplicationLayout < ApplicationView
include Phlex::Rails::Layout

def template(&block)
doctype

html do
head do
title { "You're awesome" }
meta name: 'viewport', content: 'width=device-width,initial-scale=1'
csp_meta_tag
csrf_meta_tags
include_assets
end

body do
main(&block)
end
end
end
end
7 changes: 0 additions & 7 deletions fixtures/dummy/app/views/phlex/basic.rb

This file was deleted.

File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions fixtures/dummy/app/views/phlex/basic_view.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class Phlex::BasicView < Proscenium::Phlex
def template
super do
h1 { 'Hello' }
end
end
end
Loading

0 comments on commit e150467

Please sign in to comment.