From 1ac9b43a619fc10dbe1271d21f45e58ac07dcfc2 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 10 Jun 2021 09:41:07 +0200 Subject: [PATCH] Add Blurhash to front-end Signed-off-by: Thomas Citharel --- js/package.json | 1 + js/src/components/Event/EventBanner.vue | 33 ++++++ js/src/components/Event/EventCard.vue | 30 ++++- js/src/components/Image/BlurhashImg.vue | 34 ++++++ js/src/components/Image/LazyImage.vue | 117 +++++++++++++++++++ js/src/components/Image/LazyImageWrapper.vue | 40 +++++++ js/src/types/media.model.ts | 7 ++ js/yarn.lock | 5 + 8 files changed, 261 insertions(+), 6 deletions(-) create mode 100644 js/src/components/Event/EventBanner.vue create mode 100644 js/src/components/Image/BlurhashImg.vue create mode 100644 js/src/components/Image/LazyImage.vue create mode 100644 js/src/components/Image/LazyImageWrapper.vue diff --git a/js/package.json b/js/package.json index fb05b29fc..13ad2a811 100644 --- a/js/package.json +++ b/js/package.json @@ -30,6 +30,7 @@ "@tiptap/starter-kit": "^2.0.0-beta.37", "@tiptap/vue-2": "^2.0.0-beta.21", "apollo-absinthe-upload-link": "^1.5.0", + "blurhash": "^1.1.3", "buefy": "^0.9.0", "bulma-divider": "^0.2.0", "core-js": "^3.6.4", diff --git a/js/src/components/Event/EventBanner.vue b/js/src/components/Event/EventBanner.vue new file mode 100644 index 000000000..bbdae2c67 --- /dev/null +++ b/js/src/components/Event/EventBanner.vue @@ -0,0 +1,33 @@ + + + diff --git a/js/src/components/Event/EventCard.vue b/js/src/components/Event/EventCard.vue index f6f8a7ee0..127adddf3 100644 --- a/js/src/components/Event/EventCard.vue +++ b/js/src/components/Event/EventCard.vue @@ -4,12 +4,11 @@ :to="{ name: 'Event', params: { uuid: event.uuid } }" >
-
+
+
@@ -103,6 +103,7 @@ import { IEvent, IEventCardOptions } from "@/types/event.model"; import { Component, Prop, Vue } from "vue-property-decorator"; import DateCalendarIcon from "@/components/Event/DateCalendarIcon.vue"; +import LazyImageWrapper from "@/components/Image/LazyImageWrapper.vue"; import { Actor, Person } from "@/types/actor"; import { EventStatus, ParticipantRole } from "@/types/enums"; import RouteName from "../../router/name"; @@ -110,6 +111,7 @@ import RouteName from "../../router/name"; @Component({ components: { DateCalendarIcon, + LazyImageWrapper, }, }) export default class EventCard extends Vue { @@ -220,6 +222,22 @@ a.card { .card-content { padding: 0.5rem; + & > .media { + position: relative; + display: flex; + flex-direction: column; + + & > .media-left { + margin-top: -15px; + height: 0; + display: flex; + align-items: flex-end; + align-self: flex-start; + margin-bottom: 15px; + margin-left: 0rem; + } + } + .event-title { font-size: 1.2rem; line-height: 1.25rem; diff --git a/js/src/components/Image/BlurhashImg.vue b/js/src/components/Image/BlurhashImg.vue new file mode 100644 index 000000000..9181991a1 --- /dev/null +++ b/js/src/components/Image/BlurhashImg.vue @@ -0,0 +1,34 @@ + + + + diff --git a/js/src/components/Image/LazyImage.vue b/js/src/components/Image/LazyImage.vue new file mode 100644 index 000000000..c5d95b7f5 --- /dev/null +++ b/js/src/components/Image/LazyImage.vue @@ -0,0 +1,117 @@ + + + + diff --git a/js/src/components/Image/LazyImageWrapper.vue b/js/src/components/Image/LazyImageWrapper.vue new file mode 100644 index 000000000..41779935c --- /dev/null +++ b/js/src/components/Image/LazyImageWrapper.vue @@ -0,0 +1,40 @@ + + diff --git a/js/src/types/media.model.ts b/js/src/types/media.model.ts index 69189591d..cc8e42fd4 100644 --- a/js/src/types/media.model.ts +++ b/js/src/types/media.model.ts @@ -3,6 +3,7 @@ export interface IMedia { url: string; name: string; alt: string; + metadata: IMediaMetadata; } export interface IMediaUpload { @@ -10,3 +11,9 @@ export interface IMediaUpload { name: string; alt: string | null; } + +export interface IMediaMetadata { + width?: number; + height?: number; + blurhash?: string; +} diff --git a/js/yarn.lock b/js/yarn.lock index 85fcd1939..ed73c971a 100644 --- a/js/yarn.lock +++ b/js/yarn.lock @@ -3416,6 +3416,11 @@ bluebird@^3.1.1, bluebird@^3.7.2: resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== +blurhash@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/blurhash/-/blurhash-1.1.3.tgz#dc325af7da836d07a0861d830bdd63694382483e" + integrity sha512-yUhPJvXexbqbyijCIE/T2NCXcj9iNPhWmOKbPTuR/cm7Q5snXYIfnVnz6m7MWOXxODMz/Cr3UcVkRdHiuDVRDw== + body-parser@1.19.0: version "1.19.0" resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a"