outro_rails 0.1.9 → 0.1.10

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: be553169a45e21824a1d92e6287d3777e7bf78839cce188fe86d708d40496f26
4
- data.tar.gz: 186d0ebf8b817cc88fde9561873e9949ed8f200658c0265f25162cfec56e9471
3
+ metadata.gz: faefc647f0e0140abbf35ca6c154c680f4b9288521391aed584eae48cb2657fe
4
+ data.tar.gz: 6801a967992044421351c38b537c66645a496c2f362034bcc36dd4778e9999c1
5
5
  SHA512:
6
- metadata.gz: 9c6dc62087ae7a8a0c7e393ef4ad6767a846205e3fd87a797b6e7c9c6546f0da1c4be21056e48b3a797cb82352f51b057a729a3f828f15b4eb02b3d3ac68adad
7
- data.tar.gz: 0dce5f67e95e032c29638e1da8799b626482f37efebb60ff7ec1daf678992732b54c42fbe34a1b30dd86a0e5ce17633e61b24b9d8a0d4b311bf6e83f97e94a35
6
+ metadata.gz: 6ad7f179486fce333d763331c5a6b8bb2123aba871554255a93da7ffacd667cc8783fdec510121859028ca298bccdd0059a9b61a33c7e3e0a09eff9d46e2fc08
7
+ data.tar.gz: 75ab968c2ecdfcb471e26bbdbead2a2ca59180576106abecc8d0545e2c0d16432474683c68e31f1f2473ce7e6ab8a7434d776573c6b96ff7fb70ffe2d2ed5c30
@@ -132,7 +132,7 @@
132
132
  <% next unless fret.positive? && fret >= row_start %>
133
133
  <% root = roots.include?([string, fret]) %>
134
134
  <circle cx="<%= col_x.call(string) %>" cy="<%= row_y.call(fret) %>"
135
- r="4.4" fill="<%= root ? root_color : highlight_color %>" />
135
+ r="4.4" style="fill: <%= root ? root_color : highlight_color %>" />
136
136
  <% end %>
137
137
 
138
138
  <%# sounded note names under the box %>
@@ -10,12 +10,14 @@
10
10
  1 (highest pitch) to 6 (lowest). Accepts [string, fret]
11
11
  pairs or "string:fret" strings, e.g.
12
12
  [[5, 3], [4, 2], [3, 0], [2, 1], [1, 0]] (open C major)
13
- highlight_color: any CSS color for the dots (default blue)
13
+ highlight_color: any CSS color for the dots. Omit to inherit
14
+ --outro-accent from the host app (see note below).
14
15
  root_frets: subset of positions to mark as roots with a distinct
15
16
  color, same formats as highlight_frets (default []).
16
17
  Root positions should also be included in
17
18
  highlight_frets so playback covers them.
18
- root_color: any CSS color for root dots (default red)
19
+ root_color: any CSS color for root dots. Omit to inherit
20
+ --outro-root from the host app.
19
21
 
20
22
  When highlight_frets is present, "Play Chord" strums all marked notes
21
23
  (lowest first, slightly staggered like a downstroke) and "Play Notes"
@@ -29,13 +31,18 @@
29
31
  default_tuning = OutroRails::InstrumentsHelper::GUITAR_STANDARD_TUNING
30
32
  tuning = local_assigns.fetch(:tuning, default_tuning)
31
33
  highlight_frets = guitar_positions(local_assigns.fetch(:highlight_frets, []))
32
- highlight_color = local_assigns.fetch(:highlight_color,
33
- "var(--outro-accent, #2f6bed)")
34
34
  root_frets = guitar_positions(local_assigns.fetch(:root_frets, []))
35
- root_color = local_assigns.fetch(:root_color,
36
- "var(--outro-root, #d1495b)")
37
35
  prefer = local_assigns.fetch(:prefer, 'sharps')
38
36
 
37
+ # Only emit inline custom properties for colors the caller actually
38
+ # passed; the stylesheet owns the defaults.
39
+ highlight_color = local_assigns[:highlight_color].presence
40
+ root_color = local_assigns[:root_color].presence
41
+ color_vars = [
42
+ ("--outro-guitar-highlight: #{highlight_color};" if highlight_color),
43
+ ("--outro-guitar-root: #{root_color};" if root_color)
44
+ ].compact.join(" ").presence
45
+
39
46
  start_fret, end_fret = end_fret, start_fret if start_fret > end_fret
40
47
  guitar = OutroRails::Instruments::Guitar
41
48
  fret_range = guitar::MIN_FRET..guitar::MAX_FRET
@@ -62,8 +69,7 @@
62
69
 
63
70
  <div class="outro-guitar"
64
71
  data-outro-guitar
65
- style="--outro-guitar-highlight: <%= highlight_color %>;
66
- --outro-guitar-root: <%= root_color %>;">
72
+ <%= tag.attributes(style: color_vars) %>>
67
73
  <div>
68
74
  <div class="outro-guitar__board"
69
75
  role="group"
@@ -48,8 +48,6 @@
48
48
  end
49
49
  end
50
50
 
51
- width = [white_index, 1].max * white_w
52
-
53
51
  fill_for = lambda do |key|
54
52
  if root_midis.include?(key[:midi]) then root_color
55
53
  elsif highlighted_midis.include?(key[:midi]) then highlight_color
@@ -79,13 +77,13 @@
79
77
  <% whites.each do |key| %>
80
78
  <rect x="<%= key[:x] %>" y="0"
81
79
  width="<%= white_w %>" height="<%= white_h %>"
82
- rx="1.5" fill="<%= fill_for.call(key) %>"
80
+ rx="1.5" style="fill: <%= fill_for.call(key) %>"
83
81
  stroke="#444444" stroke-width="<%= stroke_w %>" />
84
82
  <% end %>
85
83
  <% blacks.each do |key| %>
86
84
  <rect x="<%= key[:x] %>" y="0"
87
85
  width="<%= black_w %>" height="<%= black_h %>"
88
- rx="1.5" fill="<%= fill_for.call(key) %>"
86
+ rx="1.5" style="fill: <%= fill_for.call(key) %>"
89
87
  stroke="#111111" stroke-width="<%= stroke_w %>" />
90
88
  <% end %>
91
89
  </svg>
@@ -6,11 +6,13 @@
6
6
  end_note: last key, e.g. "C5" (default "C5")
7
7
  highlight_keys: array of note names to highlight,
8
8
  e.g. %w[C4 E4 G4] (default [])
9
- highlight_color: any CSS color for highlighted keys (default blue)
9
+ highlight_color: any CSS color for highlighted keys. Omit to inherit
10
+ --outro-accent from the host app (see note below).
10
11
  root_keys: subset of keys to mark as roots with a distinct color,
11
12
  e.g. %w[C4 C5] (default []). Root keys should also be
12
13
  included in highlight_keys so playback covers them.
13
- root_color: any CSS color for root keys (default red)
14
+ root_color: any CSS color for root keys. Omit to inherit
15
+ --outro-root from the host app.
14
16
 
15
17
  When highlight_keys is present, "Play Chord" plays all highlighted notes
16
18
  at once and "Play Notes" plays them one at a time (low to high).
@@ -21,13 +23,18 @@
21
23
  start_note = local_assigns.fetch(:start_note, "C3")
22
24
  end_note = local_assigns.fetch(:end_note, "C5")
23
25
  highlight_keys = Array(local_assigns.fetch(:highlight_keys, []))
24
- highlight_color = local_assigns.fetch(:highlight_color,
25
- "var(--outro-accent, #2f6bed)")
26
26
  root_keys = Array(local_assigns.fetch(:root_keys, []))
27
- root_color = local_assigns.fetch(:root_color,
28
- "var(--outro-root, #d1495b)")
29
27
  prefer = local_assigns.fetch(:prefer, 'sharps').to_sym
30
28
 
29
+ # Only emit inline custom properties for colors the caller actually
30
+ # passed; the stylesheet owns the defaults.
31
+ highlight_color = local_assigns[:highlight_color].presence
32
+ root_color = local_assigns[:root_color].presence
33
+ color_vars = [
34
+ ("--outro-piano-highlight: #{highlight_color};" if highlight_color),
35
+ ("--outro-piano-root: #{root_color};" if root_color)
36
+ ].compact.join(" ").presence
37
+
31
38
  keys = piano_keys_between(start_note, end_note, prefer: prefer)
32
39
  highlighted_midis = highlight_keys.map { |n| note_to_midi(n) }
33
40
  root_midis = root_keys.map { |n| note_to_midi(n) }
@@ -37,8 +44,7 @@
37
44
 
38
45
  <div class="outro-piano"
39
46
  data-outro-piano
40
- style="--outro-piano-highlight: <%= highlight_color %>;
41
- --outro-piano-root: <%= root_color %>;">
47
+ <%= tag.attributes(style: color_vars) %>>
42
48
  <div class="outro-piano__keys" role="group"
43
49
  aria-label="<%= keys_label %>">
44
50
  <% keys.each do |key| %>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OutroRails
4
- VERSION = "0.1.9"
4
+ VERSION = "0.1.10"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: outro_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - endtoendpaper