bulma_view_components 0.2.0 → 0.3.0
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/bulma/button_component.html.erb +3 -0
- data/app/components/bulma/button_component.rb +27 -0
- data/app/helpers/bulma/components_helper.rb +19 -0
- data/lib/bulma/view_components/engine.rb +7 -0
- data/lib/bulma/view_components/version.rb +1 -1
- metadata +5 -5
- data/app/helpers/bulma/component_helper.rb +0 -13
- data/lib/bulma/colors.rb +0 -71
- data/lib/bulma/view_components/sizes.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bbddc960e1f3fc14edcdbc09e8c629b9813106f22a991390e469c4bf871a968
|
4
|
+
data.tar.gz: 807fb83d62262365a097671958a80bdd261f784292ce3203d78f85a3df100080
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fe8bc4a34e167a644cf69a12b10a036196a08c4fced5da3afbed30d9fdf498854905949df8c60ca11a64c75e279d44c88658918c37c6ba42628ea2afc1a4e17
|
7
|
+
data.tar.gz: 5c173d47d2054e162c17675fd5671ade3777bafc42a4fef1f54de988422b2f93b5ad850cac0209aa9f9e942783b29f7408632455db57bfdacfb05a96990bd5cb
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bulma
|
4
|
+
class ButtonComponent < Component
|
5
|
+
attr_reader :type
|
6
|
+
|
7
|
+
def initialize(type: "submit", size: nil, color: nil, light: false, fullwidth: false, loading: false)
|
8
|
+
@type = type
|
9
|
+
@size = size
|
10
|
+
@color = color
|
11
|
+
@light = light
|
12
|
+
@fullwidth = fullwidth
|
13
|
+
@loading = loading
|
14
|
+
end
|
15
|
+
|
16
|
+
def classes
|
17
|
+
class_names(
|
18
|
+
"button",
|
19
|
+
"is-#{@size}" => @size,
|
20
|
+
"is-light" => @light,
|
21
|
+
"is-#{@color}" => @color.present?,
|
22
|
+
"is-fullwidth" => @fullwidth,
|
23
|
+
"is-loading" => @loading
|
24
|
+
)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bulma
|
4
|
+
module ComponentsHelper
|
5
|
+
BULMA_HELPER_COMPONENT_MAP = {
|
6
|
+
block: Bulma::BlockComponent,
|
7
|
+
box: Bulma::BoxComponent,
|
8
|
+
button: Bulma::ButtonComponent,
|
9
|
+
tag: Bulma::TagComponent,
|
10
|
+
title: Bulma::TitleComponent
|
11
|
+
}.freeze
|
12
|
+
|
13
|
+
BULMA_HELPER_COMPONENT_MAP.each do |name, component|
|
14
|
+
define_method :"bulma_#{name}" do |*args, **kwargs, &block|
|
15
|
+
render component.new(*args, **kwargs), &block
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -6,8 +6,15 @@ module Bulma
|
|
6
6
|
isolate_namespace Bulma::ViewComponents
|
7
7
|
|
8
8
|
config.autoload_paths += [
|
9
|
+
root.join("app/helpers"),
|
9
10
|
root.join("app/components")
|
10
11
|
]
|
12
|
+
|
13
|
+
initializer "bulma_view_components.helpers" do
|
14
|
+
ActiveSupport.on_load(:action_controller_base) do
|
15
|
+
helper Bulma::ComponentsHelper
|
16
|
+
end
|
17
|
+
end
|
11
18
|
end
|
12
19
|
end
|
13
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bulma_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diego Toral
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -49,14 +49,14 @@ files:
|
|
49
49
|
- README.md
|
50
50
|
- app/components/bulma/block_component.rb
|
51
51
|
- app/components/bulma/box_component.rb
|
52
|
+
- app/components/bulma/button_component.html.erb
|
53
|
+
- app/components/bulma/button_component.rb
|
52
54
|
- app/components/bulma/component.rb
|
53
55
|
- app/components/bulma/tag_component.rb
|
54
56
|
- app/components/bulma/title_component.rb
|
55
|
-
- app/helpers/bulma/
|
56
|
-
- lib/bulma/colors.rb
|
57
|
+
- app/helpers/bulma/components_helper.rb
|
57
58
|
- lib/bulma/view_components.rb
|
58
59
|
- lib/bulma/view_components/engine.rb
|
59
|
-
- lib/bulma/view_components/sizes.rb
|
60
60
|
- lib/bulma/view_components/version.rb
|
61
61
|
- lib/bulma_view_components.rb
|
62
62
|
homepage: https://github.com/diegotoral/bulma_view_components
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bulma
|
4
|
-
# Helper methods for cleaner views.
|
5
|
-
#
|
6
|
-
# These methods are automatically available to views and offer a very thin
|
7
|
-
# layer around the actual components they wrap.
|
8
|
-
module ComponentHelper
|
9
|
-
def bulma_title(*args, **kwargs, &block)
|
10
|
-
render Bulma::TitleComponent.new(*args, **kwargs, &block)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
data/lib/bulma/colors.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bulma
|
4
|
-
class InvalidColor < StandardError
|
5
|
-
def initialize(name)
|
6
|
-
super "Invalid color name #{name}"
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
module Colors
|
11
|
-
class Color
|
12
|
-
def initialize(name)
|
13
|
-
@name = name
|
14
|
-
end
|
15
|
-
|
16
|
-
def to_s
|
17
|
-
"is-#{@name}"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.white
|
22
|
-
@white ||= Color.new :white
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.black
|
26
|
-
@black ||= Color.new :black
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.light
|
30
|
-
@light ||= Color.new :light
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.dark
|
34
|
-
@dark ||= Color.new :dark
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.primary
|
38
|
-
@primary ||= Color.new :primary
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.link
|
42
|
-
@link ||= Color.new :link
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.info
|
46
|
-
@info ||= Color.new :info
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.success
|
50
|
-
@success ||= Color.new :success
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.warning
|
54
|
-
@warning ||= Color.new :warning
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.danger
|
58
|
-
@danger ||= Color.new :danger
|
59
|
-
end
|
60
|
-
|
61
|
-
def self.[](name)
|
62
|
-
return nil if name.nil?
|
63
|
-
|
64
|
-
method_name = name.to_sym
|
65
|
-
|
66
|
-
raise InvalidColor.new(name) unless respond_to?(method_name)
|
67
|
-
|
68
|
-
send(method_name)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|