Skip to content

Commit

Permalink
fix: build errors
Browse files Browse the repository at this point in the history
  • Loading branch information
andre-brandao committed Oct 10, 2024
1 parent 0afa2e0 commit 0bc7d1f
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 220 deletions.
38 changes: 0 additions & 38 deletions src/lib/client/components/animation/FlipText.svelte

This file was deleted.

63 changes: 31 additions & 32 deletions src/lib/client/components/animation/RetroGrid.svelte
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
<script lang="ts">
import { cn } from "$lib/utils";
let className: any = "";
export { className as class };
</script>

<div
class={cn(
"pointer-events-none absolute h-full w-full overflow-hidden opacity-50 [perspective:200px]",
className
)}
>
<!-- Grid -->
<div class="absolute inset-0 [transform:rotateX(35deg)]">
<div
class={cn(
"animate-grid",

"[background-repeat:repeat] [background-size:60px_60px] [height:300vh] [inset:0%_0px] [margin-left:-50%] [transform-origin:100%_0_0] [width:600vw]",

// Light Styles
"[background-image:linear-gradient(to_right,rgba(0,0,0,0.3)_1px,transparent_0),linear-gradient(to_bottom,rgba(0,0,0,0.3)_1px,transparent_0)]",

// Dark styles
"dark:[background-image:linear-gradient(to_right,rgba(255,255,255,0.2)_1px,transparent_0),linear-gradient(to_bottom,rgba(255,255,255,0.2)_1px,transparent_0)]"
)}
/>
</div>

<!-- Background Gradient -->
import { cn } from '$lib/utils'
let className: any = ''
export { className as class }
</script>

<div
class={cn(
'pointer-events-none absolute h-full w-full overflow-hidden opacity-50 [perspective:200px]',
className,
)}
>
<!-- Grid -->
<div class="absolute inset-0 [transform:rotateX(35deg)]">
<div
class="absolute inset-0 bg-gradient-to-t from-white to-transparent to-90% dark:from-black"
class={cn(
'animate-grid',

'[background-repeat:repeat] [background-size:60px_60px] [height:300vh] [inset:0%_0px] [margin-left:-50%] [transform-origin:100%_0_0] [width:600vw]',

// Light Styles
'[background-image:linear-gradient(to_right,rgba(0,0,0,0.3)_1px,transparent_0),linear-gradient(to_bottom,rgba(0,0,0,0.3)_1px,transparent_0)]',

// Dark styles
'dark:[background-image:linear-gradient(to_right,rgba(255,255,255,0.2)_1px,transparent_0),linear-gradient(to_bottom,rgba(255,255,255,0.2)_1px,transparent_0)]',
)}
/>
</div>


<!-- Background Gradient -->
<div
class="absolute inset-0 bg-gradient-to-t from-white to-transparent to-90% dark:from-black"
/>
</div>

This file was deleted.

2 changes: 1 addition & 1 deletion src/lib/client/components/cards/Card1.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { getImagePath } from '$lib/utils'
import { getImagePath } from '$lib/client/utils/image'
interface CardProps {
nome: string
Expand Down
67 changes: 0 additions & 67 deletions src/lib/client/components/cards/CardProduct.svelte

This file was deleted.

2 changes: 1 addition & 1 deletion src/lib/client/components/detail/Detail1.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { getImagePath } from '$lib/utils/image'
import { getImagePath } from '$lib/client/utils/image'
export let produto: {
id: number
Expand Down
69 changes: 34 additions & 35 deletions src/lib/client/utils/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,42 @@
* @returns {Promise<{data: number} | {error: string}>}
*/
export async function uploadImage(image: File, name: string) {
const formData = new FormData()
formData.append('name', name)
formData.append('image', image)

try {
const response = await fetch('/api/image', {
method: 'POST',
body: formData,
})

if (response.ok) {
const data = await response.json()
return { data: Number(data.img_id) }
} else {
console.error(response.statusText)

if (response.statusText === 'Unauthorized') {
return { error: 'Unauthorized' }
}
return { error: 'Error uploading image' }
const formData = new FormData()
formData.append('name', name)
formData.append('image', image)

try {
const response = await fetch('/api/image', {
method: 'POST',
body: formData,
})

if (response.ok) {
const data = await response.json()
return { data: Number(data.img_id) }
} else {
console.error(response.statusText)

if (response.statusText === 'Unauthorized') {
return { error: 'Unauthorized' }
}
} catch (error) {
console.error(error)
return { error: 'Error uploading image' }
}
} catch (error) {
console.error(error)
return { error: 'Error uploading image' }
}

export function getImagePath(id?: number | string | null) {
if (
id?.toString().startsWith('http://') ||
id?.toString().startsWith('https://')
) {
return id.toString()
}
if (!id) {
return 'https://placehold.co/400x400?text=No+Image'
}
return `/api/image/${id}`
}

export function getImagePath(id?: number | string | null) {
if (
id?.toString().startsWith('http://') ||
id?.toString().startsWith('https://')
) {
return id.toString()
}
if (!id) {
return 'https://placehold.co/400x400?text=No+Image'
}

return `/api/image/${id}`
}
3 changes: 3 additions & 0 deletions src/lib/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ export * from '../client/utils/icons'
export * from '../client/utils/device'
export * from './entities'

export * from '../client/utils/image'
export * from '../client/utils/index'

export function getEnderecoFromCEP(cep: string) {
return fetch(`https://viacep.com.br/ws/${cep}/json/`)
.then(res => res.json())
Expand Down

0 comments on commit 0bc7d1f

Please sign in to comment.