zen-wdg 2.0.0 → 2.0.1

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/index.js CHANGED
@@ -1 +1 @@
1
- export * from './src/clock.js';
1
+ import './src/register.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-wdg",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
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",
@@ -18,7 +18,8 @@
18
18
  "files": [
19
19
  "dist/",
20
20
  "index.js",
21
- "src/clock.js",
21
+ "src/widgets/",
22
+ "src/register.js",
22
23
  "AUTHORS.md"
23
24
  ]
24
25
  }
@@ -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)