Skip to content

Commit

Permalink
feat(build): improve layout of images/video
Browse files Browse the repository at this point in the history
  • Loading branch information
KeziahMoselle committed Apr 14, 2024
1 parent c86ce18 commit 6b0a279
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions frontend/src/components/molecules/LikeBuildButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
const props = defineProps<{
build?: ErBuild,
hasVoted?: boolean
class?: string
}>()
const hasVoted = ref(props.hasVoted)
Expand Down
24 changes: 20 additions & 4 deletions frontend/src/pages/build/[id].astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const REGEX_YOUTUBE_URL = /^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/|shorts\
const { id } = Astro.params
const build: ErBuild = await apiFetch(`/api/er-builds/${id}`)
const [, youtubeId] = build.youtube_url.match(REGEX_YOUTUBE_URL)
const youtubeMatches = build.youtube_url?.match(REGEX_YOUTUBE_URL)
---

<script>
Expand Down Expand Up @@ -46,19 +46,31 @@ const [, youtubeId] = build.youtube_url.match(REGEX_YOUTUBE_URL)
</div>
</section>

<section class="container grid md:grid-cols-2 gap-4">
<section class:list={[
'container grid gap-4',
{
'md:grid-cols-2': build.youtube_url && build.images.length > 0
}
]}>
{build.youtube_url && (
<div class="plyr__video-embed" id="player">
<iframe
src={`https://www.youtube.com/embed/${youtubeId}?origin=https://plyr.io&amp;iv_load_policy=3&amp;modestbranding=1&amp;playsinline=1&amp;showinfo=0&amp;rel=0&amp;enablejsapi=1`}
src={`https://www.youtube.com/embed/${youtubeMatches[1]}?origin=https://plyr.io&amp;iv_load_policy=3&amp;modestbranding=1&amp;playsinline=1&amp;showinfo=0&amp;rel=0&amp;enablejsapi=1`}
allowfullscreen
allowtransparency
allow="autoplay"
></iframe>
</div>
)}

<div class="grid grid-cols-2 grid-rows-2 gap-2">
<div
class:list={[
'grid gap-2',
{
'grid-cols-2': build.images.length > 1,
'grid-rows-2': build.images.length > 2
}
]}>
{ build.images.map((image) => (
<img
class="zoomable aspect-video h-full object-contain"
Expand All @@ -71,4 +83,8 @@ const [, youtubeId] = build.youtube_url.match(REGEX_YOUTUBE_URL)
<section class="mt-8 py-8 border-t">
<Build build={build} client:visible/>
</section>

<section class="my-8">
{JSON.stringify(build.description, null, 2)}
</section>
</Layout>

0 comments on commit 6b0a279

Please sign in to comment.