Skip to content

refactor(ui): rewrite file input component #3355

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
117 changes: 0 additions & 117 deletions apps/frontend/src/components/ui/FileInput.vue

This file was deleted.

32 changes: 0 additions & 32 deletions apps/frontend/src/helpers/fileUtils.js

This file was deleted.

76 changes: 38 additions & 38 deletions apps/frontend/src/pages/[type]/[id]/gallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,17 @@
<strong>{{ editFile ? editFile.name : "Current image" }}</strong>
<FileInput
v-if="editIndex === -1"
class="iconified-button raised-button"
prompt="Replace"
:accept="acceptFileTypes"
:max-size="524288000"
should-always-reset
aria-label="Replace image"
@change="
:callback="
(x) => {
editFile = x[0];
showPreviewImage();
}
"
:max-size="524288000"
aria-label="Replace image"
class="iconified-button raised-button"
prompt="Replace"
>
<TransferIcon aria-hidden="true" />
</FileInput>
Expand All @@ -45,9 +44,9 @@
<input
id="gallery-image-title"
v-model="editTitle"
type="text"
maxlength="64"
placeholder="Enter title..."
type="text"
/>
<label for="gallery-image-desc">
<span class="label__title">Description</span>
Expand All @@ -66,8 +65,8 @@
<input
id="gallery-image-ordering"
v-model="editOrder"
type="number"
placeholder="Enter order index..."
type="number"
/>
<label for="gallery-image-featured">
<span class="label__title">Featured</span>
Expand All @@ -91,7 +90,7 @@
class="iconified-button"
@click="editFeatured = false"
>
<StarIcon fill="currentColor" aria-hidden="true" />
<StarIcon aria-hidden="true" fill="currentColor" />
Unfeature image
</button>
<div class="button-group">
Expand All @@ -101,17 +100,17 @@
</button>
<button
v-if="editIndex === -1"
class="iconified-button brand-button"
:disabled="shouldPreventActions"
class="iconified-button brand-button"
@click="createGalleryItem"
>
<PlusIcon aria-hidden="true" />
Add gallery image
</button>
<button
v-else
class="iconified-button brand-button"
:disabled="shouldPreventActions"
class="iconified-button brand-button"
@click="editGalleryItem"
>
<SaveIcon aria-hidden="true" />
Expand All @@ -123,10 +122,10 @@
<ConfirmModal
v-if="currentMember"
ref="modal_confirm"
title="Are you sure you want to delete this gallery image?"
description="This will remove this gallery image forever (like really forever)."
:has-to-type="false"
description="This will remove this gallery image forever (like really forever)."
proceed-label="Delete"
title="Are you sure you want to delete this gallery image?"
@proceed="deleteGalleryImage"
/>
<div
Expand All @@ -136,14 +135,14 @@
>
<div class="content">
<img
class="image"
:alt="expandedGalleryItem.title ? expandedGalleryItem.title : 'gallery-image'"
:class="{ 'zoomed-in': zoomedIn }"
:src="
expandedGalleryItem.raw_url
? expandedGalleryItem.raw_url
: 'https://cdn.modrinth.com/placeholder-banner.svg'
"
:alt="expandedGalleryItem.title ? expandedGalleryItem.title : 'gallery-image'"
class="image"
@click.stop
/>

Expand All @@ -162,13 +161,13 @@
<XIcon aria-hidden="true" />
</button>
<a
class="open circle-button"
target="_blank"
:href="
expandedGalleryItem.raw_url
? expandedGalleryItem.raw_url
: 'https://cdn.modrinth.com/placeholder-banner.svg'
"
class="open circle-button"
target="_blank"
>
<ExternalIcon aria-hidden="true" />
</a>
Expand Down Expand Up @@ -197,16 +196,14 @@
</div>
<div v-if="currentMember" class="card header-buttons">
<FileInput
:max-size="524288000"
:accept="acceptFileTypes"
prompt="Upload an image"
:callback="handleFiles"
:disabled="!isPermission(currentMember?.permissions, 1 << 2)"
:max-size="524288000"
aria-label="Upload an image"
class="iconified-button brand-button"
:disabled="!isPermission(currentMember?.permissions, 1 << 2)"
@change="handleFiles"
>
<UploadIcon aria-hidden="true" />
</FileInput>
prompt="Upload an image"
/>
<span class="indicator">
<InfoIcon aria-hidden="true" /> Click to choose an image or drag one onto this page
</span>
Expand All @@ -220,8 +217,8 @@
<div v-for="(item, index) in project.gallery" :key="index" class="card gallery-item">
<a class="gallery-thumbnail" @click="expandImage(item, index)">
<img
:src="item.url ? item.url : 'https://cdn.modrinth.com/placeholder-banner.svg'"
:alt="item.title ? item.title : 'gallery-image'"
:src="item.url ? item.url : 'https://cdn.modrinth.com/placeholder-banner.svg'"
/>
</a>
<div class="gallery-body">
Expand Down Expand Up @@ -278,25 +275,23 @@

<script setup>
import {
PlusIcon,
CalendarIcon,
ContractIcon,
EditIcon,
TrashIcon,
SaveIcon,
StarIcon,
XIcon,
RightArrowIcon,
LeftArrowIcon,
ExternalIcon,
ExpandIcon,
ContractIcon,
UploadIcon,
InfoIcon,
ExternalIcon,
ImageIcon,
InfoIcon,
LeftArrowIcon,
PlusIcon,
RightArrowIcon,
SaveIcon,
StarIcon,
TransferIcon,
TrashIcon,
XIcon,
} from "@modrinth/assets";
import { ConfirmModal } from "@modrinth/ui";
import FileInput from "~/components/ui/FileInput.vue";
import { ConfirmModal, FileInput } from "@modrinth/ui";
import DropArea from "~/components/ui/DropArea.vue";
import Modal from "~/components/ui/Modal.vue";

Expand Down Expand Up @@ -611,6 +606,7 @@ export default defineNuxtComponent({
max-width: calc(100vw - 2 * var(--spacing-card-lg));
}
}

.floating {
position: absolute;
left: 50%;
Expand All @@ -626,10 +622,12 @@ export default defineNuxtComponent({

&:not(&:hover) {
opacity: 0.4;

.text {
transform: translateY(2.5rem) scale(0.8);
opacity: 0;
}

.controls {
transform: translateY(0.25rem) scale(0.9);
}
Expand Down Expand Up @@ -658,6 +656,7 @@ export default defineNuxtComponent({
margin: 0;
}
}

.controls {
background-color: var(--color-raised-bg);
padding: var(--spacing-card-md);
Expand Down Expand Up @@ -777,6 +776,7 @@ export default defineNuxtComponent({
svg {
min-width: 1rem;
}

strong {
word-wrap: anywhere;
}
Expand Down
Loading