-
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 #145 from vevcom/feat/Article
Feat/article-1-seeding
- Loading branch information
Showing
86 changed files
with
2,568 additions
and
448 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export const maxImageSize = 400 | ||
export const maxImageSize = 540 | ||
export const minImageSize = 130 | ||
export const increment = 20 |
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,8 @@ | ||
import { ReturnType as ExpandedArticleSection } from '@/cms/articleSections/ReturnType' | ||
import type { Article, CmsImage } from '@prisma/client' | ||
|
||
export type ReturnType = Article & { | ||
articleSections: ExpandedArticleSection[], | ||
coverImage: CmsImage, | ||
} | ||
|
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 |
---|---|---|
@@ -1 +1,33 @@ | ||
'use server' | ||
import { ReturnType } from './ReturnType' | ||
import { ActionReturn } from '@/actions/type' | ||
import prisma from '@/prisma' | ||
import errorHandeler from '@/prisma/errorHandler' | ||
|
||
export default async function create(name: string): Promise<ActionReturn<ReturnType>> { | ||
try { | ||
const article = await prisma.article.create({ | ||
data: { | ||
name, | ||
coverImage: { | ||
create: { | ||
name: `${name}_cover`, | ||
} | ||
}, | ||
}, | ||
include: { | ||
articleSections: { | ||
include: { | ||
cmsImage: true, | ||
cmsParagraph: true, | ||
cmsLink: true | ||
} | ||
}, | ||
coverImage: true, | ||
} | ||
}) | ||
return { success: true, data: article } | ||
} 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,29 @@ | ||
'use server' | ||
import { ReturnType } from './ReturnType' | ||
import { ActionReturn } from '@/actions/type' | ||
import prisma from '@/prisma' | ||
import errorHandeler from '@/prisma/errorHandler' | ||
|
||
export default async function read(name: string): Promise<ActionReturn<ReturnType>> { | ||
try { | ||
const article = await prisma.article.findUnique({ | ||
where: { | ||
name | ||
}, | ||
include: { | ||
articleSections: { | ||
include: { | ||
cmsImage: true, | ||
cmsParagraph: true, | ||
cmsLink: true | ||
} | ||
}, | ||
coverImage: true, | ||
} | ||
}) | ||
if (!article) return { success: false, error: [{ message: `Article ${name} not found` }] } | ||
return { success: true, data: article } | ||
} 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,33 @@ | ||
'use server' | ||
import prisma from '@/prisma' | ||
import errorHandler from '@/prisma/errorHandler' | ||
import { ActionReturn } from '@/actions/type' | ||
import type { ReturnType } from './ReturnType' | ||
|
||
export default async function update(id: number, config: { | ||
name?: string, | ||
}) : Promise<ActionReturn<ReturnType>> { | ||
try { | ||
const article = await prisma.article.update({ | ||
where: { | ||
id, | ||
}, | ||
data: { | ||
...config, | ||
}, | ||
include: { | ||
coverImage: true, | ||
articleSections: { | ||
include: { | ||
cmsImage: true, | ||
cmsParagraph: true, | ||
cmsLink: true, | ||
} | ||
} | ||
} | ||
}) | ||
return { success: true, data: article } | ||
} catch (error) { | ||
return errorHandler(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 |
---|---|---|
@@ -1,5 +1,66 @@ | ||
@use "@/styles/ohma"; | ||
|
||
$padding: 4rem; | ||
$cover-height: min(300px, 40vh); | ||
|
||
.Article { | ||
|
||
} | ||
.coverImage { | ||
overflow: hidden; | ||
isolation: isolate; | ||
display: block; | ||
width: 100%; | ||
height: $cover-height; | ||
position: relative; | ||
> *:first-child { | ||
position: relative; | ||
width: 100%; | ||
height: 100%; | ||
&::after { | ||
content: ""; | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
background: linear-gradient(to bottom, rgba(ohma.$colors-primary, 0), ohma.$colors-yellow); | ||
z-index: 1; | ||
} | ||
> * { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100% !important; | ||
height: 100%; | ||
object-fit: cover; | ||
img { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100% !important; | ||
height: $cover-height !important; // Add this line | ||
object-fit: cover; | ||
} | ||
} | ||
} | ||
>*:nth-child(2) { | ||
position: absolute; | ||
left: $padding; | ||
bottom: 1em; | ||
.title { | ||
font-size: ohma.$fonts-xxl; | ||
font-family: ohma.$fonts-secondary; | ||
text-transform: uppercase; | ||
color: ohma.$colors-white; | ||
z-index: 2; | ||
} | ||
} | ||
|
||
} | ||
article { | ||
> * { | ||
margin: 2em $padding; | ||
isolation: isolate; | ||
} | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -1,9 +1,32 @@ | ||
import styles from './Article.module.scss' | ||
import CmsImage from '@/cms/CmsImage/CmsImage' | ||
import SlideInOnView from '@/components/SlideInOnView/SlideInOnView' | ||
import ArticleSection from '@/cms/ArticleSection/ArticleSection' | ||
import type { ReturnType } from '@/cms/articles/ReturnType' | ||
|
||
export default function Article() { | ||
type PropTypes = { | ||
article: ReturnType, | ||
} | ||
|
||
export default function Article({ article } : PropTypes) { | ||
return ( | ||
<span className={styles.Article}> | ||
<h1>Article</h1> | ||
<span className={styles.coverImage}> | ||
<CmsImage width={500} name={article.coverImage.name} /> | ||
<SlideInOnView direction="bottom"> | ||
<h1 className={styles.title}>{article.name}</h1> | ||
</SlideInOnView> | ||
</span> | ||
<article> | ||
|
||
{ | ||
article.articleSections.sort((a, b) => (a.order - b.order)).map(section => ( | ||
<SlideInOnView direction="left" key={section.id}> | ||
<ArticleSection articleSection={section} /> | ||
</SlideInOnView> | ||
)) | ||
} | ||
</article> | ||
</span> | ||
) | ||
} |
33 changes: 19 additions & 14 deletions
33
src/app/components/Cms/ArticleSection/AddParts.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 |
---|---|---|
@@ -1,21 +1,26 @@ | ||
@use '@/styles/ohma'; | ||
|
||
.AddParts { | ||
position: relative; | ||
padding: ohma.$gap; | ||
border: ohma.$colors-secondary 3px solid; | ||
border-radius: ohma.$rounding; | ||
min-height: 100px; | ||
padding: 1em; | ||
> .addControls { | ||
position: absolute; | ||
bottom: 3px; | ||
right: 3px; | ||
z-index: 1; | ||
display: flex; | ||
button { | ||
max-width: calc(100% - 2 * ohma.$gap); | ||
> .wrapper { | ||
position: relative; | ||
border: ohma.$colors-secondary 3px solid; | ||
border-radius: ohma.$rounding; | ||
min-height: 100px; | ||
> .addControls { | ||
position: absolute; | ||
bottom: 3px; | ||
right: 3px; | ||
z-index: 1; | ||
display: flex; | ||
button { | ||
display: flex; | ||
} | ||
} | ||
} | ||
padding-bottom: 60px; | ||
padding: 2*ohma.$gap; | ||
&.paddingBottom { | ||
padding-bottom: 60px; | ||
} | ||
} | ||
} |
Oops, something went wrong.