Rafactoring Module.heroImage
This commit is contained in:
parent
cd0eb08153
commit
74820f52b6
|
|
@ -30,9 +30,9 @@
|
||||||
<div class="module__hero">
|
<div class="module__hero">
|
||||||
|
|
||||||
<wagtail-image class="module__hero-image"
|
<wagtail-image class="module__hero-image"
|
||||||
:src="module.heroImageJson.src"
|
:src="module.heroImage.src"
|
||||||
:original-width="module.heroImageJson.width"
|
:original-width="module.heroImage.width"
|
||||||
:original-height="module.heroImageJson.height"></wagtail-image>
|
:original-height="module.heroImage.height"></wagtail-image>
|
||||||
<pre></pre>
|
<pre></pre>
|
||||||
<h5
|
<h5
|
||||||
class="module__hero-source"
|
class="module__hero-source"
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,12 @@
|
||||||
:to="moduleLink"
|
:to="moduleLink"
|
||||||
:class="['module-teaser', { 'module-teaser--small': !teaser }]"
|
:class="['module-teaser', { 'module-teaser--small': !teaser }]"
|
||||||
>
|
>
|
||||||
<!-- <div-->
|
<wagtail-image
|
||||||
<!-- :style="{ backgroundImage: 'url(' + heroImage + ')' }"-->
|
class="module-teaser__image"
|
||||||
<!-- class="module-teaser__image"-->
|
:src="heroImage.src"
|
||||||
<!-- />-->
|
:original-height="heroImage.height"
|
||||||
<wagtail-image class="module-teaser__image" :src="heroImage"></wagtail-image>
|
:original-width="heroImage.width"
|
||||||
|
></wagtail-image>
|
||||||
<div class="module-teaser__body">
|
<div class="module-teaser__body">
|
||||||
<div class="module-teaser__content">
|
<div class="module-teaser__content">
|
||||||
<h3 class="module-teaser__content-meta-title">{{ metaTitle }}</h3>
|
<h3 class="module-teaser__content-meta-title">{{ metaTitle }}</h3>
|
||||||
|
|
@ -34,7 +35,7 @@
|
||||||
import Pill from '@/components/ui/Pill.vue';
|
import Pill from '@/components/ui/Pill.vue';
|
||||||
import { ModuleCategoryNode, ModuleLevelNode } from '@/__generated__/graphql';
|
import { ModuleCategoryNode, ModuleLevelNode } from '@/__generated__/graphql';
|
||||||
import { computed } from '@vue/reactivity';
|
import { computed } from '@vue/reactivity';
|
||||||
import WagtailImage from "@/components/ui/WagtailImage.vue";
|
import WagtailImage from '@/components/ui/WagtailImage.vue';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
metaTitle: string;
|
metaTitle: string;
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,6 @@ const placeholderStyle = computed(() => {
|
||||||
};
|
};
|
||||||
if (width.value) {
|
if (width.value) {
|
||||||
const scalingFactor = width.value / props.originalWidth;
|
const scalingFactor = width.value / props.originalWidth;
|
||||||
console.log(props.originalWidth, width.value);
|
|
||||||
const scaledHeight = Math.round(props.originalHeight * scalingFactor);
|
const scaledHeight = Math.round(props.originalHeight * scalingFactor);
|
||||||
const scaledWidth = Math.round(props.originalWidth * scalingFactor);
|
const scaledWidth = Math.round(props.originalWidth * scalingFactor);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
#import "./highlightParts.gql"
|
#import "./highlightParts.gql"
|
||||||
|
#import "./wagtailIMageParts.gql"
|
||||||
|
|
||||||
fragment ModuleLegacyParts on ModuleNode {
|
fragment ModuleLegacyParts on ModuleNode {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
|
|
@ -6,14 +8,9 @@ fragment ModuleLegacyParts on ModuleNode {
|
||||||
teaser
|
teaser
|
||||||
intro
|
intro
|
||||||
slug
|
slug
|
||||||
heroImage
|
|
||||||
heroSource
|
heroSource
|
||||||
heroImageJson{
|
heroImage {
|
||||||
src
|
...WagtailImageParts
|
||||||
alt
|
|
||||||
width
|
|
||||||
height
|
|
||||||
title
|
|
||||||
}
|
}
|
||||||
solutionsEnabled
|
solutionsEnabled
|
||||||
highlights {
|
highlights {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
fragment WagtailImageParts on WagtailImageNode {
|
||||||
|
id
|
||||||
|
src
|
||||||
|
alt
|
||||||
|
width
|
||||||
|
height
|
||||||
|
title
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -5,25 +5,9 @@ from api.graphene_wagtail import generate_image_url
|
||||||
|
|
||||||
class ModuleInterface(relay.Node):
|
class ModuleInterface(relay.Node):
|
||||||
pk = graphene.Int()
|
pk = graphene.Int()
|
||||||
hero_image = graphene.String(required=True)
|
hero_image = graphene.Field('books.schema.nodes.WagtailImageNode')
|
||||||
topic = graphene.Field('books.schema.nodes.TopicNode')
|
topic = graphene.Field('books.schema.nodes.TopicNode')
|
||||||
hero_image_json = graphene.Field('books.schema.nodes.WagtailImageNode')
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def resolve_pk(parent, info, **kwargs):
|
def resolve_pk(parent, info, **kwargs):
|
||||||
return parent.id
|
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)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,6 @@ class ModuleNode(DjangoObjectType):
|
||||||
level = graphene.Field(ModuleLevelNode)
|
level = graphene.Field(ModuleLevelNode)
|
||||||
category = graphene.Field(ModuleCategoryNode)
|
category = graphene.Field(ModuleCategoryNode)
|
||||||
language = graphene.String()
|
language = graphene.String()
|
||||||
hero_image_json = graphene.Field("books.schema.nodes.WagtailImageNode")
|
|
||||||
highlights = graphene.List("notes.schema.HighlightNode")
|
highlights = graphene.List("notes.schema.HighlightNode")
|
||||||
my_highlights = graphene.List(
|
my_highlights = graphene.List(
|
||||||
graphene.NonNull("notes.schema.HighlightNode"), required=True
|
graphene.NonNull("notes.schema.HighlightNode"), required=True
|
||||||
|
|
@ -170,10 +169,6 @@ class ModuleNode(DjangoObjectType):
|
||||||
def resolve_path(root: Module, info, **kwargs):
|
def resolve_path(root: Module, info, **kwargs):
|
||||||
return root.route
|
return root.route
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def resolve_hero_image_json(root: Module, info, **kwargs):
|
|
||||||
return root.hero_image
|
|
||||||
|
|
||||||
|
|
||||||
class RecentModuleNode(DjangoObjectType):
|
class RecentModuleNode(DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue