headmin 0.5.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4995d965477ea5691025ac2ca92fb211c13acc44f1068f402e013c1ec47cb08
4
- data.tar.gz: dc1f5842c477771e2b9b9890e8b99e03af6c96daf6451ce8a09628c0dded3f3a
3
+ metadata.gz: 8a80387ee0e1dfc309d65f5e5eb450260dc84fda671904c3886eb50d2087c3eb
4
+ data.tar.gz: 98282252c395347dbb1c2490247c323649b4d282d1bc0d7a6bad32c51ec7ebfc
5
5
  SHA512:
6
- metadata.gz: 64e5f636b7551f1348e640a2dc86e2de7169aee2b6decbda14fa9da3ceea4cbff594686fc27ed4c3a59de554491498c2f6fe60feda94f318bafdef5f8066e75e
7
- data.tar.gz: 05bd1380da40f154c741f1a42be39a466a1f4c4f4860b1e9e1176024e24e61d9d68940b3d62932cb9f0413561e7425842f3d2f523a76e66d4b73cc2eef701369
6
+ metadata.gz: 3c7271cbff3e46599c77506c07bdd0d0fc0d132bf7230202913a394b4b285f599c37866f52d28ff5d79b19ea59c754db7f25fab68bba71795e87d7d42139285a
7
+ data.tar.gz: 9900e4731b52d46486ea772433696774856b974d7bd2dc758628ce964c5d990296910c1a59a04990f5e509a5a1e341f3d9848d2043ad2ee2c14029c8096feae9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- headmin (0.4.2)
4
+ headmin (0.5.1)
5
5
  closure_tree (~> 7.4)
6
6
  inline_svg (~> 1.7)
7
7
  redcarpet (~> 3.5)
@@ -34,3 +34,10 @@
34
34
  max-width: 100%;
35
35
  }
36
36
  }
37
+
38
+ .h-table-cell-color {
39
+ width: 22px;
40
+ height: 22px;
41
+ border-radius: 3px;
42
+ background-color: var(--cell-color);
43
+ }
@@ -13204,6 +13204,12 @@ body.empty {
13204
13204
  width: 300px;
13205
13205
  max-width: 100%;
13206
13206
  }
13207
+ .h-table-cell-color {
13208
+ width: 22px;
13209
+ height: 22px;
13210
+ border-radius: 3px;
13211
+ background-color: var(--cell-color);
13212
+ }
13207
13213
  .btn-link {
13208
13214
  text-decoration: none;
13209
13215
  }
@@ -9,7 +9,7 @@ module Headmin
9
9
  end
10
10
 
11
11
  def prefixes
12
- paths + ["website/blocks", "blocks", ""]
12
+ paths + ["website/blocks", "blocks"]
13
13
  end
14
14
  end
15
15
  end
@@ -0,0 +1,48 @@
1
+ module Headmin
2
+ module Form
3
+ class ColorView < ViewModel
4
+ include Headmin::Form::Hintable
5
+ include Headmin::Form::Labelable
6
+ include Headmin::Form::Validatable
7
+ include Headmin::Form::Wrappable
8
+
9
+ def input_options
10
+ keys = attributes - %i[attribute form label validate wrapper]
11
+ options = to_h.slice(*keys)
12
+ default_input_options.deep_merge(options)
13
+ end
14
+
15
+ def label_options
16
+ {
17
+ class: ["form-label"],
18
+ attribute: attribute,
19
+ form: form,
20
+ required: required,
21
+ text: label
22
+ }
23
+ end
24
+
25
+ def value
26
+ @form.object&.send(@attribute) || "#000000"
27
+ end
28
+
29
+ def wrapper_options
30
+ default_wrapper_options.deep_merge(
31
+ {
32
+ }
33
+ ).deep_merge(@wrapper || {})
34
+ end
35
+
36
+ private
37
+
38
+ def default_input_options
39
+ {
40
+ aria: {describedby: validation_id},
41
+ class: ["form-control form-control-color", validation_class],
42
+ placeholder: placeholder,
43
+ title: value
44
+ }
45
+ end
46
+ end
47
+ end
48
+ end
@@ -15,7 +15,7 @@
15
15
  # <%= render "headmin/blocks", blockable: @page, paths: %w(website/pages/blocks) %#>
16
16
 
17
17
  blocks = Headmin::BlocksView.new(local_assigns)
18
- @lookup_context.prefixes = @lookup_context.prefixes + blocks.prefixes
18
+ @lookup_context.prefixes = blocks.prefixes + @lookup_context.prefixes
19
19
  %>
20
20
 
21
21
  <% if blockable && blockable.respond_to?(:blocks) %>
@@ -0,0 +1,32 @@
1
+ <%
2
+ # headmin/forms/color
3
+ #
4
+ # ==== Required parameters
5
+ # * +attribute+ - Name of the attribute of the form model
6
+ # * +form+ - Form object
7
+ #
8
+ # ==== Optional parameters
9
+ # * +hint+ - Informative text to assist with data input. HTML markup is allowed.
10
+ # * +label+ - Text to display inside label tag. Defaults to the attribute name. Set to false if you don"t want to show a label.
11
+ # * +wrapper+ - Hash with all options for the surrounding html tag
12
+ #
13
+ # ==== References
14
+ # https://headmin.dev/docs/forms/color
15
+ # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/color
16
+ # https://apidock.com/rails/v5.2.3/ActionView/Helpers/FormHelper/color_field
17
+ #
18
+ # ==== Examples
19
+ # Basic version
20
+ # <%= form_with do |form| %#>
21
+ # <%= render "headmin/forms/color", form: form, attribute: :active %#>
22
+ # <% end %#>
23
+
24
+ color = Headmin::Form::ColorView.new(local_assigns)
25
+ %>
26
+
27
+ <%= render "headmin/forms/wrapper", color.wrapper_options do %>
28
+ <%= render "headmin/forms/label", color.label_options if color.label? %>
29
+ <%= form.color_field(color.attribute, color.input_options) %>
30
+ <%= render "headmin/forms/validation", color.validation_options if color.validate? %>
31
+ <%= render "headmin/forms/hint", color.hint_options if color.hint? %>
32
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <%#
2
+ headmin/table/body/color
3
+ accepts block: no
4
+ parameters:
5
+ value: (hexadecimal) Color value
6
+ %>
7
+
8
+ <td>
9
+ <div class="h-table-cell-color" style="--cell-color: <%= value %>" title="<%= value %>"></div>
10
+ </td>
@@ -1,3 +1,3 @@
1
1
  module Headmin
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "headmin",
3
- "version": "0.4.2",
3
+ "version": "0.5.1",
4
4
  "description": "Admin component library",
5
5
  "module": "app/assets/javascripts/headmin.js",
6
6
  "main": "app/assets/javascripts/headmin.js",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: headmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jef Vlamings
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-05-05 00:00:00.000000000 Z
11
+ date: 2022-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: closure_tree
@@ -272,6 +272,7 @@ files:
272
272
  - app/models/headmin/filters.rb
273
273
  - app/models/headmin/form/blocks_view.rb
274
274
  - app/models/headmin/form/checkbox_view.rb
275
+ - app/models/headmin/form/color_view.rb
275
276
  - app/models/headmin/form/date_range_view.rb
276
277
  - app/models/headmin/form/date_view.rb
277
278
  - app/models/headmin/form/datetime_range_view.rb
@@ -334,6 +335,7 @@ files:
334
335
  - app/views/headmin/forms/_autocomplete.html.erb
335
336
  - app/views/headmin/forms/_blocks.html.erb
336
337
  - app/views/headmin/forms/_checkbox.html.erb
338
+ - app/views/headmin/forms/_color.html.erb
337
339
  - app/views/headmin/forms/_datalist.html.erb
338
340
  - app/views/headmin/forms/_date.html.erb
339
341
  - app/views/headmin/forms/_date_range.html.erb
@@ -402,6 +404,7 @@ files:
402
404
  - app/views/headmin/table/actions/_export.html.erb
403
405
  - app/views/headmin/table/body/_association.html.erb
404
406
  - app/views/headmin/table/body/_boolean.erb
407
+ - app/views/headmin/table/body/_color.html.erb
405
408
  - app/views/headmin/table/body/_currency.html.erb
406
409
  - app/views/headmin/table/body/_date.html.erb
407
410
  - app/views/headmin/table/body/_id.html.erb