Rafactoring Module.heroImage

This commit is contained in:
Lorenz Padberg 2024-04-25 11:43:26 +02:00
parent cd0eb08153
commit 74820f52b6
8 changed files with 2065 additions and 39 deletions

View File

@ -30,9 +30,9 @@
<div class="module__hero">
<wagtail-image class="module__hero-image"
:src="module.heroImageJson.src"
:original-width="module.heroImageJson.width"
:original-height="module.heroImageJson.height"></wagtail-image>
:src="module.heroImage.src"
:original-width="module.heroImage.width"
:original-height="module.heroImage.height"></wagtail-image>
<pre></pre>
<h5
class="module__hero-source"

View File

@ -3,11 +3,12 @@
:to="moduleLink"
:class="['module-teaser', { 'module-teaser--small': !teaser }]"
>
<!-- <div-->
<!-- :style="{ backgroundImage: 'url(' + heroImage + ')' }"-->
<!-- class="module-teaser__image"-->
<!-- />-->
<wagtail-image class="module-teaser__image" :src="heroImage"></wagtail-image>
<wagtail-image
class="module-teaser__image"
:src="heroImage.src"
:original-height="heroImage.height"
:original-width="heroImage.width"
></wagtail-image>
<div class="module-teaser__body">
<div class="module-teaser__content">
<h3 class="module-teaser__content-meta-title">{{ metaTitle }}</h3>
@ -34,7 +35,7 @@
import Pill from '@/components/ui/Pill.vue';
import { ModuleCategoryNode, ModuleLevelNode } from '@/__generated__/graphql';
import { computed } from '@vue/reactivity';
import WagtailImage from "@/components/ui/WagtailImage.vue";
import WagtailImage from '@/components/ui/WagtailImage.vue';
export interface Props {
metaTitle: string;

View File

@ -66,7 +66,6 @@ const placeholderStyle = computed(() => {
};
if (width.value) {
const scalingFactor = width.value / props.originalWidth;
console.log(props.originalWidth, width.value);
const scaledHeight = Math.round(props.originalHeight * scalingFactor);
const scaledWidth = Math.round(props.originalWidth * scalingFactor);

View File

@ -1,4 +1,6 @@
#import "./highlightParts.gql"
#import "./wagtailIMageParts.gql"
fragment ModuleLegacyParts on ModuleNode {
id
title
@ -6,14 +8,9 @@ fragment ModuleLegacyParts on ModuleNode {
teaser
intro
slug
heroImage
heroSource
heroImageJson{
src
alt
width
height
title
heroImage {
...WagtailImageParts
}
solutionsEnabled
highlights {

View File

@ -0,0 +1,8 @@
fragment WagtailImageParts on WagtailImageNode {
id
src
alt
width
height
title
}

2042
schema.graphql Normal file

File diff suppressed because it is too large Load Diff

View File

@ -5,25 +5,9 @@ from api.graphene_wagtail import generate_image_url
class ModuleInterface(relay.Node):
pk = graphene.Int()
hero_image = graphene.String(required=True)
hero_image = graphene.Field('books.schema.nodes.WagtailImageNode')
topic = graphene.Field('books.schema.nodes.TopicNode')
hero_image_json = graphene.Field('books.schema.nodes.WagtailImageNode')
@staticmethod
def resolve_pk(parent, info, **kwargs):
return parent.id
@staticmethod
def resolve_hero_image(parent, info, **kwargs):
if parent.hero_image:
image = Image.objects.get(id=parent.hero_image.id)
return generate_image_url(image, 'original')
@staticmethod
def resolve_hero_image_json(parent, info, **kwargs):
if parent.hero_image:
return Image.objects.get(id=parent.hero_image.id)

View File

@ -58,7 +58,6 @@ class ModuleNode(DjangoObjectType):
level = graphene.Field(ModuleLevelNode)
category = graphene.Field(ModuleCategoryNode)
language = graphene.String()
hero_image_json = graphene.Field("books.schema.nodes.WagtailImageNode")
highlights = graphene.List("notes.schema.HighlightNode")
my_highlights = graphene.List(
graphene.NonNull("notes.schema.HighlightNode"), required=True
@ -170,10 +169,6 @@ class ModuleNode(DjangoObjectType):
def resolve_path(root: Module, info, **kwargs):
return root.route
@staticmethod
def resolve_hero_image_json(root: Module, info, **kwargs):
return root.hero_image
class RecentModuleNode(DjangoObjectType):
class Meta: