@taole/dev-helper 0.1.5 → 0.1.7

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.
package/Tdiv/index.js CHANGED
@@ -58,7 +58,7 @@ class Tdiv extends HTMLElement {
58
58
  '_class', 'usePx', '_style', 'src', 'width', 'height', 'absolute', 'fixed',
59
59
  'top', 'left', 'right', 'bottom', 'zIndex', 'pointer', 'flex', 'column', 'center',
60
60
  'text', 'color', 'radius', 'border', 'borderColor', 'srcMode', 'onClick', 'debug', 'viewportWidth', 'viewportUnit',
61
- 'dot9', 'dot9Border', 'bold'
61
+ 'dot9', 'dot9Border', 'bold', 'textEllipsis'
62
62
  ];
63
63
  }
64
64
 
@@ -228,19 +228,24 @@ class Tdiv extends HTMLElement {
228
228
  }
229
229
  if (src) {
230
230
  let realSrc = src;
231
- if (src.indexOf('https://') === -1) {
232
- realSrc = `https://dynamics-share.tuwan.com/${src}`;
233
- if (isSupportWebp) {
234
- realSrc = `https://dynamics-share.tuwan.com/${src}?x-oss-process=image/format,webp/ignore-error,1`;
231
+ if(src.indexOf('--') == 0){
232
+ realSrc = `var(${src})`;
233
+ } else {
234
+ if (src.indexOf('https://') === -1 && src.indexOf('http://') === -1) {
235
+ realSrc = `https://dynamics-share.tuwan.com/${src}`;
236
+ if (isSupportWebp) {
237
+ realSrc = `https://dynamics-share.tuwan.com/${src}?x-oss-process=image/format,webp/ignore-error,1`;
238
+ }
235
239
  }
240
+ realSrc = `url(${realSrc})`;
236
241
  }
237
242
  if (useDot9) {
238
- layoutStyle += `border-image: url(${realSrc}) ${dot9.join(" ")} fill;`;
243
+ layoutStyle += `border-image: ${realSrc} ${dot9.join(" ")} fill;`;
239
244
  layoutStyle += `border-width: ${dot9Border.join(" ")};`;
240
245
  layoutStyle += `border-style: solid;`;
241
246
  layoutStyle += `box-sizing: border-box;`;
242
247
  } else {
243
- layoutStyle += `background-image: url(${realSrc});`;
248
+ layoutStyle += `background-image: ${realSrc};`;
244
249
  if (srcMode === 'fill') {
245
250
  layoutStyle += 'background-size: 100% 100%;';
246
251
  } else if (srcMode === 'cover') {
@@ -248,7 +253,13 @@ class Tdiv extends HTMLElement {
248
253
  }
249
254
  }
250
255
  }
251
- if (color) layoutStyle += `color: ${color};`;
256
+ if (color) {
257
+ if(color.indexOf('--') == 0){
258
+ layoutStyle += `color: var(${color});`;
259
+ } else {
260
+ layoutStyle += `color: ${color};`;
261
+ }
262
+ }
252
263
  if (styleAttr) layoutStyle += styleAttr;
253
264
  if (debug) {
254
265
  console.log('layoutStyle', layoutStyle);
@@ -273,16 +284,14 @@ class Tdiv extends HTMLElement {
273
284
 
274
285
 
275
286
 
276
- let isRegister = false;
277
287
  function registerTdiv() {
278
- if (!isRegister) {
279
- customElements.define('t-div', Tdiv);
280
- // append style for t-div
281
- const style = document.createElement('style');
282
- style.textContent = styleText;
283
- document.head.appendChild(style);
284
- isRegister = true;
288
+ if (customElements.get('t-div')) {
289
+ return;
285
290
  }
291
+ customElements.define('t-div', Tdiv);
292
+ const style = document.createElement('style');
293
+ style.textContent = styleText;
294
+ document.head.appendChild(style);
286
295
  }
287
296
 
288
297
  registerTdiv();
package/dist/tdiv.umd.js CHANGED
@@ -142,7 +142,7 @@
142
142
  '_class', 'usePx', '_style', 'src', 'width', 'height', 'absolute', 'fixed',
143
143
  'top', 'left', 'right', 'bottom', 'zIndex', 'pointer', 'flex', 'column', 'center',
144
144
  'text', 'color', 'radius', 'border', 'borderColor', 'srcMode', 'onClick', 'debug', 'viewportWidth', 'viewportUnit',
145
- 'dot9', 'dot9Border', 'bold'
145
+ 'dot9', 'dot9Border', 'bold', 'textEllipsis'
146
146
  ];
147
147
  }
148
148
 
@@ -312,19 +312,24 @@
312
312
  }
313
313
  if (src) {
314
314
  let realSrc = src;
315
- if (src.indexOf('https://') === -1) {
316
- realSrc = `https://dynamics-share.tuwan.com/${src}`;
317
- if (isSupportWebp) {
318
- realSrc = `https://dynamics-share.tuwan.com/${src}?x-oss-process=image/format,webp/ignore-error,1`;
315
+ if(src.indexOf('--') == 0){
316
+ realSrc = `var(${src})`;
317
+ } else {
318
+ if (src.indexOf('https://') === -1 && src.indexOf('http://') === -1) {
319
+ realSrc = `https://dynamics-share.tuwan.com/${src}`;
320
+ if (isSupportWebp) {
321
+ realSrc = `https://dynamics-share.tuwan.com/${src}?x-oss-process=image/format,webp/ignore-error,1`;
322
+ }
319
323
  }
324
+ realSrc = `url(${realSrc})`;
320
325
  }
321
326
  if (useDot9) {
322
- layoutStyle += `border-image: url(${realSrc}) ${dot9.join(" ")} fill;`;
327
+ layoutStyle += `border-image: ${realSrc} ${dot9.join(" ")} fill;`;
323
328
  layoutStyle += `border-width: ${dot9Border.join(" ")};`;
324
329
  layoutStyle += `border-style: solid;`;
325
330
  layoutStyle += `box-sizing: border-box;`;
326
331
  } else {
327
- layoutStyle += `background-image: url(${realSrc});`;
332
+ layoutStyle += `background-image: ${realSrc};`;
328
333
  if (srcMode === 'fill') {
329
334
  layoutStyle += 'background-size: 100% 100%;';
330
335
  } else if (srcMode === 'cover') {
@@ -332,7 +337,13 @@
332
337
  }
333
338
  }
334
339
  }
335
- if (color) layoutStyle += `color: ${color};`;
340
+ if (color) {
341
+ if(color.indexOf('--') == 0){
342
+ layoutStyle += `color: var(${color});`;
343
+ } else {
344
+ layoutStyle += `color: ${color};`;
345
+ }
346
+ }
336
347
  if (styleAttr) layoutStyle += styleAttr;
337
348
  if (debug) {
338
349
  console.log('layoutStyle', layoutStyle);
@@ -357,16 +368,14 @@
357
368
 
358
369
 
359
370
 
360
- let isRegister = false;
361
371
  function registerTdiv() {
362
- if (!isRegister) {
363
- customElements.define('t-div', Tdiv);
364
- // append style for t-div
365
- const style = document.createElement('style');
366
- style.textContent = styleText;
367
- document.head.appendChild(style);
368
- isRegister = true;
372
+ if (customElements.get('t-div')) {
373
+ return;
369
374
  }
375
+ customElements.define('t-div', Tdiv);
376
+ const style = document.createElement('style');
377
+ style.textContent = styleText;
378
+ document.head.appendChild(style);
370
379
  }
371
380
 
372
381
  registerTdiv();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taole/dev-helper",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "npx -y rimraf dist && rollup -c",