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
@@ -15,6 +15,12 @@
|
||||
"izenburua": {
|
||||
"type": "string"
|
||||
},
|
||||
"banner": {
|
||||
"type": "component",
|
||||
"component": "hasiera.banner",
|
||||
"repeatable": true,
|
||||
"max": 1
|
||||
},
|
||||
"izanLabazkide": {
|
||||
"type": "component",
|
||||
"component": "hasiera.izan-labazkide",
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"collectionName": "components_hasiera_banners",
|
||||
"info": {
|
||||
"displayName": "banner",
|
||||
"icon": "store"
|
||||
},
|
||||
"options": {},
|
||||
"attributes": {
|
||||
"izenburua": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"required": true
|
||||
},
|
||||
"mugikorIrudia": {
|
||||
"type": "media",
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"allowedTypes": [
|
||||
"images",
|
||||
"files"
|
||||
]
|
||||
},
|
||||
"desktopIrudia": {
|
||||
"type": "media",
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"allowedTypes": [
|
||||
"images",
|
||||
"files"
|
||||
]
|
||||
}
|
||||
},
|
||||
"config": {}
|
||||
}
|
||||
Vendored
+17
@@ -29,6 +29,22 @@ export interface EkintzaSarrera extends Struct.ComponentSchema {
|
||||
};
|
||||
}
|
||||
|
||||
export interface HasieraBanner extends Struct.ComponentSchema {
|
||||
collectionName: 'components_hasiera_banners';
|
||||
info: {
|
||||
displayName: 'banner';
|
||||
icon: 'store';
|
||||
};
|
||||
attributes: {
|
||||
desktopIrudia: Schema.Attribute.Media<'images' | 'files'> &
|
||||
Schema.Attribute.Required;
|
||||
izenburua: Schema.Attribute.String & Schema.Attribute.Required;
|
||||
mugikorIrudia: Schema.Attribute.Media<'images' | 'files'> &
|
||||
Schema.Attribute.Required;
|
||||
url: Schema.Attribute.String & Schema.Attribute.Required;
|
||||
};
|
||||
}
|
||||
|
||||
export interface HasieraIzanLabazkide extends Struct.ComponentSchema {
|
||||
collectionName: 'components_hasiera_izan_labazkides';
|
||||
info: {
|
||||
@@ -144,6 +160,7 @@ declare module '@strapi/strapi' {
|
||||
export interface ComponentSchemas {
|
||||
'ekintza.elkarlana': EkintzaElkarlana;
|
||||
'ekintza.sarrera': EkintzaSarrera;
|
||||
'hasiera.banner': HasieraBanner;
|
||||
'hasiera.izan-labazkide': HasieraIzanLabazkide;
|
||||
'hasiera.parte-hartu': HasieraParteHartu;
|
||||
'hasiera.parte-hartzea': HasieraParteHartzea;
|
||||
|
||||
+7
@@ -527,6 +527,13 @@ export interface ApiHasieraHasiera extends Struct.SingleTypeSchema {
|
||||
draftAndPublish: true;
|
||||
};
|
||||
attributes: {
|
||||
banner: Schema.Attribute.Component<'hasiera.banner', true> &
|
||||
Schema.Attribute.SetMinMax<
|
||||
{
|
||||
max: 1;
|
||||
},
|
||||
number
|
||||
>;
|
||||
createdAt: Schema.Attribute.DateTime;
|
||||
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
|
||||
Schema.Attribute.Private;
|
||||
|
||||
@@ -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