@osimart/create-storefront 1.0.3 → 1.0.7

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/app/app.vue CHANGED
@@ -4,12 +4,28 @@ import "#osi/assets/css/osi-controls.css";
4
4
  import { parseIds } from "#osi/utils/analytics";
5
5
 
6
6
  const { load, dir, store, error } = useStorefront();
7
+ // Captured before the first await (the request event needs Nuxt's context).
8
+ const requestEvent = import.meta.server ? useRequestEvent() : null;
7
9
  const { tokens, rootClasses, fontLinks } = useThemeTokens();
8
10
  const { start: startBuilderPreview, stop: stopBuilderPreview } = useBuilderPreview();
9
11
 
10
12
  const { error: fetchError } = await useAsyncData("storefront", () => load());
11
13
  const shown = computed(() => error.value ?? fetchError.value ?? null);
12
14
 
15
+ const unavailableStatus = computed(() => {
16
+ const e = shown.value;
17
+ if (!e) return null;
18
+ const status = Number(e.status ?? e.statusCode) || 0;
19
+ return status >= 400 && status < 500 ? status : 503;
20
+ });
21
+ if (requestEvent && unavailableStatus.value) {
22
+ setResponseStatus(requestEvent, unavailableStatus.value);
23
+ }
24
+
25
+ const publicConfig = useRuntimeConfig().public;
26
+ const osimartUrl = String(publicConfig.osimartUrl || "https://osimart.com").replace(/\/+$/, "");
27
+ const signupUrl = publicConfig.osimartSignupUrl || `${osimartUrl}/`;
28
+
13
29
  const isDev = import.meta.dev;
14
30
 
15
31
  onMounted(() => {
@@ -39,6 +55,8 @@ onBeforeUnmount(() => {
39
55
  useThemeSeo();
40
56
 
41
57
  useHead({
58
+ title: computed(() => (shown.value ? "Store unavailable" : undefined)),
59
+ meta: computed(() => (shown.value ? [{ name: "robots", content: "noindex" }] : [])),
42
60
  htmlAttrs: computed(() => ({ dir: dir.value })),
43
61
  noscript: computed(() =>
44
62
  parseIds(store.value?.meta_pixel_id, "pixel").map((id) => ({
@@ -46,10 +64,14 @@ useHead({
46
64
  innerHTML: `<img height="1" width="1" style="display:none" alt="" src="https://www.facebook.com/tr?id=${id}&ev=PageView&noscript=1" />`,
47
65
  })),
48
66
  ),
49
- bodyAttrs: computed(() => ({
50
- style: tokens.value,
51
- class: rootClasses.value.filter((c) => /^osi-(btns|inputs|labels)/.test(c)),
52
- })),
67
+ bodyAttrs: computed(() =>
68
+ shown.value
69
+ ? { class: "osi-unavailable-body" }
70
+ : {
71
+ style: tokens.value,
72
+ class: rootClasses.value.filter((c) => /^osi-(btns|inputs|labels)/.test(c)),
73
+ }
74
+ ),
53
75
  // A getter, not a snapshot: a font picked in the editor (or a theme that
54
76
  // loads later) must add its stylesheet.
55
77
  link: computed(() => [
@@ -63,13 +85,17 @@ useHead({
63
85
  </script>
64
86
 
65
87
  <template>
66
- <div v-if="shown" class="osi-fatal">
67
- <p>This store isn't available right now.</p>
88
+ <main v-if="shown" class="osi-unavailable" dir="ltr">
89
+ <a :href="osimartUrl" class="osi-unavailable-back">
90
+ <span aria-hidden="true">&larr;</span>
91
+ Osimart
92
+ </a>
93
+ <h1 class="osi-unavailable-title">This store is currently unavailable.</h1>
94
+ <a :href="signupUrl" class="osi-unavailable-cta">Start a free trial</a>
68
95
 
69
-
70
96
  <pre v-if="isDev" class="osi-fatal-detail">{{ shown.status ? `HTTP ${shown.status} — ` : "" }}{{ shown.message }}<template v-if="shown.data">
71
97
  {{ shown.data }}</template></pre>
72
- </div>
98
+ </main>
73
99
 
74
100
  <div v-else class="osi-root" :class="rootClasses" :style="tokens" :dir="dir">
75
101
  <NuxtLoadingIndicator
@@ -134,14 +160,74 @@ body .font-thoren {
134
160
  body .font-heading {
135
161
  font-family: var(--osi-font-heading);
136
162
  }
137
- .osi-fatal {
138
- padding: 4rem 1rem;
163
+ /* ---- Store unavailable (Shopify-style) — no theme tokens on purpose. */
164
+ body.osi-unavailable-body {
165
+ margin: 0;
166
+ background: #20336b;
167
+ }
168
+ .osi-unavailable {
169
+ min-height: 100vh;
170
+ min-height: 100dvh;
171
+ box-sizing: border-box;
172
+ display: flex;
173
+ flex-direction: column;
174
+ align-items: center;
175
+ padding: clamp(5rem, 18vh, 10.5rem) 1.5rem 4rem;
176
+ background: #20336b;
177
+ color: #fff;
139
178
  text-align: center;
140
- font-family: system-ui, sans-serif;
179
+ font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
180
+ -webkit-font-smoothing: antialiased;
181
+ }
182
+ .osi-unavailable a {
183
+ color: inherit;
184
+ text-decoration: none;
185
+ }
186
+ .osi-unavailable-back {
187
+ display: inline-flex;
188
+ align-items: center;
189
+ gap: 0.6rem;
190
+ font-size: 1.25rem;
191
+ line-height: 1;
192
+ opacity: 0.95;
193
+ transition: opacity 0.15s ease;
194
+ }
195
+ .osi-unavailable-back:hover {
196
+ opacity: 0.7;
197
+ }
198
+ .osi-unavailable-title {
199
+ margin: 2.25rem 0 0;
200
+ max-width: 18ch;
201
+ font-size: clamp(2.5rem, 5.6vw, 4.75rem);
202
+ font-weight: 400;
203
+ line-height: 1.05;
204
+ letter-spacing: -0.035em;
205
+ text-wrap: balance;
206
+ }
207
+ @media (min-width: 900px) {
208
+ .osi-unavailable-title {
209
+ max-width: none;
210
+ }
211
+ }
212
+ .osi-unavailable-cta {
213
+ margin-top: 1.75rem;
214
+ padding-bottom: 0.15rem;
215
+ font-size: 1.375rem;
216
+ line-height: 1.3;
217
+ border-bottom: 2px solid currentColor;
218
+ transition: opacity 0.15s ease;
219
+ }
220
+ .osi-unavailable-cta:hover {
221
+ opacity: 0.75;
222
+ }
223
+ .osi-unavailable :focus-visible {
224
+ outline: 2px solid #fff;
225
+ outline-offset: 4px;
226
+ border-radius: 2px;
141
227
  }
142
228
  .osi-fatal-detail {
143
229
  display: inline-block;
144
- margin-top: 1rem;
230
+ margin-top: 3rem;
145
231
  padding: 0.75rem 1rem;
146
232
  text-align: start;
147
233
  background: #fef2f2;
@@ -16,7 +16,9 @@ defineProps({
16
16
  // Hover / selection outlines are drawn by BuilderOverlay (pages/__builder-preview),
17
17
  // not here: a CSS outline gets clipped by overflow, can't carry a name tag or
18
18
  // buttons, and a nested block's outline would fight its section's.
19
- const { isPreview } = useBuilderPreview();
19
+ //
20
+ // A hidden section (disabled) isn't rendered at all — in the editor's preview
21
+ // too, like Shopify — so the preview shows exactly what the live store will.
20
22
  </script>
21
23
 
22
24
  <template>
@@ -24,11 +26,10 @@ const { isPreview } = useBuilderPreview();
24
26
  <template v-for="(section, i) in sections" :key="section.key">
25
27
  <component
26
28
  :is="resolveSection(section.type)"
27
- v-if="resolveSection(section.type)"
29
+ v-if="!section.disabled && resolveSection(section.type)"
28
30
  :section="section"
29
31
  :index="i"
30
32
  :data-osi-section="section.key"
31
- :class="{ 'osi-preview-disabled': isPreview && section.disabled }"
32
33
  />
33
34
  </template>
34
35
  </div>
@@ -38,9 +39,4 @@ const { isPreview } = useBuilderPreview();
38
39
  .osi-sections > :deep(*) + :deep(*) {
39
40
  margin-top: 0;
40
41
  }
41
-
42
- /* Editor only — never rendered on a live storefront. */
43
- .osi-preview-disabled {
44
- opacity: 0.45;
45
- }
46
42
  </style>