Skip to content

Commit 51528a2

Browse files
Merge pull request #376 from bitlogic/dev
Fix set charset to UTF-8
2 parents c94a3f3 + 0ec3527 commit 51528a2

File tree

11 files changed

+269
-53
lines changed

11 files changed

+269
-53
lines changed

src/components/Banners/BannerTop.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@
4040
.BannerTop {
4141
&__bgImage {
4242
min-height: 55vh;
43+
&::after {
44+
background-position: top!important;
45+
}
4346
}
4447

4548
&__titleContainer {

src/components/Footer/SocialLinks/socialLinks.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ export default function SocialLinks({ image, socialMedia }) {
1717
rel="noreferrer"
1818
aria-label={`Link externo a ${item?.name}`}
1919
>
20-
<FaIcon type={item.icon?.type} code={item.icon?.code} />
20+
<>
21+
<FaIcon type={item.icon?.type} code={item.icon?.code} />
22+
<span className="visually-hidden">Link a {item.name}</span>
23+
</>
2124
</a>
2225
))
2326

src/components/Footer/SocialLinks/socialLinks.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
color: $white;
1111
width: 21px;
1212
height: 21px;
13+
display: inline-flex;
14+
align-items: center;
15+
justify-content: center;
1316
}
1417
}
1518

@@ -31,3 +34,15 @@
3134
}
3235
}
3336
}
37+
38+
.visually-hidden {
39+
position: absolute !important;
40+
width: 1px !important;
41+
height: 1px !important;
42+
padding: 0 !important;
43+
margin: -1px !important;
44+
overflow: hidden !important;
45+
clip: rect(0, 0, 0, 0) !important;
46+
white-space: nowrap !important;
47+
border: 0 !important;
48+
}

src/components/NavBar/AnimatedNavBar/DropdownContainer/dropdownItems.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,6 @@
108108
list-style: none;
109109
}
110110

111-
.two-column-list li:nth-child(1n+11) {
112-
display: none; /* Oculta los elementos que superen el límite de 10 */
113-
}
114-
115111
.dropdownItem_icon {
116112
display: none;
117113
}

src/components/videoBackground/VideoBackground.js

Lines changed: 137 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import CustomLink from "../CustomLink/CustomLink"
44
import PropTypes from "prop-types"
55
import { GatsbyImage, getImage } from "gatsby-plugin-image"
66

7-
// ✅ CAMBIO: detectar versión de iOS
87
function getIOSVersion() {
98
if (typeof window === "undefined" || typeof navigator === "undefined") return null
109
const userAgent = navigator.userAgent
@@ -25,6 +24,39 @@ function isIOSPriorTo(version) {
2524
if (currentVersion.major > majorVersion) return false
2625
return currentVersion.minor < minorVersion
2726
}
27+
function getQS(name) {
28+
if (typeof window === "undefined") return null
29+
return new URLSearchParams(window.location.search).get(name)
30+
}
31+
32+
33+
function resolvePoster(poster, image) {
34+
const posterLocal =
35+
poster?.localFile ||
36+
poster?.data?.attributes?.localFile ||
37+
null
38+
const sharp = posterLocal ? getImage(posterLocal) : null
39+
40+
const rawUrl =
41+
poster?.url ||
42+
poster?.data?.attributes?.url ||
43+
poster?.formats?.large?.url ||
44+
poster?.formats?.medium?.url ||
45+
poster?.formats?.small?.url ||
46+
poster?.formats?.thumbnail?.url ||
47+
null
48+
49+
const toAbs = u =>
50+
!u ? null : (u.startsWith("http")
51+
? u
52+
: `https://strapi-s3-bitlogic.s3.sa-east-1.amazonaws.com${u}`)
53+
54+
const url = toAbs(rawUrl)
55+
56+
const imageSharp = image?.localFile ? getImage(image.localFile) : null
57+
58+
return { sharp: sharp || imageSharp, url }
59+
}
2860

2961
function getVideoContent(
3062
video,
@@ -36,29 +68,14 @@ function getVideoContent(
3668
image,
3769
posterData
3870
) {
39-
const posterUrl = posterData?.url?.startsWith("http")
40-
? getImage(posterData.url)
41-
: getImage(`https://strapi-s3-bitlogic.s3.sa-east-1.amazonaws.com${posterData?.url}`)
42-
const posterSharp = posterData?.localFile && getImage(posterData.localFile)
71+
const { sharp: pSharp, url: pUrl } = resolvePoster(posterData, image)
72+
const posterUrl = pUrl || pSharp?.images?.fallback?.src
4373

4474
const url = videoUrl?.replace("watch?v=", "embed/")
4575
let code = url?.substring(url.lastIndexOf("/") + 1) || ""
4676
const codeIndex = code.indexOf("?")
4777
if (codeIndex !== -1) code = code.substring(0, codeIndex)
4878

49-
const isOldIOS = isIOSPriorTo("17.4")
50-
if (isOldIOS && posterSharp) {
51-
return (
52-
<GatsbyImage
53-
className="video-poster"
54-
image={posterSharp}
55-
alt={posterData.alternativeText || "Video poster"}
56-
loading="eager"
57-
style={{ width: "100%", maxWidth: "100vw", height: "auto" }}
58-
/>
59-
)
60-
}
61-
6279
if (video?.url) {
6380
return (
6481
<video
@@ -100,8 +117,8 @@ function getVideoContent(
100117
allowFullScreen
101118
title="benefits_video"
102119
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
103-
webkitallowfullscreen
104-
mozallowfullscreen
120+
webkitallowfullscreen="true"
121+
mozallowfullscreen="true"
105122
style={{
106123
width: "100%",
107124
maxWidth: "100vw",
@@ -115,12 +132,12 @@ function getVideoContent(
115132
)
116133
}
117134

118-
if (posterSharp) {
135+
if (pSharp) {
119136
return (
120137
<GatsbyImage
121138
className="video-poster"
122-
image={posterSharp}
123-
alt={posterData.alternativeText || "Video poster"}
139+
image={pSharp}
140+
alt={posterData?.alternativeText || "Video poster"}
124141
loading="eager"
125142
style={{ width: "100%", maxWidth: "100vw", height: "auto" }}
126143
/>
@@ -141,6 +158,12 @@ const VideoBackground = ({ data }) => {
141158
poster,
142159
} = data
143160

161+
const forced = getQS("forceOldIOS") === "1"
162+
const initialIsOldIOS =
163+
forced ||
164+
(typeof navigator !== "undefined" && /iPhone/.test(navigator.userAgent) && isIOSPriorTo("17.4"))
165+
const [isOldIOS] = useState(initialIsOldIOS)
166+
144167
const [isVideoPause, setIsVideoPause] = useState(false)
145168
const [isIntersecting, setIsIntersecting] = useState(false)
146169
const videoRef = useRef(null)
@@ -157,10 +180,12 @@ const VideoBackground = ({ data }) => {
157180
pausePlay()
158181
}
159182
}
160-
161183
useEffect(() => {
184+
if (isOldIOS) return
185+
162186
const elem = videoRef.current
163187
if (!elem) return
188+
164189
const observer = new IntersectionObserver(
165190
([entry]) => {
166191
if (entry.isIntersecting) {
@@ -172,11 +197,83 @@ const VideoBackground = ({ data }) => {
172197
)
173198
observer.observe(elem)
174199
return () => observer.disconnect()
175-
}, [])
200+
}, [isOldIOS])
176201

177202
useEffect(() => {
178203
localStorage.setItem("videoPaused", isVideoPause)
179204
}, [isVideoPause])
205+
if (isOldIOS) {
206+
const { sharp: posterSharp, url: posterFromUrl } = resolvePoster(poster, image)
207+
208+
return (
209+
<div
210+
style={{
211+
backgroundImage: backgroundImage ? `url(${backgroundImage.url})` : "",
212+
backgroundRepeatY: "no-repeat",
213+
backgroundPosition: "center",
214+
}}
215+
>
216+
<div className="container videoBackground-container">
217+
<section className="videoBackground" key="poster">
218+
{posterSharp ? (
219+
<GatsbyImage
220+
className="video-poster"
221+
image={posterSharp}
222+
alt={poster?.alternativeText || "Video poster"}
223+
loading="eager"
224+
style={{ width: "100%", maxWidth: "100vw", height: "auto" }}
225+
/>
226+
) : posterFromUrl ? (
227+
<img
228+
className="video-poster"
229+
src={posterFromUrl}
230+
alt={poster?.alternativeText || "Video poster"}
231+
loading="eager"
232+
style={{
233+
width: "100%",
234+
maxWidth: "100vw",
235+
height: "auto",
236+
display: "block",
237+
borderRadius: "5px",
238+
objectFit: "cover",
239+
aspectRatio: "16/9",
240+
}}
241+
/>
242+
) : (
243+
<div
244+
style={{
245+
width: "100%",
246+
maxWidth: "100vw",
247+
aspectRatio: "16/9",
248+
borderRadius: "5px",
249+
background: "#2e2e2e",
250+
display: "grid",
251+
placeItems: "center",
252+
color: "#ccc",
253+
fontSize: 14,
254+
}}
255+
>
256+
(sin poster disponible)
257+
</div>
258+
)}
259+
260+
{description && (
261+
<div className="videoBackground-card">
262+
<h2>{description}</h2>
263+
{button && (
264+
<CustomLink
265+
content={button.content}
266+
url={button.url}
267+
landing={button.landing_page}
268+
/>
269+
)}
270+
</div>
271+
)}
272+
</section>
273+
</div>
274+
</div>
275+
)
276+
}
180277

181278
const videoContent = getVideoContent(
182279
video,
@@ -200,7 +297,7 @@ const VideoBackground = ({ data }) => {
200297
}}
201298
>
202299
<div className="container videoBackground-container">
203-
<section className="videoBackground">
300+
<section className="videoBackground" key="video">
204301
{videoContent}
205302
{description && (
206303
<div className="videoBackground-card">
@@ -223,28 +320,35 @@ const VideoBackground = ({ data }) => {
223320
VideoBackground.propTypes = {
224321
data: PropTypes.shape({
225322
video: PropTypes.shape({
226-
url: PropTypes.string.isRequired,
227-
mime: PropTypes.string.isRequired,
323+
url: PropTypes.string,
324+
mime: PropTypes.string,
228325
}),
229326
videoUrl: PropTypes.string,
230327
description: PropTypes.string,
231-
backgroundImage: PropTypes.shape({ url: PropTypes.string.isRequired }),
328+
backgroundImage: PropTypes.shape({ url: PropTypes.string }),
232329
image: PropTypes.shape({
233330
alternativeText: PropTypes.string,
234331
localFile: PropTypes.object,
235332
}),
236333
poster: PropTypes.shape({
237-
url: PropTypes.string.isRequired,
334+
url: PropTypes.string,
238335
alternativeText: PropTypes.string,
239336
localFile: PropTypes.shape({
240-
childImageSharp: PropTypes.object.isRequired,
337+
childImageSharp: PropTypes.object,
338+
}),
339+
formats: PropTypes.object,
340+
data: PropTypes.shape({
341+
attributes: PropTypes.shape({
342+
url: PropTypes.string,
343+
localFile: PropTypes.object,
344+
}),
241345
}),
242346
}),
243347
button: PropTypes.shape({
244-
content: PropTypes.string.isRequired,
348+
content: PropTypes.string,
245349
url: PropTypes.string,
246350
landing_page: PropTypes.shape({
247-
slug: PropTypes.string.isRequired,
351+
slug: PropTypes.string,
248352
}),
249353
}),
250354
}),

src/html.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export default function HTML({
1111
return (
1212
<html {...htmlAttributes}>
1313
<head>
14+
<meta charset="utf-8" />
1415
{headComponents}
1516
</head>
1617
<body {...bodyAttributes}>

src/schema/blogSchema.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
const blogSchema = `
2+
union ArticleBodyDynamicZone = ComponentHowtoHowTo
3+
24
type StrapiBlogCategory implements Node {
35
parent: Node
46
children: [Node!]!
@@ -37,11 +39,13 @@ const blogSchema = `
3739
description: String!
3840
summary: String!
3941
slug: String!
42+
destacado: Boolean
4043
image: LocalFile
4144
imagePage: LocalFile
4245
seo: ComponentSeo
4346
blog_category: StrapiBlogCategory
4447
author: [StrapiArticleAuthor]
48+
body: [ArticleBodyDynamicZone]
4549
published_at(
4650
formatString: String
4751
fromNow: Boolean

0 commit comments

Comments
 (0)