Skip to content

Commit

Permalink
chore: replace Dry with Literal
Browse files Browse the repository at this point in the history
fixes #38
  • Loading branch information
joelmoss committed Nov 4, 2024
1 parent a9e2d71 commit 083db81
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 56 deletions.
11 changes: 5 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ gemspec
gem 'debug'
gem 'rails', '~> 7.0'

# Playground
gem 'htmlbeautifier'
gem 'phlexible'
gem 'rouge'

group :development do
gem 'benchmark-ips'
gem 'puma'
Expand All @@ -18,17 +23,11 @@ group :development do
gem 'rubocop-rake', require: false
gem 'sqlite3'
gem 'web-console'

# Playground
gem 'htmlbeautifier'
gem 'phlexible'
gem 'rouge'
end

group :test do
gem 'capybara'
gem 'cuprite'
gem 'dry-initializer'
gem 'fakefs', require: 'fakefs/safe'
gem 'gem1', path: './fixtures/dummy/vendor/gem1'
gem 'gem2', path: './fixtures/external/gem2'
Expand Down
22 changes: 2 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ PATH
specs:
proscenium (0.17.0)
activesupport (>= 7.1.0, < 8.0)
dry-initializer (~> 3.1)
dry-types (~> 1.7)
ffi (~> 1.17.0)
literal (~> 1.0)
oj (~> 3.13)
railties (>= 7.1.0, < 8.0)
ruby-next (~> 1.0.1)
Expand Down Expand Up @@ -136,23 +135,6 @@ GEM
reline (>= 0.3.8)
diff-lcs (1.5.1)
drb (2.2.1)
dry-core (1.0.2)
concurrent-ruby (~> 1.0)
logger
zeitwerk (~> 2.6)
dry-inflector (1.1.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)
erubi (1.13.0)
fakefs (2.5.0)
ferrum (0.15)
Expand All @@ -173,6 +155,7 @@ GEM
reline (>= 0.4.2)
json (2.7.5)
language_server-protocol (3.17.0.3)
literal (1.0.0)
logger (1.6.1)
loofah (2.23.1)
crass (~> 1.0.2)
Expand Down Expand Up @@ -353,7 +336,6 @@ DEPENDENCIES
capybara
cuprite
debug
dry-initializer
fakefs
gem1!
gem2!
Expand Down
6 changes: 0 additions & 6 deletions lib/proscenium/ui.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
# frozen_string_literal: true

require 'dry-types'

module Proscenium::UI
extend ActiveSupport::Autoload

autoload :Component
autoload :Breadcrumbs

module Types
include Dry.Types()
end
end
2 changes: 1 addition & 1 deletion lib/proscenium/ui/breadcrumbs/component.module.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@layer proscenium-ui-component {
/*
* Custom properties:
* Properties:
*
* --puiBreadcrumbs--link-color: LinkText;
* --puiBreadcrumbs--link-hover-color: HighlightText;
Expand Down
22 changes: 8 additions & 14 deletions lib/proscenium/ui/breadcrumbs/component.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
# frozen_string_literal: true

require 'literal'

module Proscenium::UI
class Breadcrumbs::Component < Component
extend Literal::Properties
include Phlex::Rails::Helpers::URLFor

# The path (route) to use as the HREF for the home segment. Defaults to `:root`.
option :home_path, Types::String | Types::Symbol, default: -> { :root }
prop :home_path, _Union(String, Symbol), default: -> { :root }

# Assign false to hide the home segment.
option :with_home, Types::Bool, default: -> { true }

# One or more class name(s) for the base div element which will be appended to the default.
option :class, Types::Coercible::String | Types::Array.of(Types::Coercible::String),
as: :class_name, default: -> { [] }

# One or more class name(s) for the base div element which will replace the default. If both
# `class` and `class!` are provided, all values will be merged. Defaults to `:@base`.
option :class!, Types::Coercible::String | Types::Array.of(Types::Coercible::String),
as: :class_name_override, default: -> { :@base }
prop :with_home, _Boolean, default: -> { true }

def view_template
div class: [*class_name_override, *class_name] do
div class: :@base do
ol do
if with_home
if @with_home
li do
home_template
end
Expand All @@ -48,7 +42,7 @@ def view_template
# super { 'hello' }
# end
def home_template(&block)
a(href: url_for(home_path)) do
a(href: url_for(@home_path)) do
if block
yield
else
Expand Down
4 changes: 0 additions & 4 deletions lib/proscenium/ui/component.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# frozen_string_literal: true

require 'dry-initializer'

module Proscenium::UI
class Component < Proscenium::Phlex
self.abstract_class = true

extend Dry::Initializer
end
end
6 changes: 3 additions & 3 deletions playground/app/components/code_block_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
require 'phlex/testing/view_helper'

class CodeBlockComponent < ApplicationComponent
extend Literal::Properties

FORMATTER = Rouge::Formatters::HTML.new

include Dry::Initializer.define lambda {
param :syntax, Dry::Types['coercible.symbol']
}
prop :syntax, Symbol, :positional

def view_template(&)
@code = capture(&)
Expand Down
3 changes: 1 addition & 2 deletions proscenium.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ Gem::Specification.new do |spec|
spec.require_paths = ['lib']

spec.add_dependency 'activesupport', ['>= 7.1.0', '< 8.0']
spec.add_dependency 'dry-initializer', '~> 3.1'
spec.add_dependency 'dry-types', '~> 1.7'
spec.add_dependency 'ffi', '~> 1.17.0'
spec.add_dependency 'literal', '~> 1.0'
spec.add_dependency 'oj', '~> 3.13'
spec.add_dependency 'railties', ['>= 7.1.0', '< 8.0']
spec.add_dependency 'ruby-next', '~> 1.0.1'
Expand Down

0 comments on commit 083db81

Please sign in to comment.