bullet_train-themes-light 1.3.22 → 1.3.24
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5928cebefcf72bf371bd19fd488587dcd20cbe6ca21f5f207f3530ab96a142c2
|
4
|
+
data.tar.gz: de69366834b591529df60bc6499c2c3b3fd730684d32df30cdc27748da649688
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4189c039fc15e7f694d4154330164c631217a17df44a6d07b31651119481677d9517bebeaaf1bbfd9aa661068fa53cd006b5e781297e8547803ce1dd7b3bfe11
|
7
|
+
data.tar.gz: 1a07949f68f306ff7a992bbd4de05d619e2df95de63cf2bacbedc4dc8be0e7ea8feeff778b5d715acf8d84d8499f19f5211e84ef394a911be2edbdc0dde4143f
|
@@ -2,9 +2,64 @@
|
|
2
2
|
<%= javascript_include_tag "application" %>
|
3
3
|
|
4
4
|
<script>
|
5
|
-
const
|
6
|
-
const secondaryColor = "<%= BulletTrain::Themes::Light.secondary_color %>"
|
5
|
+
const BulletTrain = {}
|
7
6
|
|
8
|
-
|
9
|
-
|
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
|
43
|
+
<div class="<%= 'required' if other_options[:required] %>">
|
35
44
|
|
36
45
|
<% # the label. %>
|
37
46
|
<% unless other_options[:hide_label] == true %>
|
@@ -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
|
data/lib/tasks/application.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "masamune"
|
2
|
+
|
1
3
|
module BulletTrain
|
2
4
|
module Themes
|
3
5
|
module Application
|
@@ -148,33 +150,16 @@ module BulletTrain
|
|
148
150
|
end
|
149
151
|
|
150
152
|
def self.install_theme(theme_name)
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
"./Procfile.dev",
|
162
|
-
"./package.json"
|
163
|
-
].each do |file|
|
164
|
-
File.open(file, "r") do |f|
|
165
|
-
new_lines = f.readlines
|
166
|
-
new_lines = new_lines.map do |line|
|
167
|
-
# Make sure we get the current theme before trying to replace it in any of the files.
|
168
|
-
# We grab it from the first file in the array above.
|
169
|
-
current_theme = line.scan(current_theme_regexp).flatten.last if line.match?(current_theme_regexp)
|
170
|
-
|
171
|
-
line.gsub!(/#{current_theme}/, theme_name) unless current_theme.nil?
|
172
|
-
line
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
File.open(file, "w") do |f|
|
177
|
-
f.puts new_lines.join
|
153
|
+
helper = Pathname.new("./app/helpers/application_helper.rb")
|
154
|
+
msmn = Masamune::AbstractSyntaxTree.new(helper.readlines.join)
|
155
|
+
current_theme_def = msmn.method_definitions(name: "current_theme").pop
|
156
|
+
current_theme = msmn.symbols.find { |node| node[:line_number] > current_theme_def[:line_number] }[:token]
|
157
|
+
helper.write msmn.replace(type: :symbol, old_token: current_theme, new_token: theme_name)
|
158
|
+
|
159
|
+
[Pathname.new("./Procfile.dev"), Pathname.new("./package.json")].each do |file|
|
160
|
+
changed = file.read.gsub! current_theme, theme_name
|
161
|
+
if changed
|
162
|
+
file.write changed
|
178
163
|
end
|
179
164
|
end
|
180
165
|
end
|
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.
|
4
|
+
version: 1.3.24
|
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-
|
11
|
+
date: 2023-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|