bulma-phlex-rails 0.2.1 → 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/lib/bulma_phlex/rails/form_builder.rb +85 -0
- data/lib/bulma_phlex/rails/version.rb +1 -1
- data/lib/bulma_phlex/rails.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8534c00b03a3ae8dad07d870b62ff94369802828940f05f6e8e9389b916c3dc9
|
|
4
|
+
data.tar.gz: 8a1284dc1ec5c8dd3a8bb60fdba5e69303fb6f3ae6a18bf6b3f58e70baf1840a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ed9272374b031aba4d8a685b011a5bd9f86989302da74cf8de070295e5457ce4b3502d1a6469ce94fdd536f6bca7bf5df0d501e2d4f29cd5c6f11e43a371ad98
|
|
7
|
+
data.tar.gz: ee41ceed1abc0e13778f74dce863579396740d19854f465fb1d12d086d3ca8480a6abb34c6959a8885dd9cff237fc9618632d3b2c7e3a154dca4439929eeed80
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module BulmaPhlex
|
|
4
|
+
module Rails
|
|
5
|
+
# # Form Builder
|
|
6
|
+
#
|
|
7
|
+
# This form builder wraps inputs with [Bulma Form Fields](https://bulma.io/documentation/form/general/#form-field).
|
|
8
|
+
#
|
|
9
|
+
# In addition to standard input options, it supports the following Bulma-specific options:
|
|
10
|
+
# - `suppress_label`: If true, the label will not be rendered.
|
|
11
|
+
# - `icon_left`: If set, the specified icon will be rendered on the left side of the input.
|
|
12
|
+
# - `icon_right`: If set, the specified icon will be rendered on the right side of the input.
|
|
13
|
+
# - `column`: If true, the input will be wrapped in a Bulma column (only within a `columns` block).
|
|
14
|
+
# - `grid`: If true, the input will be wrapped in a Bulma grid cell (only within a `grid` block).
|
|
15
|
+
class FormBuilder < ActionView::Helpers::FormBuilder
|
|
16
|
+
def text_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
17
|
+
def password_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
18
|
+
def color_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
19
|
+
def search_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
20
|
+
def telephone_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
21
|
+
def phone_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
22
|
+
def date_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
23
|
+
def time_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
24
|
+
def datetime_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
25
|
+
def datetime_local_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
26
|
+
def month_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
27
|
+
def week_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
28
|
+
def url_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
29
|
+
def email_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
30
|
+
def number_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
31
|
+
def range_field(method, **options) = wrap_field(method, options) { |m, opts| super(m, opts) }
|
|
32
|
+
|
|
33
|
+
# Fields declared in a column block will be wrapped in a Bulma column and carry
|
|
34
|
+
# the `column` class by default (fields can use the `column` option to set sizes).
|
|
35
|
+
def columns(min_breakpoint = nil, &)
|
|
36
|
+
@columns_flag = true
|
|
37
|
+
columns = @template.capture(&)
|
|
38
|
+
@columns_flag = false
|
|
39
|
+
|
|
40
|
+
@template.content_tag(:div, class: [:columns, min_breakpoint]) do
|
|
41
|
+
@template.concat(columns)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Fields declared in a fixed_grid block will be wrapped in a Bulma fixed grid and
|
|
46
|
+
# carry the `grid` class by default (fields can use the `grid` option to set sizes).
|
|
47
|
+
def fixed_grid(&)
|
|
48
|
+
# TODO: Use BulmaPhlex::FixedGrid for more options
|
|
49
|
+
@template.content_tag(:div, class: "fixed-grid") do
|
|
50
|
+
grid(&)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Fields declared in a grid block will be wrapped in a Bulma fixed grid and carry
|
|
55
|
+
# the `grid` class by default (fields can use the `grid` option to set sizes).
|
|
56
|
+
def grid(&)
|
|
57
|
+
@grid_flag = true
|
|
58
|
+
cells = @template.capture(&)
|
|
59
|
+
@grid_flag = false
|
|
60
|
+
|
|
61
|
+
# TODO: Use BulmaPhlex::Grid for more options
|
|
62
|
+
@template.content_tag(:div, class: "grid") do
|
|
63
|
+
@template.concat(cells)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
private
|
|
68
|
+
|
|
69
|
+
def wrap_field(method, options, &delivered)
|
|
70
|
+
options = options.dup
|
|
71
|
+
options[:class] = "input #{options[:class]}".rstrip
|
|
72
|
+
|
|
73
|
+
form_field_options = options.extract!(:icon_left, :icon_right, :column, :grid)
|
|
74
|
+
.with_defaults(column: @columns_flag, grid: @grid_flag)
|
|
75
|
+
|
|
76
|
+
form_field = FormField.new(**form_field_options) do |f|
|
|
77
|
+
f.label { label(method, class: "label").html_safe } unless options.delete(:suppress_label)
|
|
78
|
+
f.control { delivered.call(method, options) }
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
form_field.render_in(@template)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
data/lib/bulma_phlex/rails.rb
CHANGED
|
@@ -14,6 +14,7 @@ end
|
|
|
14
14
|
loader = Zeitwerk::Loader.for_gem_extension(BulmaPhlex)
|
|
15
15
|
loader.collapse("#{__dir__}/rails/components")
|
|
16
16
|
loader.collapse("#{__dir__}/rails/helpers")
|
|
17
|
+
loader.collapse("#{__dir__}/rails/models")
|
|
17
18
|
loader.setup
|
|
18
19
|
|
|
19
20
|
require "bulma_phlex/rails/engine"
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bulma-phlex-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Todd Kummer
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-01-24 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: actionpack
|
|
@@ -29,14 +29,14 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.
|
|
32
|
+
version: 0.9.0
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 0.
|
|
39
|
+
version: 0.9.0
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: phlex-rails
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -81,6 +81,7 @@ files:
|
|
|
81
81
|
- lib/bulma-phlex-rails.rb
|
|
82
82
|
- lib/bulma_phlex/rails.rb
|
|
83
83
|
- lib/bulma_phlex/rails/engine.rb
|
|
84
|
+
- lib/bulma_phlex/rails/form_builder.rb
|
|
84
85
|
- lib/bulma_phlex/rails/helpers/card_helper.rb
|
|
85
86
|
- lib/bulma_phlex/rails/helpers/table_helper.rb
|
|
86
87
|
- lib/bulma_phlex/rails/version.rb
|