@nohemia/widgets 0.1.0 → 0.1.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/README.de.md +19 -19
- package/README.es.md +19 -19
- package/README.fr.md +10 -10
- package/README.it.md +19 -19
- package/README.ja.md +19 -19
- package/README.ko.md +19 -19
- package/README.md +47 -23
- package/README.pl.md +19 -19
- package/README.pt.md +19 -19
- package/README.tr.md +19 -19
- package/examples/index.html +5 -5
- package/package.json +2 -2
- package/src/nohemia-widget.js +44 -17
package/examples/index.html
CHANGED
|
@@ -13,22 +13,22 @@
|
|
|
13
13
|
<body>
|
|
14
14
|
<h1>Nohemia Widgets</h1>
|
|
15
15
|
<p>Free, embeddable astrology & moon widgets. See the gallery at
|
|
16
|
-
<a href="https://nohemia.com/
|
|
16
|
+
<a href="https://nohemia.com/en/widgets/">nohemia.com/en/widgets</a>.</p>
|
|
17
17
|
|
|
18
18
|
<h2>1. Plain iframe (works everywhere)</h2>
|
|
19
|
-
<iframe src="https://nohemia.com/
|
|
19
|
+
<iframe src="https://nohemia.com/en/widgets/moon/light-m/"
|
|
20
20
|
width="300" height="210" loading="lazy"
|
|
21
21
|
title="Calendrier lunaire" style="border:0;border-radius:12px;max-width:100%"></iframe>
|
|
22
22
|
<p style="font:12px/1.4 system-ui,sans-serif;margin:6px 0 0">
|
|
23
|
-
<a href="https://nohemia.com/
|
|
23
|
+
<a href="https://nohemia.com/en/lune/" rel="nofollow">Calendrier lunaire par Nohemia</a>
|
|
24
24
|
</p>
|
|
25
25
|
|
|
26
26
|
<h2>2. Web component (npm or CDN)</h2>
|
|
27
27
|
<script type="module" src="https://cdn.jsdelivr.net/npm/@nohemia/widgets"></script>
|
|
28
|
-
<nohemia-widget type="
|
|
28
|
+
<nohemia-widget type="sky" theme="dark" size="m"></nohemia-widget>
|
|
29
29
|
|
|
30
30
|
<h2>How to use</h2>
|
|
31
31
|
<pre><code><script type="module" src="https://cdn.jsdelivr.net/npm/@nohemia/widgets"></script>
|
|
32
|
-
<nohemia-widget type="
|
|
32
|
+
<nohemia-widget type="moon" theme="light" size="m"></nohemia-widget></code></pre>
|
|
33
33
|
</body>
|
|
34
34
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nohemia/widgets",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Free, embeddable astrology & moon widgets. Real ephemeris, refreshed nightly, no account, no tracking.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/nohemia-widget.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"ephemeris",
|
|
32
32
|
"nohemia"
|
|
33
33
|
],
|
|
34
|
-
"homepage": "https://nohemia.com/
|
|
34
|
+
"homepage": "https://nohemia.com/en/widgets/",
|
|
35
35
|
"repository": {
|
|
36
36
|
"type": "git",
|
|
37
37
|
"url": "git+https://github.com/jadenohemia/nohemia-widgets.git"
|
package/src/nohemia-widget.js
CHANGED
|
@@ -5,41 +5,68 @@
|
|
|
5
5
|
* styling always stay in sync with the source. No tracking, no cookies, no external runtime.
|
|
6
6
|
*
|
|
7
7
|
* <script type="module">import '@nohemia/widgets'</script>
|
|
8
|
-
* <nohemia-widget type="
|
|
8
|
+
* <nohemia-widget type="moon" locale="en" theme="light" size="m"></nohemia-widget>
|
|
9
9
|
*
|
|
10
10
|
* Attributes:
|
|
11
|
-
* type
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* type "moon" | "sky" (default "moon")
|
|
12
|
+
* locale "en"|"fr"|"pt"|"es"|"it"|"de"|"pl"|"ko"|"ja"|"tr" (default "en")
|
|
13
|
+
* theme "light" | "dark" (default "light")
|
|
14
|
+
* size "s" | "m" (default "m")
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
+
* The slug and theme word in the URL are localized for SEO (e.g. /de/widgets/mond/hell-m/),
|
|
17
|
+
* but you always pass the canonical English keys above - the component maps them per locale.
|
|
18
|
+
*
|
|
19
|
+
* MIT (c) Jade Nohemia / Nohemia - https://nohemia.com/en/widgets/
|
|
16
20
|
*/
|
|
17
21
|
|
|
18
|
-
const BASE = 'https://nohemia.com
|
|
22
|
+
const BASE = 'https://nohemia.com'
|
|
19
23
|
|
|
24
|
+
// Localized URL slug per widget type (the word natives search) - mirrors widget-locales.ts.
|
|
25
|
+
const SLUG = {
|
|
26
|
+
moon: { en: 'moon', fr: 'lune', pt: 'lua', es: 'luna', it: 'luna', de: 'mond', pl: 'ksiezyc', ko: 'dal', ja: 'tsuki', tr: 'ay' },
|
|
27
|
+
sky: { en: 'sky', fr: 'ciel', pt: 'ceu', es: 'cielo', it: 'cielo', de: 'himmel', pl: 'niebo', ko: 'haneul', ja: 'sora', tr: 'gokyuzu' },
|
|
28
|
+
}
|
|
29
|
+
// Localized theme word in the URL.
|
|
30
|
+
const THEME = {
|
|
31
|
+
light: { en: 'light', fr: 'clair', pt: 'claro', es: 'claro', it: 'chiaro', de: 'hell', pl: 'jasny', ko: 'light', ja: 'light', tr: 'acik' },
|
|
32
|
+
dark: { en: 'dark', fr: 'sombre', pt: 'escuro', es: 'oscuro', it: 'scuro', de: 'dunkel', pl: 'ciemny', ko: 'dark', ja: 'dark', tr: 'koyu' },
|
|
33
|
+
}
|
|
20
34
|
// Pixel dimensions per type and size, matching the official widget pages.
|
|
21
35
|
const DIMS = {
|
|
22
|
-
|
|
23
|
-
|
|
36
|
+
moon: { s: [220, 140], m: [300, 210] },
|
|
37
|
+
sky: { s: [230, 150], m: [300, 200] },
|
|
24
38
|
}
|
|
25
39
|
|
|
40
|
+
// Backward-compatible aliases (the first release used the French keys).
|
|
41
|
+
const TYPE_ALIAS = { lune: 'moon', ciel: 'sky' }
|
|
42
|
+
const THEME_ALIAS = { clair: 'light', sombre: 'dark' }
|
|
43
|
+
const LOCALES = ['en', 'fr', 'pt', 'es', 'it', 'de', 'pl', 'ko', 'ja', 'tr']
|
|
44
|
+
|
|
26
45
|
class NohemiaWidget extends HTMLElement {
|
|
27
46
|
connectedCallback() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
47
|
+
let type = (this.getAttribute('type') || 'moon').toLowerCase()
|
|
48
|
+
type = TYPE_ALIAS[type] || type
|
|
49
|
+
if (!DIMS[type]) type = 'moon'
|
|
50
|
+
|
|
51
|
+
let locale = (this.getAttribute('locale') || 'en').toLowerCase()
|
|
52
|
+
if (LOCALES.indexOf(locale) === -1) locale = 'en'
|
|
53
|
+
|
|
54
|
+
let theme = (this.getAttribute('theme') || 'light').toLowerCase()
|
|
55
|
+
theme = THEME_ALIAS[theme] || theme
|
|
56
|
+
if (theme !== 'dark') theme = 'light'
|
|
57
|
+
|
|
58
|
+
const size = this.getAttribute('size') === 's' ? 's' : 'm'
|
|
59
|
+
const [w, h] = DIMS[type][size]
|
|
31
60
|
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const safeTheme = theme === 'sombre' ? 'sombre' : 'clair'
|
|
35
|
-
const [w, h] = DIMS[safeType][safeSize]
|
|
61
|
+
const slug = SLUG[type][locale]
|
|
62
|
+
const themeWord = THEME[theme][locale]
|
|
36
63
|
|
|
37
64
|
const iframe = document.createElement('iframe')
|
|
38
|
-
iframe.src = `${BASE}/${
|
|
65
|
+
iframe.src = `${BASE}/${locale}/widgets/${slug}/${themeWord}-${size}/`
|
|
39
66
|
iframe.width = String(w)
|
|
40
67
|
iframe.height = String(h)
|
|
41
68
|
iframe.loading = 'lazy'
|
|
42
|
-
iframe.title = '
|
|
69
|
+
iframe.title = 'Nohemia widget'
|
|
43
70
|
iframe.style.cssText = 'border:0;border-radius:12px;max-width:100%'
|
|
44
71
|
iframe.setAttribute('referrerpolicy', 'strict-origin-when-cross-origin')
|
|
45
72
|
|