zen-wdg 2.0.0 → 2.0.2
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/dist/zen-wdg.css +1 -0
- package/dist/zen-wdg.es.js +68 -82
- package/dist/zen-wdg.umd.js +1 -1
- package/index.js +1 -1
- package/package.json +5 -3
- package/src/register.js +13 -0
- package/src/widgets/z-clock-widget.vue +108 -0
- package/src/clock.js +0 -102
package/dist/zen-wdg.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.clock-container[data-v-dc4ab000]{display:flex;justify-content:center;align-items:center;height:100%;width:100%}.clock[data-v-dc4ab000]{text-align:center;font-family:Arial,sans-serif;color:#333;background-color:#14141466;backdrop-filter:blur(.2rem);border-radius:15px;padding:20px;width:100%}.time[data-v-dc4ab000]{font-size:4em;font-weight:700;color:#fff;display:flex;justify-content:center}.date[data-v-dc4ab000]{font-size:1.2em;color:#fff;margin-top:10px}@media (max-width: 500px){.time[data-v-dc4ab000]{font-size:3em}.date[data-v-dc4ab000]{font-size:1em}}
|
package/dist/zen-wdg.es.js
CHANGED
|
@@ -1,67 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
color: #fff;
|
|
29
|
-
display: flex;
|
|
30
|
-
justify-content: center;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.date {
|
|
34
|
-
font-size: 1.2em;
|
|
35
|
-
color: #fff;
|
|
36
|
-
margin-top: 10px;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@media (max-width: 500px) {
|
|
40
|
-
.time {
|
|
41
|
-
font-size: 3em;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.date {
|
|
45
|
-
font-size: 1em;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
`;
|
|
49
|
-
const wrapper = document.createElement("div");
|
|
50
|
-
wrapper.innerHTML = `
|
|
51
|
-
<div class="clock-container">
|
|
52
|
-
<div class="clock">
|
|
53
|
-
<div class="time" id="clock-time">--:--</div>
|
|
54
|
-
<div class="date" id="clock-date">--</div>
|
|
55
|
-
</div>
|
|
56
|
-
</div>
|
|
57
|
-
`;
|
|
58
|
-
shadow.appendChild(style);
|
|
59
|
-
shadow.appendChild(wrapper);
|
|
60
|
-
const updateClock = () => {
|
|
1
|
+
import { createElementBlock, openBlock, createElementVNode, createTextVNode, toDisplayString, defineCustomElement } from "vue";
|
|
2
|
+
const _export_sfc = (sfc, props) => {
|
|
3
|
+
const target = sfc.__vccOpts || sfc;
|
|
4
|
+
for (const [key, val] of props) {
|
|
5
|
+
target[key] = val;
|
|
6
|
+
}
|
|
7
|
+
return target;
|
|
8
|
+
};
|
|
9
|
+
const _sfc_main = {
|
|
10
|
+
name: "DigitalClock",
|
|
11
|
+
data() {
|
|
12
|
+
return {
|
|
13
|
+
hours: "00",
|
|
14
|
+
minutes: "00",
|
|
15
|
+
seconds: "00",
|
|
16
|
+
dayOfWeek: "",
|
|
17
|
+
day: "",
|
|
18
|
+
month: "",
|
|
19
|
+
year: ""
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
mounted() {
|
|
23
|
+
this.updateClock();
|
|
24
|
+
setInterval(this.updateClock, 1e3);
|
|
25
|
+
},
|
|
26
|
+
methods: {
|
|
27
|
+
updateClock() {
|
|
61
28
|
const now = /* @__PURE__ */ new Date();
|
|
62
|
-
|
|
63
|
-
|
|
29
|
+
this.hours = now.getHours().toString().padStart(2, "0");
|
|
30
|
+
this.minutes = now.getMinutes().toString().padStart(2, "0");
|
|
31
|
+
this.seconds = now.getSeconds().toString().padStart(2, "0");
|
|
32
|
+
this.dayOfWeek = this.getDayOfWeek(now.getDay());
|
|
33
|
+
this.day = now.getDate();
|
|
34
|
+
this.month = this.getMonthName(now.getMonth());
|
|
35
|
+
this.year = now.getFullYear();
|
|
36
|
+
},
|
|
37
|
+
getDayOfWeek(dayIndex) {
|
|
64
38
|
const days = ["Domingo", "Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado"];
|
|
39
|
+
return days[dayIndex];
|
|
40
|
+
},
|
|
41
|
+
getMonthName(monthIndex) {
|
|
65
42
|
const months = [
|
|
66
43
|
"Enero",
|
|
67
44
|
"Febrero",
|
|
@@ -76,25 +53,34 @@ class ClockWidget extends HTMLElement {
|
|
|
76
53
|
"Noviembre",
|
|
77
54
|
"Diciembre"
|
|
78
55
|
];
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const month = months[now.getMonth()];
|
|
82
|
-
const year = now.getFullYear();
|
|
83
|
-
const timeEl = shadow.getElementById("clock-time");
|
|
84
|
-
const dateEl = shadow.getElementById("clock-date");
|
|
85
|
-
if (timeEl && dateEl) {
|
|
86
|
-
timeEl.textContent = `${hours}:${minutes}`;
|
|
87
|
-
dateEl.textContent = `${dayOfWeek}, ${day} ${month} ${year}`;
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
updateClock();
|
|
91
|
-
this._interval = setInterval(updateClock, 1e3);
|
|
56
|
+
return months[monthIndex];
|
|
57
|
+
}
|
|
92
58
|
}
|
|
93
|
-
disconnectedCallback() {
|
|
94
|
-
clearInterval(this._interval);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
customElements.define("clock-widget", ClockWidget);
|
|
98
|
-
export {
|
|
99
|
-
ClockWidget
|
|
100
59
|
};
|
|
60
|
+
const _hoisted_1 = { class: "clock-container" };
|
|
61
|
+
const _hoisted_2 = { class: "clock" };
|
|
62
|
+
const _hoisted_3 = { class: "time" };
|
|
63
|
+
const _hoisted_4 = { class: "date" };
|
|
64
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
65
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
66
|
+
createElementVNode("div", _hoisted_2, [
|
|
67
|
+
createElementVNode("div", _hoisted_3, [
|
|
68
|
+
createElementVNode("span", null, toDisplayString($data.hours), 1),
|
|
69
|
+
_cache[0] || (_cache[0] = createTextVNode(":", -1)),
|
|
70
|
+
createElementVNode("span", null, toDisplayString($data.minutes), 1)
|
|
71
|
+
]),
|
|
72
|
+
createElementVNode("div", _hoisted_4, [
|
|
73
|
+
createElementVNode("span", null, toDisplayString($data.dayOfWeek) + ", " + toDisplayString($data.day) + " " + toDisplayString($data.month) + " " + toDisplayString($data.year), 1)
|
|
74
|
+
])
|
|
75
|
+
])
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
const ClockWidget = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-dc4ab000"]]);
|
|
79
|
+
const widgets = [
|
|
80
|
+
{ name: "z-clock-widget", component: defineCustomElement(ClockWidget) }
|
|
81
|
+
];
|
|
82
|
+
widgets.forEach(({ name, component }) => {
|
|
83
|
+
if (!customElements.get(name)) {
|
|
84
|
+
customElements.define(name, component);
|
|
85
|
+
}
|
|
86
|
+
});
|
package/dist/zen-wdg.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(require("vue")):"function"==typeof define&&define.amd?define(["vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Vue)}(this,function(e){"use strict";const t={class:"clock-container"},o={class:"clock"},n={class:"time"},s={class:"date"};const a=((e,t)=>{const o=e.__vccOpts||e;for(const[n,s]of t)o[n]=s;return o})({name:"DigitalClock",data:()=>({hours:"00",minutes:"00",seconds:"00",dayOfWeek:"",day:"",month:"",year:""}),mounted(){this.updateClock(),setInterval(this.updateClock,1e3)},methods:{updateClock(){const e=new Date;this.hours=e.getHours().toString().padStart(2,"0"),this.minutes=e.getMinutes().toString().padStart(2,"0"),this.seconds=e.getSeconds().toString().padStart(2,"0"),this.dayOfWeek=this.getDayOfWeek(e.getDay()),this.day=e.getDate(),this.month=this.getMonthName(e.getMonth()),this.year=e.getFullYear()},getDayOfWeek:e=>["Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado"][e],getMonthName:e=>["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"][e]}},[["render",function(a,i,r,c,l,d){return e.openBlock(),e.createElementBlock("div",t,[e.createElementVNode("div",o,[e.createElementVNode("div",n,[e.createElementVNode("span",null,e.toDisplayString(l.hours),1),i[0]||(i[0]=e.createTextVNode(":",-1)),e.createElementVNode("span",null,e.toDisplayString(l.minutes),1)]),e.createElementVNode("div",s,[e.createElementVNode("span",null,e.toDisplayString(l.dayOfWeek)+", "+e.toDisplayString(l.day)+" "+e.toDisplayString(l.month)+" "+e.toDisplayString(l.year),1)])])])}],["__scopeId","data-v-dc4ab000"]]);[{name:"z-clock-widget",component:e.defineCustomElement(a)}].forEach(({name:e,component:t})=>{customElements.get(e)||customElements.define(e,t)})});
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import './src/register.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zen-wdg",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Minimal widget library for Gridstack-based newtab extensions",
|
|
5
5
|
"main": "dist/zen-wdg.umd.js",
|
|
6
6
|
"module": "dist/zen-wdg.es.js",
|
|
@@ -12,13 +12,15 @@
|
|
|
12
12
|
"author": "Im-Jota",
|
|
13
13
|
"license": "AGPL-3.0",
|
|
14
14
|
"devDependencies": {
|
|
15
|
+
"@vitejs/plugin-vue": "^5.2.4",
|
|
15
16
|
"terser": "^5.43.1",
|
|
16
|
-
"vite": "^
|
|
17
|
+
"vite": "^7.0.5"
|
|
17
18
|
},
|
|
18
19
|
"files": [
|
|
19
20
|
"dist/",
|
|
20
21
|
"index.js",
|
|
21
|
-
"src/
|
|
22
|
+
"src/widgets/",
|
|
23
|
+
"src/register.js",
|
|
22
24
|
"AUTHORS.md"
|
|
23
25
|
]
|
|
24
26
|
}
|
package/src/register.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/register.js
|
|
2
|
+
import { defineCustomElement } from 'vue'
|
|
3
|
+
import ClockWidget from './widgets/z-clock-widget.vue'
|
|
4
|
+
|
|
5
|
+
const widgets = [
|
|
6
|
+
{ name: 'z-clock-widget', component: defineCustomElement(ClockWidget) },
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
widgets.forEach(({ name, component }) => {
|
|
10
|
+
if (!customElements.get(name)) {
|
|
11
|
+
customElements.define(name, component)
|
|
12
|
+
}
|
|
13
|
+
})
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="clock-container">
|
|
3
|
+
<div class="clock">
|
|
4
|
+
<!-- Reloj digital -->
|
|
5
|
+
<div class="time">
|
|
6
|
+
<span>{{ hours }}</span>:<span>{{ minutes }}</span><!--:<span>{{ seconds }}</span>-->
|
|
7
|
+
</div>
|
|
8
|
+
<!-- Fecha -->
|
|
9
|
+
<div class="date">
|
|
10
|
+
<span>{{ dayOfWeek }}, {{ day }} {{ month }} {{ year }}</span>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script>
|
|
17
|
+
export default {
|
|
18
|
+
name: 'DigitalClock',
|
|
19
|
+
data() {
|
|
20
|
+
return {
|
|
21
|
+
hours: '00',
|
|
22
|
+
minutes: '00',
|
|
23
|
+
seconds: '00',
|
|
24
|
+
dayOfWeek: '',
|
|
25
|
+
day: '',
|
|
26
|
+
month: '',
|
|
27
|
+
year: '',
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
mounted() {
|
|
31
|
+
this.updateClock();
|
|
32
|
+
setInterval(this.updateClock, 1000); // Actualizar la hora cada segundo
|
|
33
|
+
},
|
|
34
|
+
methods: {
|
|
35
|
+
updateClock() {
|
|
36
|
+
const now = new Date();
|
|
37
|
+
|
|
38
|
+
// Formatear la hora
|
|
39
|
+
this.hours = now.getHours().toString().padStart(2, '0');
|
|
40
|
+
this.minutes = now.getMinutes().toString().padStart(2, '0');
|
|
41
|
+
this.seconds = now.getSeconds().toString().padStart(2, '0');
|
|
42
|
+
|
|
43
|
+
// Formatear la fecha
|
|
44
|
+
this.dayOfWeek = this.getDayOfWeek(now.getDay());
|
|
45
|
+
this.day = now.getDate();
|
|
46
|
+
this.month = this.getMonthName(now.getMonth());
|
|
47
|
+
this.year = now.getFullYear();
|
|
48
|
+
},
|
|
49
|
+
getDayOfWeek(dayIndex) {
|
|
50
|
+
const days = ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'];
|
|
51
|
+
return days[dayIndex];
|
|
52
|
+
},
|
|
53
|
+
getMonthName(monthIndex) {
|
|
54
|
+
const months = [
|
|
55
|
+
'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio',
|
|
56
|
+
'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'
|
|
57
|
+
];
|
|
58
|
+
return months[monthIndex];
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<style scoped>
|
|
65
|
+
.clock-container {
|
|
66
|
+
display: flex;
|
|
67
|
+
justify-content: center;
|
|
68
|
+
align-items: center;
|
|
69
|
+
height: 100%; /* Centra el reloj verticalmente */
|
|
70
|
+
width: 100%;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.clock {
|
|
74
|
+
text-align: center;
|
|
75
|
+
font-family: 'Arial', sans-serif;
|
|
76
|
+
color: #333;
|
|
77
|
+
background-color: rgba(20, 20, 20, .4);
|
|
78
|
+
backdrop-filter: blur(.2rem);
|
|
79
|
+
border-radius: 15px;
|
|
80
|
+
padding: 20px;
|
|
81
|
+
width: 100%;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.time {
|
|
85
|
+
font-size: 4em;
|
|
86
|
+
font-weight: bold;
|
|
87
|
+
color: #fff;
|
|
88
|
+
display: flex;
|
|
89
|
+
justify-content: center;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.date {
|
|
93
|
+
font-size: 1.2em;
|
|
94
|
+
color: #fff;
|
|
95
|
+
margin-top: 10px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@media (max-width: 500px) {
|
|
99
|
+
.time {
|
|
100
|
+
font-size: 3em;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.date {
|
|
104
|
+
font-size: 1em;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
</style>
|
|
108
|
+
|
package/src/clock.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
export class ClockWidget extends HTMLElement {
|
|
2
|
-
connectedCallback() {
|
|
3
|
-
const shadow = this.attachShadow({ mode: 'open' })
|
|
4
|
-
|
|
5
|
-
// Estilos
|
|
6
|
-
const style = document.createElement('style')
|
|
7
|
-
style.textContent = `
|
|
8
|
-
.clock-container {
|
|
9
|
-
display: flex;
|
|
10
|
-
justify-content: center;
|
|
11
|
-
align-items: center;
|
|
12
|
-
height: 100%;
|
|
13
|
-
width: 100%;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.clock {
|
|
17
|
-
text-align: center;
|
|
18
|
-
font-family: 'Arial', sans-serif;
|
|
19
|
-
color: #333;
|
|
20
|
-
background-color: rgba(20, 20, 20, 0.4);
|
|
21
|
-
backdrop-filter: blur(0.2rem);
|
|
22
|
-
border-radius: 15px;
|
|
23
|
-
padding: 20px;
|
|
24
|
-
width: 100%;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.time {
|
|
28
|
-
font-size: 4em;
|
|
29
|
-
font-weight: bold;
|
|
30
|
-
color: #fff;
|
|
31
|
-
display: flex;
|
|
32
|
-
justify-content: center;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.date {
|
|
36
|
-
font-size: 1.2em;
|
|
37
|
-
color: #fff;
|
|
38
|
-
margin-top: 10px;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
@media (max-width: 500px) {
|
|
42
|
-
.time {
|
|
43
|
-
font-size: 3em;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.date {
|
|
47
|
-
font-size: 1em;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
`
|
|
51
|
-
|
|
52
|
-
// Estructura HTML
|
|
53
|
-
const wrapper = document.createElement('div')
|
|
54
|
-
wrapper.innerHTML = `
|
|
55
|
-
<div class="clock-container">
|
|
56
|
-
<div class="clock">
|
|
57
|
-
<div class="time" id="clock-time">--:--</div>
|
|
58
|
-
<div class="date" id="clock-date">--</div>
|
|
59
|
-
</div>
|
|
60
|
-
</div>
|
|
61
|
-
`
|
|
62
|
-
|
|
63
|
-
shadow.appendChild(style)
|
|
64
|
-
shadow.appendChild(wrapper)
|
|
65
|
-
|
|
66
|
-
// Actualización del reloj
|
|
67
|
-
const updateClock = () => {
|
|
68
|
-
const now = new Date()
|
|
69
|
-
const hours = now.getHours().toString().padStart(2, '0')
|
|
70
|
-
const minutes = now.getMinutes().toString().padStart(2, '0')
|
|
71
|
-
|
|
72
|
-
const days = ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado']
|
|
73
|
-
const months = [
|
|
74
|
-
'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio',
|
|
75
|
-
'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'
|
|
76
|
-
]
|
|
77
|
-
|
|
78
|
-
const dayOfWeek = days[now.getDay()]
|
|
79
|
-
const day = now.getDate()
|
|
80
|
-
const month = months[now.getMonth()]
|
|
81
|
-
const year = now.getFullYear()
|
|
82
|
-
|
|
83
|
-
const timeEl = shadow.getElementById('clock-time')
|
|
84
|
-
const dateEl = shadow.getElementById('clock-date')
|
|
85
|
-
|
|
86
|
-
if (timeEl && dateEl) {
|
|
87
|
-
timeEl.textContent = `${hours}:${minutes}`
|
|
88
|
-
dateEl.textContent = `${dayOfWeek}, ${day} ${month} ${year}`
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
updateClock()
|
|
93
|
-
this._interval = setInterval(updateClock, 1000)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
disconnectedCallback() {
|
|
97
|
-
clearInterval(this._interval)
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// Registro del componente
|
|
102
|
-
customElements.define('clock-widget', ClockWidget)
|