@easy-web/content-blocks 1.0.0 → 1.1.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/package.json CHANGED
@@ -1,51 +1,50 @@
1
- {
2
- "name": "@easy-web/content-blocks",
3
- "version": "1.0.0",
4
- "packageManager": "pnpm@10.34.4",
5
- "type": "module",
6
- "description": "Reusable Astro content-block components for the easy-web ecosystem.",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "import": "./dist/index.js"
11
- },
12
- "./components/*": "./src/components/*.astro",
13
- "./schemas/*": "./src/schemas/*.ts"
14
- },
15
- "files": [
16
- "dist",
17
- "src/components",
18
- "src/schemas",
19
- "README.md"
20
- ],
21
- "sideEffects": false,
22
- "scripts": {
23
- "build": "tsc",
24
- "typecheck": "tsc --noEmit",
25
- "test": "vitest run"
26
- },
27
- "peerDependencies": {
28
- "@easy-web/i18n": ">=1.0.0",
29
- "@easy-web/theme-core": ">=1.0.0",
30
- "astro": ">=6.0.0 <8.0.0",
31
- "zod": ">=4.0.0"
32
- },
33
- "devDependencies": {
34
- "@easy-web/i18n": "workspace:*",
35
- "@easy-web/theme-core": "workspace:*",
36
- "astro": "^6.4.0",
37
- "typescript": "^5.5.0",
38
- "vitest": "^4.1.10",
39
- "zod": "^4.0.0"
40
- },
41
- "publishConfig": {
42
- "access": "public",
43
- "provenance": true
44
- },
45
- "repository": {
46
- "type": "git",
47
- "url": "https://github.com/achimismaili/easy-web.git",
48
- "directory": "packages/easy-web-content-blocks"
49
- },
50
- "license": "MIT"
51
- }
1
+ {
2
+ "name": "@easy-web/content-blocks",
3
+ "version": "1.1.0",
4
+ "type": "module",
5
+ "description": "Reusable Astro content-block components for the easy-web ecosystem.",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/index.d.ts",
9
+ "import": "./dist/index.js"
10
+ },
11
+ "./components/*": "./src/components/*.astro",
12
+ "./schemas/*": "./src/schemas/*.ts"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "src/components",
17
+ "src/schemas",
18
+ "README.md"
19
+ ],
20
+ "sideEffects": false,
21
+ "peerDependencies": {
22
+ "astro": ">=6.0.0 <8.0.0",
23
+ "zod": ">=4.0.0"
24
+ },
25
+ "dependencies": {
26
+ "@easy-web/i18n": "1.1.0",
27
+ "@easy-web/theme-core": "1.1.0"
28
+ },
29
+ "devDependencies": {
30
+ "astro": "^6.4.0",
31
+ "typescript": "^5.5.0",
32
+ "vitest": "^4.1.10",
33
+ "zod": "^4.0.0"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public",
37
+ "provenance": true
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "https://github.com/achimismaili/easy-web.git",
42
+ "directory": "packages/easy-web-content-blocks"
43
+ },
44
+ "license": "MIT",
45
+ "scripts": {
46
+ "build": "tsc",
47
+ "typecheck": "tsc --noEmit",
48
+ "test": "vitest run"
49
+ }
50
+ }
@@ -1,124 +1,124 @@
1
- ---
2
- /**
3
- * NotFound – shared brand-conform 404 content block.
4
- *
5
- * Slotted body component (no `<html>`/`<head>`/`<body>`): consumers wrap it in
6
- * their own layout. Public by design (never auth-gated per ADR 0010), so no
7
- * `client:*` directives, `<script>` tags, or auth imports.
8
- *
9
- * `heading` / `message` are CMS overrides; when absent, the inline LABELS
10
- * dictionary supplies DE/EN fallback copy (`easy-web-i18n` intentionally does
11
- * not ship a UI-string dictionary — inline LABELS is the source of truth for
12
- * uncustomised sites).
13
- */
14
-
15
- interface Props {
16
- /** Current page locale (e.g. `"de"`, `"en"`). */
17
- currentLang: string;
18
- /** Site default locale — used for `rootHref` auto-compute and LABELS fallback. */
19
- defaultLocale: string;
20
- /** Explicit back-home link. Auto-computed from `currentLang` vs `defaultLocale` when omitted. */
21
- rootHref?: string;
22
- /** Alternate locale URL. When present, renders a language switcher link. */
23
- alternateHref?: string;
24
- /** CMS override for the `<h1>` heading (falls back to LABELS). */
25
- heading?: string;
26
- /** CMS override for the paragraph message (falls back to LABELS). */
27
- message?: string;
28
- /** Optional illustration URL. When present, renders `<img>` above the heading. */
29
- image?: string;
30
- }
31
-
32
- const LABELS: Record<
33
- string,
34
- { backHome: string; notFoundHeading: string; notFoundMessage: string; switchLanguage: string }
35
- > = {
36
- de: {
37
- backHome: 'Zur Startseite',
38
- notFoundHeading: 'Seite nicht gefunden',
39
- notFoundMessage: 'Die aufgerufene Seite existiert nicht.',
40
- switchLanguage: 'English',
41
- },
42
- en: {
43
- backHome: 'Home',
44
- notFoundHeading: 'Page not found',
45
- notFoundMessage: 'The requested page does not exist.',
46
- switchLanguage: 'Deutsch',
47
- },
48
- };
49
-
50
- const { currentLang, defaultLocale, rootHref, alternateHref, heading, message, image } = Astro.props;
51
-
52
- const t = LABELS[currentLang] ?? LABELS[defaultLocale] ?? LABELS.en;
53
- const resolvedRootHref = rootHref ?? (currentLang === defaultLocale ? '/' : `/${currentLang}/`);
54
- const resolvedHeading = heading ?? t.notFoundHeading;
55
- const resolvedMessage = message ?? t.notFoundMessage;
56
- ---
57
-
58
- <section class="ew-not-found" data-testid="not-found">
59
- {image ? <img src={image} alt="" class="ew-not-found__image" loading="lazy" /> : null}
60
- <h1 class="ew-not-found__heading">{resolvedHeading}</h1>
61
- <p class="ew-not-found__message">{resolvedMessage}</p>
62
- <p class="ew-not-found__actions">
63
- <a href={resolvedRootHref} class="ew-not-found__link">{t.backHome}</a>
64
- </p>
65
- {alternateHref ? (
66
- <p class="ew-not-found__alt">
67
- <a href={alternateHref} class="ew-not-found__alt-link">{t.switchLanguage}</a>
68
- </p>
69
- ) : null}
70
- </section>
71
-
72
- <style>
73
- .ew-not-found {
74
- max-width: 40rem;
75
- margin: var(--ew-space-12) auto;
76
- padding: 0 var(--ew-space-5);
77
- text-align: center;
78
- color: var(--ew-on-surface);
79
- }
80
- .ew-not-found__image {
81
- display: block;
82
- max-width: 12rem;
83
- height: auto;
84
- margin: 0 auto var(--ew-space-5);
85
- }
86
- .ew-not-found__heading {
87
- font-family: var(--ew-font-sans);
88
- font-size: clamp(1.75rem, 4vw, 2.5rem);
89
- color: var(--ew-on-surface);
90
- margin: 0 0 var(--ew-space-3);
91
- letter-spacing: -0.01em;
92
- }
93
- .ew-not-found__message {
94
- color: var(--ew-on-surface);
95
- margin: 0 0 var(--ew-space-5);
96
- }
97
- .ew-not-found__actions {
98
- margin: 0 0 var(--ew-space-3);
99
- }
100
- .ew-not-found__link {
101
- display: inline-block;
102
- padding: var(--ew-space-2) var(--ew-space-5);
103
- background: var(--ew-primary);
104
- color: var(--ew-on-primary);
105
- border-radius: var(--ew-radius-md);
106
- font-weight: 600;
107
- text-decoration: none;
108
- }
109
- .ew-not-found__link:hover {
110
- filter: brightness(0.95);
111
- }
112
- .ew-not-found__link:focus-visible {
113
- outline: 2px solid var(--ew-primary);
114
- outline-offset: 2px;
115
- }
116
- .ew-not-found__alt {
117
- margin: 0;
118
- }
119
- .ew-not-found__alt-link {
120
- color: var(--ew-primary);
121
- text-decoration: underline;
122
- font-size: var(--ew-text-sm);
123
- }
124
- </style>
1
+ ---
2
+ /**
3
+ * NotFound – shared brand-conform 404 content block.
4
+ *
5
+ * Slotted body component (no `<html>`/`<head>`/`<body>`): consumers wrap it in
6
+ * their own layout. Public by design (never auth-gated per ADR 0010), so no
7
+ * `client:*` directives, `<script>` tags, or auth imports.
8
+ *
9
+ * `heading` / `message` are CMS overrides; when absent, the inline LABELS
10
+ * dictionary supplies DE/EN fallback copy (`easy-web-i18n` intentionally does
11
+ * not ship a UI-string dictionary — inline LABELS is the source of truth for
12
+ * uncustomised sites).
13
+ */
14
+
15
+ interface Props {
16
+ /** Current page locale (e.g. `"de"`, `"en"`). */
17
+ currentLang: string;
18
+ /** Site default locale — used for `rootHref` auto-compute and LABELS fallback. */
19
+ defaultLocale: string;
20
+ /** Explicit back-home link. Auto-computed from `currentLang` vs `defaultLocale` when omitted. */
21
+ rootHref?: string;
22
+ /** Alternate locale URL. When present, renders a language switcher link. */
23
+ alternateHref?: string;
24
+ /** CMS override for the `<h1>` heading (falls back to LABELS). */
25
+ heading?: string;
26
+ /** CMS override for the paragraph message (falls back to LABELS). */
27
+ message?: string;
28
+ /** Optional illustration URL. When present, renders `<img>` above the heading. */
29
+ image?: string;
30
+ }
31
+
32
+ const LABELS: Record<
33
+ string,
34
+ { backHome: string; notFoundHeading: string; notFoundMessage: string; switchLanguage: string }
35
+ > = {
36
+ de: {
37
+ backHome: 'Zur Startseite',
38
+ notFoundHeading: 'Seite nicht gefunden',
39
+ notFoundMessage: 'Die aufgerufene Seite existiert nicht.',
40
+ switchLanguage: 'English',
41
+ },
42
+ en: {
43
+ backHome: 'Home',
44
+ notFoundHeading: 'Page not found',
45
+ notFoundMessage: 'The requested page does not exist.',
46
+ switchLanguage: 'Deutsch',
47
+ },
48
+ };
49
+
50
+ const { currentLang, defaultLocale, rootHref, alternateHref, heading, message, image } = Astro.props;
51
+
52
+ const t = LABELS[currentLang] ?? LABELS[defaultLocale] ?? LABELS.en;
53
+ const resolvedRootHref = rootHref ?? (currentLang === defaultLocale ? '/' : `/${currentLang}/`);
54
+ const resolvedHeading = heading ?? t.notFoundHeading;
55
+ const resolvedMessage = message ?? t.notFoundMessage;
56
+ ---
57
+
58
+ <section class="ew-not-found" data-testid="not-found">
59
+ {image ? <img src={image} alt="" class="ew-not-found__image" loading="lazy" /> : null}
60
+ <h1 class="ew-not-found__heading">{resolvedHeading}</h1>
61
+ <p class="ew-not-found__message">{resolvedMessage}</p>
62
+ <p class="ew-not-found__actions">
63
+ <a href={resolvedRootHref} class="ew-not-found__link">{t.backHome}</a>
64
+ </p>
65
+ {alternateHref ? (
66
+ <p class="ew-not-found__alt">
67
+ <a href={alternateHref} class="ew-not-found__alt-link">{t.switchLanguage}</a>
68
+ </p>
69
+ ) : null}
70
+ </section>
71
+
72
+ <style>
73
+ .ew-not-found {
74
+ max-width: 40rem;
75
+ margin: var(--ew-space-12) auto;
76
+ padding: 0 var(--ew-space-5);
77
+ text-align: center;
78
+ color: var(--ew-on-surface);
79
+ }
80
+ .ew-not-found__image {
81
+ display: block;
82
+ max-width: 12rem;
83
+ height: auto;
84
+ margin: 0 auto var(--ew-space-5);
85
+ }
86
+ .ew-not-found__heading {
87
+ font-family: var(--ew-font-sans);
88
+ font-size: clamp(1.75rem, 4vw, 2.5rem);
89
+ color: var(--ew-on-surface);
90
+ margin: 0 0 var(--ew-space-3);
91
+ letter-spacing: -0.01em;
92
+ }
93
+ .ew-not-found__message {
94
+ color: var(--ew-on-surface);
95
+ margin: 0 0 var(--ew-space-5);
96
+ }
97
+ .ew-not-found__actions {
98
+ margin: 0 0 var(--ew-space-3);
99
+ }
100
+ .ew-not-found__link {
101
+ display: inline-block;
102
+ padding: var(--ew-space-2) var(--ew-space-5);
103
+ background: var(--ew-primary);
104
+ color: var(--ew-on-primary);
105
+ border-radius: var(--ew-radius-md);
106
+ font-weight: 600;
107
+ text-decoration: none;
108
+ }
109
+ .ew-not-found__link:hover {
110
+ filter: brightness(0.95);
111
+ }
112
+ .ew-not-found__link:focus-visible {
113
+ outline: 2px solid var(--ew-primary);
114
+ outline-offset: 2px;
115
+ }
116
+ .ew-not-found__alt {
117
+ margin: 0;
118
+ }
119
+ .ew-not-found__alt-link {
120
+ color: var(--ew-primary);
121
+ text-decoration: underline;
122
+ font-size: var(--ew-text-sm);
123
+ }
124
+ </style>
@@ -1,82 +1,82 @@
1
- ---
2
- /**
3
- * ThemeToggle – switches between light and dark themes using @easy-web/theme-core.
4
- * Pure Astro component with inline vanilla JS. No framework dependency.
5
- */
6
- interface Props {
7
- /** Accessible label for the toggle button. */
8
- label?: string;
9
- }
10
-
11
- const { label = 'Toggle color theme (Darkmode)' } = Astro.props;
12
- ---
13
-
14
- <button
15
- type="button"
16
- class="ew-theme-toggle"
17
- aria-label={label}
18
- title={label}
19
- >
20
- <svg class="ew-theme-toggle__icon ew-theme-toggle__icon--sun" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
21
- <circle cx="12" cy="12" r="5"></circle>
22
- <line x1="12" y1="1" x2="12" y2="3"></line>
23
- <line x1="12" y1="21" x2="12" y2="23"></line>
24
- <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
25
- <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
26
- <line x1="1" y1="12" x2="3" y2="12"></line>
27
- <line x1="21" y1="12" x2="23" y2="12"></line>
28
- <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
29
- <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
30
- </svg>
31
- <svg class="ew-theme-toggle__icon ew-theme-toggle__icon--moon" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
32
- <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
33
- </svg>
34
- </button>
35
-
36
- <style>
37
- .ew-theme-toggle {
38
- display: inline-flex;
39
- align-items: center;
40
- justify-content: center;
41
- box-sizing: border-box;
42
- /* Shared header-control height. Icon-only → same value for width for a square button. */
43
- width: 2.25rem;
44
- height: 2.25rem;
45
- background: transparent;
46
- border: 1px solid var(--ew-border);
47
- border-radius: var(--ew-radius-md);
48
- color: var(--ew-on-surface);
49
- cursor: pointer;
50
- padding: 0;
51
- }
52
- .ew-theme-toggle:hover {
53
- background: var(--ew-surface-muted);
54
- }
55
- .ew-theme-toggle:focus-visible {
56
- outline: 2px solid var(--ew-primary);
57
- outline-offset: 2px;
58
- }
59
-
60
- /* Default: show sun, hide moon (light mode) */
61
- .ew-theme-toggle__icon--moon { display: none; }
62
- .ew-theme-toggle__icon--sun { display: block; }
63
-
64
- :global([data-theme="dark"]) .ew-theme-toggle__icon--sun { display: none; }
65
- :global([data-theme="dark"]) .ew-theme-toggle__icon--moon { display: block; }
66
-
67
- @media (prefers-color-scheme: dark) {
68
- :global(:root:not([data-theme="light"])) .ew-theme-toggle__icon--sun { display: none; }
69
- :global(:root:not([data-theme="light"])) .ew-theme-toggle__icon--moon { display: block; }
70
- }
71
- </style>
72
-
73
- <script>
74
- import { applyTheme, getPreferredTheme } from '@easy-web/theme-core';
75
-
76
- const btn = document.querySelector('.ew-theme-toggle') as HTMLButtonElement | null;
77
- btn?.addEventListener('click', () => {
78
- const current = getPreferredTheme();
79
- const next = current === 'dark' ? 'light' : 'dark';
80
- applyTheme(next);
81
- });
82
- </script>
1
+ ---
2
+ /**
3
+ * ThemeToggle – switches between light and dark themes using @easy-web/theme-core.
4
+ * Pure Astro component with inline vanilla JS. No framework dependency.
5
+ */
6
+ interface Props {
7
+ /** Accessible label for the toggle button. */
8
+ label?: string;
9
+ }
10
+
11
+ const { label = 'Toggle color theme (Darkmode)' } = Astro.props;
12
+ ---
13
+
14
+ <button
15
+ type="button"
16
+ class="ew-theme-toggle"
17
+ aria-label={label}
18
+ title={label}
19
+ >
20
+ <svg class="ew-theme-toggle__icon ew-theme-toggle__icon--sun" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
21
+ <circle cx="12" cy="12" r="5"></circle>
22
+ <line x1="12" y1="1" x2="12" y2="3"></line>
23
+ <line x1="12" y1="21" x2="12" y2="23"></line>
24
+ <line x1="4.22" y1="4.22" x2="5.64" y2="5.64"></line>
25
+ <line x1="18.36" y1="18.36" x2="19.78" y2="19.78"></line>
26
+ <line x1="1" y1="12" x2="3" y2="12"></line>
27
+ <line x1="21" y1="12" x2="23" y2="12"></line>
28
+ <line x1="4.22" y1="19.78" x2="5.64" y2="18.36"></line>
29
+ <line x1="18.36" y1="5.64" x2="19.78" y2="4.22"></line>
30
+ </svg>
31
+ <svg class="ew-theme-toggle__icon ew-theme-toggle__icon--moon" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
32
+ <path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"></path>
33
+ </svg>
34
+ </button>
35
+
36
+ <style>
37
+ .ew-theme-toggle {
38
+ display: inline-flex;
39
+ align-items: center;
40
+ justify-content: center;
41
+ box-sizing: border-box;
42
+ /* Shared header-control height. Icon-only → same value for width for a square button. */
43
+ width: 2.25rem;
44
+ height: 2.25rem;
45
+ background: transparent;
46
+ border: 1px solid var(--ew-border);
47
+ border-radius: var(--ew-radius-md);
48
+ color: var(--ew-on-surface);
49
+ cursor: pointer;
50
+ padding: 0;
51
+ }
52
+ .ew-theme-toggle:hover {
53
+ background: var(--ew-surface-muted);
54
+ }
55
+ .ew-theme-toggle:focus-visible {
56
+ outline: 2px solid var(--ew-primary);
57
+ outline-offset: 2px;
58
+ }
59
+
60
+ /* Default: show sun, hide moon (light mode) */
61
+ .ew-theme-toggle__icon--moon { display: none; }
62
+ .ew-theme-toggle__icon--sun { display: block; }
63
+
64
+ :global([data-theme="dark"]) .ew-theme-toggle__icon--sun { display: none; }
65
+ :global([data-theme="dark"]) .ew-theme-toggle__icon--moon { display: block; }
66
+
67
+ @media (prefers-color-scheme: dark) {
68
+ :global(:root:not([data-theme="light"])) .ew-theme-toggle__icon--sun { display: none; }
69
+ :global(:root:not([data-theme="light"])) .ew-theme-toggle__icon--moon { display: block; }
70
+ }
71
+ </style>
72
+
73
+ <script>
74
+ import { applyTheme, getPreferredTheme } from '@easy-web/theme-core';
75
+
76
+ const btn = document.querySelector('.ew-theme-toggle') as HTMLButtonElement | null;
77
+ btn?.addEventListener('click', () => {
78
+ const current = getPreferredTheme();
79
+ const next = current === 'dark' ? 'light' : 'dark';
80
+ applyTheme(next);
81
+ });
82
+ </script>