Просмотр исходного кода

Added caption and subtitle fonts edits

Dmitriy Slipak 4 лет назад
Родитель
Сommit
79aa4e3673
9 измененных файлов с 334 добавлено и 13 удалено
  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 Просмотреть файл

@@ -105,8 +105,14 @@ function redraw() {
105 105
   });
106 106
 
107 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 Просмотреть файл

@@ -1,6 +1,9 @@
1 1
 var d3 = require("d3"),
2 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 8
 function _initialize() {
6 9
     d3.select("#btn-new-theme").on("click", uploadTheme);
@@ -8,6 +11,21 @@ function _initialize() {
8 11
   	d3.select("#input-new-caption").on("change keyup", updateNewCaption).each(updateNewCaption);
9 12
   	d3.select("#btn-delete-theme").on("click", deleteTheme);
10 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 31
 function setClass(cl, msg) {
@@ -184,6 +202,21 @@ function setNoPattern() {
184 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 220
 module.exports = {
188 221
 	initialize: _initialize
189 222
 };

+ 5 - 0
editor/css/editor.css Просмотреть файл

@@ -301,3 +301,8 @@ g.time line {
301 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 Просмотреть файл

@@ -68,6 +68,32 @@
68 68
           </div>
69 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 97
         <div class="row form-row" style="padding: 20px 0 10px 0">
72 98
           <p>
73 99
             Please note: Theme assets can be only of png or jpeg file format
@@ -86,11 +112,6 @@
86 112
           <input id="input-new-caption" name="new-caption" type="text" autocomplete="off" placeholder="Add a new theme name" />
87 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 115
         <div class="row form-row">
95 116
           <button type="button" id="btn-new-theme" class="left"><i class="fa fa-arrow-circle-up"></i>Add</button>
96 117
         </div>

+ 9 - 3
package-lock.json Просмотреть файл

@@ -13,6 +13,14 @@
13 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 24
     "abbrev": {
17 25
       "version": "1.1.1",
18 26
       "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@@ -3121,7 +3129,6 @@
3121 3129
       "version": "2.0.4",
3122 3130
       "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
3123 3131
       "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
3124
-      "dev": true,
3125 3132
       "requires": {
3126 3133
         "isobject": "^3.0.1"
3127 3134
       }
@@ -3182,8 +3189,7 @@
3182 3189
     "isobject": {
3183 3190
       "version": "3.0.1",
3184 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 3194
     "isstream": {
3189 3195
       "version": "0.1.2",

+ 1 - 0
package.json Просмотреть файл

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

+ 1 - 0
renderer/index.js Просмотреть файл

@@ -24,6 +24,7 @@ module.exports = function(t) {
24 24
     theme.backgroundColor = theme.backgroundColor || "#fff";
25 25
     theme.waveColor = theme.waveColor || theme.foregroundColor || "#000";
26 26
     theme.captionColor = theme.captionColor || theme.foregroundColor || "#000";
27
+    theme.subtitleColor = theme.subtitleColor || theme.foregroundColor || "#000";
27 28
 
28 29
     // Default wave dimensions
29 30
     if (typeof theme.waveTop !== "number") theme.waveTop = 0;

+ 1 - 1
renderer/text-wrapper.js Просмотреть файл

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

Разница между файлами не показана из-за своего большого размера
+ 249 - 1
settings/themes.json