bullet_train-themes-light 1.3.22 → 1.3.23

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: 001a0d44ebf47d4ec75398cf011dafdf7fd85c4e5f4aefc1ad82b5c9082d738b
4
- data.tar.gz: f8051ae0dbe0930264f8074d52df5940ca6a0d87e9edd4709d098ba1693f3329
3
+ metadata.gz: 437f822c3d8ab03b2b316020e1597f0a25626e24051f503a7225046af0cda90a
4
+ data.tar.gz: 4fe3b37b205202c6680f325f88dc71b48a0ec36ba33212da35ccb909d345ff72
5
5
  SHA512:
6
- metadata.gz: f34781fd7662b6753273a430545843083515855cbf2f03aae46f8bc216de9d862d0b481f6b5e7432a2b88b40b4d6499d06f328f3ccdab562442e384e86fe4506
7
- data.tar.gz: 3649a581630ff0ee8daf3289d471d6eac1a96b9fddeef4aa5b1c5a2955c7505e985c7d555e9136fbcd09ead021bba6f2a90bd50148a9b33dff63e563ccb4df1b
6
+ metadata.gz: 9e8cf89ea54197232dd36f34b417b7fd787532728bee6ce7f68a2a7e3a08f303b82aa56a0ad3e5b38c91d20411056018799fe3bc9395991ee9b1038046d5260d
7
+ data.tar.gz: 6f5d15ed50126e67e76db0c2adefb5b41c8bd15178d01c76fd97a35ea812f0a86b35110f647a885d888f672f22f61da2f5431297e03c3bcbb0d80d2141bbbc40
@@ -2,9 +2,64 @@
2
2
  <%= javascript_include_tag "application" %>
3
3
 
4
4
  <script>
5
- const color = "<%= BulletTrain::Themes::Light.color %>"
6
- const secondaryColor = "<%= BulletTrain::Themes::Light.secondary_color %>"
5
+ const BulletTrain = {}
7
6
 
8
- if (color) document.documentElement.classList.add(`theme-${color}`)
9
- if (secondaryColor) document.documentElement.classList.add(`theme-secondary-${secondaryColor}`)
7
+ class ___theme {
8
+ start() {
9
+ this.color = "<%= BulletTrain::Themes::Light.color %>"
10
+ this.secondaryColor = "<%= BulletTrain::Themes::Light.secondary_color %>"
11
+ }
12
+
13
+ set color(value) {
14
+ this.removeMatching(/theme-\w+$/)
15
+ if (value) this.classList.add(`theme-${value}`)
16
+ }
17
+
18
+ set secondaryColor(value) {
19
+ this.removeMatching(/theme-secondary-\w+$/)
20
+ if (value) this.classList.add(`theme-secondary-${value}`)
21
+ }
22
+
23
+ removeMatching(matching) {
24
+ const values = Array.from(this.classList.values()).filter((key) => matching.test(key))
25
+ if (values.length) this.classList.remove(...values)
26
+ }
27
+
28
+ get classList() {
29
+ return document.documentElement.classList
30
+ }
31
+ }
32
+
33
+ BulletTrain.theme = new ___theme()
34
+ BulletTrain.theme.start()
35
+
36
+ function placeThemeSelector() {
37
+ const node = document.getElementById("bullet_train_theme_selects").content.cloneNode(true)
38
+ document.querySelector("main").appendChild(node)
39
+ const selectorNode = document.getElementById("bt-theme-selector")
40
+ document.querySelector("main").style.paddingBottom = selectorNode.offsetHeight + "px"
41
+ }
42
+
43
+ document.addEventListener("DOMContentLoaded", placeThemeSelector);
44
+ document.addEventListener("turbo:load", placeThemeSelector);
10
45
  </script>
46
+
47
+ <template id="bullet_train_theme_selects">
48
+ <section class="border-t w-full p-4 flex justify-end left-0 bottom-0 fixed bg-white dark:sc-bg-neutral-900" id="bt-theme-selector">
49
+ <h3 class="pt-2">Bullet Train Light theme options</h3>
50
+
51
+ <div>
52
+ <label for="bullet_train_color" class="pl-4">Color</label>
53
+ <select id="bullet_train_color" class="rounded-lg text-xs" style="background-color: inherit !important;" onchange="BulletTrain.theme.color = this.value">
54
+ <option value=""></option>
55
+ <%= options_for_select BulletTrain::Themes::Light.colors.index_by(&:humanize), BulletTrain::Themes::Light.color %>
56
+ </select>
57
+
58
+ <label for="bullet_train_secondary_color" class="pl-4">Secondary Color</label>
59
+ <select id="bullet_train_secondary_color" class="rounded-lg text-xs" style="background-color: inherit !important;" onchange="BulletTrain.theme.secondaryColor = this.value">
60
+ <option value=""></option>
61
+ <%= options_for_select BulletTrain::Themes::Light.colors.index_by(&:humanize), BulletTrain::Themes::Light.secondary_color %>
62
+ </select>
63
+ </div>
64
+ </section>
65
+ </template>
@@ -15,9 +15,18 @@ options ||= {}
15
15
  options[:id] ||= form.field_id(method)
16
16
  # options[:disabled] ||= !field_editable?(form.object, method) if user_signed_in?
17
17
  options[:placeholder] ||= labels.placeholder if labels.placeholder
18
+
18
19
  other_options ||= {}
19
20
  other_options[:help] = [other_options[:help], labels.help].compact.join(" ")
20
21
 
22
+ if !other_options.key?(:required)
23
+ other_options[:required] = options.fetch(:required) { presence_validated?(form.object, method) }
24
+ end
25
+
26
+ if other_options[:required]
27
+ options[:"aria-required"] = true
28
+ end
29
+
21
30
  errors = [method, method.to_s.gsub(/_id$/, '').to_sym].uniq.map { |attribute| form.object.errors.full_messages_for(attribute) }.flatten
22
31
  has_errors = errors.any? || partial.error? || other_options[:error].present?
23
32
 
@@ -31,7 +40,7 @@ end
31
40
 
32
41
  %>
33
42
 
34
- <div class="<%= 'required' if presence_validated?(form.object, method) %>">
43
+ <div class="<%= 'required' if other_options[:required] %>">
35
44
 
36
45
  <% # the label. %>
37
46
  <% unless other_options[:hide_label] == true %>
@@ -1,7 +1,7 @@
1
1
  module BulletTrain
2
2
  module Themes
3
3
  module Light
4
- VERSION = "1.3.22"
4
+ VERSION = "1.3.23"
5
5
  end
6
6
  end
7
7
  end
@@ -7,6 +7,32 @@ require "bullet_train/themes/light/custom_theme_file_replacer"
7
7
  module BulletTrain
8
8
  module Themes
9
9
  module Light
10
+ # Matches the color list in app/assets/stylesheets/light/tailwind/colors.css
11
+ mattr_accessor :colors, default: %w[
12
+ blue
13
+ slate
14
+ gray
15
+ zinc
16
+ neutral
17
+ stone
18
+ red
19
+ orange
20
+ amber
21
+ yellow
22
+ lime
23
+ green
24
+ emerald
25
+ teal
26
+ cyan
27
+ sky
28
+ indigo
29
+ violet
30
+ purple
31
+ fuchsia
32
+ pink
33
+ rose
34
+ ]
35
+
10
36
  # TODO Not sure this is the right place for this in the long-term.
11
37
  mattr_accessor :color, default: :blue
12
38
  mattr_accessor :secondary_color, default: nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-themes-light
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.22
4
+ version: 1.3.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-01 00:00:00.000000000 Z
11
+ date: 2023-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard