@bytebrand/fe-ui-core-autobahn 1.0.174 → 1.0.175

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.
@@ -3,12 +3,15 @@ import useModal from './useModal';
3
3
  import { updateCookieList } from '../../utils/CommonUtils';
4
4
  import { OPEN_COOKIE_SETTINGS_EVENT } from '../../utils/cookieConsent';
5
5
  import Modal from './Modal';
6
+ import { TranslationFunction } from '../../types';
6
7
 
7
8
  export interface ICookieModal {
8
9
  handleSentryInit?: () => void;
10
+ /** the host's `t` with the `autobahn` namespace (`cookieModal.*`); without it the dialog is German */
11
+ t?: TranslationFunction;
9
12
  }
10
13
 
11
- const CookieModal = ({ handleSentryInit = () => {} }: ICookieModal) => {
14
+ const CookieModal = ({ handleSentryInit = () => {}, t }: ICookieModal) => {
12
15
  const { isVisible, toggleModal, openModal } = useModal();
13
16
  const [modal, setModal] = useState('');
14
17
 
@@ -59,6 +62,7 @@ const CookieModal = ({ handleSentryInit = () => {} }: ICookieModal) => {
59
62
  ? <Modal
60
63
  isVisible={isVisible}
61
64
  handleSentryInit={handleSentryInit}
65
+ t={t}
62
66
  toggleModal={toggleModal}
63
67
  name={modal}
64
68
  modalProps={modalProps}
@@ -16,6 +16,7 @@ import * as React from 'react';
16
16
  import * as ReactDOM from 'react-dom';
17
17
 
18
18
  import ModalsConfig from './ModalsConfig';
19
+ import { TranslationFunction } from '../../types';
19
20
  import styles from './Modal.styl';
20
21
 
21
22
  interface IBasicModal {
@@ -24,6 +25,7 @@ interface IBasicModal {
24
25
  handleSentryInit?: () => void;
25
26
  name: string;
26
27
  modalProps?: any;
28
+ t?: TranslationFunction;
27
29
  }
28
30
 
29
31
  const OVERLAY: React.CSSProperties = {
@@ -40,16 +42,17 @@ const SURFACE: React.CSSProperties = {
40
42
  maxWidth: 640, width: '100%', maxHeight: '92vh', overflowY: 'auto'
41
43
  };
42
44
 
43
- const BasicModal = ({ isVisible, toggleModal, name, modalProps, handleSentryInit }: IBasicModal) => {
45
+ const BasicModal = ({ isVisible, toggleModal, name, modalProps, handleSentryInit, t }: IBasicModal) => {
44
46
  if (!isVisible || typeof document === 'undefined') return null;
47
+ const label = t ? t('autobahn:cookieModal.dialogLabel') : '';
45
48
  return ReactDOM.createPortal(
46
49
  // wrapped in .md3: autobahn.css scopes every token/utility class (incl.
47
50
  // .mbtn used by the modal buttons) under `.md3` and intentionally does
48
51
  // nothing outside it — a bare document.body portal loses the theme.
49
52
  <div className='md3'>
50
- <div className={styles.overlay} style={OVERLAY} role='dialog' aria-modal='true' aria-label='Cookie-Einstellungen'>
53
+ <div className={styles.overlay} style={OVERLAY} role='dialog' aria-modal='true' aria-label={label && !label.endsWith('cookieModal.dialogLabel') ? label : 'Cookie-Einstellungen'}>
51
54
  <div className={styles.surface} style={SURFACE}>
52
- {ModalsConfig[name] && ModalsConfig[name]({ ...modalProps, toggleModal, handleSentryInit })}
55
+ {ModalsConfig[name] && ModalsConfig[name]({ ...modalProps, toggleModal, handleSentryInit, t })}
53
56
  </div>
54
57
  </div>
55
58
  </div>,
@@ -9,19 +9,42 @@ import MaterialSwitch from '../../../MdSwitch/MdSwitch';
9
9
  import { COOKIE_SCHEMA, COOKIE_SCHEMA_LINKS } from '../../../../constants/common';
10
10
  import { updateCookieList } from '../../../../utils/CommonUtils';
11
11
  import { saveCookieConfig } from '../../../../utils/cookieConsent';
12
+ import { TranslationFunction } from '../../../../types';
12
13
 
13
14
  import styles from './ManageCookieModal.styl';
14
15
 
15
16
  interface IManageCookieModal {
16
17
  toggleModal: () => void;
17
18
  handleSentryInit?: () => void;
19
+ /** the host's `t` with the `autobahn` namespace loaded; without it the dialog stays German (fe-landing) */
20
+ t?: TranslationFunction;
18
21
  }
19
22
 
20
23
  interface IMarketingSwitches {
21
24
  [key: string]: any;
22
25
  }
23
26
 
24
- const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModal) => {
27
+ // the German copy (locales/de/autobahn.json `cookieModal`), used as is when the host passes no `t`
28
+ const DE: Record<string, string> = {
29
+ title: 'Nach den Cookies geht die Fahrt weiter.',
30
+ manageText: 'Für ein bestmögliches Nutzererlebnis setzen wir Cookies und andere Technologien ein. Diese können Sie hier verwalten.',
31
+ 'necessary.title': 'Notwendig',
32
+ 'necessary.text': 'Wir verwenden Browser-Cookies, die notwendig sind, damit die Website wie vorgesehen funktioniert. Beispiel: Wir speichern Ihre Präferenzen bei der Datenerfassung auf der Website, damit wir sie berücksichtigen können, wenn Sie auf unsere Website zurückkehren. Sie können diese Cookies in den Einstellungen Ihres Browsers deaktivieren, aber wenn Sie dies tun, funktioniert die Website möglicherweise nicht wie vorgesehen.',
33
+ 'analytics.title': 'Analytisch',
34
+ 'analytics.text': 'Um das Nutzerverhalten zu verstehen und Ihnen ein relevanteres Surferlebnis zu bieten oder den Inhalt unserer Website zu personalisieren. Beispiel: Wir sammeln Informationen darüber, welche Seiten Sie besuchen, damit wir Ihnen relevantere Informationen präsentieren können.',
35
+ 'marketing.title': 'Marketing',
36
+ 'marketing.text': 'Zur Personalisierung und Messung der Effektivität von Werbung auf unserer Website und anderen Websites. Beispiel: Wir können Ihnen eine personalisierte Werbung auf der Grundlage der von Ihnen besuchten Seiten auf unserer Website anzeigen.',
37
+ privacyPolicy: 'Datenschutzbestimmungen',
38
+ saveSelection: 'Auswahl speichern',
39
+ acceptAll: 'Alles akzeptieren'
40
+ };
41
+
42
+ const ManageCookieModal = ({ toggleModal, handleSentryInit, t } : IManageCookieModal) => {
43
+ // a key the host can't resolve (namespace not loaded) comes back as the key itself
44
+ const tr = (key: string) => {
45
+ const text = t ? t(`autobahn:cookieModal.${key}`) : '';
46
+ return text && !text.endsWith(`cookieModal.${key}`) ? text : DE[key];
47
+ };
25
48
  const [analytcisMasterSwitch, setAnalyticsMasterSwitch] = useState(false);
26
49
  const [marketingMasterSwitch, setMarketingMasterSwitch] = useState(false);
27
50
  const [analyticsSwitches, setAnalyticsSwitches] = useState<IMarketingSwitches>({});
@@ -115,34 +138,34 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
115
138
  return (
116
139
  <div className={styles.modalWrapper}>
117
140
  <IconSVG name='autodeLogo' customDimensions />
118
- <div className={styles.modalTitle}>Nach den Cookies geht die Fahrt weiter.</div>
119
- <div className={styles.modalContent}>Für ein bestmögliches Nutzererlebnis setzen wir Cookies und andere Technologien ein. Diese können Sie hier verwalten.</div>
141
+ <div className={styles.modalTitle}>{tr('title')}</div>
142
+ <div className={styles.modalContent}>{tr('manageText')}</div>
120
143
  <div className={styles.accordions}>
121
144
  <MaterialAccordionGroup
122
- title='Notwendig'
145
+ title={tr('necessary.title')}
123
146
  // tooltipText='Notwendig'
124
147
  withSwitch
125
148
  switchProps={necessarySwitchProps}
126
149
  >
127
- <span className={styles.accordionDescription}>Wir verwenden Browser-Cookies, die notwendig sind, damit die Website wie vorgesehen funktioniert. Beispiel: Wir speichern Ihre Präferenzen bei der Datenerfassung auf der Website, damit wir sie berücksichtigen können, wenn Sie auf unsere Website zurückkehren. Sie können diese Cookies in den Einstellungen Ihres Browsers deaktivieren, aber wenn Sie dies tun, funktioniert die Website möglicherweise nicht wie vorgesehen.</span>
150
+ <span className={styles.accordionDescription}>{tr('necessary.text')}</span>
128
151
  {Object.keys(COOKIE_SCHEMA.necessary).map(cookie => {
129
152
  const getLinkFromCategory = _get(COOKIE_SCHEMA_LINKS, [cookie], '');
130
153
  return (
131
154
  <div className={styles.switchBlock} key={cookie} >
132
155
  <span className={styles.switchBlockTitle}>{cookie}</span>
133
- <a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>Datenschutzbestimmungen</a>
156
+ <a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>{tr('privacyPolicy')}</a>
134
157
  <MaterialSwitch sx={{ marginLeft: 'auto' }} disabled={true} value={true} onChange={() => {}} />
135
158
  </div>
136
159
  );
137
160
  })}
138
161
  </MaterialAccordionGroup>
139
162
  <MaterialAccordionGroup
140
- title='Analytisch'
163
+ title={tr('analytics.title')}
141
164
  withSwitch
142
165
  // tooltipText='Analytisch'
143
166
  switchProps={analyticsSwitchProps}
144
167
  >
145
- <span className={styles.accordionDescription}>Um das Nutzerverhalten zu verstehen und Ihnen ein relevanteres Surferlebnis zu bieten oder den Inhalt unserer Website zu personalisieren. Beispiel: Wir sammeln Informationen darüber, welche Seiten Sie besuchen, damit wir Ihnen relevantere Informationen präsentieren können.</span>
168
+ <span className={styles.accordionDescription}>{tr('analytics.text')}</span>
146
169
  {Object.keys(COOKIE_SCHEMA.analytics).map(cookie => {
147
170
  const getItemsFromCategory = _get(COOKIE_SCHEMA, `analytics['${cookie}']`, null);
148
171
  const getLinkFromCategory = _get(COOKIE_SCHEMA_LINKS, [cookie], '');
@@ -150,7 +173,7 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
150
173
  return (
151
174
  <div className={styles.switchBlock} key={cookie} >
152
175
  <span className={styles.switchBlockTitle}>{cookie}</span>
153
- <a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>Datenschutzbestimmungen</a>
176
+ <a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>{tr('privacyPolicy')}</a>
154
177
  <MaterialSwitch
155
178
  sx={{ marginLeft: 'auto' }}
156
179
  value={isChecked}
@@ -161,12 +184,12 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
161
184
  })}
162
185
  </MaterialAccordionGroup>
163
186
  <MaterialAccordionGroup
164
- title='Marketing'
187
+ title={tr('marketing.title')}
165
188
  withSwitch
166
189
  // tooltipText='Marketing'
167
190
  switchProps={marketingSwitchProps}
168
191
  >
169
- <span className={styles.accordionDescription}>Zur Personalisierung und Messung der Effektivität von Werbung auf unserer Website und anderen Websites. Beispiel: Wir können Ihnen eine personalisierte Werbung auf der Grundlage der von Ihnen besuchten Seiten auf unserer Website anzeigen.</span>
192
+ <span className={styles.accordionDescription}>{tr('marketing.text')}</span>
170
193
  {Object.keys(COOKIE_SCHEMA.marketing).map(cookie => {
171
194
  const getItemsFromCategory = _get(COOKIE_SCHEMA, `marketing['${cookie}']`, null);
172
195
  const getLinkFromCategory = _get(COOKIE_SCHEMA_LINKS, [cookie], '');
@@ -174,7 +197,7 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
174
197
  return (
175
198
  <div className={styles.switchBlock} key={cookie} >
176
199
  <span className={styles.switchBlockTitle}>{cookie}</span>
177
- <a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>Datenschutzbestimmungen</a>
200
+ <a className={styles.switchBlockLink} href={getLinkFromCategory} target='_blank'>{tr('privacyPolicy')}</a>
178
201
  <MaterialSwitch
179
202
  sx={{ marginLeft: 'auto' }}
180
203
  value={isChecked}
@@ -186,8 +209,8 @@ const ManageCookieModal = ({ toggleModal, handleSentryInit } : IManageCookieModa
186
209
  </MaterialAccordionGroup>
187
210
  </div>
188
211
  <div className={styles.buttonsContainer}>
189
- <Button onClick={() => onAccept()} className={classNames(styles.modalBtn, styles.outlinedBtn, styles.zustimmenBtn)} >Auswahl speichern</Button>
190
- <Button onClick={() => onAccept({ marketing: [], analytics: [] })} className={classNames(styles.modalBtn, styles.zustimmenBtn)}>Alles akzeptieren</Button>
212
+ <Button onClick={() => onAccept()} className={classNames(styles.modalBtn, styles.outlinedBtn, styles.zustimmenBtn)} >{tr('saveSelection')}</Button>
213
+ <Button onClick={() => onAccept({ marketing: [], analytics: [] })} className={classNames(styles.modalBtn, styles.zustimmenBtn)}>{tr('acceptAll')}</Button>
191
214
  </div>
192
215
  </div>
193
216
  );