-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from menthorlabs/creators/image
Creators/image
- Loading branch information
Showing
42 changed files
with
1,152 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: [menthorlabs] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<script setup lang="ts"> | ||
import { useClipboard } from "@vueuse/core"; | ||
const { fileUrl = "" } = defineProps<{ | ||
fileUrl: string; | ||
}>(); | ||
const source = ref(fileUrl); | ||
const { copy, copied } = useClipboard({ source }); | ||
</script> | ||
|
||
<template> | ||
<div | ||
v-if="fileUrl === 'loading'" | ||
class="flex items-center justify-center w-full aspect-video bg-zinc-100 animate-pulse" | ||
> | ||
<svg | ||
class="w-10 h-10 text-zinc-200" | ||
aria-hidden="true" | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="currentColor" | ||
viewBox="0 0 20 18" | ||
> | ||
<path | ||
d="M18 0H2a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2Zm-5.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Zm4.376 10.481A1 1 0 0 1 16 15H4a1 1 0 0 1-.895-1.447l3.5-7A1 1 0 0 1 7.468 6a.965.965 0 0 1 .9.5l2.775 4.757 1.546-1.887a1 1 0 0 1 1.618.1l2.541 4a1 1 0 0 1 .028 1.011Z" | ||
/> | ||
</svg> | ||
</div> | ||
<div v-else class="relative group"> | ||
<div | ||
class="absolute top-2 right-2 z-20 hidden group-hover:flex items-center gap-1" | ||
> | ||
<nuxt-link external target="_blank" :to="fileUrl"> | ||
<MIconButton icon="external-link-alt" class="!text-white" /> | ||
</nuxt-link> | ||
<MIconButton icon="times" class="!text-white" /> | ||
</div> | ||
|
||
<div | ||
class="absolute z-10 top-0 left-0 w-full h-full items-center justify-center bg-black/50 cursor-pointer hidden group-hover:flex" | ||
@click="copy()" | ||
> | ||
<span class="font-semibold text-sm text-white"> | ||
{{ copied ? "Copiado!" : "Copiar url" }} | ||
</span> | ||
</div> | ||
<div class="aspect-video w-full overflow-hidden bg-zinc-100"> | ||
<nuxt-img | ||
:src="fileUrl" | ||
:quality="85" | ||
format="webp" | ||
width="250" | ||
height="140" | ||
alt="Roadmap" | ||
class="h-full w-full object-cover object-center transition-all group-hover:scale-110" | ||
/> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<template> | ||
<div class="w-full flex-1 p-3"> | ||
<div class="text-zinc-700 font-medium pl-4 py-[10px] text-sm"> | ||
Criação de conteúdo | ||
</div> | ||
<nuxt-link | ||
to="/creators/images" | ||
class="group" | ||
exact-active-class="is-active" | ||
> | ||
<LeftMenuItem | ||
icon="image" | ||
text="Imagens" | ||
class="group-[.is-active]:text-zinc-950 group-[.is-active]:bg-zinc-100" | ||
/> | ||
</nuxt-link> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<script setup lang="ts"> | ||
const creatorsStore = useCreatorsStore(); | ||
const uploadStore = useUploadStore(); | ||
const loading = ref(true); | ||
onMounted(async () => { | ||
await creatorsStore.getImages(); | ||
loading.value = false; | ||
}); | ||
function getSizePercentage(bytes: number) { | ||
const tenGigabytes = 10737418240; | ||
return Number((bytes * 100) / tenGigabytes).toFixed(2); | ||
} | ||
function onInput(event: Event) { | ||
const allFiles = (event.target as HTMLInputElement).files; | ||
if (!allFiles) return; | ||
for (let i = 0; i < allFiles.length; ++i) { | ||
const file = allFiles[i]; | ||
uploadFile(file); | ||
} | ||
} | ||
async function uploadFile(file: File) { | ||
loading.value = true; | ||
const response = await creatorsStore.signUrl(file.type); | ||
await uploadStore.uploadFileOnUrl(file, response.signedUrl.url); | ||
await creatorsStore.addImage(response.signedUrl.fileName); | ||
loading.value = false; | ||
} | ||
</script> | ||
|
||
<template> | ||
<div | ||
class="container pt-4" | ||
:class="{ 'overflow-hidden h-[calc(100%_-_56px)]': loading }" | ||
> | ||
<h1 class="text-4xl font-extrabold mb-4">Suas imagens</h1> | ||
<div class="flex items-center gap-4 mb-8"> | ||
<MButton | ||
variant="outline" | ||
text="Fazer upload" | ||
icon-left="cloud-arrow-up" | ||
@click="($refs['creators_image'] as HTMLInputElement).click()" | ||
/> | ||
<input | ||
ref="creators_image" | ||
id="creators_image" | ||
name="creators_image" | ||
type="file" | ||
accept="image/*" | ||
multiple | ||
class="hidden" | ||
@input="onInput" | ||
/> | ||
|
||
<div class="space-y-[4px] w-full max-w-[240px] pt-2"> | ||
<div class="rounded-full bg-zinc-200 h-[4px]"> | ||
<div | ||
class="w-full h-full rounded-full bg-emerald-500" | ||
:style="`max-width: ${getSizePercentage( | ||
creatorsStore.filesSize | ||
)}%;`" | ||
></div> | ||
</div> | ||
<div class="flex text-zinc-500 text-sm"> | ||
<div class="flex-1"> | ||
Usado: | ||
<span class="text-zinc-950 font-medium">{{ | ||
$filters.bytesToSize(creatorsStore.filesSize) | ||
}}</span> | ||
de 10 GB | ||
</div> | ||
<div>{{ getSizePercentage(creatorsStore.filesSize) }} %</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div | ||
class="grid grid-cols-[repeat(auto-fill,_minmax(200px,_1fr))] gap-1 relative" | ||
v-if="loading" | ||
> | ||
<CreatorsImageCard v-for="i in 30" :key="i" fileUrl="loading" /> | ||
<div | ||
class="absolute top-0 left-0 w-full h-full bg-[linear-gradient(180deg,_rgba(255,_255,_255,_0.00)_0%,_#FFF_100%)] z-10" | ||
></div> | ||
</div> | ||
<div | ||
class="grid grid-cols-[repeat(auto-fill,_minmax(200px,_1fr))] gap-1" | ||
v-else | ||
> | ||
<CreatorsImageCard | ||
v-for="fileName in creatorsStore.images.reverse()" | ||
:key="fileName" | ||
:fileUrl="`https://menthor-content.s3.sa-east-1.amazonaws.com/${fileName}`" | ||
/> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.