@autobusal/common 1.10.0 → 1.11.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,106 @@
1
+ import { useEffect } from 'react';
2
+ import { TFunction } from 'i18next';
3
+ import { Screen, Content, Logo, Title, Message, Road } from './styles';
4
+ import { useGetSettings } from '@autobusal/providers/services';
5
+
6
+ interface Props {
7
+ t: TFunction<'common'>
8
+ }
9
+
10
+ /**
11
+ * The holding page a brand shows while its site is still being built.
12
+ *
13
+ * Edited: Ferjolt Ozuni - Date: 2026-08-01
14
+ *
15
+ * Rendered INSTEAD of the router, so no real page is reachable while it is
16
+ * on - a visitor who guesses a deep URL gets this too, which is the point.
17
+ *
18
+ * Two things happen alongside the visuals:
19
+ *
20
+ * - crawlers are told not to index. The tag is written directly rather
21
+ * than through <Meta>, because this renders before the app and must not
22
+ * depend on any of it. It also removes any competing robots tag a
23
+ * prerendered snapshot may have baked in, so an older "index" directive
24
+ * cannot win by being first in the document.
25
+ *
26
+ * - Google Tag Manager loads, if the brand configured a container. That is
27
+ * deliberate: a pre-launch page is exactly when a brand wants to measure
28
+ * interest, and it is the only analytics that runs here since the app
29
+ * itself never boots.
30
+ */
31
+ const UnderConstruction = ({ t }: Props): JSX.Element => {
32
+ const { data: settings } = useGetSettings();
33
+
34
+ const construction = settings?.construction;
35
+
36
+ const company = settings?.preferences?.company ?? '';
37
+
38
+ useEffect(() => {
39
+ // Own the robots directive outright - see the note above on why a
40
+ // leftover tag from a prerendered snapshot would otherwise be picked up
41
+ // in preference to this one.
42
+ document.querySelectorAll('meta[name="robots"]').forEach(tag => tag.remove());
43
+
44
+ const robots = document.createElement('meta');
45
+ robots.setAttribute('name', 'robots');
46
+ robots.setAttribute('content', 'noindex, nofollow');
47
+ document.head.appendChild(robots);
48
+
49
+ return () => {
50
+ robots.remove();
51
+ };
52
+ }, []);
53
+
54
+ useEffect(() => {
55
+ const container = construction?.gtm_id;
56
+
57
+ if (!container) {
58
+ return;
59
+ }
60
+
61
+ // Guard against a double insert - this component can re-render, and two
62
+ // GTM containers on one page double-count everything they measure.
63
+ if (document.getElementById('gtm-container')) {
64
+ return;
65
+ }
66
+
67
+ (window as any).dataLayer = (window as any).dataLayer || [];
68
+ (window as any).dataLayer.push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });
69
+
70
+ const script = document.createElement('script');
71
+ script.id = 'gtm-container';
72
+ script.async = true;
73
+ script.src = `https://www.googletagmanager.com/gtm.js?id=${ encodeURIComponent(container) }`;
74
+ document.head.appendChild(script);
75
+ }, [construction?.gtm_id]);
76
+
77
+ const title = construction?.title || t('under_construction.title', { ns: 'common', company });
78
+
79
+ const message = construction?.message || t('under_construction.message', { ns: 'common' });
80
+
81
+ return (
82
+ <Screen>
83
+ <Content>
84
+ { settings?.url && (
85
+ // the brand's own light-theme logo, same asset the site header
86
+ // uses; hidden rather than showing a broken image if a brand has
87
+ // not uploaded one yet
88
+ <Logo
89
+ src={ `${ settings.url }/logo-light.svg` }
90
+ alt={ company }
91
+ onError={ (event) => { event.currentTarget.style.display = 'none'; } }
92
+ />
93
+ ) }
94
+
95
+ <Title>{ title }</Title>
96
+
97
+ <Message>{ message }</Message>
98
+
99
+ </Content>
100
+
101
+ <Road aria-hidden="true" />
102
+ </Screen>
103
+ );
104
+ };
105
+
106
+ export default UnderConstruction;
@@ -0,0 +1,115 @@
1
+ import styled, { keyframes } from 'styled-components';
2
+
3
+ /**
4
+ * The holding page shown while a brand is still being built.
5
+ *
6
+ * Edited: Ferjolt Ozuni - Date: 2026-08-01
7
+ *
8
+ * Deliberately self-contained: it renders INSTEAD of the app, before any
9
+ * route or layout, so it cannot lean on the site chrome for anything. It
10
+ * uses the brand's own theme colours so it still looks like the brand
11
+ * rather than a generic maintenance page.
12
+ */
13
+
14
+ const drift = keyframes`
15
+ from { transform: translate3d(0, 0, 0); }
16
+ to { transform: translate3d(-50%, 0, 0); }
17
+ `;
18
+
19
+ const rise = keyframes`
20
+ from { opacity: 0; transform: translateY(14px); }
21
+ to { opacity: 1; transform: translateY(0); }
22
+ `;
23
+
24
+ export const Screen = styled.main`
25
+ position: relative;
26
+ display: flex;
27
+ flex-direction: column;
28
+ align-items: center;
29
+ justify-content: center;
30
+ min-height: 100dvh;
31
+ padding: 40px 20px 0;
32
+ overflow: hidden;
33
+ text-align: center;
34
+ /* Inherit the app's own page background rather than naming a theme key.
35
+ There is no primary.background in the theme - guessing at one fell
36
+ through to primary.neutral, a mid grey that belongs to cards and
37
+ borders, so the holding page came out lighter than the site it stands
38
+ in for. body already carries the brand's real page colour. */
39
+ background: inherit;
40
+ color: ${ props => props.theme.font.normal };
41
+ `;
42
+
43
+ export const Content = styled.div`
44
+ position: relative;
45
+ z-index: 1;
46
+ max-width: 620px;
47
+ animation: ${ rise } 0.6s ease-out both;
48
+ `;
49
+
50
+ export const Logo = styled.img`
51
+ display: block;
52
+ width: 180px;
53
+ height: 64px;
54
+
55
+ /* same rule as everywhere else - never crop or stretch a brand logo */
56
+ object-fit: contain;
57
+ object-position: center;
58
+ margin: 0 auto 32px;
59
+ `;
60
+
61
+ export const Title = styled.h1`
62
+ margin: 0 0 16px;
63
+ font-size: clamp(28px, 5vw, 44px);
64
+ line-height: 1.15;
65
+ `;
66
+
67
+ export const Message = styled.p`
68
+ margin: 0 auto;
69
+ max-width: 46ch;
70
+ font-size: clamp(15px, 2vw, 18px);
71
+ line-height: 1.6;
72
+ color: ${ props => props.theme.font.faded };
73
+ `;
74
+
75
+ /**
76
+ * A slow band of road at the foot of the page. Purely decorative, and
77
+ * hidden from assistive tech - it carries no information.
78
+ */
79
+ export const Road = styled.div`
80
+ position: absolute;
81
+ right: 0;
82
+ bottom: 0;
83
+ left: 0;
84
+ height: 96px;
85
+ opacity: 0.5;
86
+ background: linear-gradient(
87
+ to top,
88
+ ${ props => props.theme.primary.normal }22,
89
+ transparent
90
+ );
91
+
92
+ &::after {
93
+ content: '';
94
+ position: absolute;
95
+ bottom: 34px;
96
+ left: 0;
97
+ width: 200%;
98
+ height: 3px;
99
+ border-radius: 3px;
100
+ background: repeating-linear-gradient(
101
+ to right,
102
+ ${ props => props.theme.primary.normal }66 0 42px,
103
+ transparent 42px 84px
104
+ );
105
+ animation: ${ drift } 6s linear infinite;
106
+ }
107
+
108
+ /* a moving dashed line is exactly the kind of thing that should stop for
109
+ anyone who has asked motion to stop */
110
+ @media (prefers-reduced-motion: reduce) {
111
+ &::after {
112
+ animation: none;
113
+ }
114
+ }
115
+ `;
package/index.ts CHANGED
@@ -31,6 +31,7 @@ import RouteFeature from './RouteFeature/RouteFeature';
31
31
  import RouteItem from './RouteItem/RouteItem';
32
32
  import Row from './Table/Row';
33
33
  import Table from './Table/Table';
34
+ import UnderConstruction from './UnderConstruction/UnderConstruction';
34
35
  import Viewer from './Viewer/Viewer';
35
36
 
36
37
  export {
@@ -71,5 +72,6 @@ export {
71
72
  RouteItem,
72
73
  Row,
73
74
  Table,
75
+ UnderConstruction,
74
76
  Viewer
75
77
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/common",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"