componeer 0.0.1a

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e3c4b85f711607615e138a7a1f4e8daf968027a526397ac84049a771861ac1c1
4
+ data.tar.gz: b622a354a38801d06acd42905bbd93f5f5448bf093e21b11db75f5525fe74660
5
+ SHA512:
6
+ metadata.gz: e73e90c188ccb86131457881a389a080b1b914378ce885a15cb75ac1e4278a19553905d48c76403603e64f70a0635b93e4b041a3b2028438bd43f6cda7a41a11
7
+ data.tar.gz: 2d4efb986f449539532ff30342e71cccf375c514ab2383d30d83bd5599c89748cf3d4965aad102917de3a80ef0da8933c8e6b34c37d9056ae7bbed465d94e9cd
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'Run bundle install to run rake tasks'
5
+ end
6
+
7
+ require 'rails'
8
+ require 'combustion'
9
+
10
+ Bundler.require :default, Rails.env
11
+ Combustion.path = 'spec/dummy'
12
+ Combustion::Application.configure_for_combustion
13
+
14
+ APP_RAKEFILE = File.expand_path('spec/dummy/Rakefile', __dir__)
15
+ load 'rails/tasks/engine.rake'
16
+
17
+ load 'rails/tasks/statistics.rake'
18
+
19
+ require 'bundler/gem_tasks'
20
+
21
+ Combustion::Application.load_tasks
@@ -0,0 +1 @@
1
+ //= link_directory ../stylesheets/componeer .css
File without changes
@@ -0,0 +1,34 @@
1
+ module Componeer
2
+ class BaseComponent < ViewComponent::Base
3
+ def self.register_as(name)
4
+ name = name.to_s.to_sym
5
+
6
+ Componeer.register(name.to_sym, self)
7
+ end
8
+
9
+ def resolve_params(content_or_options, options)
10
+ if content_or_options.is_a?(Hash)
11
+ [nil, content_or_options]
12
+ else
13
+ [content_or_options, options]
14
+ end
15
+ end
16
+
17
+ def classes
18
+ @classes ||= [base_classes, custom_classes].flatten.compact_blank.uniq.join(' ')
19
+ end
20
+
21
+ def custom_classes
22
+ @custom_classes ||= options.delete(:class).to_s.split.compact_blank
23
+ end
24
+
25
+ def styles
26
+ @styles ||= begin
27
+ file_path = self.class.instance_method(:initialize).source_location[0]
28
+ styles_yaml_file = Rails.root.join(File.dirname(file_path), 'styles.yml')
29
+
30
+ File.exist?(styles_yaml_file) ? YAML.load(ERB.new(File.read(styles_yaml_file)).result) : {}
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ <%= button_tag class: classes, **options do %>
2
+ <%= content.presence || text %>
3
+ <% end %>
@@ -0,0 +1,25 @@
1
+ module Componeer
2
+ module Buttons
3
+ class ButtonComponent < BaseComponent
4
+ register_as :button
5
+
6
+ attr_reader :text, :options, :custom_classes
7
+
8
+ def initialize(content_or_options = nil, options = {})
9
+ @text, @options = resolve_params(content_or_options, options)
10
+ end
11
+
12
+ def base_classes
13
+ [styles[:base],
14
+ styles.dig(:size, size),
15
+ styles.dig(:color, mode, color),
16
+ styles.dig(:shape, shape)]
17
+ end
18
+
19
+ def color = @color ||= @options.delete(:color) || :brand
20
+ def mode = @mode ||= @options.delete(:primary) ? :primary : :outlined
21
+ def size = @size ||= @options.delete(:size) || :medium
22
+ def shape = @shape ||= @options.delete(:shape) || :rounded
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,42 @@
1
+ ---
2
+ :base: transition duration-300 ease-in-out
3
+ :size:
4
+ :small: text-xs px-2.5 py-1.5
5
+ :medium: text-sm px-3 py-2
6
+ :large: text-base px-4 py-2
7
+ :shape:
8
+ :rounded: rounded-md
9
+ :flat: rounded-none
10
+ :color:
11
+ :outlined:
12
+ :brand: |
13
+ text-brand-500 border border-brand-500 hover:text-white hover:bg-brand-500
14
+ focus:ring-4 focus:ring-brand-300
15
+ :green: |
16
+ text-green-500 border border-green-500 hover:text-white hover:bg-green-500
17
+ focus:ring-4 focus:ring-green-300
18
+ :red: |
19
+ text-red-500 border border-red-500 hover:text-white hover:bg-red-500
20
+ focus:ring-4 focus:ring-red-300
21
+ :blue: |
22
+ text-indigo-500 border border-indigo-500 hover:text-white hover:bg-indigo-500
23
+ focus:ring-4 focus:ring-indigo-300
24
+ :yellow: |
25
+ text-yellow-400 border border-yellow-400 hover:text-white hover:bg-yellow-400
26
+ focus:ring-4 focus:ring-yellow-300
27
+ :orange: |
28
+ text-orange-400 border border-orange-400 hover:text-white hover:bg-orange-400
29
+ focus:ring-4 focus:ring-orange-300
30
+ :primary:
31
+ :brand: |
32
+ text-white bg-brand-500 hover:bg-brand-600 focus:ring-4 focus:ring-brand-300
33
+ :green: |
34
+ text-white bg-green-500 hover:bg-green-600 focus:ring-4 focus:ring-green-300
35
+ :red: |
36
+ text-white bg-red-500 hover:bg-red-600 focus:ring-4 focus:ring-red-300
37
+ :blue: |
38
+ text-white bg-indigo-500 hover:bg-indigo-600 focus:ring-4 focus:ring-indigo-300
39
+ :yellow: |
40
+ text-white bg-yellow-500 hover:bg-yellow-600 focus:ring-4 focus:ring-yellow-300
41
+ :orange: |
42
+ text-white bg-orange-400 hover:bg-orange-500 focus:ring-4 focus:ring-orange-300
@@ -0,0 +1,2 @@
1
+ class ApplicationController < ActionController::Base
2
+ end
@@ -0,0 +1,4 @@
1
+ module Componeer
2
+ class ApplicationController < ::ApplicationController
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Componeer
2
+ module ApplicationHelper
3
+ end
4
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Componeer::Engine.routes.draw do
2
+ # Reserved for future use
3
+ end
@@ -0,0 +1,9 @@
1
+ module Componeer
2
+ class Configuration
3
+ attr_writer :include_componeer_helpers
4
+
5
+ def include_componeer_helpers?
6
+ @include_componeer_helpers.nil? ? true : @include_componeer_helpers.present?
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,18 @@
1
+ module Componeer
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Componeer
4
+
5
+ initializer 'componeer.include_componeer_helpers' do |app|
6
+ app.config do |config|
7
+ config.to_prepare do
8
+ Componeer.config do |componeer_config|
9
+ if componeer_config.include_componeer_helpers?
10
+ ActiveSupport.on_load(:action_controller) { include Helpers }
11
+ ActiveSupport.on_load(:action_view) { include Helpers }
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,32 @@
1
+ module Componeer
2
+ module Helpers
3
+ def componeer
4
+ @componeer ||= Helper.new(self)
5
+ end
6
+ alias c componeer unless method_defined?(:c)
7
+
8
+ class Helper
9
+ delegate :render, to: :view_context
10
+
11
+ def initialize(view_context)
12
+ @view_context = view_context
13
+ end
14
+
15
+ def method_missing(method, *args, **kwargs, &)
16
+ if Componeer.registry.key?(method)
17
+ render(Componeer.registry[method].new(*args, **kwargs), &)
18
+ else
19
+ super
20
+ end
21
+ end
22
+
23
+ def respond_to_missing?(method, include_private = false)
24
+ Componeer.registry.key?(method) || super
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :view_context
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,17 @@
1
+ module Componeer
2
+ class Registry
3
+ delegate :key?, to: :components
4
+
5
+ attr_reader :components
6
+
7
+ def initialize
8
+ @components = {}
9
+ end
10
+
11
+ def register(name, component_klazz)
12
+ components[name] = component_klazz
13
+ end
14
+
15
+ delegate :[], to: :components
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Componeer
2
+ VERSION = '0.0.1a'.freeze
3
+ end
data/lib/componeer.rb ADDED
@@ -0,0 +1,27 @@
1
+ require 'componeer/version'
2
+ require 'componeer/engine'
3
+ require 'componeer/configuration'
4
+ require 'componeer/helpers'
5
+ require 'componeer/registry'
6
+
7
+ module Componeer
8
+ def self.config
9
+ @config ||= Configuration.new.tap do |config|
10
+ yield config if block_given?
11
+ end
12
+ end
13
+
14
+ def self.registry
15
+ @registry ||= Registry.new
16
+ end
17
+
18
+ def self.register(*args)
19
+ registry.register(*args)
20
+ end
21
+
22
+ def self.eager_load!
23
+ path = File.expand_path('../app/components/**/*.rb', __dir__)
24
+
25
+ Dir[path].each { |file| require_dependency file }
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ run 'bundle add tailwindcss-rails'
2
+
3
+ rails_command 'tailwindcss:install'
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :componeer do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,8 @@
1
+ namespace :componeer do
2
+ desc 'Install Componeer'
3
+ task install: :environment do
4
+ location = File.expand_path('../install/componeer.rb', __dir__)
5
+
6
+ system "#{RbConfig.ruby} ./bin/rails app:template LOCATION=#{location}"
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: componeer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1a
5
+ platform: ruby
6
+ authors:
7
+ - Andre Rodrigues
8
+ - Mauricio Pereira
9
+ - Lucas Pesqueira
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2024-05-27 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: inline_svg
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.9'
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 1.9.0
25
+ type: :runtime
26
+ prerelease: false
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - "~>"
30
+ - !ruby/object:Gem::Version
31
+ version: '1.9'
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 1.9.0
35
+ - !ruby/object:Gem::Dependency
36
+ name: view_component
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '3.1'
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 3.1.0
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - "~>"
50
+ - !ruby/object:Gem::Version
51
+ version: '3.1'
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 3.1.0
55
+ description: |-
56
+ Componeer is a non-intrusive gem that enhances component-based development
57
+ in Ruby on Rails applications. It empowers developers to effortlessly build modular, reusable,
58
+ and highly maintainable UI components within their Rails projects. With an intuitive syntax and
59
+ comprehensive features, Componeer simplifies component management, promotes code reusability,
60
+ and enhances the scalability and flexibility of your Rails applications.
61
+ email:
62
+ - andrerpbts@gmail.com
63
+ - mauriciopdvg@gmail.com
64
+ - pesqueira.lucas@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - Rakefile
70
+ - app/assets/config/componeer_manifest.js
71
+ - app/assets/stylesheets/componeer/application.css
72
+ - app/components/componeer/base_component.rb
73
+ - app/components/componeer/buttons/button_component.html.erb
74
+ - app/components/componeer/buttons/button_component.rb
75
+ - app/components/componeer/buttons/styles.yml
76
+ - app/controllers/application_controller.rb
77
+ - app/controllers/componeer/application_controller.rb
78
+ - app/helpers/componeer/application_helper.rb
79
+ - config/routes.rb
80
+ - lib/componeer.rb
81
+ - lib/componeer/configuration.rb
82
+ - lib/componeer/engine.rb
83
+ - lib/componeer/helpers.rb
84
+ - lib/componeer/registry.rb
85
+ - lib/componeer/version.rb
86
+ - lib/install/componeer.rb
87
+ - lib/tasks/componeer_tasks.rake
88
+ - lib/tasks/install.rake
89
+ homepage: https://docs.componeer.me
90
+ licenses:
91
+ - MIT
92
+ metadata:
93
+ homepage_uri: https://docs.componeer.me
94
+ source_code_uri: https://github.com/trytechlabs/componeer
95
+ changelog_uri: https://github.com/trytechlabs/componeer/blob/main/CHANGELOG.md
96
+ rubygems_mfa_required: 'true'
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 3.1.0
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.3.1
111
+ requirements: []
112
+ rubygems_version: 3.3.26
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: A non-intrusive gem for component-based development in Ruby on Rails
116
+ test_files: []