Browse Source

Added caption and subtitle fonts edits

Dmitriy Slipak 4 years ago
parent
commit
79aa4e3673
9 changed files with 334 additions and 13 deletions
  1. 8 2
      client/preview.js
  2. 34 1
      client/theme-editor.js
  3. 5 0
      editor/css/editor.css
  4. 26 5
      editor/theme.html
  5. 9 3
      package-lock.json
  6. 1 0
      package.json
  7. 1 0
      renderer/index.js
  8. 1 1
      renderer/text-wrapper.js
  9. 249 1
      settings/themes.json

+ 8 - 2
client/preview.js View File

105
   });
105
   });
106
 
106
 
107
   if (location.pathname === "/theme") {
107
   if (location.pathname === "/theme") {
108
-    const tf = (theme.noPattern === undefined) ? false : theme.noPattern;
109
-    d3.select("#chkNoPattern").property("checked", tf);
108
+    const noPattern = (theme.noPattern === undefined) ? false : theme.noPattern;
109
+    d3.select("#chkNoPattern").property("checked", noPattern);
110
+    const font = theme.subtitleFont;
111
+    if (font !== undefined) {
112
+      var fontName = font.substring(font.indexOf("'"));
113
+      fontName = fontName.substring(1, fontName.length-1);
114
+      d3.select("#input-font").property("value", fontName);
115
+    }
110
   }
116
   }
111
 
117
 
112
 }
118
 }

+ 34 - 1
client/theme-editor.js View File

1
 var d3 = require("d3"),
1
 var d3 = require("d3"),
2
     $ = require("jquery"),
2
     $ = require("jquery"),
3
-    preview = require("./preview.js");
3
+    preview = require("./preview.js"),
4
+    fonts = [{name: "Neue Haas Grotesk Text Pro"},
5
+      {name: "Source Sans Pro"}],
6
+    AColorPicker = require("a-color-picker");
4
 
7
 
5
 function _initialize() {
8
 function _initialize() {
6
     d3.select("#btn-new-theme").on("click", uploadTheme);
9
     d3.select("#btn-new-theme").on("click", uploadTheme);
8
   	d3.select("#input-new-caption").on("change keyup", updateNewCaption).each(updateNewCaption);
11
   	d3.select("#input-new-caption").on("change keyup", updateNewCaption).each(updateNewCaption);
9
   	d3.select("#btn-delete-theme").on("click", deleteTheme);
12
   	d3.select("#btn-delete-theme").on("click", deleteTheme);
10
     d3.select("#chkNoPattern").on("change", setNoPattern);
13
     d3.select("#chkNoPattern").on("change", setNoPattern);
14
+
15
+    d3.select("#input-font")
16
+    .on("change", updateFont)
17
+    .selectAll("option")
18
+    .data(fonts)
19
+    .enter()
20
+    .append("option")
21
+      .text(function(d){
22
+        return d.name;
23
+      });
24
+
25
+    AColorPicker.from('.picker')
26
+    .on('change', (picker, color) => {
27
+      console.log(color);
28
+    });
11
 }
29
 }
12
 
30
 
13
 function setClass(cl, msg) {
31
 function setClass(cl, msg) {
184
   saveTheme();
202
   saveTheme();
185
 }
203
 }
186
 
204
 
205
+function updateFont() {
206
+  var font = d3.select("#input-font").property("value");
207
+  if (theme.captionFont) {
208
+    theme.captionFont = "300 52px '" + font + "'";
209
+  } else {
210
+    theme['captionFont'] = "300 52px '" + font + "'";
211
+  }
212
+  if (theme.subtitleFont) {
213
+    theme.subtitleFont = "300 44px '" + font + "'";
214
+  } else {
215
+    theme['subtitleFont'] = "300 44px '" + font + "'";
216
+  }
217
+  saveTheme();
218
+}
219
+
187
 module.exports = {
220
 module.exports = {
188
 	initialize: _initialize
221
 	initialize: _initialize
189
 };
222
 };

+ 5 - 0
editor/css/editor.css View File

301
     -webkit-transform: scaleY(1.0);
301
     -webkit-transform: scaleY(1.0);
302
   }
302
   }
303
 }
303
 }
304
+
305
+.picker {
306
+  display: inline-block;
307
+  box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16), 0 0 0 1px rgba(3, 1, 1, 0.08);
308
+}

+ 26 - 5
editor/theme.html View File

68
           </div>
68
           </div>
69
         </div>
69
         </div>
70
 
70
 
71
+        <div class="row form-row" id="row-font">
72
+          <label for="input-font">Font</label>
73
+          <select id="input-font" name="font"></select>
74
+        </div>
75
+
76
+        <div class="row form-row">
77
+          <input type="checkbox" class="form-check-input" id="chkNoPattern">
78
+          <label class="form-check-label" for="chkNoPattern">No pattern</label>
79
+        </div>
80
+
81
+        <div class="row form-row">
82
+          <label for="captionColor">
83
+            Caption color
84
+          </label>
85
+          <div class="picker" acp-color="#EFE9E7" id="captionColor" name="captionColor">
86
+          </div>
87
+        </div>
88
+
89
+        <div class="row form-row">
90
+          <label for="captionColor">
91
+            Subtitle color
92
+          </label>
93
+          <div class="picker" acp-color="#EFE9E7" id="subtitleColor" name="subtitleColor">
94
+          </div>
95
+        </div>
96
+
71
         <div class="row form-row" style="padding: 20px 0 10px 0">
97
         <div class="row form-row" style="padding: 20px 0 10px 0">
72
           <p>
98
           <p>
73
             Please note: Theme assets can be only of png or jpeg file format
99
             Please note: Theme assets can be only of png or jpeg file format
86
           <input id="input-new-caption" name="new-caption" type="text" autocomplete="off" placeholder="Add a new theme name" />
112
           <input id="input-new-caption" name="new-caption" type="text" autocomplete="off" placeholder="Add a new theme name" />
87
         </div>
113
         </div>
88
 
114
 
89
-        <div class="row form-row">
90
-          <input type="checkbox" class="form-check-input" id="chkNoPattern">
91
-          <label class="form-check-label" for="chkNoPattern">No pattern</label>
92
-        </div>
93
-
94
         <div class="row form-row">
115
         <div class="row form-row">
95
           <button type="button" id="btn-new-theme" class="left"><i class="fa fa-arrow-circle-up"></i>Add</button>
116
           <button type="button" id="btn-new-theme" class="left"><i class="fa fa-arrow-circle-up"></i>Add</button>
96
         </div>
117
         </div>

+ 9 - 3
package-lock.json View File

13
         "through": ">=2.2.7 <3"
13
         "through": ">=2.2.7 <3"
14
       }
14
       }
15
     },
15
     },
16
+    "a-color-picker": {
17
+      "version": "1.2.1",
18
+      "resolved": "https://registry.npmjs.org/a-color-picker/-/a-color-picker-1.2.1.tgz",
19
+      "integrity": "sha512-aMCUKd2zTDWK2YWnjz0k3YhFc9XL0jZlPIywF6XkP6i3wdq2iHTEnl1BFPZkOVDV89M12t+zeZ8m23cfzn57/Q==",
20
+      "requires": {
21
+        "is-plain-object": "^2.0.4"
22
+      }
23
+    },
16
     "abbrev": {
24
     "abbrev": {
17
       "version": "1.1.1",
25
       "version": "1.1.1",
18
       "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
26
       "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
3121
       "version": "2.0.4",
3129
       "version": "2.0.4",
3122
       "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
3130
       "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
3123
       "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
3131
       "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
3124
-      "dev": true,
3125
       "requires": {
3132
       "requires": {
3126
         "isobject": "^3.0.1"
3133
         "isobject": "^3.0.1"
3127
       }
3134
       }
3182
     "isobject": {
3189
     "isobject": {
3183
       "version": "3.0.1",
3190
       "version": "3.0.1",
3184
       "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
3191
       "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
3185
-      "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=",
3186
-      "dev": true
3192
+      "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8="
3187
     },
3193
     },
3188
     "isstream": {
3194
     "isstream": {
3189
       "version": "0.1.2",
3195
       "version": "0.1.2",

+ 1 - 0
package.json View File

24
   },
24
   },
25
   "license": "MIT",
25
   "license": "MIT",
26
   "dependencies": {
26
   "dependencies": {
27
+    "a-color-picker": "^1.2.1",
27
     "aws-sdk": "^2.2.39",
28
     "aws-sdk": "^2.2.39",
28
     "browserify": "^13.0.0",
29
     "browserify": "^13.0.0",
29
     "canvas": "^2.6.1",
30
     "canvas": "^2.6.1",

+ 1 - 0
renderer/index.js View File

24
     theme.backgroundColor = theme.backgroundColor || "#fff";
24
     theme.backgroundColor = theme.backgroundColor || "#fff";
25
     theme.waveColor = theme.waveColor || theme.foregroundColor || "#000";
25
     theme.waveColor = theme.waveColor || theme.foregroundColor || "#000";
26
     theme.captionColor = theme.captionColor || theme.foregroundColor || "#000";
26
     theme.captionColor = theme.captionColor || theme.foregroundColor || "#000";
27
+    theme.subtitleColor = theme.subtitleColor || theme.foregroundColor || "#000";
27
 
28
 
28
     // Default wave dimensions
29
     // Default wave dimensions
29
     if (typeof theme.waveTop !== "number") theme.waveTop = 0;
30
     if (typeof theme.waveTop !== "number") theme.waveTop = 0;

+ 1 - 1
renderer/text-wrapper.js View File

65
     y = top;
65
     y = top;
66
   }
66
   }
67
 
67
 
68
-  // context.fillStyle = theme.subtitleColor;
68
+  context.fillStyle = theme.subtitleColor;
69
   lines.forEach(function(line, i){
69
   lines.forEach(function(line, i){
70
     context.fillText(line.join(" "), x, y + i * (theme.subtitleLineHeight + theme.subtitleLineSpacing));
70
     context.fillText(line.join(" "), x, y + i * (theme.subtitleLineHeight + theme.subtitleLineSpacing));
71
   });
71
   });

File diff suppressed because it is too large
+ 249 - 1
settings/themes.json