accomadesc 0.3.1 → 0.3.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.
@@ -82,6 +82,10 @@
82
82
  let disabled = $derived(preview || errored || successfullySent);
83
83
  </script>
84
84
 
85
+ {#if sending}
86
+ <Spinner />
87
+ {/if}
88
+
85
89
  <div class="wrapper">
86
90
  {#if explainer}
87
91
  <div class="explainer">{@html translateFunc ? translateFunc(explainer) : ''}</div>
@@ -147,9 +151,6 @@
147
151
  />
148
152
  </div>
149
153
  </form>
150
- {#if sending}
151
- <Spinner />
152
- {/if}
153
154
  </div>
154
155
 
155
156
  <style>
@@ -14,6 +14,8 @@
14
14
  import { fade } from 'svelte/transition';
15
15
  import Icon from './basic/Icon.svelte';
16
16
  import { page } from '$app/state';
17
+ import Button from './basic/Button.svelte';
18
+ import { onMount } from 'svelte';
17
19
 
18
20
  let {
19
21
  hero,
@@ -56,17 +58,22 @@
56
58
  }
57
59
  };
58
60
 
61
+ let theme = $state('light');
62
+ onMount(() => {
63
+ if (window) {
64
+ const prefersDarkMode = window.matchMedia('(prefers-color-scheme: dark)');
65
+ if (prefersDarkMode) {
66
+ theme = 'dark';
67
+ }
68
+ }
69
+ });
70
+
59
71
  let hamburgerOpen = $state(false);
60
72
  let pageWidth = $state(0);
61
73
  </script>
62
74
 
63
75
  <svelte:head>
64
- <title
65
- >{translateFunc && pageTitle
66
- ? translateFunc(pageTitle)
67
- : //TODO default to something here?
68
- ''}</title
69
- >
76
+ <title>{translateFunc && pageTitle ? translateFunc(pageTitle) : ''}</title>
70
77
  </svelte:head>
71
78
 
72
79
  {#snippet navbar(nav: Nav)}
@@ -101,7 +108,22 @@
101
108
  </div>
102
109
  {/snippet}
103
110
 
104
- <div class="page-wrapper" bind:clientWidth={pageWidth}>
111
+ {#snippet themeswitcher()}
112
+ <div class="theme" class:hero={!!hero}>
113
+ {#if theme == 'light'}
114
+ <Button iconName="moon" clicked={() => (theme = 'dark')} />
115
+ {:else}
116
+ <Button iconName="sun" clicked={() => (theme = 'light')} />
117
+ {/if}
118
+ </div>
119
+ {/snippet}
120
+
121
+ <div
122
+ class="page-wrapper"
123
+ bind:clientWidth={pageWidth}
124
+ class:light={theme == 'light'}
125
+ class:dark={theme == 'dark'}
126
+ >
105
127
  {#if hero}
106
128
  <header class="hero-image">
107
129
  <Photo photoPath={hero.photoPath} alt="Hero Image" eager={true} />
@@ -192,9 +214,20 @@
192
214
  {/each}
193
215
  </fieldset>
194
216
  {/if}
217
+ {@render themeswitcher()}
195
218
  </div>
196
219
 
197
220
  <style>
221
+ .theme {
222
+ position: absolute;
223
+ top: 7rem;
224
+ right: 0.5rem;
225
+ }
226
+
227
+ .theme.hero {
228
+ top: 0.5rem;
229
+ }
230
+
198
231
  div.section-wrapper {
199
232
  margin-bottom: 2rem;
200
233
  width: 100%;
@@ -8,7 +8,6 @@
8
8
  PricingEntry,
9
9
  PricingColumn,
10
10
  } from './types.js';
11
- import type { Dinero, DineroSnapshot } from 'dinero.js';
12
11
 
13
12
  let filteredRanges: PricingRange[] = $state([]);
14
13
  let {
@@ -47,10 +46,7 @@
47
46
  minNumNights: 'text-align:right;',
48
47
  };
49
48
 
50
- const formatAdditionalPersonPrice = (
51
- price: Dinero<number> | DineroSnapshot<number>,
52
- termsRef: string | undefined,
53
- ): string => {
49
+ const formatAdditionalPersonPrice = (price: number, termsRef: string | undefined): string => {
54
50
  if (formatFunc && translateFunc) {
55
51
  let terms = '';
56
52
  if (termsRef) terms = translateFunc(termsRef);
@@ -1,7 +1,5 @@
1
1
  <script lang="ts">
2
2
  import { DateTime } from 'luxon';
3
- import { add, allocate, dinero, multiply, greaterThan, lessThan, type Dinero } from 'dinero.js';
4
- import { EUR } from '@dinero.js/currencies';
5
3
  import type { I18nFacade, PricingShortContent, PricingEntry } from './types.js';
6
4
 
7
5
  let {
@@ -27,39 +25,34 @@
27
25
  });
28
26
  });
29
27
 
30
- let calculatedMinimum = $state(dinero({ amount: Number.MAX_SAFE_INTEGER, currency: EUR }));
31
- let calculatedMaximum = $state(dinero({ amount: 0, currency: EUR }));
28
+ let calculatedMinimum = $state(Number.MAX_SAFE_INTEGER);
29
+ let calculatedMaximum = $state(0);
32
30
 
33
- const calcAverage = (entry: PricingEntry): Dinero<number> | undefined => {
34
- let avg: Dinero<number> | undefined;
31
+ const calcAverage = (entry: PricingEntry): number | undefined => {
35
32
  if (entry && entry.firstNightPrice && entry.perNightPrice && entry.minNumberOfNights) {
36
- const fnp = dinero(entry.firstNightPrice);
37
- const pnp = dinero(entry.perNightPrice);
38
-
39
- [avg] = allocate(
40
- add(multiply(pnp, entry.minNumberOfNights - 1), fnp),
41
- new Array(entry.minNumberOfNights).fill(1),
42
- );
33
+ const fnp = entry.firstNightPrice;
34
+ const pnp = entry.perNightPrice;
35
+ const oda = (entry.minNumberOfNights - 1) * pnp;
36
+ const avg = (oda + fnp) / entry.minNumberOfNights;
37
+ return Math.round(avg);
43
38
  } else if (entry && entry.firstNightPrice && entry.perNightPrice) {
44
- const fnp = dinero(entry.firstNightPrice);
45
- const pnp = dinero(entry.perNightPrice);
46
-
47
- [avg] = allocate(add(pnp, fnp), [1, 1]);
39
+ const avg = (entry.firstNightPrice + entry.perNightPrice) / 2;
40
+ return Math.round(avg);
48
41
  } else if (entry && entry.perNightPrice) {
49
- avg = dinero(entry.perNightPrice);
42
+ return entry.perNightPrice;
50
43
  }
51
- return avg;
44
+ return;
52
45
  };
53
46
 
54
47
  $effect(() => {
55
48
  [...filteredEntries, ...staticRanges].forEach((fe) => {
56
49
  let entry = fe.entry;
57
- let avg: Dinero<number> | undefined = calcAverage(entry);
50
+ let avg: number | undefined = calcAverage(entry);
58
51
  if (avg) {
59
- if (greaterThan(avg, calculatedMaximum)) {
52
+ if (avg > calculatedMaximum) {
60
53
  calculatedMaximum = avg;
61
54
  }
62
- if (lessThan(avg, calculatedMinimum)) {
55
+ if (avg < calculatedMinimum) {
63
56
  calculatedMinimum = avg;
64
57
  }
65
58
  }
@@ -68,10 +61,10 @@
68
61
  if (global) {
69
62
  let globalAvg = calcAverage(global);
70
63
  if (globalAvg) {
71
- if (greaterThan(globalAvg, calculatedMaximum)) {
64
+ if (globalAvg > calculatedMaximum) {
72
65
  calculatedMaximum = globalAvg;
73
66
  }
74
- if (lessThan(globalAvg, calculatedMinimum)) {
67
+ if (globalAvg < calculatedMinimum) {
75
68
  calculatedMinimum = globalAvg;
76
69
  }
77
70
  }
@@ -119,7 +119,7 @@
119
119
  event.preventDefault();
120
120
  }
121
121
 
122
- if (event.keyCode === 13 || event.keyCode === 32) {
122
+ if (event.key == ' ' || event.key == 'Enter') {
123
123
  activated = false;
124
124
  }
125
125
  }
@@ -132,7 +132,7 @@
132
132
  if (preventDefault) {
133
133
  event.preventDefault();
134
134
  }
135
- if (event.keyCode === 13 || event.keyCode === 32) {
135
+ if (event.key == ' ' || event.key == 'Return') {
136
136
  activated = true;
137
137
  }
138
138
  }
@@ -38,16 +38,6 @@
38
38
  </div>
39
39
  </div>
40
40
 
41
- <svelte:head>
42
- {#if !inline}
43
- <style>
44
- body {
45
- overflow: hidden;
46
- }
47
- </style>
48
- {/if}
49
- </svelte:head>
50
-
51
41
  <style>
52
42
  div.background {
53
43
  height: 100vh;
@@ -408,6 +408,8 @@ export const getIcon = (name, color = 'black') => {
408
408
  not: `<svg width="100%" height="100%" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="30" cy="30" r="26" stroke="var(--icon-not-color, ${color})" stroke-width="8" /><line x1="12.8669" y1="13.2106" x2="48.8669" y2="50.2106" stroke="var(--icon-not-color, ${color})" stroke-width="8" /></svg>`,
409
409
  picLinkExt: `<svg width="100%" height="100%" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M38 42V38H30V34H38V30L44 36L38 42ZM24 36C24 31.6 26.4 27.8 30 25.6C29.8 24.6 29 24 28 24H16V20H20C21.2 20 22 19.2 22 18V14H26C28.2 14 30 12.2 30 10V9.2C35.8 11.6 40 17.2 40 24V24.6C41.4 25 42.6 25.8 43.8 26.8C44 26 44 25 44 24C44 13 35 4 24 4C13 4 4 13 4 24C4 35 13 44 24 44C25 44 26 44 26.8 43.8C25 41.6 24 39 24 36ZM22 39.8C14 38.8 8 32.2 8 24C8 22.8 8.2 21.6 8.4 20.4L18 30V32C18 34.2 19.8 36 22 36V39.8Z" fill="var(--external-link-font-color, ${color})"/></svg>`,
410
410
  picLink: `<svg width="100%" height="100%" viewBox="0 0 36 36" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14 6V10H4V32H26V22H30V34C30 34.5304 29.7893 35.0391 29.4142 35.4142C29.0391 35.7893 28.5304 36 28 36H2C1.46957 36 0.960859 35.7893 0.585786 35.4142C0.210714 35.0391 0 34.5304 0 34V8C0 7.46957 0.210714 6.96086 0.585786 6.58579C0.960859 6.21071 1.46957 6 2 6H14ZM36 0V18L28.412 10.414L16.414 22.414L13.586 19.586L25.584 7.586L18 0H36Z" fill="var(--picture-link-font-color, ${color})"/></svg>`,
411
+ moon: `<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 24 24"><g fill="${color}" fill-opacity="0"><path d="M15.22 6.03l2.53 -1.94l-3.19 -0.09l-1.06 -3l-1.06 3l-3.19 0.09l2.53 1.94l-0.91 3.06l2.63 -1.81l2.63 1.81l-0.91 -3.06Z"><animate fill="freeze" attributeName="fill-opacity" begin="0.7s" dur="0.4s" values="0;1"/></path><path d="M19.61 12.25l1.64 -1.25l-2.06 -0.05l-0.69 -1.95l-0.69 1.95l-2.06 0.05l1.64 1.25l-0.59 1.98l1.7 -1.17l1.7 1.17l-0.59 -1.98Z"><animate fill="freeze" attributeName="fill-opacity" begin="1.1s" dur="0.4s" values="0;1"/></path></g><path fill="${color}" fill-opacity="0" stroke="${color}" stroke-dasharray="56" stroke-dashoffset="56" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 6c0 6.08 4.92 11 11 11c0.53 0 1.05 -0.04 1.56 -0.11c-1.61 2.47 -4.39 4.11 -7.56 4.11c-4.97 0 -9 -4.03 -9 -9c0 -3.17 1.64 -5.95 4.11 -7.56c-0.07 0.51 -0.11 1.03 -0.11 1.56Z"><animate fill="freeze" attributeName="fill-opacity" begin="1.5s" dur="0.5s" values="0;1"/><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.6s" values="56;0"/></path></svg>`,
412
+ sun: `<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 16 16"><path fill="${color}" d="M8 11a3 3 0 1 1 0-6a3 3 0 0 1 0 6m0 1a4 4 0 1 0 0-8a4 4 0 0 0 0 8M8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0m0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13m8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5M3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8m10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0m-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0m9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707M4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708"/></svg>`,
411
413
  };
412
414
  return svgs[name];
413
415
  };
@@ -152,7 +152,7 @@
152
152
  }
153
153
  });
154
154
 
155
- const requestHovering = (d: DateTime) => {};
155
+ const requestHovering = (_: DateTime) => {};
156
156
 
157
157
  let monthGridTemplateColumns = `[rowLegend] 1fr [d1] 1fr [d2] 1fr [d3] 1fr [d4] 1fr [d5] 1fr [d6] 1fr [d7] 1fr`;
158
158
 
package/dist/types.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { type Dinero, type DineroSnapshot } from 'dinero.js';
2
1
  import type { FirstMonth, OccuplanTranslations } from './occuplan/state.svelte.js';
3
2
  import type { DateTime, MonthNumbers, WeekdayNumbers } from 'luxon';
4
3
  import type { CookieType, Translation as CookieTranslation } from 'gdpr-cooco-banner';
@@ -170,14 +169,14 @@ export interface StaticPricingRange {
170
169
  entry: PricingEntry;
171
170
  }
172
171
  export interface PricingEntry {
173
- firstNightPrice?: DineroSnapshot<number>;
174
- perNightPrice: DineroSnapshot<number>;
172
+ firstNightPrice?: number;
173
+ perNightPrice: number;
175
174
  numberOfGuestsBase?: number;
176
175
  numberOfGuestsMax?: number;
177
176
  minNumberOfNights?: number;
178
- additionalPersonPrice1?: DineroSnapshot<number>;
179
- additionalPersonPrice2?: DineroSnapshot<number>;
180
- additionalPersonPrice3?: DineroSnapshot<number>;
177
+ additionalPersonPrice1?: number;
178
+ additionalPersonPrice2?: number;
179
+ additionalPersonPrice3?: number;
181
180
  additionalPersonText1?: string;
182
181
  additionalPersonText2?: string;
183
182
  additionalPersonText3?: string;
@@ -395,7 +394,7 @@ export interface I18nFacade {
395
394
  calendarTranslation?: OccuplanTranslations;
396
395
  translateFunc?: (ref: string) => string;
397
396
  formatFunc?: (formatter: string, props: Record<string, any>) => string;
398
- formatMoneyFunc?: (d: Dinero<number> | DineroSnapshot<number>) => string;
397
+ formatMoneyFunc?: (d: number) => string;
399
398
  formatDateFunc?: (d: DateTime | string) => string;
400
399
  updateCurrentLang?: (lang: string) => void;
401
400
  }
package/dist/types.js CHANGED
@@ -1,4 +1,3 @@
1
- import {} from 'dinero.js';
2
1
  export const DEFAULT_TEXT_FONT_SIZE = '1rem';
3
2
  export const DEFAULT_HEADERS_FONT_SIZE = '1.5rem';
4
3
  export const DEFAULT_EXT_HEADERS_1_FONT_SIZE = '3.2rem';
@@ -14,6 +13,7 @@ export const PRICING_COLUMNS = [
14
13
  'minNumNights',
15
14
  ];
16
15
  export const FORMAT_TEMPLATE_NAMES = [
16
+ 'locale',
17
17
  'dateFormat',
18
18
  'monthHeader',
19
19
  'nothingAvailable',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "accomadesc",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build --minify false && npm run package",
@@ -59,7 +59,6 @@
59
59
  "@fontsource/raleway": "^5.2.5",
60
60
  "@twicpics/components": "^0.31.4",
61
61
  "@types/leaflet": "^1.9.17",
62
- "dinero.js": "2.0.0-alpha.14",
63
62
  "leaflet": "^1.9.4",
64
63
  "luxon": "^3.6.1"
65
64
  },