-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from vevcom/feat/ImageLink
Feat/image link
- Loading branch information
Showing
69 changed files
with
1,281 additions
and
504 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use server' | ||
import prisma from '@/prisma' | ||
import type { Image, ImageLink } from '@prisma/client' | ||
import type { ActionReturn } from '@/actions/type' | ||
import errorHandeler from '@/prisma/errorHandler' | ||
|
||
export default async function read(name: string) : Promise<ActionReturn<ImageLink & {image: Image | null}>> { | ||
//Note this action reates a image link if it does not exist and returns it | ||
try { | ||
const imageLink = await prisma.imageLink.findUnique({ | ||
where: { | ||
name, | ||
}, | ||
include: { | ||
image: true, | ||
} | ||
}) | ||
if (!imageLink) { | ||
const created = { | ||
...await prisma.imageLink.create({ | ||
data: { | ||
name, | ||
}, | ||
}), | ||
image: null, | ||
} | ||
return { success: true, data: created } | ||
} | ||
return { success: true, data: imageLink } | ||
} catch (error) { | ||
return errorHandeler(error) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use server' | ||
import { ActionReturn } from '@/actions/type' | ||
import { ImageLink } from '@prisma/client' | ||
import prisma from '@/prisma' | ||
import errorHandeler from '@/prisma/errorHandler' | ||
|
||
export default async function update(linkId: number, imageId: number) : Promise<ActionReturn<ImageLink>> { | ||
try { | ||
const imageLink = await prisma.imageLink.update({ | ||
where: { | ||
id: linkId, | ||
}, | ||
data: { | ||
image: { | ||
connect: { | ||
id: imageId, | ||
} | ||
} | ||
} | ||
}) | ||
return { success: true, data: imageLink } | ||
} catch (error) { | ||
return errorHandeler(error) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/app/components/Image/Collection/CollectionCard.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
@use '@/styles/ohma'; | ||
|
||
.CollectionCard { | ||
margin: ohma.$gap; | ||
overflow: hidden; | ||
@include ohma.round; | ||
position: relative; | ||
place-self: center; | ||
display: block; | ||
> .imageCount { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
padding: 0.3em; | ||
color: ohma.$colors-white; | ||
background-color: ohma.$colors-black; | ||
border-radius: 0 0 0 1em; | ||
min-width: 30px; | ||
z-index: 1; | ||
text-align: center; | ||
} | ||
&::after { | ||
content: ''; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background: radial-gradient(ellipse at center bottom, transparent 20%, ohma.$colors-secondary 70%, ohma.$colors-secondary 100%); | ||
rotate: 180deg; | ||
scale: 1.5; | ||
z-index: 0; | ||
} | ||
> *:first-child { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100% !important; | ||
height: 100%; | ||
> img { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
object-fit: cover; | ||
transition: scale 0.5s; | ||
} | ||
} | ||
> .info { | ||
position: absolute; | ||
bottom: 0; | ||
left: 0; | ||
width: 100%; | ||
padding: 0.3em; | ||
color: ohma.$colors-black; | ||
text-decoration: none; | ||
transition: min-height 0.5s; | ||
padding: ohma.$gap; | ||
z-index: 1; | ||
i { | ||
margin-top: ohma.$gap; | ||
transition: opacity 0.5s; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
} | ||
} | ||
&:hover img { | ||
scale: 1.2; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import Link from 'next/link' | ||
import styles from './CollectionCard.module.scss' | ||
import Image from '@/components/Image/Image' | ||
import type { Image as ImageT, ImageCollection } from '@prisma/client' | ||
|
||
type PropTypes = { | ||
collection: ImageCollection & { | ||
coverImage: ImageT | null, | ||
numberOfImages: number, | ||
}, | ||
className?: string, | ||
} | ||
|
||
export default function CollectionCard({ collection, className }: PropTypes) { | ||
return ( | ||
<Link href={`/images/collections/${collection.id}`} className={`${styles.CollectionCard} ${className}`} key={collection.id}> | ||
{ | ||
collection.coverImage ? ( | ||
<Image width={100} image={collection.coverImage} /> | ||
) : ( | ||
<p>Something went wrong</p> | ||
) | ||
} | ||
<div className={styles.info}> | ||
<h2>{collection.name}</h2> | ||
<i>{collection.description}</i> | ||
<p>{collection.createdAt.toUTCString().split(' ').slice(0, 4).join(' ')}</p> | ||
</div> | ||
<p className={styles.imageCount}>{collection.numberOfImages}</p> | ||
</Link> | ||
) | ||
} |
Oops, something went wrong.