world-clock-strip 0.2.0
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/README.md +204 -0
- package/assets/weather/Cloudy.webp +0 -0
- package/assets/weather/Foggy.webp +0 -0
- package/assets/weather/Partly_Cloudy.webp +0 -0
- package/assets/weather/Partly_Cloudy_Day.webp +0 -0
- package/assets/weather/Rainy.webp +0 -0
- package/assets/weather/Snow.webp +0 -0
- package/assets/weather/Sunny.webp +0 -0
- package/assets/weather/starry-night.webp +0 -0
- package/assets/weather/storm.webp +0 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1456 -0
- package/dist/index.js.map +1 -0
- package/dist/world-clock.d.ts +164 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# World Clock Strip
|
|
2
|
+
|
|
3
|
+
Reusable `world-clock-strip` web component extracted from the Dashboard web app. It ships with animated weather art, moving day-cycle background, editable locations, sharing tools, presets, and a bottom config drawer.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Shadow DOM custom element: `world-clock-strip`
|
|
8
|
+
- Default cities: Las Vegas, Israel, New Delhi, Macau, Sydney
|
|
9
|
+
- Built-in client-side weather via Open-Meteo
|
|
10
|
+
- Optional backend weather endpoint override
|
|
11
|
+
- Shareable URL state
|
|
12
|
+
- JSON import/export
|
|
13
|
+
- Saved presets in local storage
|
|
14
|
+
- Optional persistent local config
|
|
15
|
+
- Optional read-only mode
|
|
16
|
+
- Visual presets: `default`, `minimal`, `cinematic`, `wallboard`
|
|
17
|
+
- `configchange` event for host apps
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
If the repo is private, install from GitHub with access:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install git+ssh://git@github.com/steve777/World-Clock.git
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
For local development in this repo:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Run
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm run dev
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Open [http://127.0.0.1:4173](http://127.0.0.1:4173).
|
|
40
|
+
|
|
41
|
+
## Build
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm run build
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm run build:demo
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm run test
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm run test:package
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Basic Usage
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { defineWorldClockStrip } from "world-clock-strip";
|
|
63
|
+
|
|
64
|
+
defineWorldClockStrip();
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<world-clock-strip></world-clock-strip>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Imperative Usage
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { createWorldClockStrip } from "world-clock-strip";
|
|
75
|
+
|
|
76
|
+
const clock = createWorldClockStrip({
|
|
77
|
+
locations: [
|
|
78
|
+
{ label: "Las Vegas", timeZone: "America/Los_Angeles", weatherQuery: "Las Vegas, Nevada" },
|
|
79
|
+
{ label: "London", timeZone: "Europe/London", weatherQuery: "London, United Kingdom" }
|
|
80
|
+
],
|
|
81
|
+
weatherEnabled: true,
|
|
82
|
+
visualPreset: "cinematic",
|
|
83
|
+
persistKey: "executive-clock",
|
|
84
|
+
enableUrlState: true,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
document.body.append(clock);
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Public API
|
|
91
|
+
|
|
92
|
+
Exports:
|
|
93
|
+
|
|
94
|
+
- `defineWorldClockStrip()`
|
|
95
|
+
- `createWorldClockStrip()`
|
|
96
|
+
- `normalizeClockLocations()`
|
|
97
|
+
- `serializeWorldClockConfig()`
|
|
98
|
+
- `deserializeWorldClockConfig()`
|
|
99
|
+
- `defaultClockLocations`
|
|
100
|
+
|
|
101
|
+
Types:
|
|
102
|
+
|
|
103
|
+
- `ClockLocation`
|
|
104
|
+
- `ClockWeatherSnapshot`
|
|
105
|
+
- `CommonClockCity`
|
|
106
|
+
- `VisualPreset`
|
|
107
|
+
- `WorldClockConfig`
|
|
108
|
+
- `WorldClockStripOptions`
|
|
109
|
+
|
|
110
|
+
## Config Options
|
|
111
|
+
|
|
112
|
+
`WorldClockStripOptions` supports:
|
|
113
|
+
|
|
114
|
+
- `locations`
|
|
115
|
+
- `weatherEnabled`
|
|
116
|
+
- `weatherEndpoint`
|
|
117
|
+
- `weatherOverrides`
|
|
118
|
+
- `visualPreset`
|
|
119
|
+
- `readOnly`
|
|
120
|
+
- `persistKey`
|
|
121
|
+
- `enableUrlState`
|
|
122
|
+
- `shareQueryParam`
|
|
123
|
+
- `cityCatalog`
|
|
124
|
+
|
|
125
|
+
Temperature units are automatic:
|
|
126
|
+
|
|
127
|
+
- U.S. system time zones show `F`
|
|
128
|
+
- all other system time zones show `C`
|
|
129
|
+
|
|
130
|
+
## Sharing
|
|
131
|
+
|
|
132
|
+
The drawer supports:
|
|
133
|
+
|
|
134
|
+
- `Share`: copies a URL with encoded clock config
|
|
135
|
+
- `JSON`: copy current config JSON or import one
|
|
136
|
+
- `Saved presets`: save, load, and delete local presets
|
|
137
|
+
|
|
138
|
+
You can also use the helpers directly:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import {
|
|
142
|
+
serializeWorldClockConfig,
|
|
143
|
+
deserializeWorldClockConfig,
|
|
144
|
+
} from "world-clock-strip";
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Events
|
|
148
|
+
|
|
149
|
+
The component dispatches `configchange`:
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
clock.addEventListener("configchange", (event) => {
|
|
153
|
+
const detail = (event as CustomEvent).detail;
|
|
154
|
+
console.log(detail.config, detail.source);
|
|
155
|
+
});
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`detail.source` is one of:
|
|
159
|
+
|
|
160
|
+
- `api`
|
|
161
|
+
- `drawer`
|
|
162
|
+
- `url`
|
|
163
|
+
- `storage`
|
|
164
|
+
- `preset`
|
|
165
|
+
- `attribute`
|
|
166
|
+
|
|
167
|
+
## Read-Only Mode
|
|
168
|
+
|
|
169
|
+
Hide the config drawer entirely:
|
|
170
|
+
|
|
171
|
+
```html
|
|
172
|
+
<world-clock-strip read-only></world-clock-strip>
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Or:
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
clock.readOnly = true;
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Weather Source
|
|
182
|
+
|
|
183
|
+
Most apps do not need a backend endpoint. If `weatherEnabled` is on and `weatherEndpoint` is blank, the component fetches weather itself.
|
|
184
|
+
|
|
185
|
+
If your app already has a backend route:
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
clock.weatherEndpoint = "/api/weather/clocks";
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Docker
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
docker build -t world-clock-strip .
|
|
195
|
+
docker run --rm -p 4173:4173 world-clock-strip
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Notes
|
|
199
|
+
|
|
200
|
+
- The drawer stores presets in local storage.
|
|
201
|
+
- `persistKey` stores the current config in local storage.
|
|
202
|
+
- If both persisted state and shared URL state exist, the shared URL wins.
|
|
203
|
+
- The weather art bundle is much smaller than before, but the package still benefits from continued asset optimization.
|
|
204
|
+
- `npm run test:package` validates the packed tarball in a clean temporary install.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { WORLD_CLOCK_TAG_NAME, WorldClockStripElement, createWorldClockStrip, deserializeWorldClockConfig, defaultClockLocations, defineWorldClockStrip, getFallbackWeatherCondition, isDaytimeWeather, mapWeatherCode, normalizeClockLocations, serializeWorldClockConfig, } from "./world-clock";
|
|
2
|
+
export type { ClockLocation, ClockWeatherSnapshot, CommonClockCity, VisualPreset, WorldClockConfig, WorldClockStripOptions, } from "./world-clock";
|