Skip to content

Commit

Permalink
Merge pull request #332 from CodeCrowCorp/dev
Browse files Browse the repository at this point in the history
Update playwright.config.ts
  • Loading branch information
gagansuie authored Mar 23, 2023
2 parents b04daa9 + 1102271 commit 1053f9f
Show file tree
Hide file tree
Showing 17 changed files with 373 additions and 94 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dev": "concurrently \"npm run dev:only\" \"npm run tailwind:watch\"",
"build": "npm run tailwind:build && npm run build:only",
"preview": "vite preview",
"test": "playwright test",
"test": "npx playwright test",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --plugin-search-dir . --check . && eslint .",
Expand Down
10 changes: 4 additions & 6 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import type { PlaywrightTestConfig } from '@playwright/test'
import { defineConfig } from '@playwright/test'

const config: PlaywrightTestConfig = {
export default defineConfig({
reporter: [['json', { outputFile: 'e2eresults.json' }]],
webServer: {
command: 'npm run dev',
url: 'http://localhost:5173/',
port:5173,
timeout: 240000,
reuseExistingServer: !process.env.CI,
},
use: {
baseURL: 'http://localhost:5173/',
},
workers: process.env.CI ? 4 : undefined
}

export default config
});
5 changes: 3 additions & 2 deletions src/lib/components/Browse/DrawerAddCategory.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import gameUrlsJson from '$lib/assets/svg-json/game.json'
export let showAddCategory: boolean = true,
categories: any = []
categories: any = [],
classes: string = ''
let maxCategory = 4,
tabs = ['Game', 'Web2', 'Web3'],
Expand Down Expand Up @@ -87,7 +88,7 @@
})
</script>

<div class="bg-base-200 w-80 md:w-[30rem] flex flex-col">
<div class="bg-base-200 rounded-lg w-80 md:w-[30rem] flex flex-col {classes}">
<p class="p-3 text-xl mb-5 pb-2 border-purple-500 font-semibold border-b-2">Select category</p>
<div class="flex flex-col p-3 h-full">
<div class="relative">
Expand Down
4 changes: 3 additions & 1 deletion src/lib/components/Browse/DrawerCreateChannel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<div class="drawer-side">
<label
for="create-channel-drawer"
on:keyup
on:click={() =>
setTimeout(() => {
showDrawer = false
Expand All @@ -88,12 +89,13 @@
<DrawerAddCategory bind:showAddCategory bind:categories={newChannel.category} />
{:else}
<form
class="flex m-5"
action="?/create-channel"
method="post"
use:enhance={({ data }) => {
data.append('newChannel', JSON.stringify(newChannel))
}}>
<div class="bg-base-200 w-80 md:w-[30rem] h-full flex flex-col">
<div class="bg-base-200 w-80 md:w-[30rem] h-full flex flex-col rounded-lg">
<p class="p-3 text-xl mb-5 pb-2 border-purple-500 font-semibold border-b-2">
Create a new channel
</p>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/Browse/Sections/SectionChannelItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export let channel: any
</script>

<div class="flex flex-col shrink-0 first:pl-8 last:pr-8 w-[300px] md:w-[400px] rounded-md">
<a class="flex flex-col shrink-0 first:pl-8 last:pr-8 w-[300px] md:w-[400px] rounded-md" href="/channel/{channel._id}">
<div class="relative">
<div class="video-thumbnail" on:click|preventDefault={() => goto(`/channel/${channel._id}`)}>
{#if channel.thumbnail}
Expand Down Expand Up @@ -34,4 +34,4 @@
<p class="text-sm text-gray-600">{channel.description}</p>
</div>
</div>
</div>
</a>
10 changes: 7 additions & 3 deletions src/lib/components/Channel/Chat/DrawerChat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import DropdownViewChannel from '$lib/components/Channel/Chat/DropdownViewChannel.svelte'
import { page } from '$app/stores'
export let channel: any = undefined
export let channel: any = undefined,
showEditChannelDrawer: boolean = false
let chatHistory: any[] = []
Expand Down Expand Up @@ -39,12 +40,15 @@
}
chatHistory = chatHistory.reverse()
}
if (parsedMsg.eventName === `channel-update-${channel._id}`) {
channel = parsedMsg.channel
}
})
</script>

<div class="bg-base-100 flex flex-col overflow-y-hidden">
<!--lg:opacity-70-->
<DropdownViewChannel bind:channel />
<DropdownViewChannel bind:channel bind:showEditChannelDrawer />
<div class="flex flex-col-reverse p-3 grow overflow-y-scroll lg:w-[425px] w-[415px]">
{#each chatHistory as sender}
<Message bind:sender bind:hostId={channel.user} />
Expand Down
228 changes: 228 additions & 0 deletions src/lib/components/Channel/Chat/DrawerEditChannel.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,228 @@
<script lang="ts">
// import IconPhoto from '$lib/assets/icons/IconPhoto.svelte'
import { tags } from '$lib/stores/channelStore'
import { onDestroy, onMount } from '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'
import { category_list } from '$lib/stores/channelStore'
import { emitChannelUpdate } from '$lib/websocket'
export let channel: any, showDrawer: boolean
let fileuploader: HTMLInputElement,
thumbnailRef: any,
showThumbnail = false,
showAddCategory = false,
maxTag = 3,
maxCategory = 4
$: maxTagLabel = channel?.tags.length == maxTag ? 'max reached' : 'max ' + maxTag
$: maxCategoryLabel =
channel?.category.length == maxCategory ? 'max reached' : 'max ' + maxCategory
onMount(async () => {
if (!$tags.length) {
const suggestedTags = await get(`tags`)
$tags = suggestedTags
}
})
onDestroy(() => {
showDrawer = false
})
const fileupload = async () => {
const file = fileuploader.files && fileuploader.files[0]
if (file) {
const reader = new FileReader()
reader.addEventListener('load', function () {
thumbnailRef.setAttribute('src', reader.result)
})
reader.readAsDataURL(file)
// channel.thumbnail = reader.result
showThumbnail = true
return
}
showThumbnail = false
}
const addTag = (tagName: string) => {
tagName && channel.tags.length < maxTag ? channel.tags.push(tagName) : ''
channel = channel
}
let refToggle: any
const toggleDrawer = () => {
if (refToggle) {
refToggle.checked = false
}
setTimeout(() => {
showDrawer = false
}, 200)
}
</script>

<div class="drawer drawer-end absolute right-0 z-10 top-0">
<input id="edit-channel-drawer" bind:this={refToggle} type="checkbox" class="drawer-toggle" />

<div class="drawer-side m-5 rounded-lg">
<label
on:keyup
for="edit-channel-drawer"
class="drawer-overlay"
on:click={() =>
setTimeout(() => {
showDrawer = false
}, 200)} />
{#if showAddCategory}
<DrawerAddCategory
classes={'w-[415px] lg:w-[425px]'}
bind:showAddCategory
bind:categories={channel.category} />
{:else}
<form
action="?/edit-channel"
method="post"
use:enhance={({ data }) => {
data.append('category-selected', JSON.stringify(channel.category))
data.append('tags-selected', JSON.stringify(channel.tags))
return ({ result }) => {
if (result.type === 'success') {
console.log('channel', channel)
emitChannelUpdate({ channel })
toggleDrawer()
}
}
}}>
<div class="bg-base-200 rounded-lg w-[415px] lg:w-[425px] h-full flex flex-col">
<p class="p-3 text-xl mb-5 pb-2 border-purple-500 font-semibold border-b-2">
Edit channel
</p>
<div class="flex flex-col p-3">
<p class="text-lg font-semibold">Please hide all sensitive data before going live.</p>

<!-- <div class="flex flex-row justify-center w-full">
<div class="card w-40 shadow-xl">
<div class="card-body items-center max-h-40 {showThumbnail ? '!p-3' : ''}">
{#if showThumbnail}
<img bind:this={thumbnailRef} src="" alt="Preview" class="rounded-lg h-full" />
{:else}
<IconPhoto />
{/if}
</div>
</div>
</div>
<input
bind:this={fileuploader}
on:change={fileupload}
type="file"
class="file-input file-input-bordered file-input-primary w-full mt-5" /> -->
<input
bind:value={channel.title}
type="text"
name="title"
required
placeholder="Title"
class="input input-primary input-bordered mt-5 w-full" />
<textarea
bind:value={channel.description}
placeholder="Description"
name="description"
required
class="textarea textarea-primary mt-5 text-base w-full h-28" />
<p class="text-base text-gray-500 mt-5 mb-2">Suggested Tags</p>
<div class="flex flex-wrap">
{#if $tags && $tags.length > 0}
{#each $tags as tag}
<span
class="badge badge-md text-primary bg-gray-200 rounded-md font-semibold mx-1 cursor-pointer border-none"
on:keyup
on:click={() => addTag(tag.name)}>{tag.name}</span>
{/each}
{:else}
<div class="flex justify-center w-full">
<span class="btn btn-circle btn-outline btn-sm loading" />
</div>
{/if}
</div>
<div class="relative">
<Tags
bind:tags={channel.tags}
maxTags={maxTag}
id="tags"
placeholder={channel.tags.length > 0 ? '' : 'Tag'} />
<span class="absolute right-0 top-1/2 text-gray-400 pr-3">({maxTagLabel})</span>
</div>
<div class="relative">
<input
on:click={() => (showAddCategory = true)}
type="text"
name="category"
required={!channel.category.length}
placeholder={channel?.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>
<span class="absolute flex flex-row gap-2 left-0 top-1/2 pl-5">
{#if channel?.category?.length}
{#each channel?.category as icon}
<img src={$category_list[icon]} alt="" class="h-5 w-5" />
{/each}
{/if}
</span>
</div>
<!-- <div class="flex flex-row mt-5 ">
<input
bind:checked={channel.isPrivate}
type="checkbox"
class="checkbox checkbox-primary mr-3" /> Private
</div> -->
</div>

<div class="flex flex-row gap-2 mt-auto md:mb-4 p-3">
<button type="button" class="btn btn-default grow" on:click={() => toggleDrawer()}
>Cancel</button>
<button type="submit" class="btn btn-primary grow">Edit</button>
</div>
</div>
</form>
{/if}
</div>
</div>

<style>
:global(.svelte-tags-input-layout) {
--tw-border-opacity: 1 !important;
border-color: hsl(var(--p) / var(--tw-border-opacity)) !important;
border-radius: var(--rounded-btn, 0.5rem) !important;
height: 3rem;
padding-left: 1rem !important;
padding-right: 1rem !important;
--tw-bg-opacity: 1 !important;
background-color: hsl(var(--b1) / var(--tw-bg-opacity)) !important;
flex-wrap: nowrap !important;
}
:global(.svelte-tags-input-layout) {
@apply mt-5 w-full;
}
:global(.svelte-tags-input-layout:focus-within) {
outline: 2px solid hsl(var(--p)) !important;
outline-offset: 2px !important;
}
:global(.svelte-tags-input) {
width: 100%;
font-size: 1rem !important;
font-family: inherit !important;
background-color: hsl(var(--b1) / var(--tw-bg-opacity)) !important;
}
:global(.svelte-tags-input-tag) {
background-color: hsl(var(--p) / var(--tw-bg-opacity)) !important;
padding-left: 0.5rem !important;
padding-right: 0.5rem !important;
border-radius: var(--rounded-badge, 1.5rem) !important;
}
</style>
Loading

0 comments on commit 1053f9f

Please sign in to comment.