@eeacms/volto-eea-website-theme 0.7.1 → 0.7.3

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/CHANGELOG.md CHANGED
@@ -4,11 +4,21 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
- ### [0.7.1](https://github.com/eea/volto-eea-website-theme/compare/0.7.0...0.7.1) - 1 September 2022
7
+ ### [0.7.3](https://github.com/eea/volto-eea-website-theme/compare/0.7.2...0.7.3) - 22 September 2022
8
+
9
+ #### :hammer_and_wrench: Others
10
+
11
+ - Set slate StyleMenu if defined [Miu Razvan - [`6e2d8a3`](https://github.com/eea/volto-eea-website-theme/commit/6e2d8a34824f7cffc51680758e16c91c70cbcfe7)]
12
+ - Add slate StyleMenu styles [Miu Razvan - [`2863524`](https://github.com/eea/volto-eea-website-theme/commit/286352490e3413a8cbc4672c0a08d9fb9b2ac4c1)]
13
+ - Revert "fix(voltoCustom.css): Fix to work with seamless mode - refs #148213" [Alin Voinea - [`f954e02`](https://github.com/eea/volto-eea-website-theme/commit/f954e024a739c67ae390d3d5a4e397f076534388)]
14
+ ### [0.7.2](https://github.com/eea/volto-eea-website-theme/compare/0.7.1...0.7.2) - 19 September 2022
8
15
 
9
16
  #### :bug: Bug Fixes
10
17
 
11
- - fix(layoutViews): Extend instead of override - refs #151566 [Alin Voinea - [`d166ad9`](https://github.com/eea/volto-eea-website-theme/commit/d166ad9a1e662d8f8103606119ca03a5389a542f)]
18
+ - fix(header): letter case of know [David Ichim - [`ace90d9`](https://github.com/eea/volto-eea-website-theme/commit/ace90d97ad8bc4e7392f81635536631b8a9563c4)]
19
+ - fix(Header): language list output proper html code (ul, li) [Alin Voinea - [`6405531`](https://github.com/eea/volto-eea-website-theme/commit/6405531bd2480d3e109ac7f0581738310f662829)]
20
+
21
+ ### [0.7.1](https://github.com/eea/volto-eea-website-theme/compare/0.7.0...0.7.1) - 1 September 2022
12
22
 
13
23
  #### :nail_care: Enhancements
14
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-eea-website-theme",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "@eeacms/volto-eea-website-theme: Volto add-on",
5
5
  "main": "src/index.js",
6
6
  "author": "European Environment Agency: IDM2 A-Team",
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
-
3
2
  import config from '@plone/volto/registry';
4
3
 
5
4
  const CustomCSS = (props) => {
@@ -85,13 +85,20 @@ const EEAHeader = ({ pathname, token, items, history }) => {
85
85
  <Image src={eeaFlag} alt="eea flag"></Image>
86
86
  <Header.TopDropdownMenu
87
87
  text="An official website of the European Union | How do you Know?"
88
+ tabletText="EEA information systems"
88
89
  mobileText=" "
89
90
  icon="chevron down"
90
91
  aria-label="dropdown"
91
92
  className=""
92
93
  viewportWidth={width}
93
94
  >
94
- <div className="content">
95
+ <div
96
+ className="content"
97
+ role="menu"
98
+ tabIndex="0"
99
+ onClick={(evt) => evt.stopPropagation()}
100
+ onKeyDown={(evt) => evt.stopPropagation()}
101
+ >
95
102
  <p>
96
103
  All official European Union website addresses are in the{' '}
97
104
  <b>europa.eu</b> domain.
@@ -142,9 +149,14 @@ const EEAHeader = ({ pathname, token, items, history }) => {
142
149
  }
143
150
  viewportWidth={width}
144
151
  >
145
- <div className="wrapper">
152
+ <ul
153
+ className="wrapper language-list"
154
+ role="listbox"
155
+ aria-label="language switcher"
156
+ >
146
157
  {eea.languages.map((item, index) => (
147
158
  <Dropdown.Item
159
+ as="li"
148
160
  key={index}
149
161
  text={
150
162
  <span>
@@ -166,7 +178,7 @@ const EEAHeader = ({ pathname, token, items, history }) => {
166
178
  }}
167
179
  ></Dropdown.Item>
168
180
  ))}
169
- </div>
181
+ </ul>
170
182
  </Header.TopDropdownMenu>
171
183
  </Header.TopHeader>
172
184
  <Header.Main
@@ -0,0 +1,34 @@
1
+ import superagent from 'superagent';
2
+ import config from '@plone/volto/registry';
3
+ import { addHeadersFactory } from '@plone/volto/helpers/Proxy/Proxy';
4
+
5
+ /**
6
+ * Get a resource image/file with authenticated (if token exist) API headers
7
+ * @function getBackendResourceWithAuth
8
+ * @param {Object} req Request object
9
+ * @return {string} The response with the image
10
+ */
11
+ export const getBackendResourceWithAuth = (req) =>
12
+ new Promise((resolve, reject) => {
13
+ const { settings } = config;
14
+
15
+ let apiPath = '';
16
+ if (settings.internalApiPath && __SERVER__) {
17
+ apiPath = settings.internalApiPath;
18
+ } else if (__DEVELOPMENT__ && settings.devProxyToApiPath) {
19
+ apiPath = settings.devProxyToApiPath;
20
+ } else {
21
+ apiPath = settings.apiPath;
22
+ }
23
+ const backendURL = `${apiPath}${req.path}`;
24
+ const request = superagent
25
+ .get(backendURL)
26
+ .maxResponseSize(settings.maxResponseSize)
27
+ .responseType('blob');
28
+ const authToken = req.universalCookies.get('auth_token');
29
+ if (authToken) {
30
+ request.set('Authorization', `Bearer ${authToken}`);
31
+ }
32
+ request.use(addHeadersFactory(req));
33
+ request.then(resolve).catch(reject);
34
+ });
package/src/index.js CHANGED
@@ -7,7 +7,9 @@ import { TokenWidget } from '@eeacms/volto-eea-website-theme/components/theme/Wi
7
7
  import HomePageView from '@eeacms/volto-eea-website-theme/components/theme/Homepage/HomePageView';
8
8
  import HomePageInverseView from '@eeacms/volto-eea-website-theme/components/theme/Homepage/HomePageInverseView';
9
9
  import { Icon } from '@plone/volto/components';
10
+ import paintSVG from '@plone/volto/icons/paint.svg';
10
11
  import contentBoxSVG from './icons/content-box.svg';
12
+ import voltoCustomMiddleware from './middleware/voltoCustom';
11
13
 
12
14
  const applyConfig = (config) => {
13
15
  // EEA specific settings
@@ -48,6 +50,15 @@ const applyConfig = (config) => {
48
50
  config.widgets.views.widget.tags = TokenWidget;
49
51
  }
50
52
 
53
+ // voltoCustom.css express-middleware
54
+ if (__SERVER__) {
55
+ const express = require('express');
56
+ config.settings.expressMiddleware = [
57
+ ...(config.settings.expressMiddleware || []),
58
+ voltoCustomMiddleware(express),
59
+ ];
60
+ }
61
+
51
62
  // InPage navigation, Custom CSS voltoCustom.css and Draft Background
52
63
  config.settings.appExtras = [
53
64
  ...(config.settings.appExtras || []),
@@ -65,6 +76,35 @@ const applyConfig = (config) => {
65
76
  },
66
77
  ];
67
78
 
79
+ // Slate StyleMenu configuration
80
+ if (config.settings.slate) {
81
+ config.settings.slate.styleMenu = {
82
+ ...(config.settings.slate.styleMenu || {}),
83
+ blockStyles: [
84
+ {
85
+ cssClass: 'primary',
86
+ label: 'Primary',
87
+ icon: () => <Icon name={paintSVG} size="18px" />,
88
+ },
89
+ {
90
+ cssClass: 'secondary',
91
+ label: 'Secondary',
92
+ icon: () => <Icon name={paintSVG} size="18px" />,
93
+ },
94
+ {
95
+ cssClass: 'tertiary',
96
+ label: 'Tertiary',
97
+ icon: () => <Icon name={paintSVG} size="18px" />,
98
+ },
99
+ {
100
+ cssClass: 'bordered',
101
+ label: 'Bordered',
102
+ icon: () => <Icon name={paintSVG} size="18px" />,
103
+ },
104
+ ],
105
+ };
106
+ }
107
+
68
108
  // Custom block styles
69
109
  config.settings.previewText = '';
70
110
  config.settings.pluggableStyles = [
@@ -0,0 +1,41 @@
1
+ import { getBackendResourceWithAuth } from '@eeacms/volto-eea-website-theme/helpers';
2
+
3
+ const HEADERS = [
4
+ 'Accept-Ranges',
5
+ 'Cache-Control',
6
+ 'Content-Disposition',
7
+ 'Content-Range',
8
+ 'Content-Type',
9
+ ];
10
+
11
+ function voltoCustomMiddleware(req, res, next) {
12
+ getBackendResourceWithAuth(req)
13
+ .then((resource) => {
14
+ // Just forward the headers that we need
15
+ HEADERS.forEach((header) => {
16
+ if (resource.get(header)) {
17
+ res.set(header, resource.get(header));
18
+ }
19
+ });
20
+ res.status(resource.statusCode);
21
+ res.send(resource.body);
22
+ })
23
+ .catch((resource) => {
24
+ HEADERS.forEach((header) => {
25
+ if (resource.get(header)) {
26
+ res.set(header, resource.get(header));
27
+ }
28
+ });
29
+ res.status(200);
30
+ res.send(
31
+ '/* Override this by adding a File called voltoCustom.css to backend at portal_skins/custom/manage_main */',
32
+ );
33
+ });
34
+ }
35
+
36
+ export default function (express) {
37
+ const middleware = express.Router();
38
+ middleware.all(['**/voltoCustom.css$'], voltoCustomMiddleware);
39
+ middleware.id = 'voltoCustom.css';
40
+ return middleware;
41
+ }