shimmer 0.0.21 → 0.0.23

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: 89571a33faa2d1fd1d8c9624ab42a51f019418efc9c91af68fb3bb0385b5f602
4
- data.tar.gz: 814bca1dbd13b0e147df173b1b41077c0c585f4bd5b8e1b9e6933051d597f231
3
+ metadata.gz: 5b8e13a67c158deb5255b9a047415eca407baded8da093d1710c2a63d4e505fb
4
+ data.tar.gz: ecdfa43b53f32bca080085f2a1ffafe6393ba2c6739137843d54913fdadd0327
5
5
  SHA512:
6
- metadata.gz: 6d1c9bfa6f442914ca03747cf391ebf52086cb2c92d334641715031539cef826f09e171d3510e20866780ed87a1829182872485f6cd143c833ddebab97e1abf8
7
- data.tar.gz: 5db21bb6096a9a4a555b17c05d2ba128379f049ed87bae1e9fd9cddf824a05214c9858d8760924ea948d11645f9052b3d503167a098ece2ba97fb5ca498db754
6
+ metadata.gz: 84811ac4a7369eff4cd958e0a111151dc98a9998ef0a087959b2ecb41cc883def34ffe4db77d0eb2ec66be752106f654a8884d01aad7e8d5666a02ef80555ca9
7
+ data.tar.gz: 5830376aea6021ddf9b557ddab8ebe3b1157cc08ecc5badaead61cf024d24bed9013b3264b350c362b0b3b4f63eb295496595b07d900a36a0f2efe5b3a7a3912
@@ -13,7 +13,7 @@ module Shimmer
13
13
  end
14
14
  end
15
15
 
16
- def input(method, as: guess_type(method), **options)
16
+ def input(method, as: guess_type(method), wrapper_options: {}, description: nil, **options)
17
17
  as ||= guess_type(method)
18
18
  options[:class] ||= "input__input"
19
19
  collection = options.delete :collection
@@ -25,12 +25,12 @@ module Shimmer
25
25
  options[:required] ||= true if options[:required].nil? && required_attributes.include?(method)
26
26
  options[:data] ||= {}
27
27
  options[:data][:controller] = options.delete(:controller) if options[:controller]
28
- wrapper_data = {}
29
28
  extra = []
30
29
  input_class = self.class.input_registry[as]
31
30
  raise "Unknown type #{as}" unless input_class
32
31
  input = input_class.new(builder: self, method: method, options: options, id_method: id_method, collection: collection, name_method: name_method)
33
- wrap method: method, content: input.render, classes: classes + ["input--#{as}"], label: options[:label], data: wrapper_data, extra: extra
32
+ wrapper_options.reverse_merge! input.wrapper_options
33
+ wrap method: method, content: input.render, classes: classes + ["input--#{as}"], label: options[:label], extra: extra, description: description, options: wrapper_options
34
34
  end
35
35
 
36
36
  private
@@ -65,13 +65,14 @@ module Shimmer
65
65
  object.class.types.keys if object.class.respond_to?(method.to_s.pluralize)
66
66
  end
67
67
 
68
- def wrap(method:, content:, classes:, label:, data: nil, extra: nil)
68
+ def wrap(method:, content:, classes:, label:, data: nil, extra: nil, description: nil, options: {})
69
69
  if object&.errors&.[](method)&.any?
70
70
  classes << "input--error"
71
71
  errors = safe_join(object.errors[method].map { |e| content_tag :div, e, class: "input__error" })
72
72
  end
73
73
  label = label == false ? nil : self.label(method, label, class: "input__label")
74
- content_tag(:div, safe_join([label, content, errors, extra].compact), class: ["input"] + classes, data: data)
74
+ description = description.presence ? content_tag(:div, description, class: "input__description") : nil
75
+ content_tag(:div, safe_join([label, content, description, errors, extra].compact), class: ["input"] + classes, **options)
75
76
  end
76
77
 
77
78
  def helper
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shimmer
4
+ module Form
5
+ class CheckboxField < Field
6
+ self.type = :checkbox
7
+
8
+ def render
9
+ builder.check_box method, options
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shimmer
4
+ module Form
5
+ class DatetimeField < Field
6
+ self.type = :datetime
7
+
8
+ def render
9
+ builder.datetime_field method, options
10
+ end
11
+ end
12
+ end
13
+ end
@@ -13,6 +13,10 @@ module Shimmer
13
13
  end
14
14
  end
15
15
 
16
+ def wrapper_options
17
+ {}
18
+ end
19
+
16
20
  def initialize(builder:, method:, collection:, id_method:, name_method:, options: {})
17
21
  @builder = builder
18
22
  @method = method
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shimmer
4
+ module Form
5
+ class ImageField < Field
6
+ self.type = :image
7
+
8
+ def render
9
+ builder.file_field method, options.reverse_merge(accept: "image/*")
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shimmer
4
- VERSION = "0.0.21"
4
+ VERSION = "0.0.23"
5
5
  end
data/src/consent.ts CHANGED
@@ -53,12 +53,14 @@ export class Consent {
53
53
  role: ConsentCategory = "statistic"
54
54
  ): Promise<void> {
55
55
  await this.consentFor(role);
56
+ window.gtag("js", new Date());
56
57
  window.gtag("config", id);
57
58
  const script = document.createElement("script");
59
+ script.async = true;
58
60
  script.setAttribute(
59
61
  "src",
60
62
  `https://www.googletagmanager.com/gtag/js?id=${id}`
61
63
  );
62
- document.head.appendChild(script);
64
+ document.head.prepend(script);
63
65
  }
64
66
  }
@@ -12,12 +12,13 @@ declare global {
12
12
  }
13
13
 
14
14
  const dataLayer = (window.dataLayer = window.dataLayer ?? []);
15
-
16
- window.gtag = (...arg) => {
17
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
- dataLayer.push(arg as any);
19
- };
20
- window.gtag("js", new Date());
15
+ function gtag(): void {
16
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
17
+ // @ts-ignore
18
+ // eslint-disable-next-line prefer-rest-params
19
+ dataLayer.push(arguments);
20
+ }
21
+ window.gtag = gtag;
21
22
 
22
23
  export default class extends Controller {
23
24
  connect(): void {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Ravens
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-08 00:00:00.000000000 Z
11
+ date: 2022-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -147,10 +147,13 @@ files:
147
147
  - lib/shimmer/controllers/sitemaps_controller.rb
148
148
  - lib/shimmer/form.rb
149
149
  - lib/shimmer/form/builder.rb
150
+ - lib/shimmer/form/checkbox_field.rb
150
151
  - lib/shimmer/form/checkboxes_field.rb
151
152
  - lib/shimmer/form/date_field.rb
153
+ - lib/shimmer/form/datetime_field.rb
152
154
  - lib/shimmer/form/email_field.rb
153
155
  - lib/shimmer/form/field.rb
156
+ - lib/shimmer/form/image_field.rb
154
157
  - lib/shimmer/form/number_field.rb
155
158
  - lib/shimmer/form/password_field.rb
156
159
  - lib/shimmer/form/pdf_field.rb