Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: tags and category required #494

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"daisyui": "^2.52.0",
"nprogress": "^0.2.0",
"playwright-e2e-coverage-report": "^1.0.28",
"svelte-tags-input": "^5.0.0",
"theme-change": "^2.5.0"
}
}
2 changes: 2 additions & 0 deletions src/app.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ declare namespace svelteHTML {
}

declare const __VERSION__: string

declare module 'svelte-tags-input'
19 changes: 13 additions & 6 deletions src/lib/components/Browse/DrawerCreateChannel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// import IconPhoto from '$lib/assets/icons/IconPhoto.svelte'
import { tags } from '$lib/stores/channelStore'
import { onMount } from 'svelte'
import Tags from '$lib/components/Browse/Tags.svelte'
import Tags from 'svelte-tags-input'
import DrawerAddCategory from '$lib/components/Browse/DrawerAddCategory.svelte'
import { get } from '$lib/api'
import { enhance } from '$app/forms'
Expand All @@ -28,7 +28,6 @@
showThumbnail = false,
showAddCategory = false,
maxTag = 3,
maxTagChars = 18,
maxCategory = 4,
isLoadingChannel = false

Expand Down Expand Up @@ -65,7 +64,7 @@
newChannel = newChannel
}

const onTagValidation = (evt: any) => {
const onValidation = (evt: any) => {
if (Number(evt.target.value) < 1) {
evt.target.setCustomValidity('Please fill out this field.')
}
Expand Down Expand Up @@ -165,7 +164,6 @@
<Tags
bind:tags={newChannel.tags}
maxTags={maxTag}
maxChars={maxTagChars}
id="tags"
placeholder={newChannel.tags.length > 0 ? '' : 'Tag'} />
<span class="absolute right-0 top-1/2 text-gray-400 pr-3">({maxTagLabel})</span>
Expand All @@ -177,15 +175,14 @@
min="1"
class="opacity-0 pointer-events-none absolute left-0 right-0 mx-auto bottom-0"
bind:value={newChannel.tags.length}
on:invalid={onTagValidation} />
on:invalid={onValidation} />
{/if}
</div>
<div class="relative">
<input
on:click={() => (showAddCategory = true)}
type="text"
name="category"
required={!newChannel.category.length}
placeholder={newChannel?.category?.length ? '' : 'Category'}
class="input input-primary input-bordered mt-5 w-full" />
<span class="absolute right-0 top-1/2 text-gray-400 pr-3">({maxCategoryLabel})</span>
Expand All @@ -196,6 +193,16 @@
{/each}
{/if}
</span>
{#if newChannel.category.length === 0}
<input
type="number"
name="mincats"
required
min="1"
class="opacity-0 pointer-events-none absolute left-0 right-0 mx-auto bottom-0"
bind:value={newChannel.category.length}
on:invalid={onValidation} />
{/if}
</div>
<!-- <div class="flex flex-row mt-5 ">
<input
Expand Down
Loading