Skip to content

Commit 7f0b0f7

Browse files
committed
feat: integrate editoria11y web component into pdc & vth frontends
1 parent 268d5f0 commit 7f0b0f7

11 files changed

Lines changed: 1312 additions & 648 deletions

File tree

apps/pdc-frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"watch:e2e": "playwright --help test test/e2e/"
2727
},
2828
"dependencies": {
29+
"@frameless/editoria11y": "0.1.0",
2930
"@frameless/ui": "0.1.2",
3031
"@frameless/utils": "0.1.0",
3132
"@nl-design-system-unstable/documentation": "1.1.0",

apps/pdc-frontend/src/app/[locale]/(openFormsLayout)/layout.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import '@utrecht/design-tokens/dist/index.css';
3131
import { Main } from '@/components/Main';
3232
import { SearchBar } from '@/components/SearchBar';
3333
import 'react-loading-skeleton/dist/skeleton.css';
34+
import { Editoria11yWrapper } from '@/lib/stencil-client';
3435
import { GET_OPEN_FORMS_TEMPLATE } from '@/query';
3536
import { buildAlternateLinks, config, fetchData, getStrapiGraphqlURL } from '@/util';
3637
import { ComponentComponentsUtrechtNavigation, GetTemplateDataQuery } from '../../../../gql/graphql';
@@ -56,6 +57,7 @@ type Params = {
5657
export async function generateMetadata({ params: { locale } }: Params): Promise<Metadata> {
5758
// eslint-disable-next-line react-hooks/rules-of-hooks
5859
const { t } = await useTranslation(locale, 'common');
60+
const nonce = headers().get('x-nonce') || '';
5961
const url = buildURL({
6062
env: process.env,
6163
key: 'FRONTEND_PUBLIC_URL',
@@ -110,6 +112,9 @@ export async function generateMetadata({ params: { locale } }: Params): Promise<
110112
...buildAlternateLinks({ languages, segment: '/' }),
111113
},
112114
},
115+
other: {
116+
'csp-nonce': nonce,
117+
},
113118
};
114119
}
115120

@@ -183,6 +188,7 @@ const RootLayout = async ({ children, params: { locale } }: LayoutProps) => {
183188
)}
184189
<QueryClientProvider>
185190
<Surface>
191+
{isEnabled && <Editoria11yWrapper />}
186192
<Page className="utrecht-custom-page">
187193
<PageHeader className="utrecht-custom-header">
188194
<SkipLink href="#main">{t('components.skip-link.main')}</SkipLink>

apps/pdc-frontend/src/app/[locale]/(rootLayout)/layout.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
import { GoogleTranslate } from '@/components/GoogleTranslate';
3030
import { Main } from '@/components/Main';
3131
import { SearchBar } from '@/components/SearchBar';
32+
import { Editoria11yWrapper } from '@/lib/stencil-client';
3233
import { GET_TEMPLATE } from '@/query';
3334
import { buildAlternateLinks, config, fetchData, getStrapiGraphqlURL } from '@/util';
3435
import {
@@ -61,6 +62,7 @@ type Params = {
6162
export async function generateMetadata({ params: { locale } }: Params): Promise<Metadata> {
6263
// eslint-disable-next-line react-hooks/rules-of-hooks
6364
const { t } = await useTranslation(locale, 'common');
65+
const nonce = headers().get('x-nonce') || '';
6466
const url = buildURL({
6567
env: process.env,
6668
key: 'FRONTEND_PUBLIC_URL',
@@ -115,6 +117,9 @@ export async function generateMetadata({ params: { locale } }: Params): Promise<
115117
...buildAlternateLinks({ languages, segment: '/' }),
116118
},
117119
},
120+
other: {
121+
'csp-nonce': nonce,
122+
},
118123
};
119124
}
120125

@@ -164,6 +169,8 @@ const RootLayout = async ({ children, params: { locale } }: LayoutProps) => {
164169
<QueryClientProvider>
165170
<GoogleTranslate />
166171
<Surface>
172+
{isEnabled && <Editoria11yWrapper />}
173+
167174
<Page className="utrecht-custom-page">
168175
<PageHeader className="utrecht-custom-header">
169176
<SkipLink href="#main">{t('components.skip-link.main')}</SkipLink>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use client';
2+
import { defineCustomElements } from '@frameless/editoria11y/loader';
3+
import { createElement, useEffect, useState } from 'react';
4+
5+
export const Editoria11yWrapper = () => {
6+
const [nonce, setNonce] = useState<string>('');
7+
8+
useEffect(() => {
9+
defineCustomElements(window);
10+
// Get nonce from meta tag or document
11+
const nonceValue = document.querySelector('meta[name="csp-nonce"]')?.getAttribute('content') || '';
12+
setNonce(nonceValue);
13+
}, []);
14+
15+
return createElement('frameless-editoria11y', {
16+
theme: 'darkTheme',
17+
language: 'nl',
18+
nonce: nonce,
19+
});
20+
};

apps/vth-frontend/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"lint-build": "tsc --noEmit --project tsconfig.json"
1717
},
1818
"dependencies": {
19+
"@frameless/editoria11y": "0.1.0",
1920
"@frameless/ui": "0.1.2",
2021
"@tanstack/react-query": "4.29.25",
2122
"@utrecht/component-library-css": "4.2.0",
@@ -34,8 +35,7 @@
3435
"react-dom": "18.3.1",
3536
"react-i18next": "12.3.1",
3637
"react-loading-skeleton": "3.3.1",
37-
"sharp": "0.32.6",
38-
"editoria11y": "github:itmaybejj/editoria11y#2.2.4"
38+
"sharp": "0.32.6"
3939
},
4040
"devDependencies": {
4141
"eslint": "8.35.0",

apps/vth-frontend/src/app/[locale]/(nestedNavLayout)/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { Footer, FooterData, Page, PreviewAlert, Surface } from '@/components';
1010
import '@utrecht/component-library-css';
1111
import '@utrecht/design-tokens/dist/index.css';
1212
import 'react-loading-skeleton/dist/skeleton.css';
13-
import { Editoria11y } from '@/components/Editoria11y';
1413
import '@frameless/ui/dist/bundle.css';
1514
import '../../../styles/globals.css';
15+
import { Editoria11yWrapper } from '@/lib/stencil-client';
1616

1717
interface LayoutProps {
1818
children: React.ReactNode;
@@ -124,7 +124,7 @@ const RootLayout = async ({ children, params: { locale } }: LayoutProps) => {
124124
<QueryClientProvider>
125125
<Surface>
126126
<Page className="utrecht-page--full-width">
127-
{isEnabled && <Editoria11y />}
127+
{isEnabled && <Editoria11yWrapper />}
128128
{children}
129129
</Page>
130130
</Surface>

apps/vth-frontend/src/app/[locale]/(rootLayout)/layout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { Footer, FooterData, Header, Page, PreviewAlert, Surface } from '@/compo
1010
import '@utrecht/component-library-css';
1111
import '@utrecht/design-tokens/dist/index.css';
1212
import 'react-loading-skeleton/dist/skeleton.css';
13-
import { Editoria11y } from '@/components/Editoria11y';
1413
import { Main } from '@/components/Main';
14+
import { Editoria11yWrapper } from '@/lib/stencil-client';
1515
import { config } from '@/util';
1616
import { getNavData } from '@/util/getNavData';
1717
import '@frameless/ui/dist/bundle.css';
@@ -138,7 +138,7 @@ const RootLayout = async ({ children, params: { locale } }: LayoutProps) => {
138138
}) || '',
139139
}}
140140
/>
141-
{isEnabled && <Editoria11y />}
141+
{isEnabled && <Editoria11yWrapper />}
142142
<Main id="main">{children}</Main>
143143
</Page>
144144
</Surface>

apps/vth-frontend/src/components/Editoria11y/index.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use client';
2+
import { defineCustomElements } from '@frameless/editoria11y/loader';
3+
import { createElement, useEffect } from 'react';
4+
5+
export const Editoria11yWrapper = () => {
6+
useEffect(() => {
7+
defineCustomElements(window);
8+
}, []);
9+
return createElement('frameless-editoria11y', {
10+
theme: 'darkTheme',
11+
language: 'nl',
12+
});
13+
};

0 commit comments

Comments
 (0)