-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfigContext.ts
More file actions
153 lines (150 loc) · 4.76 KB
/
Copy pathconfigContext.ts
File metadata and controls
153 lines (150 loc) · 4.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import type React from 'react';
import { createContext } from 'react';
import type { ApolloClient, NormalizedCacheObject } from '@apollo/client';
import type { ButtonPresetTheme, ButtonTheme, ButtonVariant } from 'hds-react';
import type {
ArticleType,
LanguageCodeEnum,
PageType,
} from '../../common/headlessService/types';
import type { ModuleItemTypeEnum } from '../../common/headlessService/constants';
import type { EventType } from '../../common/eventsService/types';
import type { VenueType } from '../../common/venuesService/types';
import type { CardProps } from '../card/Card';
import type { HtmlToReactProps } from '../../common/components/htmlToReact/HtmlToReact';
import type {
FallbackTranslations,
OptionalTranslationsWithFallbacks,
} from '../translation/types';
import { defaultConfig } from './defaultConfig';
export type Config = {
/**
* Site or App name.
*/
siteName: string;
/**
* Id of the html element where SkipTo link will point.
*/
mainContentId?: string;
/**
* Internal origins for generating correct urls for app routing.
*/
internalHrefOrigins: string[];
/**
* List of organizations for additional UI highlights (f.e. check icon after title if its Helsinki specific item).
*/
organisationPrefixes: string[];
/**
* Current language code of the app.
*/
currentLanguageCode: LanguageCodeEnum;
/**
* Fallback image urls. Used if image is not defined, but imaage is still required in the component.
*/
fallbackImageUrls: string[];
/**
* Fallback translations.
*/
fallbackTranslations: FallbackTranslations;
/**
* Translated texts which are needed to render components properly.
*/
copy: {
breadcrumbNavigationLabel: string;
breadcrumbListLabel: string;
menuButtonLabel: string;
menuToggleAriaLabel: string;
skipToContentLabel: string;
openInExternalDomainAriaLabel: string;
openInNewTabAriaLabel: string;
closeButtonLabelText: string;
loadMoreButtonLabelText: string;
showAllText: string;
next: string;
previous: string;
archiveSearch?: {
title: string;
searchTextPlaceholder: string;
searchButtonLabelText: string;
loadMoreButtonLabelText: string;
noResultsTitle: string;
noResultsText: string;
clearAll: string;
};
} & OptionalTranslationsWithFallbacks;
/**
* Custom translated texts which are needed to render components properly.
* Used when for technical reasons the use of the copy property is not possible.
*/
customCopy?: {
loadMoreButtonVariant?: Exclude<ButtonVariant, 'supplementary'>;
loadMoreButtonTheme?: ButtonTheme | ButtonPresetTheme;
};
/**
* React component replacements for defined html elements.
*/
components: {
A: (
props: React.AnchorHTMLAttributes<HTMLAnchorElement>,
) => React.JSX.Element;
Img: (
props: React.ImgHTMLAttributes<HTMLImageElement>,
) => React.JSX.Element;
Link?: (
props: React.AnchorHTMLAttributes<HTMLAnchorElement>,
) => React.JSX.Element;
Head?: (props: { children: React.ReactNode }) => React.JSX.Element;
EventCardContent?: React.FC<Record<string, unknown>>;
VenueCardContent?: React.FC<Record<string, unknown>>;
ArticleCardContent?: React.FC<Record<string, unknown>>;
HelsinkiCityOwnedIcon?: React.FC<Record<string, unknown>>;
};
/**
* Apollo client to make gql calls to headless cms.
*/
apolloClient?: ApolloClient<NormalizedCacheObject>;
/**
* Apollo client to make gql calls to linked events.
*/
eventsApolloClient?: ApolloClient<NormalizedCacheObject> | 'disabled';
/**
* Apollo client to make gql calls to venues search.
*/
venuesApolloClient?: ApolloClient<NormalizedCacheObject> | 'disabled';
/**
* Utilities custom implementation provided by apps (app specific).
*/
utils: {
getArticlePageCardProps: (item: ArticleType | PageType) => CardProps;
getEventCardProps: (
item: EventType,
organisationPrefixes: string[],
locale: string,
) => CardProps;
getLocationCardProps: (item: VenueType) => CardProps;
getIsHrefExternal: (href: string) => boolean;
getRoutedInternalHref: (
link: string | null | undefined,
type?: ModuleItemTypeEnum,
) => string;
redirectToUrl: (url: string) => void;
redirectToArticlesSearch?: (tag: string) => void;
};
/**
* Meta data for the Head components.
*/
meta?: {
appleTouchIconUrl?: string;
favIconUrl?: string;
favIconSvgUrl?: string;
manifestUrl?: string;
};
/**
* App specific html sanitising configs for html editors.
*/
htmlSanitizer: {
allowedUnsafeTags: HtmlToReactProps['allowedUnsafeTags'];
trustedOrigins: HtmlToReactProps['trustedOrigins'];
};
};
export const ConfigContext = createContext<Config>(defaultConfig);