componeer 0.0.3a → 0.0.7a
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/components/componeer/base_component.rb +10 -0
- data/app/components/componeer/empty_states/empty_state_component.html.erb +15 -18
- data/app/components/componeer/empty_states/empty_state_component.rb +2 -0
- data/app/components/componeer/tables/column_component.rb +45 -0
- data/app/components/componeer/tables/styles.yml +24 -0
- data/app/components/componeer/tables/table_component.html.erb +33 -0
- data/app/components/componeer/tables/table_component.rb +38 -0
- data/app/components/componeer/tags/styles.yml +16 -0
- data/app/components/componeer/tags/tag_component.html.erb +3 -0
- data/app/components/componeer/tags/tag_component.rb +24 -0
- data/config/initializers/componeer.rb +8 -0
- data/config/initializers/inline_svg.rb +1 -1
- data/lib/componeer/engine.rb +0 -13
- data/lib/componeer/version.rb +1 -1
- metadata +10 -3
- data/lib/tasks/componeer_tasks.rake +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9fbc69925280e333c8d89044bd85e4e15c4d371eb6acad1d581e832df75cbb9d
|
|
4
|
+
data.tar.gz: 5e6d85cb8b73c1050f8fd277d802e3be1c269908ffd43c8ac5bf99f073863a75
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1f5610e4a528847aae3ab4952a2720cf55a8af20e2a07854b0760e47577252392c25d3e83cd2ae77e61bb439fb67c86f69cbb137daeef450735ae9c9a74b862f
|
|
7
|
+
data.tar.gz: 3c48fb148673ca0be5f176f49d8d616354ee004fdbb89c1c5aadcac1469214d5fa0fe9eb72beb6aca1401874c9a1470b6564a24a11f74a039425945117389603
|
|
@@ -30,5 +30,15 @@ module Componeer
|
|
|
30
30
|
File.exist?(styles_yaml_file) ? YAML.load(ERB.new(File.read(styles_yaml_file)).result) : {}
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
|
+
|
|
34
|
+
def i18n(value, **options)
|
|
35
|
+
I18n.t(value,
|
|
36
|
+
scope: "componeer.#{self.class.to_s.demodulize.underscore.gsub('_component', '')}",
|
|
37
|
+
**options)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def to_classes_string(array)
|
|
41
|
+
array.flatten.compact_blank.uniq.join(' ')
|
|
42
|
+
end
|
|
33
43
|
end
|
|
34
44
|
end
|
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
<div class="flex flex-col py-12 justify-center items-center bg-gray-50 rounded-md">
|
|
2
2
|
<% if @icon %>
|
|
3
|
-
<div
|
|
3
|
+
<div>
|
|
4
|
+
<%= inline_svg_tag("#{@icon}.svg", class: 'mx-auto h-12 w-12 text-gray-400') %>
|
|
5
|
+
</div>
|
|
4
6
|
<% end %>
|
|
5
7
|
|
|
6
|
-
<h3 class="text-sm font-medium text-gray-900">
|
|
8
|
+
<h3 class="mt-2 text-sm font-medium text-gray-900">
|
|
9
|
+
<%= i18n('no_resouces', resource_name: @resource_name,
|
|
10
|
+
resource_name_pluralized: @resource_name.pluralize,
|
|
11
|
+
default: 'No %{resource_name_pluralized}') %>
|
|
12
|
+
</h3>
|
|
13
|
+
|
|
7
14
|
<% if @description %>
|
|
8
|
-
<p class="text-sm text-gray-500"
|
|
15
|
+
<p class="text-sm text-gray-500">
|
|
16
|
+
<%= @description %>
|
|
17
|
+
</p>
|
|
9
18
|
<% end %>
|
|
10
|
-
<% if @new_resource_path %>
|
|
11
|
-
<div class="flex flex-col items-center space-y-2">
|
|
12
|
-
<p class="text-sm text-gray-500">
|
|
13
|
-
Get started by creating a new <%= @resource_name %>.
|
|
14
|
-
</p>
|
|
15
|
-
<div>
|
|
16
|
-
<%= componeer.button(size: :small) do %>
|
|
17
|
-
<%= link_to @new_resource_path do %>
|
|
18
|
-
<div class="flex items-center space-x-2">
|
|
19
|
-
<%= inline_svg_tag('plus.svg', class: 'h-5 w-5') %>
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<% end %>
|
|
25
|
-
</div>
|
|
20
|
+
<% if new_resource_action %>
|
|
21
|
+
<div class="mt-3">
|
|
22
|
+
<%= new_resource_action %>
|
|
26
23
|
</div>
|
|
27
24
|
<% end %>
|
|
28
25
|
</div>
|
|
@@ -3,6 +3,8 @@ module Componeer
|
|
|
3
3
|
class EmptyStateComponent < BaseComponent
|
|
4
4
|
register_as :empty_state
|
|
5
5
|
|
|
6
|
+
renders_one :new_resource_action
|
|
7
|
+
|
|
6
8
|
def initialize(resource_name:, icon: :exclamation, new_resource_path: nil, description: nil)
|
|
7
9
|
@resource_name = resource_name
|
|
8
10
|
@icon = icon
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Componeer
|
|
2
|
+
module Tables
|
|
3
|
+
class ColumnComponent < BaseComponent
|
|
4
|
+
attr_reader :table, :title, :custom_classes, :alignment, :options
|
|
5
|
+
delegate :density, to: :table
|
|
6
|
+
|
|
7
|
+
def initialize(table, title, **options, &block)
|
|
8
|
+
@table = table
|
|
9
|
+
@title = title
|
|
10
|
+
@custom_classes = resolve_classes(options.delete(:class)) || {}
|
|
11
|
+
@alignment = options.delete(:align) || :left
|
|
12
|
+
@options = options
|
|
13
|
+
@block = block
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def call(record)
|
|
17
|
+
@block.call(record)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def th_classes
|
|
21
|
+
attribute_classes(:th, key: :header)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def td_classes
|
|
25
|
+
attribute_classes(:td, key: :body)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def attribute_classes(attr, key:)
|
|
31
|
+
to_classes_string([styles.dig(key, :column, :density, density),
|
|
32
|
+
styles.dig(key, :column, :alignment, alignment),
|
|
33
|
+
custom_classes[attr].to_s.split])
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def resolve_classes(hash_or_string)
|
|
37
|
+
if hash_or_string.is_a?(String)
|
|
38
|
+
{ th: hash_or_string, td: hash_or_string }
|
|
39
|
+
else
|
|
40
|
+
hash_or_string
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
:header:
|
|
3
|
+
:column:
|
|
4
|
+
:density:
|
|
5
|
+
:default: 'p-3 text-sm font-semibold'
|
|
6
|
+
:compact: 'p-1.5 text-xs font-semibold'
|
|
7
|
+
:alignment:
|
|
8
|
+
:left: 'text-left'
|
|
9
|
+
:right: 'text-right'
|
|
10
|
+
:center: 'text-center'
|
|
11
|
+
:row: 'bg-white border-b border-gray-200'
|
|
12
|
+
|
|
13
|
+
:body:
|
|
14
|
+
:column:
|
|
15
|
+
:density:
|
|
16
|
+
:default: 'p-3 text-sm font-normal'
|
|
17
|
+
:compact: 'p-1.5 text-xs font-normal'
|
|
18
|
+
:alignment:
|
|
19
|
+
:left: 'text-left'
|
|
20
|
+
:right: 'text-right'
|
|
21
|
+
:center: 'text-center'
|
|
22
|
+
:row:
|
|
23
|
+
:default: 'bg-white'
|
|
24
|
+
:striped: 'bg-gray-50'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<% if @records.present? %>
|
|
2
|
+
<table class="w-full">
|
|
3
|
+
<thead>
|
|
4
|
+
<tr class="<%= tr_classes(:header) %>">
|
|
5
|
+
<% columns.each do |column| %>
|
|
6
|
+
<th scope="col" class="<%= column.th_classes %>">
|
|
7
|
+
<%= column.title %>
|
|
8
|
+
</th>
|
|
9
|
+
<% end %>
|
|
10
|
+
</tr>
|
|
11
|
+
</thead>
|
|
12
|
+
|
|
13
|
+
<tbody>
|
|
14
|
+
<% @records.each do |record| %>
|
|
15
|
+
<tr
|
|
16
|
+
<% if record.respond_to?(:id) %>
|
|
17
|
+
id="<%= dom_id(record) %>"
|
|
18
|
+
<% end %>
|
|
19
|
+
class="<%= tr_classes %>"
|
|
20
|
+
>
|
|
21
|
+
<% columns.each do |column| %>
|
|
22
|
+
<td class="<%= column.td_classes %>">
|
|
23
|
+
<%= column.call(record) %>
|
|
24
|
+
</td>
|
|
25
|
+
<% end %>
|
|
26
|
+
</tr>
|
|
27
|
+
<% end %>
|
|
28
|
+
</tbody>
|
|
29
|
+
<tfoot><%= footer %></tfoot>
|
|
30
|
+
</table>
|
|
31
|
+
<% else %>
|
|
32
|
+
<%= empty_state %>
|
|
33
|
+
<% end %>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Componeer
|
|
2
|
+
module Tables
|
|
3
|
+
class TableComponent < BaseComponent
|
|
4
|
+
register_as :table
|
|
5
|
+
|
|
6
|
+
renders_many :columns,
|
|
7
|
+
lambda { |title: '', **options, &block|
|
|
8
|
+
ColumnComponent.new(self, title, **options, &block)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
renders_one :empty_state,
|
|
12
|
+
lambda { |resource_name: nil, icon: :exclamation|
|
|
13
|
+
EmptyStates::EmptyStateComponent.new(resource_name: resource_name ||
|
|
14
|
+
records_resource_name,
|
|
15
|
+
icon:)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
renders_one :footer
|
|
19
|
+
|
|
20
|
+
attr_reader :records, :density, :striped, :options
|
|
21
|
+
|
|
22
|
+
def initialize(records: nil, **options)
|
|
23
|
+
@records = records
|
|
24
|
+
@striped = options.delete(:striped) || true
|
|
25
|
+
@density = options.delete(:density) || :default
|
|
26
|
+
@options = options
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def tr_classes(level = :body)
|
|
30
|
+
if level == :body
|
|
31
|
+
styles.dig(level, :row, striped ? cycle(:striped, :default).to_sym : :default)
|
|
32
|
+
else
|
|
33
|
+
styles.dig(level, :row)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
:size:
|
|
3
|
+
:small: text-xs px-1 p-0.5
|
|
4
|
+
:default: text-sm px-2 py-1
|
|
5
|
+
:large: text-base px-3 py-1.5
|
|
6
|
+
:shape:
|
|
7
|
+
:rounded: rounded rounded-lg
|
|
8
|
+
:flat: rounded-none
|
|
9
|
+
:color:
|
|
10
|
+
:gray: bg-gray-100 text-gray-700
|
|
11
|
+
:brand: bg-brand-100 text-brand-700
|
|
12
|
+
:blue: bg-blue-100 text-blue-700
|
|
13
|
+
:green: bg-green-100 text-green-700
|
|
14
|
+
:red: bg-red-100 text-red-700
|
|
15
|
+
:yellow: bg-yellow-100 text-yellow-700
|
|
16
|
+
:purple: bg-purple-100 text-purple-700
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Componeer
|
|
2
|
+
module Tags
|
|
3
|
+
class TagComponent < BaseComponent
|
|
4
|
+
register_as :tag
|
|
5
|
+
|
|
6
|
+
attr_reader :text, :type, :size, :color, :shape, :options
|
|
7
|
+
|
|
8
|
+
def initialize(text = nil, **options)
|
|
9
|
+
@text = text
|
|
10
|
+
@type = options.delete(:type) || :default
|
|
11
|
+
@size = options.delete(:size) || :default
|
|
12
|
+
@color = options.delete(:color) || :gray
|
|
13
|
+
@shape = options.delete(:shape) || :rounded
|
|
14
|
+
@options = options
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def base_classes
|
|
18
|
+
to_classes_string([styles.dig(:size, size),
|
|
19
|
+
styles.dig(:color, color),
|
|
20
|
+
styles.dig(:shape, shape)])
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Componeer.config do |componeer_config|
|
|
2
|
+
if componeer_config.include_componeer_helpers?
|
|
3
|
+
ActiveSupport.on_load(:action_controller) { include Componeer::Helpers }
|
|
4
|
+
ActiveSupport.on_load(:action_view) { include Componeer::Helpers }
|
|
5
|
+
end
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
Componeer.eager_load!
|
data/lib/componeer/engine.rb
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
1
|
module Componeer
|
|
2
2
|
class Engine < ::Rails::Engine
|
|
3
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
4
|
end
|
|
18
5
|
end
|
data/lib/componeer/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: componeer
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7a
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andre Rodrigues
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2024-
|
|
13
|
+
date: 2024-06-04 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: inline_svg
|
|
@@ -78,9 +78,17 @@ files:
|
|
|
78
78
|
- app/components/componeer/buttons/styles.yml
|
|
79
79
|
- app/components/componeer/empty_states/empty_state_component.html.erb
|
|
80
80
|
- app/components/componeer/empty_states/empty_state_component.rb
|
|
81
|
+
- app/components/componeer/tables/column_component.rb
|
|
82
|
+
- app/components/componeer/tables/styles.yml
|
|
83
|
+
- app/components/componeer/tables/table_component.html.erb
|
|
84
|
+
- app/components/componeer/tables/table_component.rb
|
|
85
|
+
- app/components/componeer/tags/styles.yml
|
|
86
|
+
- app/components/componeer/tags/tag_component.html.erb
|
|
87
|
+
- app/components/componeer/tags/tag_component.rb
|
|
81
88
|
- app/controllers/application_controller.rb
|
|
82
89
|
- app/controllers/componeer/application_controller.rb
|
|
83
90
|
- app/helpers/componeer/application_helper.rb
|
|
91
|
+
- config/initializers/componeer.rb
|
|
84
92
|
- config/initializers/inline_svg.rb
|
|
85
93
|
- config/routes.rb
|
|
86
94
|
- lib/componeer.rb
|
|
@@ -90,7 +98,6 @@ files:
|
|
|
90
98
|
- lib/componeer/registry.rb
|
|
91
99
|
- lib/componeer/version.rb
|
|
92
100
|
- lib/install/componeer.rb
|
|
93
|
-
- lib/tasks/componeer_tasks.rake
|
|
94
101
|
- lib/tasks/install.rake
|
|
95
102
|
homepage: https://docs.componeer.me
|
|
96
103
|
licenses:
|