Skip to content

Commit 3b6e97f

Browse files
Minotriz02Minotriz02
Minotriz02
authored and
Minotriz02
committed
news style fixed
1 parent ea309b6 commit 3b6e97f

File tree

1 file changed

+51
-39
lines changed

1 file changed

+51
-39
lines changed

src/src/components/new/New.js

+51-39
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,57 @@
1-
import { Col, Row } from 'react-bootstrap';
2-
import React, { useEffect, useRef } from 'react';
3-
import './New.css';
4-
import { useTranslation } from 'react-i18next';
1+
import { Col, Row } from "react-bootstrap";
2+
import React, { useEffect, useRef } from "react";
3+
import "./New.css";
4+
import { useTranslation } from "react-i18next";
55

66
function New(props) {
7+
const hiddenElement = useRef(null);
8+
const [t, i18n] = useTranslation("global");
79

8-
const hiddenElement = useRef(null);
9-
const [t, i18n] = useTranslation("global")
10+
useEffect(() => {
11+
const observer = new IntersectionObserver((entries) => {
12+
entries.forEach((entry) => {
13+
if (entry.isIntersecting) {
14+
setTimeout(() => {
15+
entry.target.classList.add("show-news");
16+
}, props.delay);
17+
}
18+
});
19+
});
1020

11-
useEffect(() => {
12-
const observer = new IntersectionObserver((entries) => {
13-
entries.forEach((entry) => {
14-
if (entry.isIntersecting) {
15-
setTimeout(() => {
16-
entry.target.classList.add('show-news');
17-
}, props.delay);
18-
}
19-
});
20-
});
21-
22-
observer.observe(hiddenElement.current);
23-
return () => {
24-
observer.disconnect();
25-
};
26-
}, []);
27-
return (
28-
<a href={props.link} target="_blank" rel="noreferrer" className='link-news '>
29-
<Row style={{}} className="m-0 p-4 border-bottom border-2 hidden-news flex-column flex-lg-row" ref={hiddenElement}>
30-
<Col className='col-1'>
31-
<p className="text-muted">{props.date}</p>
32-
</Col>
33-
<Col className="p-0">
34-
<h5>{props.title}</h5>
35-
<p className="fs-6 text-wrap-balance">{i18n.language === "es" ? props.summaryEs : props.summaryEn}</p>
36-
</Col>
37-
{props.image && <Col className="align-self-center col-lg-4 col-xxl-3">
38-
<img src={props.image} alt="" className="img-fluid" />
39-
</Col>}
40-
</Row>
41-
</a>
42-
)
21+
observer.observe(hiddenElement.current);
22+
return () => {
23+
observer.disconnect();
24+
};
25+
}, []);
26+
return (
27+
<a
28+
href={props.link}
29+
target="_blank"
30+
rel="noreferrer"
31+
className="link-news "
32+
>
33+
<Row
34+
style={{}}
35+
className="m-0 p-4 border-bottom border-2 hidden-news flex-column flex-lg-row"
36+
ref={hiddenElement}
37+
>
38+
<Col className="col-1">
39+
<p className="text-muted">{props.date}</p>
40+
</Col>
41+
<Col className="p-0">
42+
<h5>{props.title}</h5>
43+
<p className="fs-6 text-wrap-balance">
44+
{i18n.language === "es" ? props.summaryEs : props.summaryEn}
45+
</p>
46+
</Col>
47+
{props.image && (
48+
<Col className="align-self-center col-lg-4 col-xxl-3 text-center ">
49+
<img src={props.image} alt="" className="img-fluid" style={{maxHeight:"200px"}} />
50+
</Col>
51+
)}
52+
</Row>
53+
</a>
54+
);
4355
}
4456

45-
export default New;
57+
export default New;

0 commit comments

Comments
 (0)