Skip to content

Commit f9e2baa

Browse files
committed
Merge branch 'dev' of github.com:ec-europa/ecl-ssg into eu-playground
2 parents 1e985c3 + 04c2ea5 commit f9e2baa

File tree

12 files changed

+22
-169
lines changed

12 files changed

+22
-169
lines changed

gatsby-browser.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React, { useEffect } from "react";
2+
import CustomTheme from "./src/components/Utils/theme";
3+
4+
const ThemeInjector = ({ children }) => {
5+
const theme = CustomTheme();
6+
7+
useEffect(() => {
8+
document.documentElement.setAttribute("data-ecl-theme", theme);
9+
}, [theme]);
10+
11+
return children;
12+
};
13+
14+
export const wrapRootElement = ({ element }) => (
15+
<ThemeInjector>{element}</ThemeInjector>
16+
);

src/components/Breadcrumb.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import { useLocation } from '@reach/router';
33
import { graphql, useStaticQuery } from 'gatsby';
4-
import CustomTheme from './Utils/theme';
54
import Languages from './Languages';
65

76
const Breadcrumb = () => {
@@ -33,7 +32,6 @@ const Breadcrumb = () => {
3332
<ecl-breadcrumb-item
3433
key={index}
3534
path={isLastItem ? null : path}
36-
theme={theme}
3735
current-page={isLastItem ? 'true' : null}
3836
>
3937
{label}
@@ -42,8 +40,8 @@ const Breadcrumb = () => {
4240
});
4341

4442
return (
45-
<ecl-breadcrumb slot="breadcrumb" variant={theme === 'ec' ? 'breadcrumbVariant' : 'default'} theme={theme} ecl-script>
46-
<ecl-breadcrumb-item path="/" theme={theme}>
43+
<ecl-breadcrumb slot="breadcrumb" ecl-script>
44+
<ecl-breadcrumb-item path="/">
4745
{title}
4846
</ecl-breadcrumb-item>
4947
{breadcrumbItems}

src/components/Head.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from "react";
2-
import CustomTheme from "./Utils/theme"
2+
import CustomTheme from "./Utils/theme";
33

44
export const Head: React.FC = () => {
55
const theme = CustomTheme();

src/components/InPageNavigation.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const InPageNavigation = forwardRef((props, ref) => {
2424
{...props}
2525
ref={ref}
2626
inpage-title={t('Page contents')}
27-
theme={theme}
2827
ecl-script
2928
inpage-id={Math.random().toString(36).substring(2)}
3029
>

src/components/LanguageSwitcher.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { useStaticQuery, graphql } from 'gatsby';
33
import { useLocation } from '@reach/router';
44
import { useTranslation } from 'react-i18next';
55

6-
import CustomTheme from './Utils/theme';
76
import getLang from './Utils/getLang';
87
import Languages from './Languages';
98

@@ -15,7 +14,6 @@ const LanguageSwitcher = () => {
1514
const { pathname } = useLocation();
1615
const languagePrefix = pathname.split('/')[1];
1716
const path = languagePrefix ? pathname.replace(`/${languagePrefix}/`, '/') : 'home';
18-
const theme = CustomTheme();
1917

2018
const handleLanguageChange = (language) => {
2119
i18n.changeLanguage(language);
@@ -25,7 +23,6 @@ const LanguageSwitcher = () => {
2523
<>
2624
{langCodes.map((language, index) => (
2725
<ecl-language-item
28-
theme={theme}
2926
slot="eu-category"
3027
path={`/${language}/${path}`}
3128
lang-code={language}

src/components/Layout.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { useStaticQuery, graphql } from 'gatsby';
33
import { I18nextProvider } from 'react-i18next';
44
import i18n from '../i18n';
55

6-
import CustomTheme from './Utils/theme';
76
import getLang from './Utils/getLang';
87

98
import SiteHeader from './SiteHeader';
@@ -15,7 +14,6 @@ interface LayoutProps {
1514

1615
const Layout: React.FC<LayoutProps> = ({ children, pageHeader }) => {
1716
const lang = getLang();
18-
const theme = CustomTheme();
1917

2018
return (
2119
<I18nextProvider i18n={i18n}>

src/components/Menu.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import { useStaticQuery, graphql } from 'gatsby';
3-
import CustomTheme from './Utils/theme';
43
import ReactHtmlParser from 'react-html-parser';
54
import stripPTag from './Utils/stripP';
65
import getLang from './Utils/getLang';
@@ -9,7 +8,6 @@ import { useTranslation } from 'react-i18next';
98
const Menu = () => {
109
const { t } = useTranslation();
1110
const language = getLang();
12-
const theme = CustomTheme();
1311
const data = useStaticQuery(graphql`
1412
query {
1513
menuItems: allMarkdownRemark(
@@ -70,7 +68,6 @@ const Menu = () => {
7068
) : (
7169
<ecl-menu
7270
slot="menu"
73-
theme={theme}
7471
close-label={t('Close')}
7572
back-label={t('Back')}
7673
menu-link="/example"
@@ -82,7 +79,6 @@ const Menu = () => {
8279
link={`/${language}/${
8380
page.fields.customPath || page.fields.slug.replace(`/${language}/`, '').slice(0, -1)
8481
}/`}
85-
theme={theme}
8682
key={`menu-item-${index}`}
8783
>
8884
{page.frontmatter.title}

src/components/SearchForm.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ const SearchForm: React.FC = () => {
2222
<EclSearchForm
2323
id="ecl-site-header-search-form"
2424
onSubmit={handleSearch}
25-
theme={theme}
2625
input-id="ecl-search-form"
2726
width="m"
2827
placeholder={t('Placeholder text')}

src/components/SearchResults.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ const SearchResults: React.FC<SearchResultsProps> = ({ searchQuery, searchResult
2222
return (
2323
<>
2424
<ecl-spacing value="l" direction="t"></ecl-spacing>
25-
<ecl-text level="1">Search Results</ecl-text>
25+
<ecl-text tag="h1">Search Results</ecl-text>
2626
<ecl-spacing value="m" direction="b"></ecl-spacing>
2727
<ecl-text>Search Query: {searchQuery}</ecl-text>
2828
<ul>
2929
{searchResults.map((result) => (
3030
<li key={result.slug}>
3131
<Link to={result.slug}>
32-
<ecl-text level="3" bold> {highlightSearchQuery(result.title)}</ecl-text>
32+
<ecl-text tag="h3" weight="bold"> {highlightSearchQuery(result.title)}</ecl-text>
3333
</Link>
3434
{highlightSearchQuery(result.content)}
3535
</li>

src/components/SiteHeader.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ const SiteHeader = () => {
4646
) : (
4747
<ecl-site-header
4848
ecl-script
49-
theme={theme}
5049
language-block
5150
search-block="false"
5251
language={languages[lang]}
@@ -64,9 +63,7 @@ const SiteHeader = () => {
6463
<LanguageSwitcher />
6564
<Menu />
6665
<div slot="search" className={`ecl-site-header__search-container sc-ecl-search-form-${theme}`}>
67-
<Search
68-
theme={theme}
69-
/>
66+
<Search />
7067
</div>
7168
</ecl-site-header>
7269
)}

0 commit comments

Comments
 (0)