maverick-wave-astro 1.38.0 → 1.40.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.
@@ -0,0 +1,252 @@
1
+ ---
2
+ // The contact form of a werkbank section with the field contactForm. It shows
3
+ // once the werkbank wrote where it posts to, which needs the booked forms and
4
+ // the switch "Formular zeigen" - until then the default slot, the mail link.
5
+ import { config } from '../dist/config.js';
6
+ import { contactEndpoint, type ContactFormContent } from '../dist/forms.js';
7
+ import { linkTo } from '../dist/path.js';
8
+ import { content, languages } from '../dist/werkbank.js';
9
+
10
+ type Labels = {
11
+ name: string;
12
+ email: string;
13
+ phone: string;
14
+ topic: string;
15
+ choose: string;
16
+ message: string;
17
+ optional: string;
18
+ yes: string;
19
+ no: string;
20
+ button: string;
21
+ privacy: string;
22
+ privacyLink: string;
23
+ trap: string;
24
+ };
25
+
26
+ interface Props {
27
+ /** The werkbank section that holds the field contactForm. */
28
+ section: string;
29
+ labels?: Partial<Labels>;
30
+ privacyHref?: string;
31
+ /** Prefix of the field ids, so two forms on one page stay apart. */
32
+ id?: string;
33
+ class?: string;
34
+ }
35
+
36
+ const german = config.site.lang.startsWith('de');
37
+ const defaults: Labels = german
38
+ ? {
39
+ name: 'Name',
40
+ email: 'E-Mail',
41
+ phone: 'Telefon',
42
+ topic: 'Worum geht es?',
43
+ choose: 'Bitte wählen',
44
+ message: 'Nachricht',
45
+ optional: 'optional',
46
+ yes: 'Ja',
47
+ no: 'Nein',
48
+ button: 'Nachricht senden',
49
+ privacy: 'Die Nachricht geht nur an uns.',
50
+ privacyLink: 'Datenschutz',
51
+ trap: 'Bitte leer lassen',
52
+ }
53
+ : {
54
+ name: 'Name',
55
+ email: 'Email',
56
+ phone: 'Phone',
57
+ topic: 'What is it about?',
58
+ choose: 'Please choose',
59
+ message: 'Message',
60
+ optional: 'optional',
61
+ yes: 'Yes',
62
+ no: 'No',
63
+ button: 'Send message',
64
+ privacy: 'The message goes to us only.',
65
+ privacyLink: 'Privacy',
66
+ trap: 'Please leave empty',
67
+ };
68
+
69
+ const {
70
+ section,
71
+ labels,
72
+ privacyHref = linkTo('/datenschutz'),
73
+ id = 'kontakt',
74
+ class: className,
75
+ } = Astro.props;
76
+ const t = { ...defaults, ...labels };
77
+
78
+ type Section = { contactForm?: ContactFormContent };
79
+ const own = content<Section>(section, Astro.url).contactForm;
80
+ const form = own?.active ? own : undefined;
81
+ const endpoint = form ? contactEndpoint(section) : undefined;
82
+
83
+ // The werkbank checks answers against the first language, so a translated
84
+ // page shows its own words but sends the base ones - matched by position.
85
+ const base = content<Section>(section, languages[0]).contactForm;
86
+ const label = (text: string, required: boolean) =>
87
+ required ? text : `${text} (${t.optional})`;
88
+ const questions = (form?.questions ?? []).map((question, i) => ({
89
+ ...question,
90
+ name: `q${i}`,
91
+ label: label(question.label, question.required ?? false),
92
+ options: (question.options ?? []).map((text, j) => ({
93
+ text,
94
+ value: base?.questions?.[i]?.options?.[j] ?? text,
95
+ })),
96
+ }));
97
+ const topics = (form?.topics ?? []).map((text, i) => ({
98
+ text,
99
+ value: base?.topics?.[i] ?? text,
100
+ }));
101
+ const phone = form?.phone ?? 'off';
102
+ ---
103
+
104
+ {
105
+ endpoint ? (
106
+ <form
107
+ class:list={['mw-form', className]}
108
+ method="post"
109
+ action={endpoint.aktion}
110
+ >
111
+ <div class="mw-field">
112
+ <label class="mw-field-label" for={`${id}-name`}>
113
+ {t.name}
114
+ </label>
115
+ <input
116
+ id={`${id}-name`}
117
+ name="name"
118
+ class="mw-input"
119
+ autocomplete="name"
120
+ maxlength="100"
121
+ required
122
+ />
123
+ </div>
124
+ <div class="mw-field">
125
+ <label class="mw-field-label" for={`${id}-email`}>
126
+ {t.email}
127
+ </label>
128
+ <input
129
+ id={`${id}-email`}
130
+ name="email"
131
+ type="email"
132
+ class="mw-input"
133
+ autocomplete="email"
134
+ maxlength="254"
135
+ required
136
+ />
137
+ </div>
138
+ {phone !== 'off' && (
139
+ <div class="mw-field">
140
+ <label class="mw-field-label" for={`${id}-phone`}>
141
+ {label(t.phone, phone === 'required')}
142
+ </label>
143
+ <input
144
+ id={`${id}-phone`}
145
+ name="phone"
146
+ type="tel"
147
+ class="mw-input"
148
+ autocomplete="tel"
149
+ maxlength="40"
150
+ required={phone === 'required'}
151
+ />
152
+ </div>
153
+ )}
154
+ {topics.length > 0 && (
155
+ <div class="mw-field">
156
+ <label class="mw-field-label" for={`${id}-topic`}>
157
+ {t.topic}
158
+ </label>
159
+ <select id={`${id}-topic`} name="topic" class="mw-select" required>
160
+ <option value="">{t.choose}</option>
161
+ {topics.map(topic => (
162
+ <option value={topic.value}>{topic.text}</option>
163
+ ))}
164
+ </select>
165
+ </div>
166
+ )}
167
+ <div class="mw-field">
168
+ <label class="mw-field-label" for={`${id}-message`}>
169
+ {t.message}
170
+ </label>
171
+ <textarea
172
+ id={`${id}-message`}
173
+ name="message"
174
+ class="mw-textarea"
175
+ rows="5"
176
+ maxlength="4000"
177
+ required
178
+ />
179
+ </div>
180
+ {questions.map(question => (
181
+ <div class="mw-field">
182
+ <label class="mw-field-label" for={`${id}-${question.name}`}>
183
+ {question.label}
184
+ </label>
185
+ {question.type === 'long' ? (
186
+ <textarea
187
+ id={`${id}-${question.name}`}
188
+ name={question.name}
189
+ class="mw-textarea"
190
+ rows="3"
191
+ maxlength="2000"
192
+ required={question.required}
193
+ />
194
+ ) : question.type === 'choice' || question.type === 'yesno' ? (
195
+ <select
196
+ id={`${id}-${question.name}`}
197
+ name={question.name}
198
+ class="mw-select"
199
+ required={question.required}
200
+ >
201
+ <option value="">{t.choose}</option>
202
+ {question.type === 'yesno' ? (
203
+ <>
204
+ <option value="ja">{t.yes}</option>
205
+ <option value="nein">{t.no}</option>
206
+ </>
207
+ ) : (
208
+ question.options.map(option => (
209
+ <option value={option.value}>{option.text}</option>
210
+ ))
211
+ )}
212
+ </select>
213
+ ) : (
214
+ <input
215
+ id={`${id}-${question.name}`}
216
+ name={question.name}
217
+ class="mw-input"
218
+ maxlength="200"
219
+ required={question.required}
220
+ />
221
+ )}
222
+ </div>
223
+ ))}
224
+
225
+ <p class="mw-field-hint">
226
+ {t.privacy}{' '}
227
+ <a class="mw-link" href={privacyHref}>
228
+ {t.privacyLink}
229
+ </a>
230
+ </p>
231
+
232
+ <div class="mw-sr-only" aria-hidden="true">
233
+ <label for={`${id}-website`}>{t.trap}</label>
234
+ <input
235
+ id={`${id}-website`}
236
+ name="website"
237
+ tabindex="-1"
238
+ autocomplete="off"
239
+ />
240
+ </div>
241
+ <input type="hidden" name="zeichen" value={endpoint.zeichen} />
242
+
243
+ <div class="mw-form-actions mw-form-actions-left">
244
+ <button type="submit" class="mw-btn mw-btn-primary">
245
+ {form?.button?.trim() || t.button}
246
+ </button>
247
+ </div>
248
+ </form>
249
+ ) : (
250
+ <slot />
251
+ )
252
+ }
@@ -0,0 +1,135 @@
1
+ ---
2
+ // The open job ads as cards, each linking to its own page (JobPosting). The
3
+ // site passes what jobPages() kept, so an expired ad never reaches the HTML.
4
+ // Without any ad the default slot shows, e.g. an EmptyState.
5
+ import '../styles/jobs.css';
6
+
7
+ import { siteLocale } from '../dist/config.js';
8
+ import { longDate, parseIsoDate } from '../dist/date.js';
9
+ import { PACKAGE_ICONS } from '../dist/icons.js';
10
+ import {
11
+ isNewJob,
12
+ type Job,
13
+ jobTeaser,
14
+ type JobType,
15
+ salaryRange,
16
+ } from '../dist/jobs.js';
17
+ import Icon from './Icon.astro';
18
+
19
+ type Labels = {
20
+ types: Record<JobType, string>;
21
+ isNew: string;
22
+ /** Without a start date. */
23
+ now: string;
24
+ /** {date} becomes the start date. */
25
+ from: string;
26
+ units: Record<NonNullable<Job['salaryUnit']>, string>;
27
+ more: string;
28
+ };
29
+
30
+ interface Props {
31
+ jobs: readonly { href: string; job: Job }[];
32
+ /** Where the business is, for ads without a place of their own. */
33
+ city?: string;
34
+ labels?: Partial<Labels>;
35
+ locale?: string;
36
+ class?: string;
37
+ }
38
+
39
+ const {
40
+ jobs,
41
+ city,
42
+ labels,
43
+ locale = siteLocale,
44
+ class: className,
45
+ } = Astro.props;
46
+ const german = locale.startsWith('de');
47
+ const defaults: Labels = german
48
+ ? {
49
+ types: {
50
+ fullTime: 'Vollzeit',
51
+ partTime: 'Teilzeit',
52
+ minijob: 'Minijob',
53
+ apprenticeship: 'Ausbildung',
54
+ internship: 'Praktikum',
55
+ },
56
+ isNew: 'Neu',
57
+ now: 'ab sofort',
58
+ from: 'ab {date}',
59
+ units: { hour: 'je Stunde', month: 'im Monat', year: 'im Jahr' },
60
+ more: 'Zur Anzeige',
61
+ }
62
+ : {
63
+ types: {
64
+ fullTime: 'Full time',
65
+ partTime: 'Part time',
66
+ minijob: 'Mini job',
67
+ apprenticeship: 'Apprenticeship',
68
+ internship: 'Internship',
69
+ },
70
+ isNew: 'New',
71
+ now: 'right away',
72
+ from: 'from {date}',
73
+ units: { hour: 'per hour', month: 'per month', year: 'per year' },
74
+ more: 'View job',
75
+ };
76
+ const t = { ...defaults, ...labels };
77
+ const start = (job: Job) =>
78
+ job.start
79
+ ? t.from.replace('{date}', longDate(parseIsoDate(job.start), locale))
80
+ : t.now;
81
+ type Fact = { icon: string; text: string };
82
+ const facts = (job: Job) => {
83
+ const place = job.location || city;
84
+ const salary = salaryRange(job, locale);
85
+ return [
86
+ place && { icon: PACKAGE_ICONS['map-pin'], text: place },
87
+ { icon: PACKAGE_ICONS.calendar, text: start(job) },
88
+ job.hours && { icon: PACKAGE_ICONS.clock, text: job.hours },
89
+ salary && {
90
+ icon: PACKAGE_ICONS.banknote,
91
+ text: `${salary} € ${t.units[job.salaryUnit ?? 'month']}`,
92
+ },
93
+ ].filter((fact): fact is Fact => typeof fact === 'object');
94
+ };
95
+ ---
96
+
97
+ {
98
+ jobs.length > 0 ? (
99
+ <div class:list={['mw-grid-3 mw-reveal-stagger', className]}>
100
+ {jobs.map(({ href, job }) => (
101
+ <article class="mw-card">
102
+ <div class="mw-card-body">
103
+ <p class="mwa-job-tags">
104
+ <span class="mw-tag">{t.types[job.type]}</span>
105
+ {isNewJob(job) && (
106
+ <span class="mw-tag mw-tag-success">{t.isNew}</span>
107
+ )}
108
+ </p>
109
+ <h3 class="mw-card-title">{job.title}</h3>
110
+ <p class="mwa-job-card-teaser">{jobTeaser(job.description)}</p>
111
+ <ul class="mwa-job-card-facts">
112
+ {facts(job).map(fact => (
113
+ <li>
114
+ <Icon svg={fact.icon} size={17} />
115
+ <span>{fact.text}</span>
116
+ </li>
117
+ ))}
118
+ </ul>
119
+ <div class="mw-card-footer">
120
+ <a
121
+ class="mw-btn mw-btn-outline"
122
+ href={href}
123
+ aria-label={`${t.more}: ${job.title}`}
124
+ >
125
+ {t.more}
126
+ </a>
127
+ </div>
128
+ </div>
129
+ </article>
130
+ ))}
131
+ </div>
132
+ ) : (
133
+ <slot />
134
+ )
135
+ }