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

Updated with shadcn UI #4

Merged
merged 34 commits into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
16863e1
sveltekit tailwind init
prokawsar Jan 25, 2024
859cbd0
button
prokawsar Jan 25, 2024
a7f81f8
folder upload working
prokawsar Jan 25, 2024
a29cf32
loading images
prokawsar Jan 25, 2024
42bc833
store and header
prokawsar Jan 25, 2024
ce8fd21
filter wip
prokawsar Jan 25, 2024
ad258ef
sort
prokawsar Jan 25, 2024
a893e74
temp
prokawsar Jan 25, 2024
244f199
temp
prokawsar Jan 25, 2024
60adabc
image tag
prokawsar Jan 25, 2024
0d7a9d4
tag sign
prokawsar Jan 25, 2024
1e61f75
wip delete image
prokawsar Jan 25, 2024
867786d
update readme
prokawsar Jan 25, 2024
6b6a2fb
delete image wip
prokawsar Jan 27, 2024
bb6dae3
delete working
prokawsar Jan 28, 2024
b28861e
modal wip
prokawsar Jan 28, 2024
6e428c4
using shadcn
prokawsar Jan 29, 2024
7d1759c
ignore lock file
prokawsar Jan 29, 2024
858d3a8
update
prokawsar Jan 29, 2024
054ed7a
delete modal added
prokawsar Jan 29, 2024
a09384f
adapter
prokawsar Jan 29, 2024
955e519
fix modal UI
prokawsar Jan 31, 2024
a243cd9
slider
prokawsar Jan 31, 2024
e439036
fix ui load
prokawsar Jan 31, 2024
03b43b0
fix slider
prokawsar Jan 31, 2024
58e2bf5
zoom level wip
prokawsar Jan 31, 2024
603b1a4
fix ui
prokawsar Jan 31, 2024
00d00eb
zooming
prokawsar Jan 31, 2024
cf78279
ignore lock file
prokawsar Mar 5, 2024
f9b09c0
Merge branch 'shadcn'
prokawsar Mar 5, 2024
52d197b
Merge branch 'main' into vercel
prokawsar Mar 13, 2024
5798d1c
fix max height
prokawsar Mar 14, 2024
1b3a02e
Merge branch 'ARK-Builders:main' into vercel
prokawsar Mar 17, 2024
0319df2
update icon and name
prokawsar Mar 17, 2024
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
13 changes: 13 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://shadcn-svelte.com/schema.json",
"style": "default",
"tailwind": {
"config": "tailwind.config.js",
"css": "src/app.css",
"baseColor": "slate"
},
"aliases": {
"components": "$lib/components",
"utils": "$lib/utils"
}
}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
},
"type": "module",
"dependencies": {
"@sveltejs/adapter-vercel": "^5.1.0"
"@sveltejs/adapter-vercel": "^5.1.0",
"bits-ui": "^0.16.0",
"clsx": "^2.1.0",
"lucide-svelte": "^0.316.0",
"tailwind-merge": "^2.2.1",
"tailwind-variants": "^0.1.20"
}
}
75 changes: 75 additions & 0 deletions src/app.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,78 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

@layer base {
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;

--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;

--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;

--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;

--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;

--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;

--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;

--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;

--destructive: 0 72.2% 50.6%;
--destructive-foreground: 210 40% 98%;

--ring: 222.2 84% 4.9%;

--radius: 0.5rem;
}

.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;

--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;

--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;

--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;

--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;

--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 11.2%;

--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;

--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;

--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;

--ring: hsl(212.7, 26.8%, 83.9);
}
}

@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
40 changes: 24 additions & 16 deletions src/lib/components/Actions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,40 @@
import { createEventDispatcher } from 'svelte'
import Fa from 'svelte-fa'

import { Button } from '$lib/components/ui/button'
import { Tooltip, TooltipContent, TooltipTrigger } from './ui/tooltip'

const dispatch = createEventDispatcher()
$: hasImages = $galleryStore.images?.length
</script>

<div class="flex flex-row gap-3 justify-end mt-10">
<button
class:hidden={!$galleryStore.images?.length}
class="flex flex-row items-center text-white gap-2 rounded-xl bg-blue-400 hover:bg-blue-600 px-4 py-2"
<Button
class="flex flex-row items-center text-white gap-2 rounded-xl bg-blue-400 hover:bg-blue-600 px-4 py-2 {!hasImages
? 'hidden'
: ''}"
>
<Fa icon={faTag} />
<span>Add tag to image</span>
</button>
<button
on:click={() => dispatch('upload')}
class="flex flex-row items-center text-white gap-2 rounded-xl bg-blue-400 hover:bg-blue-600 px-4 py-2"
>
<Fa icon={faImage} />
<span>Select images</span>
</button>
</Button>
<Tooltip>
<TooltipTrigger>
<Button
on:click={() => dispatch('upload')}
class="flex flex-row items-center text-white gap-2 rounded-xl bg-blue-400 hover:bg-blue-600 px-4 py-2"
>
<Fa icon={faImage} />
<span>Select images</span>
</Button>
</TooltipTrigger>
</Tooltip>

<button
<Button
variant={'outline'}
disabled={!$galleryStore.selectedImage}
on:click={() => dispatch('delete')}
class:hidden={!$galleryStore.images?.length}
class:cursor-not-allowed={!$galleryStore.selectedImage}
class="px-3 bg-slate-200 rounded-lg"
class="px-3 bg-gray-200 rounded-lg {!hasImages ? 'hidden' : ''}"
>
<Fa icon={faTrash} />
</button>
</Button>
</div>
56 changes: 47 additions & 9 deletions src/lib/components/Filter.svelte
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
<script lang="ts">
import { page } from '$app/stores'
import { galleryStore } from '$lib/store'
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectLabel,
SelectTrigger,
SelectValue
} from '$lib/components/ui/select'
import type { Selected } from 'bits-ui'

export let filter = ''
export let filter: Selected<string> = { value: '' }

const filters = ['date', 'map', 'name', 'size', 'tag']
const filters = [
{ value: 'date', label: 'date' },
{ value: 'map', label: 'map' },
{ value: 'name', label: 'name' },
{ value: 'size', label: 'size' },
{ value: 'tag', label: 'tag' }
]
let tmr: number

const updateFilter = async () => {
let _images = $galleryStore.images

// $page.url.searchParams.set('filter', filter)
switch (filter.value) {

switch (filter) {
case 'date':
_images.sort((a: File, b: File) => {
return a.lastModified - b.lastModified
Expand All @@ -35,16 +50,39 @@
default:
break
}
$galleryStore.images = _images

if (tmr) clearTimeout(tmr)
tmr = setTimeout(() => {
$galleryStore.images = _images
}, 10)
}
$: filter, updateFilter()
</script>

<div class="flex flex-row items-center w-full rounded-full shadow-lg bg-white py-3 px-10">
<div class="flex flex-row items-center w-full rounded-full shadow-lg bg-white py-2 px-10">
<p>Show</p>
<select bind:value={filter} on:change={() => updateFilter()} class="outline-none px-1 pb-[1px]">

<!-- <select bind:value={filter} on:change={() => updateFilter()} class="outline-none px-1 pb-[1px]">
<option value="">All photos</option>
{#each filters as _filter}
<option value={_filter}>By {_filter}</option>
{/each}
</select>
</select> -->

<Select bind:selected={filter}>
<SelectTrigger class="w-32 flex border-none focus:ring-0 focus:ring-offset-0">
<SelectValue class="text-base" placeholder="All photos"></SelectValue>
</SelectTrigger>
<SelectContent>
<SelectGroup>
<SelectLabel class="pl-7">All photos</SelectLabel>
{#each filters as filter}
<SelectItem class="cursor-pointer" value={filter.value} label={filter.label}
>by {filter.label}</SelectItem
>
{/each}
</SelectGroup>
</SelectContent>
</Select>

</div>
17 changes: 9 additions & 8 deletions src/lib/components/Gallery.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<script lang="ts">
import { galleryStore } from "$lib/store"
import Image from "$lib/components/Image.svelte"

import { galleryStore } from '$lib/store'
import Image from '$lib/components/Image.svelte'
</script>

{#if $galleryStore.images?.length}
<div class="grid grid-cols-4 md:grid-cols-5 xl:grid-cols-7 gap-3 mt-10">
{#each $galleryStore.images as image, i}
<Image bind:image />
{/each}
</div>
<div
class="grid grid-cols-2 md:grid-cols-4 xl:grid-cols-6 px-2 gap-3 mt-10 max-h-[520px] overflow-auto"
>
prokawsar marked this conversation as resolved.
Show resolved Hide resolved
{#each $galleryStore.images as image, i}
<Image bind:image />
{/each}
</div>
{/if}
7 changes: 6 additions & 1 deletion src/lib/components/Image.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@

export let image: any
let hasHover = false

$: imageHeight = $galleryStore.zoomLevel + 80
prokawsar marked this conversation as resolved.
Show resolved Hide resolved

</script>

<div
role="img"
on:focus
on:mouseover={() => (hasHover = true)}
on:mouseleave={() => (hasHover = false)}
class="flex flex-col relative rounded-md h-36 bg-gray-100"
class="flex flex-col relative rounded-md bg-gray-100"
style="height: {imageHeight}px;"

>
<button
on:click={() => ($galleryStore.selectedImage = image)}
Expand Down
31 changes: 17 additions & 14 deletions src/lib/components/Modal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@
import Fa from 'svelte-fa'
import { onMount } from 'svelte'
import { galleryStore } from '$lib/store'
import Button from './ui/button/button.svelte'


let data: any
let disabled: boolean = false

const handleYes = () => {
$galleryStore.isDeleteImage = true
$galleryStore.modal = false
}

</script>

<div
Expand All @@ -15,25 +22,21 @@
class="flex overflow-y-auto overflow-x-hidden backdrop-blur-sm fixed bg-black bg-opacity-40 z-50 justify-center items-center w-screen h-screen"
>
<div class="flex flex-col min-w-96 rounded-xl border shadow-sm pb-5 px-5 bg-white">
<div class="flex flex-row justify-between">
<p class="capitalize font-semibold text-lg py-4">Questions here</p>
<button on:click={() => $galleryStore.modal = false}>
<div class="flex flex-row mt-2 justify-end">
<button on:click={() => ($galleryStore.modal = false)}>
<Fa icon={faMultiply} />
</button>
</div>
<hr class="py-1" />
<div class="p-2">
<p class="text text-center py-4">{$galleryStore.modalQuestion}</p>
</div>
<!-- <hr class="py-1" /> -->
<!-- <div>Body</div> -->
<div class="flex flex-row gap-5 w-full py-2">
<button
class="bg-white outline outline-1 outline-gray-400 text-black w-full rounded-lg py-2 disabled:cursor-not-allowed disabled:bg-opacity-60"
>
<div class="flex flex-row gap-5 justify-center py-2">
<Button on:click={() => ($galleryStore.modal = false)} variant={'outline'} class="w-32">
No
</button>
<button
class="bg-black w-full rounded-lg text-white py-2 disabled:cursor-not-allowed disabled:bg-opacity-60"
>
Yes
</button>
</Button>
<Button class="w-32" on:click={() => handleYes()}>Yes</Button>
</div>
</div>
</div>
25 changes: 25 additions & 0 deletions src/lib/components/ui/button/button.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<script lang="ts">
import { Button as ButtonPrimitive } from "bits-ui";
import { cn } from "$lib/utils";
import { buttonVariants, type Props, type Events } from ".";

type $$Props = Props;
type $$Events = Events;

let className: $$Props["class"] = undefined;
export let variant: $$Props["variant"] = "default";
export let size: $$Props["size"] = "default";
export let builders: $$Props["builders"] = [];
export { className as class };
</script>

<ButtonPrimitive.Root
{builders}
class={cn(buttonVariants({ variant, size, className }))}
type="button"
{...$$restProps}
on:click
on:keydown
>
<slot />
</ButtonPrimitive.Root>
Loading