Skip to content

Commit

Permalink
fix: fix overflowing script card titles, decreate the script titles t…
Browse files Browse the repository at this point in the history
…o a maximum of 31 characters
  • Loading branch information
Torwent committed Jan 16, 2024
1 parent d27d512 commit 51714c7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 31 deletions.
50 changes: 23 additions & 27 deletions src/lib/backend/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,28 @@ async function checkClientImageDimensions(file: any, w: number, h: number): Prom
})
}

const title = z
.string()
.min(4, "Must be more than 3 characters long.")
.max(31, "Must be less than 31 characters long.")

const description = z
.string()
.min(10, "Must be more than 9 characters long.")
.max(160, "Must be less than 160 characters long.")
.includes(" ", { message: "You have no spaces, this is supposed to be a sentence." })

const content = z.string().min(10).includes(" ", {
message:
"You have no spaces, this is supposed to be at least a couple of words, ideally a few sentences."
})

export const scriptSchema = z
.object({
id: z.string().uuid("ID must be a valid UUIDv4").optional(),
title: z
.string()
.min(4, "Must be more than 3 characters long.")
.max(46, "Must be less than 47 characters long."),
description: z
.string()
.min(10, "Must be more than 9 characters long.")
.max(160, "Must be less than 160 characters long.")
.includes(" ", { message: "You have no spaces, this is supposed to be a sentence." }),
content: z
.string()
.min(10)
.includes(" ", { message: "You have no spaces, this is supposed to be a sentence." }),
title: title,
description: description,
content: content,
categories: z
.array(z.string())
.min(3, "You should have at least 3 categories.")
Expand Down Expand Up @@ -110,19 +116,9 @@ export const scriptSchema = z

export const postSchema = z.object({
id: z.string().uuid("ID must be a valid UUID.").optional(),
title: z
.string()
.min(4, "Must be more than 3 characters long.")
.max(46, "Must be less than 47 characters long."),
description: z
.string()
.min(10, "Must be more than 9 characters long.")
.max(160, "Must be less than 160 characters long.")
.includes(" ", { message: "You have no spaces, this is supposed to be a sentence." }),
content: z
.string()
.min(10)
.includes(" ", { message: "You have no spaces, this is supposed to be a sentence." }),
title: title,
description: description,
content: content,
level: z
.number()
.int("Level has to be between 0 and 2")
Expand Down Expand Up @@ -167,7 +163,7 @@ export const scripterSchema = z.object({
"The paypal ID seems to have the wrong length. If you put the correct ID please contact Torwent."
)
.nullable(),
content: z.string().includes(" ", { message: "This should be a couple of words." }).nullable()
content: content.nullable()
})

export const subscriptionsSchema = z.object({
Expand Down
8 changes: 4 additions & 4 deletions src/lib/components/ScriptCardBase.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
</header>
<section class="p-4">
<header class="h-12">
<h5 class="font-semibold text-primary-600 dark:text-primary-500 whitespace-nowrap">
<div class="font-semibold text-primary-600 dark:text-primary-500 whitespace-nowrap">
{script.title}
</h5>
<span class="text-xs whitespace-nowrap text-primary-600 dark:text-secondary-500 drop-shadow">
</div>
<div class="text-xs whitespace-nowrap text-primary-600 dark:text-secondary-500 drop-shadow">
by
<a
href="/scripters/{encodeSEO(script.protected.username.normalize('NFKC'))}"
Expand All @@ -53,7 +53,7 @@
{script.protected.username}
</a>
{#if !script.published}<small class="text-error-500">Unpublished</small>{/if}
</span>
</div>
</header>
<article class="h-20 mt-4 dark:text-surface-300 text-surface-600 text-sm break-words">
{cropString(script.description, 80)}
Expand Down

0 comments on commit 51714c7

Please sign in to comment.