asbru 0.0.7 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asbru/cml.rb +17 -40
- data/lib/asbru/components/sage.rb +3 -0
- data/lib/asbru/components/savage.rb +6 -0
- data/lib/asbru/form_builder.rb +10 -3
- data/lib/asbru/ragna.rb +2 -2
- data/lib/asbru/version.rb +1 -1
- data/lib/asbru.rb +8 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45ab6b9c6737f74c9bc7b395f1bd7df468feb923ccdc07b09f51ddd9d39c90fd
|
4
|
+
data.tar.gz: ef4da4d80683a0bfb4a24701ce22d4f2bb231f2c6b8f530e048cc3bfa372118a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c924577583ce3eeb2734aa77d90c13de7a3866b7a0626f737c7015151cca29c05d307c131bf3c624092d1232257caa9db8adaa3832eed5f03d8fcf1aa697d960
|
7
|
+
data.tar.gz: f600444f70190663de4c021da4bc0f353aec551be1b151cbfab95754c0bf32d1d12b273ab5a886c5238006d7d00a52b2081fd97a701f44903a01065c0944cd54
|
data/lib/asbru/cml.rb
CHANGED
@@ -1,88 +1,65 @@
|
|
1
1
|
require 'asbru/components/savage'
|
2
2
|
|
3
3
|
module Asbru
|
4
|
-
# This module defines a bunch of methods that
|
5
|
-
|
6
|
-
|
4
|
+
# This module defines a bunch of methods that make component based pages
|
5
|
+
# appear more similar to HTML.
|
6
|
+
# The limitation is that nested components won't work.
|
7
|
+
module Cml
|
8
|
+
C = Asbru::Config.component_mode.tap(&:setup)
|
7
9
|
|
8
|
-
# Problems:
|
9
|
-
# How can we make this module work with Sage/Savage depending on config?
|
10
|
-
# Do we want to do that?
|
11
|
-
|
12
|
-
# Ideas:
|
13
|
-
# 1. We can make Sage implement to exactly the same interface as Savage and
|
14
|
-
# somehow inject it.
|
15
|
-
# 2. We could also ALWAYS load the sage classed needed here and call these
|
16
|
-
# required.
|
17
|
-
#
|
18
|
-
# I think I prefer 1 even though the syntax of Sage is nicer imo.
|
19
10
|
class << self
|
20
11
|
def p text, **opts
|
21
|
-
C.send "#{
|
12
|
+
C.send "#{prefix(opts)}_content",
|
22
13
|
text: text,
|
23
14
|
**opts
|
24
15
|
end
|
25
16
|
|
26
17
|
def h1 text, **opts
|
27
|
-
C.send "#{
|
18
|
+
C.send "#{prefix(opts)}_title",
|
28
19
|
size: 'h1',
|
29
20
|
text: text
|
30
21
|
end
|
31
22
|
|
32
23
|
def h2 text, **opts
|
33
|
-
C.send "#{
|
24
|
+
C.send "#{prefix(opts)}_title",
|
34
25
|
size: 'h2',
|
35
26
|
text: text
|
36
27
|
end
|
37
28
|
|
38
29
|
def h3 text, **opts
|
39
|
-
C.send "#{
|
30
|
+
C.send "#{prefix(opts)}_title",
|
40
31
|
size: 'h3',
|
41
32
|
text: text
|
42
33
|
end
|
43
34
|
|
44
35
|
def h4 text, **opts
|
45
|
-
C.send "#{
|
36
|
+
C.send "#{prefix(opts)}_title",
|
46
37
|
size: 'h4',
|
47
38
|
text: text
|
48
39
|
end
|
49
40
|
|
50
41
|
def h5 text, **opts
|
51
|
-
C.send "#{
|
42
|
+
C.send "#{prefix(opts)}_title",
|
52
43
|
size: 'h5',
|
53
44
|
text: text
|
54
45
|
end
|
55
46
|
|
56
|
-
def hr color: 'stable-500'
|
57
|
-
C.send "#{
|
47
|
+
def hr color: 'stable-500', **opts
|
48
|
+
C.send "#{prefix}_divider",
|
58
49
|
color: color,
|
59
50
|
height: 1
|
60
51
|
end
|
61
52
|
|
62
|
-
def vertical_spacer height
|
63
|
-
C.send "#{
|
53
|
+
def vertical_spacer height, **opts
|
54
|
+
C.send "#{prefix(opts)}_divider",
|
64
55
|
color: :transparent,
|
65
56
|
height: height
|
66
57
|
end
|
67
58
|
|
68
|
-
def table_row(*cells)
|
69
|
-
{ data: cells }
|
70
|
-
end
|
71
|
-
|
72
|
-
def table_cell(text, action: nil, method: nil, confirm: nil, color: nil)
|
73
|
-
cell = { text: text}
|
74
|
-
cell[:color] = color if color.present?
|
75
|
-
cell[:action] = action if action.present?
|
76
|
-
cell[:customData] = {}
|
77
|
-
cell[:customData]['data-method'] = method if method.present?
|
78
|
-
cell[:customData]['data-confirm'] = confirm if confirm.present?
|
79
|
-
cell
|
80
|
-
end
|
81
|
-
|
82
59
|
private
|
83
60
|
|
84
|
-
def
|
85
|
-
Asbru.config.component_prefix
|
61
|
+
def prefix(opts)
|
62
|
+
opts[:module] || Asbru.config.component_prefix
|
86
63
|
end
|
87
64
|
end
|
88
65
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'react/rails/view_helper'
|
2
|
+
|
1
3
|
module Asbru
|
2
4
|
module Components
|
3
5
|
# This module uses components.json to see what components are available to
|
@@ -9,6 +11,7 @@ module Asbru
|
|
9
11
|
extend ::React::Rails::ViewHelper
|
10
12
|
class << self
|
11
13
|
def setup
|
14
|
+
debugger
|
12
15
|
file = File.open(Rails.root.join('app',
|
13
16
|
'javascript',
|
14
17
|
'components',
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'react/rails/view_helper'
|
2
|
+
|
1
3
|
module Asbru
|
2
4
|
module Components
|
3
5
|
# This module is used to generate react components in the views and loads
|
@@ -6,6 +8,10 @@ module Asbru
|
|
6
8
|
class Savage
|
7
9
|
extend ::React::Rails::ViewHelper
|
8
10
|
class << self
|
11
|
+
def setup
|
12
|
+
# No-op
|
13
|
+
end
|
14
|
+
|
9
15
|
def method_missing(method_id, **opts)
|
10
16
|
if self.respond_to? :method_id
|
11
17
|
super
|
data/lib/asbru/form_builder.rb
CHANGED
@@ -35,7 +35,7 @@ module Asbru
|
|
35
35
|
{ check_box: { type: 'checkbox' } },
|
36
36
|
{ file_field: { type: 'file' } },
|
37
37
|
{ text_field: {} },
|
38
|
-
{ telephone_field: { type: 'tel
|
38
|
+
{ telephone_field: { type: 'tel'}}
|
39
39
|
].freeze
|
40
40
|
|
41
41
|
def errors(name)
|
@@ -54,10 +54,11 @@ module Asbru
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def render_form_element(attribute, options)
|
57
|
-
new_options = options.
|
57
|
+
new_options = options.reverse_merge(
|
58
58
|
{
|
59
59
|
name: tag_name_for(attribute),
|
60
|
-
errors: errors(attribute)
|
60
|
+
errors: errors(attribute),
|
61
|
+
errorIcon: error_icon
|
61
62
|
}
|
62
63
|
)
|
63
64
|
|
@@ -210,5 +211,11 @@ module Asbru
|
|
210
211
|
)
|
211
212
|
)
|
212
213
|
end
|
214
|
+
|
215
|
+
private
|
216
|
+
|
217
|
+
def error_icon
|
218
|
+
Asbru.config.default_form_error_icon
|
219
|
+
end
|
213
220
|
end
|
214
221
|
end
|
data/lib/asbru/ragna.rb
CHANGED
@@ -5,8 +5,8 @@ require 'asbru/cml'
|
|
5
5
|
|
6
6
|
# We use the C for binding components. We might want to make this configurable
|
7
7
|
# later on
|
8
|
-
::C = Asbru
|
9
|
-
::
|
8
|
+
::C = Asbru.config.component_mode.tap(&:setup)
|
9
|
+
::Cml = Asbru::Cml
|
10
10
|
|
11
11
|
module Asbru
|
12
12
|
module Ragna
|
data/lib/asbru/version.rb
CHANGED
data/lib/asbru.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
require "asbru/railtie"
|
2
2
|
require 'dry-configurable'
|
3
|
+
require 'asbru/components/savage'
|
4
|
+
require 'asbru/components/sage'
|
3
5
|
|
4
6
|
module Asbru
|
5
7
|
extend Dry::Configurable
|
6
|
-
setting :component_prefix,'app'
|
7
|
-
setting :form_builder_prefix, 'app'
|
8
|
+
setting :component_prefix, default: 'app'
|
9
|
+
setting :form_builder_prefix, default: 'app'
|
10
|
+
setting :default_form_error_icon, default: 'icon-error'
|
11
|
+
setting :component_mode, default: Asbru::Components::Savage
|
12
|
+
|
13
|
+
Config = self.config
|
8
14
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asbru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stev-0
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|