@eeacms/volto-datahub 1.0.20 → 1.0.21
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 +5 -0
- package/package.json +1 -1
- package/src/components/ItemView/ItemView.jsx +38 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ 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
|
+
### [1.0.21](https://github.com/eea/volto-datahub/compare/1.0.20...1.0.21) - 15 March 2023
|
|
8
|
+
|
|
9
|
+
#### :hammer_and_wrench: Others
|
|
10
|
+
|
|
11
|
+
- Add read more for description [kreafox - [`ef255b7`](https://github.com/eea/volto-datahub/commit/ef255b731cfb5c1269006a3f611848bc244ad2bd)]
|
|
7
12
|
### [1.0.20](https://github.com/eea/volto-datahub/compare/1.0.19...1.0.20) - 14 March 2023
|
|
8
13
|
|
|
9
14
|
#### :hammer_and_wrench: Others
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { Portal } from 'react-portal';
|
|
3
3
|
import { useDispatch, useSelector } from 'react-redux';
|
|
4
4
|
import { Link, useLocation } from 'react-router-dom';
|
|
5
|
-
import { Container, Icon } from 'semantic-ui-react';
|
|
5
|
+
import { Container, Icon, Button } from 'semantic-ui-react';
|
|
6
6
|
import { Toolbar } from '@plone/volto/components';
|
|
7
7
|
import { BodyClass } from '@plone/volto/helpers';
|
|
8
8
|
import config from '@plone/volto/registry';
|
|
@@ -21,6 +21,21 @@ import { setDatahubResult } from '@eeacms/volto-datahub/store';
|
|
|
21
21
|
import { isObsolete } from './utils.js';
|
|
22
22
|
|
|
23
23
|
const appName = 'datahub';
|
|
24
|
+
const WORD_COUNT = 60;
|
|
25
|
+
|
|
26
|
+
const splitContent = (content, wordCount) => {
|
|
27
|
+
const words = content.split(' ');
|
|
28
|
+
let firstTextPart = '',
|
|
29
|
+
secondTextPart = '';
|
|
30
|
+
words.forEach((word, idx) => {
|
|
31
|
+
if (idx < wordCount) {
|
|
32
|
+
firstTextPart += ' ' + word;
|
|
33
|
+
} else {
|
|
34
|
+
secondTextPart += ' ' + word;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
return [firstTextPart.trim(), secondTextPart.trim()];
|
|
38
|
+
};
|
|
24
39
|
|
|
25
40
|
function IsomorphicPortal({ children }) {
|
|
26
41
|
const [isClient, setIsClient] = React.useState();
|
|
@@ -75,6 +90,13 @@ function ItemView(props) {
|
|
|
75
90
|
|
|
76
91
|
const rawTitle = item && item._meta.found ? title?.raw || '' : docid;
|
|
77
92
|
|
|
93
|
+
const splitDescription = description?.raw.split(' ').length > WORD_COUNT;
|
|
94
|
+
const [firstTextPart, secondTextPart] = splitContent(
|
|
95
|
+
description?.raw,
|
|
96
|
+
WORD_COUNT,
|
|
97
|
+
);
|
|
98
|
+
const [isReadMore, setIsReadMore] = React.useState(false);
|
|
99
|
+
|
|
78
100
|
React.useEffect(() => {
|
|
79
101
|
const handler = async () => {
|
|
80
102
|
if (item) {
|
|
@@ -139,7 +161,21 @@ function ItemView(props) {
|
|
|
139
161
|
</IsomorphicPortal>
|
|
140
162
|
|
|
141
163
|
<div className="dataset-container">
|
|
142
|
-
<Callout>
|
|
164
|
+
<Callout>
|
|
165
|
+
{splitDescription ? (
|
|
166
|
+
<p>
|
|
167
|
+
{firstTextPart} {isReadMore ? secondTextPart : ''}
|
|
168
|
+
<Button
|
|
169
|
+
onClick={() => setIsReadMore(!isReadMore)}
|
|
170
|
+
className={`see-more ${isReadMore ? 'open' : 'close'}`}
|
|
171
|
+
>
|
|
172
|
+
{isReadMore ? 'See less' : ' See more'}
|
|
173
|
+
</Button>
|
|
174
|
+
</p>
|
|
175
|
+
) : (
|
|
176
|
+
<p>{description?.raw}</p>
|
|
177
|
+
)}
|
|
178
|
+
</Callout>
|
|
143
179
|
</div>
|
|
144
180
|
|
|
145
181
|
<DatasetsView item={item} appConfig={appConfig} />
|