ublo-lib 1.8.11 → 1.8.13
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/es/common/components/analytics.js +7 -7
- package/es/common/components/cookie-consent/cookie-consent.js +8 -5
- package/es/common/components/error-404/error-404.js +14 -10
- package/es/common/components/error-404/messages.js +2 -12
- package/es/common/components/plausible/hooks/use-plausible.js +8 -8
- package/package.json +1 -1
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
|
-
import
|
|
2
|
+
import getConfig from "next/config";
|
|
3
|
+
const {
|
|
4
|
+
publicRuntimeConfig
|
|
5
|
+
} = getConfig();
|
|
6
|
+
const {
|
|
7
|
+
gaAccount
|
|
8
|
+
} = publicRuntimeConfig;
|
|
3
9
|
const loadGTag = id => new Promise(resolve => {
|
|
4
10
|
const script = document.createElement("script");
|
|
5
11
|
script.src = `https://www.googletagmanager.com/gtag/js?id=${id}`;
|
|
@@ -10,12 +16,6 @@ const Analytics = ({
|
|
|
10
16
|
consent,
|
|
11
17
|
gaAccountOverride
|
|
12
18
|
}) => {
|
|
13
|
-
const {
|
|
14
|
-
config
|
|
15
|
-
} = useUbloContext();
|
|
16
|
-
const {
|
|
17
|
-
gaAccount
|
|
18
|
-
} = config;
|
|
19
19
|
const gaId = gaAccountOverride || gaAccount;
|
|
20
20
|
useEffect(() => {
|
|
21
21
|
const startGTag = async () => {
|
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as ReactDOM from "react-dom";
|
|
3
|
+
import getConfig from "next/config";
|
|
3
4
|
import classnames from "classnames";
|
|
4
|
-
import { useUbloContext } from "ublo/with-ublo";
|
|
5
5
|
import * as Messages from "./messages";
|
|
6
6
|
import Button from "dt-design-system/es/button";
|
|
7
7
|
import css from "./cookie-consent.module.css";
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
const {
|
|
11
|
+
publicRuntimeConfig
|
|
12
|
+
} = getConfig();
|
|
13
|
+
const {
|
|
14
|
+
gaAccount
|
|
15
|
+
} = publicRuntimeConfig;
|
|
10
16
|
const COOKIE_STORAGE = "cookie_allowed";
|
|
11
17
|
const CookieConsent = ({
|
|
12
18
|
lang,
|
|
13
19
|
consent,
|
|
14
20
|
updateConsent
|
|
15
21
|
}) => {
|
|
16
|
-
const {
|
|
17
|
-
config
|
|
18
|
-
} = useUbloContext();
|
|
19
22
|
const [mounted, setMounted] = React.useState(false);
|
|
20
|
-
const isEnabled =
|
|
23
|
+
const isEnabled = Boolean(gaAccount);
|
|
21
24
|
const cookieAllowed = value => () => {
|
|
22
25
|
updateConsent(value);
|
|
23
26
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { useUbloContext } from "ublo/with-ublo";
|
|
2
3
|
import classnames from "classnames";
|
|
3
4
|
import Button from "dt-design-system/es/button";
|
|
4
5
|
import { useGoal } from "../plausible";
|
|
5
|
-
import
|
|
6
|
+
import message from "./messages";
|
|
6
7
|
import css from "./error-404.module.css";
|
|
7
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -11,6 +12,15 @@ const Error404 = ({
|
|
|
11
12
|
className
|
|
12
13
|
}) => {
|
|
13
14
|
useGoal("404 error");
|
|
15
|
+
const {
|
|
16
|
+
lang: ubloLang
|
|
17
|
+
} = useUbloContext();
|
|
18
|
+
const [lang, setLang] = React.useState(ubloLang);
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
if (!lang) {
|
|
21
|
+
setLang(document.documentElement.getAttribute("lang") || "en");
|
|
22
|
+
}
|
|
23
|
+
}, [lang]);
|
|
14
24
|
const classes = classnames(css.error, className);
|
|
15
25
|
return _jsxs("div", {
|
|
16
26
|
className: classes,
|
|
@@ -21,21 +31,15 @@ const Error404 = ({
|
|
|
21
31
|
className: css.inner,
|
|
22
32
|
children: [_jsx("div", {
|
|
23
33
|
className: css.title,
|
|
24
|
-
children:
|
|
25
|
-
id: "title"
|
|
26
|
-
})
|
|
34
|
+
children: message(lang, "title")
|
|
27
35
|
}), _jsx("div", {
|
|
28
36
|
className: css.tagline,
|
|
29
|
-
children:
|
|
30
|
-
id: "tagline"
|
|
31
|
-
})
|
|
37
|
+
children: message(lang, "tagline")
|
|
32
38
|
}), _jsx(Button, {
|
|
33
39
|
tag: "a",
|
|
34
40
|
className: css.button,
|
|
35
41
|
href: "/",
|
|
36
|
-
children:
|
|
37
|
-
id: "button"
|
|
38
|
-
})
|
|
42
|
+
children: message(lang, "button")
|
|
39
43
|
}), _jsx("div", {
|
|
40
44
|
className: css.errorCode,
|
|
41
45
|
children: "404"
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { useUbloContext } from "ublo/with-ublo";
|
|
2
1
|
const messages = {
|
|
3
2
|
fr: {
|
|
4
3
|
title: "Erreur",
|
|
@@ -11,16 +10,7 @@ const messages = {
|
|
|
11
10
|
button: "Back to home page"
|
|
12
11
|
}
|
|
13
12
|
};
|
|
14
|
-
|
|
13
|
+
export default function message(lang, id) {
|
|
15
14
|
const _lang = lang === "fr" ? "fr" : "en";
|
|
16
15
|
return messages[_lang]?.[id] || `??${id}??`;
|
|
17
|
-
}
|
|
18
|
-
export const Message = ({
|
|
19
|
-
id
|
|
20
|
-
}) => {
|
|
21
|
-
const {
|
|
22
|
-
lang
|
|
23
|
-
} = useUbloContext();
|
|
24
|
-
return message(lang, id);
|
|
25
|
-
};
|
|
26
|
-
export default Message;
|
|
16
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
2
|
+
import getConfig from "next/config";
|
|
3
3
|
import load from "../services/load";
|
|
4
4
|
import sendGoal from "../services/send-goal";
|
|
5
|
+
const {
|
|
6
|
+
publicRuntimeConfig
|
|
7
|
+
} = getConfig();
|
|
8
|
+
const {
|
|
9
|
+
plausibleDomain
|
|
10
|
+
} = publicRuntimeConfig;
|
|
5
11
|
const usePlausible = overridenDomain => {
|
|
6
12
|
const [loaded, setLoaded] = React.useState(false);
|
|
7
|
-
const {
|
|
8
|
-
config
|
|
9
|
-
} = useUbloContext();
|
|
10
|
-
const {
|
|
11
|
-
plausibleDomain
|
|
12
|
-
} = config;
|
|
13
13
|
React.useEffect(() => {
|
|
14
14
|
if (!overridenDomain && !plausibleDomain) return;
|
|
15
15
|
load();
|
|
16
16
|
setLoaded(true);
|
|
17
|
-
}, [overridenDomain
|
|
17
|
+
}, [overridenDomain]);
|
|
18
18
|
return [loaded, setLoaded];
|
|
19
19
|
};
|
|
20
20
|
const useGoal = (goal, props, overridenDomain) => {
|