shimmer 0.0.24 → 0.0.26

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0eaed2568e6fdbdc41b8c47337b1c514f0db410c597c3b5727eb3de9ffa2367
4
- data.tar.gz: b946998c24efbe8fe0307ef55ea9971233be36623cdbcdbd283306c319132d02
3
+ metadata.gz: 56d4b2433dce6cff2fbaee9f1eb4591caf4f9abdbbc50aa9154f9eb81c5ce068
4
+ data.tar.gz: 9f95b3f5e0dfda4d102f529d7bd0334dbbbd4cbc31c026069be0a949f49f04c3
5
5
  SHA512:
6
- metadata.gz: 13279649e9331c200c8491974f57fc659aff3b60242f93683fba9a55d0d75583a32c6b9eaab4a4d128207f5be416b55493af629cd87edd02d01cc52c946da4da
7
- data.tar.gz: 8f200cd8ed792dc4a33d2ab7fc2d0607a00ea9a2a4ad32f278d655a21d1510d7cd614483d15077cb99ab2ca9b124c6ec94b02cf8471740b0b17497f94bc61354
6
+ metadata.gz: 5625382dc2804fd1d0f6b93c8a2bdb391f2c2d632c70ab023ca22abdb7d661a746a799f13772f269ed160f420b32712825ec0ae5693683c98beb84f57c324f89
7
+ data.tar.gz: 559862f18bca1477be21b2cf40666da06c2b294177ecf4fac46a4d769ede304d55c767eab945c87b470d145bef7fbba3e0ebc1635f8174a633c7925279fadb94
@@ -13,7 +13,7 @@ module Shimmer
13
13
  end
14
14
  end
15
15
 
16
- def input(method, as: guess_type(method), wrapper_options: {}, description: nil, **options)
16
+ def input(method, as: guess_type(method), wrapper_options: {}, description: nil, label_method: nil, **options)
17
17
  as ||= guess_type(method)
18
18
  options[:class] ||= "input__input"
19
19
  collection = options.delete :collection
@@ -29,8 +29,10 @@ module Shimmer
29
29
  input_class = self.class.input_registry[as]
30
30
  raise "Unknown type #{as}" unless input_class
31
31
  input = input_class.new(builder: self, method: method, options: options, id_method: id_method, collection: collection, name_method: name_method)
32
+ input.prepare
32
33
  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
+ label_method ||= wrapper_options.delete(:label_method)
35
+ wrap method: method, content: input.render, classes: classes + ["input--#{as}"], label: options[:label], extra: extra, description: description, options: wrapper_options, label_method: label_method
34
36
  end
35
37
 
36
38
  private
@@ -65,12 +67,12 @@ module Shimmer
65
67
  object.class.types.keys if object.class.respond_to?(method.to_s.pluralize)
66
68
  end
67
69
 
68
- def wrap(method:, content:, classes:, label:, data: nil, extra: nil, description: nil, options: {})
70
+ def wrap(method:, content:, classes:, label:, data: nil, extra: nil, description: nil, options: {}, label_method: nil)
69
71
  if object&.errors&.[](method)&.any?
70
72
  classes << "input--error"
71
73
  errors = safe_join(object.errors[method].map { |e| content_tag :div, e, class: "input__error" })
72
74
  end
73
- label = label == false ? nil : self.label(method, label, class: "input__label")
75
+ label = label == false ? nil : self.label(label_method || method, label, class: "input__label")
74
76
  description = description.presence ? content_tag(:div, description, class: "input__description") : nil
75
77
  content_tag(:div, safe_join([label, content, description, errors, extra].compact), class: ["input"] + classes, **options)
76
78
  end
@@ -17,6 +17,9 @@ module Shimmer
17
17
  {}
18
18
  end
19
19
 
20
+ def prepare
21
+ end
22
+
20
23
  def initialize(builder:, method:, collection:, id_method:, name_method:, options: {})
21
24
  @builder = builder
22
25
  @method = method
@@ -5,8 +5,16 @@ module Shimmer
5
5
  class RadioField < Field
6
6
  self.type = :radio
7
7
 
8
+ def prepare
9
+ @value = options.delete(:value)
10
+ end
11
+
8
12
  def render
9
- builder.collection_radio_buttons method, collection, id_method, name_method, {}, options
13
+ builder.radio_button method, @value, options
14
+ end
15
+
16
+ def wrapper_options
17
+ {label_method: "#{method}_#{@value.to_s.underscore}".to_sym}
10
18
  end
11
19
  end
12
20
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shimmer
4
+ module Form
5
+ class RadiosField < Field
6
+ self.type = :radios
7
+
8
+ def render
9
+ builder.collection_radio_buttons method, collection, id_method, name_method, {}, options
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.24"
4
+ VERSION = "0.0.26"
5
5
  end
data/src/consent.ts CHANGED
@@ -54,7 +54,7 @@ export class Consent {
54
54
  ): Promise<void> {
55
55
  await this.consentFor(role);
56
56
  window.gtag("js", new Date());
57
- window.gtag("config", id);
57
+ window.gtag("config", id, { send_page_view: false }); // page view is disabled because it's tracked via the analytics stimulus controller already
58
58
  const script = document.createElement("script");
59
59
  script.async = true;
60
60
  script.setAttribute(
@@ -12,7 +12,8 @@ declare global {
12
12
  }
13
13
 
14
14
  const dataLayer = (window.dataLayer = window.dataLayer ?? []);
15
- function gtag(): void {
15
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
+ function gtag(..._arg): void {
16
17
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
17
18
  // @ts-ignore
18
19
  // eslint-disable-next-line prefer-rest-params
@@ -29,15 +30,15 @@ export default class extends Controller {
29
30
  const data = JSON.parse(
30
31
  (event.target as HTMLElement).dataset.analytics ?? "{}"
31
32
  );
32
- dataLayer.push(data);
33
+ const eventName = data["event"];
34
+ delete data["event"];
35
+ gtag("event", eventName, data);
33
36
  }
34
37
 
35
38
  recordPage(): void {
36
- const event = {
37
- event: "Pageview",
38
- path: location.pathname + location.search,
39
- host: location.host,
40
- };
41
- dataLayer.push(event);
39
+ gtag("event", "page_view", {
40
+ page_title: document.title,
41
+ page_location: document.location.toString(),
42
+ });
42
43
  }
43
44
  }
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.24
4
+ version: 0.0.26
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-10-07 00:00:00.000000000 Z
11
+ date: 2022-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -158,6 +158,7 @@ files:
158
158
  - lib/shimmer/form/password_field.rb
159
159
  - lib/shimmer/form/pdf_field.rb
160
160
  - lib/shimmer/form/radio_field.rb
161
+ - lib/shimmer/form/radios_field.rb
161
162
  - lib/shimmer/form/select_field.rb
162
163
  - lib/shimmer/form/text_area_field.rb
163
164
  - lib/shimmer/form/text_field.rb