feat: banner bakarra erakusten du
This commit is contained in:
1 parent
286437118c
commit
35776ff7c1
8 files changed
+160
-1
No files matched your search
@@ -16,9 +16,17 @@ interface Url {
|
||||
url: string;
|
||||
}
|
||||
|
||||
export interface Banner {
|
||||
izenburua: string;
|
||||
url: string;
|
||||
mugikorIrudia: ImageMedia;
|
||||
desktopIrudia: ImageMedia;
|
||||
}
|
||||
|
||||
export interface Hasiera {
|
||||
id: number;
|
||||
izenburua: string;
|
||||
banner: Banner[];
|
||||
izanLabazkide: {
|
||||
izenburua: string;
|
||||
deskribapena: Markdown;
|
||||
|
||||
@@ -11,6 +11,18 @@ const response = await fetch(`${import.meta.env.STRAPI_URL}/graphql`, {
|
||||
query {
|
||||
hasiera {
|
||||
izenburua
|
||||
banner {
|
||||
izenburua
|
||||
url
|
||||
mugikorIrudia {
|
||||
alternativeText
|
||||
formats
|
||||
}
|
||||
desktopIrudia {
|
||||
alternativeText
|
||||
formats
|
||||
}
|
||||
}
|
||||
izanLabazkide {
|
||||
izenburua
|
||||
deskribapena
|
||||
|
||||
@@ -12,6 +12,7 @@ import Header from "../_components/Header.astro";
|
||||
import Footer from "../_components/Footer.astro";
|
||||
import EkintzaZerrenda from "../_components/EkintzaZerrenda.astro";
|
||||
import IrudiEstela from "views/_components/IrudiEstela.astro";
|
||||
import Banner from "./components/Banner.astro";
|
||||
|
||||
interface Props {
|
||||
hasiera: Hasiera;
|
||||
@@ -20,7 +21,7 @@ interface Props {
|
||||
|
||||
const { hasiera, ekintzak } = Astro.props;
|
||||
|
||||
const { izenburua, izanLabazkide, parteHartu, mosaikoa }: Hasiera = hasiera;
|
||||
const { izenburua, izanLabazkide, parteHartu, mosaikoa, banner }: Hasiera = hasiera;
|
||||
|
||||
const hurrengoEkintzak = ekintzak.filter((ekintza) =>
|
||||
dayjs().isBefore(ekintza.hitzordua)
|
||||
@@ -43,6 +44,12 @@ const hurrengoEkintzak = ekintzak.filter((ekintza) =>
|
||||
<IrudiEstela mosaikoa={mosaikoa} />
|
||||
</section>
|
||||
|
||||
{banner?.length > 0 &&
|
||||
<section class="banner">
|
||||
<Banner banner={banner[0]} />
|
||||
</section>
|
||||
}
|
||||
|
||||
{hurrengoEkintzak.length > 0 &&
|
||||
<ZigZag from="marroia" />
|
||||
|
||||
@@ -150,6 +157,11 @@ const hurrengoEkintzak = ekintzak.filter((ekintza) =>
|
||||
}
|
||||
}
|
||||
|
||||
.banner {
|
||||
background-color: var(--marroia);
|
||||
@include sectionPadding;
|
||||
}
|
||||
|
||||
.agenda {
|
||||
z-index: 20;
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
---
|
||||
import type { Banner } from "models/Hasiera";
|
||||
import { getImageData } from "models/ImageMedia";
|
||||
|
||||
interface Props {
|
||||
banner: Banner;
|
||||
}
|
||||
|
||||
const { banner } = Astro.props;
|
||||
|
||||
const desktopBanner = getImageData(banner.desktopIrudia, {
|
||||
preferredFormat: "large",
|
||||
});
|
||||
const mobileBanner = getImageData(banner.mugikorIrudia, {
|
||||
preferredFormat: "medium",
|
||||
});
|
||||
---
|
||||
|
||||
<div>
|
||||
<a href={banner.url}>
|
||||
<picture>
|
||||
<source
|
||||
media="(min-width:1024px)"
|
||||
srcset={desktopBanner.src}
|
||||
height={desktopBanner.height}
|
||||
width={desktopBanner.width}
|
||||
/>
|
||||
<img
|
||||
src={mobileBanner.src}
|
||||
alt={mobileBanner.alt}
|
||||
height={mobileBanner.height}
|
||||
width={mobileBanner.width}
|
||||
/>
|
||||
</picture>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
@use "../../../style/tools/mediaQueries.scss";
|
||||
div {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
a {
|
||||
z-index: 100;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
border-radius: var(--space-04-mobile);
|
||||
|
||||
@include mediaQueries.aboveTablet {
|
||||
border-radius: var(--space-04-desktop);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user