alveole 0.0.1
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 +7 -0
- data/.gitignore +8 -0
- data/.gitlab-ci.yml +55 -0
- data/.rubocop.yml +63 -0
- data/.rubocop_todo.yml +12 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +171 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +10 -0
- data/alveole.gemspec +35 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/alveole/components/avatar_component/avatar_component.html.slim +6 -0
- data/lib/alveole/components/avatar_component.rb +9 -0
- data/lib/alveole/components/badge_component/badge_component.html.slim +2 -0
- data/lib/alveole/components/badge_component.rb +8 -0
- data/lib/alveole/components/breadcrumb_component/breadcrumb_component.html.slim +2 -0
- data/lib/alveole/components/breadcrumb_component.rb +8 -0
- data/lib/alveole/components/breadcrumbs_component.rb +7 -0
- data/lib/alveole/components/button_component/button_component.html.slim +5 -0
- data/lib/alveole/components/button_component.rb +15 -0
- data/lib/alveole/components/definition_component/definition_component.html.slim +4 -0
- data/lib/alveole/components/definition_component.rb +13 -0
- data/lib/alveole/components/form_component/form_component.html.slim +3 -0
- data/lib/alveole/components/form_component.rb +3 -0
- data/lib/alveole/components/form_submit_component/form_submit_component.html.slim +1 -0
- data/lib/alveole/components/form_submit_component.rb +7 -0
- data/lib/alveole/components/heading_component/heading_component.html.slim +4 -0
- data/lib/alveole/components/heading_component.rb +8 -0
- data/lib/alveole/components/input_component/input_component.html.slim +17 -0
- data/lib/alveole/components/input_component.rb +42 -0
- data/lib/alveole/components/notice_component/notice_component.html.slim +5 -0
- data/lib/alveole/components/notice_component.rb +15 -0
- data/lib/alveole/components/page_component/page_component.html.slim +10 -0
- data/lib/alveole/components/page_component.rb +4 -0
- data/lib/alveole/components/sidebar_component/sidebar_component.html.slim +7 -0
- data/lib/alveole/components/sidebar_component.rb +4 -0
- data/lib/alveole/components/table_column_component/table_column_component.html.slim +3 -0
- data/lib/alveole/components/table_column_component.rb +12 -0
- data/lib/alveole/components/table_component/table_component.html.slim +7 -0
- data/lib/alveole/components/table_component.rb +3 -0
- data/lib/alveole/components/table_header_component/table_header_component.html.slim +2 -0
- data/lib/alveole/components/table_header_component.rb +8 -0
- data/lib/alveole/components/table_row_component/table_row_component.html.slim +4 -0
- data/lib/alveole/components/table_row_component.rb +3 -0
- data/lib/alveole/components/toolbar_component/toolbar_component.html.slim +7 -0
- data/lib/alveole/components/toolbar_component.rb +4 -0
- data/lib/alveole/concerns/bem.rb +21 -0
- data/lib/alveole/engine.rb +30 -0
- data/lib/alveole/helpers/method_helper.rb +31 -0
- data/lib/alveole/javascript/components.js +5 -0
- data/lib/alveole/previews/avatar_component_preview.rb +11 -0
- data/lib/alveole/previews/badge_component_preview.rb +11 -0
- data/lib/alveole/previews/breadcrumb_component_preview.rb +15 -0
- data/lib/alveole/previews/button_component_preview.rb +7 -0
- data/lib/alveole/previews/definition_component_preview.rb +33 -0
- data/lib/alveole/previews/form_component_preview.rb +18 -0
- data/lib/alveole/previews/form_submit_component_preview.rb +7 -0
- data/lib/alveole/previews/heading_component_preview.rb +11 -0
- data/lib/alveole/previews/input_component_preview.rb +32 -0
- data/lib/alveole/previews/notice_component_preview.rb +15 -0
- data/lib/alveole/previews/page_component_preview.rb +33 -0
- data/lib/alveole/previews/sidebar_component_preview.rb +33 -0
- data/lib/alveole/previews/table_column_component_preview.rb +36 -0
- data/lib/alveole/previews/table_component_preview.rb +12 -0
- data/lib/alveole/previews/table_header_component_preview.rb +27 -0
- data/lib/alveole/previews/table_row_component_preview.rb +18 -0
- data/lib/alveole/previews/toolbar_component_preview.rb +33 -0
- data/lib/alveole/version.rb +3 -0
- data/lib/alveole.rb +16 -0
- data/lib/generators/alveole/config_generator.rb +17 -0
- data/lib/generators/alveole/templates/alveole_config.rb +1 -0
- metadata +197 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
module Alveole
|
2
|
+
module Helper
|
3
|
+
module ComponentHelper
|
4
|
+
def component(name, *args, &block)
|
5
|
+
component_args = {}
|
6
|
+
component_args = args.pop if args[-1].is_a? Hash
|
7
|
+
component_args[:modifiers] = args unless args.empty?
|
8
|
+
component_class = "#{name}_component".camelize.constantize
|
9
|
+
|
10
|
+
render(component_class.new(**component_args), &block)
|
11
|
+
end
|
12
|
+
|
13
|
+
def format_value(value, options = {})
|
14
|
+
return if value.nil?
|
15
|
+
|
16
|
+
v = value
|
17
|
+
v = I18n.l(v.to_date, format: :short) if options[:date]
|
18
|
+
v = I18n.l(v.to_datetime, format: :short) if options[:time]
|
19
|
+
|
20
|
+
v
|
21
|
+
end
|
22
|
+
|
23
|
+
def label_for(obj, fieldname)
|
24
|
+
return unless obj && fieldname
|
25
|
+
|
26
|
+
return obj.class.human_attribute_name(fieldname) if obj.class.respond_to?(:human_attribute_name)
|
27
|
+
return obj.klass.human_attribute_name(fieldname) if obj.respond_to?(:klass) && obj.klass.respond_to?(:human_attribute_name)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class BadgeComponentPreview < ViewComponent::Preview
|
2
|
+
layout false
|
3
|
+
|
4
|
+
def default
|
5
|
+
render(BadgeComponent.new(label: 'example de badge'))
|
6
|
+
end
|
7
|
+
|
8
|
+
def with_options
|
9
|
+
render(BadgeComponent.new(label: 'example de badge', options: { data: 'example-option' }))
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class BreadcrumbComponentPreview < ViewComponent::Preview
|
2
|
+
layout false
|
3
|
+
|
4
|
+
def default
|
5
|
+
render(BreadcrumbComponent.new(label: 'Example Breadcrumb', url: '/example/url'))
|
6
|
+
end
|
7
|
+
|
8
|
+
def without_url
|
9
|
+
render(BreadcrumbComponent.new(label: 'Example Breadcrumb'))
|
10
|
+
end
|
11
|
+
|
12
|
+
def breadcrumbs
|
13
|
+
render(BreadcrumbsComponent.new)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class DefinitionComponentPreview < ViewComponent::Preview
|
2
|
+
class TempObj
|
3
|
+
def self.human_attribute_name(_)
|
4
|
+
'label'
|
5
|
+
end
|
6
|
+
|
7
|
+
def fieldname
|
8
|
+
'value'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
layout false
|
13
|
+
|
14
|
+
def default
|
15
|
+
temp_obj = TempObj.new
|
16
|
+
render(DefinitionComponent.new(label: nil, value: nil, obj: temp_obj, fieldname: :fieldname, options: {}))
|
17
|
+
end
|
18
|
+
|
19
|
+
def with_label
|
20
|
+
temp_obj = TempObj.new
|
21
|
+
render(DefinitionComponent.new(label: 'custom label', value: nil, obj: temp_obj, fieldname: :fieldname, options: {}))
|
22
|
+
end
|
23
|
+
|
24
|
+
def with_value
|
25
|
+
temp_obj = TempObj.new
|
26
|
+
render(DefinitionComponent.new(label: nil, value: 'custom value', obj: temp_obj, fieldname: :fieldname, options: {}))
|
27
|
+
end
|
28
|
+
|
29
|
+
def with_options
|
30
|
+
temp_obj = TempObj.new
|
31
|
+
render(DefinitionComponent.new(label: nil, value: nil, obj: temp_obj, fieldname: :fieldname, options: { style: 'color:red' }))
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class FormComponentPreview < ViewComponent::Preview
|
2
|
+
layout false
|
3
|
+
|
4
|
+
def default
|
5
|
+
render(FormComponent.new) do |form|
|
6
|
+
form.actions do
|
7
|
+
tag.span('Example actions')
|
8
|
+
end
|
9
|
+
tag.span('Example content')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def without_actions
|
14
|
+
render(FormComponent.new) do |_form|
|
15
|
+
tag.span('Example content')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class HeadingComponentPreview < ViewComponent::Preview
|
2
|
+
layout false
|
3
|
+
|
4
|
+
def default
|
5
|
+
render(HeadingComponent.new(heading: 'Example heading', sub: 'Example sub title'))
|
6
|
+
end
|
7
|
+
|
8
|
+
def without_sub
|
9
|
+
render(HeadingComponent.new(heading: 'Example heading', sub: nil))
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class InputComponentPreview < ViewComponent::Preview
|
2
|
+
class TempObj
|
3
|
+
attr_accessor :fieldname
|
4
|
+
|
5
|
+
def initialize(fieldname = 'Example value')
|
6
|
+
@fieldname = fieldname
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.human_attribute_name(_)
|
10
|
+
'label'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
layout false
|
15
|
+
|
16
|
+
def default
|
17
|
+
raise 'not implemented yet'
|
18
|
+
# temp_obj = TempObj.new
|
19
|
+
|
20
|
+
# ActionView::Helpers.form_for temp_obj do |form_builder|
|
21
|
+
# # form_builder = ActionView::Helpers::FormBuilder.new(:temp_obj, temp_obj, {}, {})
|
22
|
+
|
23
|
+
# render(InputComponent.new(type: :text,
|
24
|
+
# label: nil,
|
25
|
+
# value: nil,
|
26
|
+
# form: form_builder,
|
27
|
+
# fieldname: :fieldname,
|
28
|
+
# collection: nil,
|
29
|
+
# options: {}))
|
30
|
+
# end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class NoticeComponentPreview < ViewComponent::Preview
|
2
|
+
layout false
|
3
|
+
|
4
|
+
def default
|
5
|
+
render(NoticeComponent.new(title: 'Example Alert', messages: ['Message 1', 'Message 2']))
|
6
|
+
end
|
7
|
+
|
8
|
+
def without_messages
|
9
|
+
render(NoticeComponent.new(title: 'Example Notice'))
|
10
|
+
end
|
11
|
+
|
12
|
+
def with_type_notice
|
13
|
+
render(NoticeComponent.new(title: 'Example Notice', messages: ['Message 1', 'Message 2'], type: 'notice'))
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class PageComponentPreview < ViewComponent::Preview
|
2
|
+
layout false
|
3
|
+
|
4
|
+
def default
|
5
|
+
render(PageComponent.new) do |page|
|
6
|
+
page.actions do
|
7
|
+
tag.span('Example actions')
|
8
|
+
end
|
9
|
+
page.header do
|
10
|
+
tag.span('Example header')
|
11
|
+
end
|
12
|
+
tag.span('Example content')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def without_actions
|
17
|
+
render(PageComponent.new) do |page|
|
18
|
+
page.header do
|
19
|
+
tag.span('Example header')
|
20
|
+
end
|
21
|
+
tag.span('Example content')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def without_header
|
26
|
+
render(PageComponent.new) do |page|
|
27
|
+
page.actions do
|
28
|
+
tag.span('Example actions')
|
29
|
+
end
|
30
|
+
tag.span('Example content')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class SidebarComponentPreview < ViewComponent::Preview
|
2
|
+
layout false
|
3
|
+
|
4
|
+
def default
|
5
|
+
render(SidebarComponent.new) do |sidebar|
|
6
|
+
sidebar.top do
|
7
|
+
tag.span('Example top')
|
8
|
+
end
|
9
|
+
sidebar.bottom do
|
10
|
+
tag.span('Example bottom')
|
11
|
+
end
|
12
|
+
tag.span('Example content')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def without_top
|
17
|
+
render(SidebarComponent.new) do |sidebar|
|
18
|
+
sidebar.bottom do
|
19
|
+
tag.span('Example bottom')
|
20
|
+
end
|
21
|
+
tag.span('Example content')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def without_bottom
|
26
|
+
render(SidebarComponent.new) do |sidebar|
|
27
|
+
sidebar.top do
|
28
|
+
tag.span('Example top')
|
29
|
+
end
|
30
|
+
tag.span('Example content')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class TableColumnComponentPreview < ViewComponent::Preview
|
2
|
+
class TempObj
|
3
|
+
attr_accessor :fieldname
|
4
|
+
|
5
|
+
def initialize(fieldname = 'Example value')
|
6
|
+
@fieldname = fieldname
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
layout false
|
11
|
+
|
12
|
+
def default
|
13
|
+
temp_obj = TempObj.new
|
14
|
+
render(TableColumnComponent.new(value: nil, obj: temp_obj, fieldname: :fieldname, url: nil, options: {}))
|
15
|
+
end
|
16
|
+
|
17
|
+
def with_url
|
18
|
+
temp_obj = TempObj.new
|
19
|
+
render(TableColumnComponent.new(value: nil, obj: temp_obj, fieldname: :fieldname, url: 'example/url', options: {}))
|
20
|
+
end
|
21
|
+
|
22
|
+
def with_date
|
23
|
+
temp_obj = TempObj.new(Time.zone.today)
|
24
|
+
render(TableColumnComponent.new(value: nil, obj: temp_obj, fieldname: :fieldname, url: 'example/url', options: { date: true }))
|
25
|
+
end
|
26
|
+
|
27
|
+
def with_time
|
28
|
+
temp_obj = TempObj.new(Time.zone.now)
|
29
|
+
render(TableColumnComponent.new(value: nil, obj: temp_obj, fieldname: :fieldname, url: 'example/url', options: { time: true }))
|
30
|
+
end
|
31
|
+
|
32
|
+
def with_custom_value
|
33
|
+
temp_obj = TempObj.new
|
34
|
+
render(TableColumnComponent.new(value: 'custom value', obj: temp_obj, fieldname: :fieldname, url: nil, options: {}))
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class TableHeaderComponentPreview < ViewComponent::Preview
|
2
|
+
class TempObj
|
3
|
+
def self.human_attribute_name(_)
|
4
|
+
'label'
|
5
|
+
end
|
6
|
+
|
7
|
+
def fieldname
|
8
|
+
'value'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
layout false
|
13
|
+
|
14
|
+
def default
|
15
|
+
temp_obj = TempObj.new
|
16
|
+
render(TableHeaderComponent.new(label: nil, url: nil, obj: temp_obj, fieldname: :fieldname))
|
17
|
+
end
|
18
|
+
|
19
|
+
def with_url
|
20
|
+
temp_obj = TempObj.new
|
21
|
+
render(TableHeaderComponent.new(label: nil, url: 'example/url', obj: temp_obj, fieldname: :fieldname))
|
22
|
+
end
|
23
|
+
|
24
|
+
def with_custom_label
|
25
|
+
render(TableHeaderComponent.new(label: 'Custom label', url: nil, obj: nil, fieldname: nil))
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class TableRowComponentPreview < ViewComponent::Preview
|
2
|
+
layout false
|
3
|
+
|
4
|
+
def default
|
5
|
+
render(TableRowComponent.new) do |tablerow|
|
6
|
+
tablerow.actions do
|
7
|
+
tag.td('Example actions')
|
8
|
+
end
|
9
|
+
tag.td('Example content')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def without_actions
|
14
|
+
render(TableRowComponent.new) do |_tablerow|
|
15
|
+
tag.td('Example content')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class ToolbarComponentPreview < ViewComponent::Preview
|
2
|
+
layout false
|
3
|
+
|
4
|
+
def default
|
5
|
+
render(ToolbarComponent.new) do |toolbar|
|
6
|
+
toolbar.left do
|
7
|
+
tag.span('Example left')
|
8
|
+
end
|
9
|
+
toolbar.right do
|
10
|
+
tag.span('Example right')
|
11
|
+
end
|
12
|
+
tag.span('Example content')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def without_left
|
17
|
+
render(ToolbarComponent.new) do |toolbar|
|
18
|
+
toolbar.right do
|
19
|
+
tag.span('Example right')
|
20
|
+
end
|
21
|
+
tag.span('Example content')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def without_right
|
26
|
+
render(ToolbarComponent.new) do |toolbar|
|
27
|
+
toolbar.left do
|
28
|
+
tag.span('Example left')
|
29
|
+
end
|
30
|
+
tag.span('Example content')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/alveole.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'view_component'
|
3
|
+
|
4
|
+
require 'alveole/version'
|
5
|
+
require 'alveole/concerns/bem'
|
6
|
+
require 'alveole/helpers/method_helper'
|
7
|
+
|
8
|
+
if defined? ::Rails::Railtie
|
9
|
+
# require 'alveole/railtie'
|
10
|
+
require 'alveole/engine'
|
11
|
+
end
|
12
|
+
|
13
|
+
module Alveole
|
14
|
+
class Error < StandardError; end
|
15
|
+
# Your code goes here...
|
16
|
+
end
|