Skip to content

Commit

Permalink
cover image tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
tdjsnelling committed Oct 29, 2023
1 parent ae0735d commit c49c8e7
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 61 deletions.
28 changes: 25 additions & 3 deletions client/components/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,40 @@ export const WrapLabel = ({ label, children, as = "label", ...rest }) =>
children
);

const Input = ({ label, rows, my, mt, mb, width, forwardedRef, ...rest }) => {
const Input = ({
label,
rows,
my,
mt,
mb,
width,
forwardedRef,
required,
...rest
}) => {
return (
<WrapLabel label={label} my={my} mt={mt} mb={mb} width={width}>
<WrapLabel
label={label && required ? `${label} *` : label}
my={my}
mt={mt}
mb={mb}
width={width}
>
{rows ? (
<StyledTextarea
ref={forwardedRef}
rows={rows}
width={width}
required={required}
{...rest}
/>
) : (
<StyledInput ref={forwardedRef} width={width} {...rest} />
<StyledInput
ref={forwardedRef}
width={width}
required={required}
{...rest}
/>
)}
</WrapLabel>
);
Expand Down
6 changes: 3 additions & 3 deletions client/components/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ const StyledSelect = styled.select(
typography
);

const Select = ({ label, fRef, ...rest }) => {
const Select = ({ label, required, fRef, ...rest }) => {
return (
<WrapLabel label={label}>
<WrapLabel label={label && required ? `${label} *` : label}>
<Box position="relative" display="inline-block">
<StyledSelect {...rest} ref={fRef} />
<StyledSelect {...rest} ref={fRef} required={required} />
<Box
position="absolute"
top="7px"
Expand Down
3 changes: 1 addition & 2 deletions client/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
"uploadCouldNotUploadTorrent": "Could not upload .torrent",
"uploadDescription": "Description",
"uploadDragDropClickSelect": "Drag and drop .torrent file here, or click to select",
"uploadDragDropClickSelectPoster": "Drag and drop your poster file here, or click to select",
"uploadDragDropClickSelectPoster": "Drag and drop your cover image here, or click to select",
"uploadDropFileHere": "Drop the file here...",
"uploadGroupWith": "Group with",
"uploadGroupWithThisTorrent": "Group with this torrent",
Expand All @@ -252,7 +252,6 @@
"uploadMarkdownSupport": "Markdown supported",
"uploadMediaInfo": "MediaInfo",
"uploadName": "Name",
"uploadPosterImage": "Poster file",
"uploadSource": "Source",
"uploadTags": "Tags",
"uploadTorrentFile": "Torrent file",
Expand Down
1 change: 0 additions & 1 deletion client/locales/eo.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@
"uploadMarkdownSupport": "Markdown subtenata",
"uploadMediaInfo": "MediaInfo",
"uploadName": "Nomo",
"uploadPosterImage": "Alŝuti afiŝo-dosieron",
"uploadSource": "Fonto",
"uploadTags": "Etikedoj",
"uploadTorrentFile": "Torenta dosiero",
Expand Down
1 change: 0 additions & 1 deletion client/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@
"uploadDragDropClickSelect": "Faites glisser et déposez un fichier .torrent ici, ou cliquez pour sélectionner",
"uploadDragDropClickSelectPoster": "Glissez et déposez votre fichier d'affiche ici, ou cliquez pour sélectionner",
"uploadDropFileHere": "Déposez le fichier ici...",
"uploadPosterImage": "Uploader le fichier d'affiche",
"uploadGroupWith": "Regrouper avec",
"uploadGroupWithThisTorrent": "Regrouper avec ce torrent",
"uploadInfoBox1": "Les extensions de fichier suivantes sont interdites. Tout torrent contenant des fichiers de ces types ne sera pas téléchargé.",
Expand Down
1 change: 0 additions & 1 deletion client/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@
"uploadMarkdownSupport": "Поддержка Markdown",
"uploadMediaInfo": "Медиаинфо",
"uploadName": "Имя",
"uploadPosterImage": "Загрузить файл плаката",
"uploadSource": "Источник",
"uploadTags": "Метки",
"uploadTorrentFile": "Торрент файл",
Expand Down
1 change: 0 additions & 1 deletion client/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@
"uploadMarkdownSupport": "支持 Markdown",
"uploadMediaInfo": "MediaInfo",
"uploadName": "名称",
"uploadPosterImage": "上传海报文件",
"uploadSource": "来源",
"uploadTags": "标签",
"uploadTorrentFile": "Torrent 文件",
Expand Down
9 changes: 6 additions & 3 deletions client/pages/torrent/[infoHash].js
Original file line number Diff line number Diff line change
Expand Up @@ -675,13 +675,16 @@ const Torrent = ({ token, torrent = {}, userId, userRole, uid, userStats }) => {
>
{getLocaleString("posterImage")}
</Text>
<img
<Box
as="img"
src={`data:image/${
isPngImage(torrent.poster) ? "png" : "jpeg"
};base64,${torrent.poster}`}
alt="Poster"
alt={`Cover image for “${torrent.name}”`}
width="auto"
height={200}
height="auto"
maxWidth="500px"
maxHeight="500px"
/>
</Infobox>
)}
Expand Down
99 changes: 53 additions & 46 deletions client/pages/upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ const Upload = ({ token, userId }) => {
setDropError(e.message);
}
}, []);

const onPosterDrop = useCallback((acceptedFiles) => {
try {
const [file] = acceptedFiles;
Expand Down Expand Up @@ -395,59 +396,66 @@ const Upload = ({ token, userId }) => {
</Infobox>
)}
<form onSubmit={handleUpload}>
<Box mb={4}>
<WrapLabel label={getLocaleString("uploadTorrentFile")} as="div">
<FileUpload {...getRootProps()}>
<input {...getInputProps()} />
{torrentFile ? (
<Text icon={Check} iconColor="success" iconSize={24} ml={2}>
{torrentFile.name}
</Text>
) : isDragActive ? (
<Text color="grey">
{getLocaleString("uploadDropFileHere")}
</Text>
) : (
<Text color="grey">
{getLocaleString("uploadDragDropClickSelect")}
</Text>
)}
</FileUpload>
</WrapLabel>
{dropError && (
<Text color="error" mt={3}>
{getLocaleString("uploadCouldNotUploadTorrent")}: {dropError}
</Text>
)}
</Box>
<Box mb={4}>
<WrapLabel label={getLocaleString("uploadPosterImage")} as="div">
<FileUpload {...getPosterRootProps()}>
<input {...getPosterInputProps()} />
{posterFile ? (
<img
src={`data:image/${
isPngImage(posterFile.b64) ? "png" : "jpeg"
};base64,${posterFile.b64}`}
alt="Poster"
width={"auto"}
height={200}
/>
) : (
isPosterDragActive ? (
<Box
display="grid"
gridTemplateColumns={["1fr", "repeat(2, 1fr)"]}
gridGap={4}
mb={4}
>
<Box>
<WrapLabel
label={`${getLocaleString("uploadTorrentFile")} *`}
as="div"
>
<FileUpload {...getRootProps()}>
<input {...getInputProps()} />
{torrentFile ? (
<Text icon={Check} iconColor="success" iconSize={24} ml={2}>
{torrentFile.name}
</Text>
) : isDragActive ? (
<Text color="grey">
{getLocaleString("uploadDropFileHere")}
</Text>
) : (
<Text color="grey">
{getLocaleString("uploadDragDropClickSelect")}
</Text>
)}
</FileUpload>
</WrapLabel>
{dropError && (
<Text color="error" mt={3}>
{getLocaleString("uploadCouldNotUploadTorrent")}: {dropError}
</Text>
)}
</Box>
<Box>
<WrapLabel label={getLocaleString("posterImage")} as="div">
<FileUpload {...getPosterRootProps()}>
<input {...getPosterInputProps()} />
{posterFile ? (
<img
src={`data:image/${
isPngImage(posterFile.b64) ? "png" : "jpeg"
};base64,${posterFile.b64}`}
alt="Poster"
width={"auto"}
height={200}
/>
) : isPosterDragActive ? (
<Text color="grey">
{getLocaleString("uploadDropImageHere")}
</Text>
) : (
<Text color="grey">
{getLocaleString("uploadDragDropClickSelectPoster")}
</Text>
)
)}
</FileUpload>
</WrapLabel>
)}
</FileUpload>
</WrapLabel>
</Box>
</Box>

<TorrentFields
categories={SQ_TORRENT_CATEGORIES}
handleGroupSearch={handleGroupSearch}
Expand Down Expand Up @@ -512,7 +520,6 @@ const Upload = ({ token, userId }) => {
) : undefined
}
/>

{groupWith && (
<Box display="flex" alignItems="flex-end" mb={4}>
<Input
Expand Down

0 comments on commit c49c8e7

Please sign in to comment.