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

feat(a11y): Change behavior of some file upload fields #1577

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
dc43c51
fix(a11y): Change the look and behavior of some file upload fields
jsit Jun 25, 2023
7d44bc4
Merge remote-tracking branch 'lemmy/main' into feat/create-post-file-…
jsit Jun 25, 2023
78e1ab9
Merge branch 'main' into feat/create-post-file-upload-a11y
jsit Jun 25, 2023
f27bb07
chore: Separate post mod buttons into functions
jsit Jun 25, 2023
00d7a8d
fix: Move things back to where they were
jsit Jun 25, 2023
1db654e
fix: Remove extraneous classes
jsit Jun 25, 2023
bbe897d
fix: Remove wrapping li's
jsit Jun 25, 2023
984de71
fix: Restore removed classes
jsit Jun 25, 2023
32cc253
fix: Remove unnecessary classes
jsit Jun 25, 2023
04770d7
fix: Remove unnecessary class
jsit Jun 25, 2023
8fd08e5
fix: Remove unnecessary string interpolations
jsit Jun 25, 2023
9dc25f2
Associate NSFW label with its checkbox
minorninth Jun 26, 2023
308785b
Only give child comments colored borders
SleeplessOne1917 Jun 25, 2023
91122f4
chore(DX): Add prettier to eslint config for use with editors
jsit Jun 26, 2023
cf10bd6
Fix: missing semantic css classes and html elements (#1583)
0xAnansi Jun 26, 2023
f5be909
feat(UI): Reduce base font size (#1591)
jsit Jun 26, 2023
950dfad
Move password reset form to separate route, view (#1390)
alectrocute Jun 26, 2023
022c27a
capitalize button (#1616)
alectrocute Jun 26, 2023
dd09b3c
Indicate valid and invalid fields in signup form (#1450)
dullbananas Jun 26, 2023
d816b8f
remove icon (#1618)
alectrocute Jun 26, 2023
28661df
fix vote button alignment
alectrocute Jun 26, 2023
8e2f83e
Fix feedback on banning an unbanning
pascaldevink Jun 26, 2023
b2b6f45
fix: Use Bootstrap file upload form control styles
jsit Jun 26, 2023
044441d
Merge branch 'main' into feat/create-post-file-upload-a11y
jsit Jun 26, 2023
0bd0a49
Merge branch 'main' into feat/create-post-file-upload-a11y
jsit Jul 2, 2023
3c6505b
fix: Add some spacing between upload field and image; fix circle imag…
jsit Jul 2, 2023
61276ec
fix: Fix circle image aspect ratio
jsit Jul 2, 2023
0047c17
fix: Fix avatar image overlay aspect ratio
jsit Jul 2, 2023
d620dea
Merge branch 'main' into feat/create-post-file-upload-a11y
jsit Jul 2, 2023
e7f7bc2
Merge branch 'main' into feat/create-post-file-upload-a11y
SleeplessOne1917 Jul 2, 2023
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
10 changes: 4 additions & 6 deletions src/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,6 @@ hr {
-ms-filter: blur(10px);
}

.img-cover {
object-fit: cover;
}

.img-expanded {
max-height: 90vh;
}
Expand Down Expand Up @@ -350,10 +346,12 @@ br.big {
}

.avatar-overlay {
width: 20%;
height: 20%;
width: 20vw;
height: 20vw;
max-width: 120px;
max-height: 120px;
min-width: 80px;
min-height: 80px;
}

.avatar-pushup {
Expand Down
52 changes: 25 additions & 27 deletions src/shared/components/common/image-upload-form.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { randomStr } from "@utils/helpers";
import classNames from "classnames";
import { Component, linkEvent } from "inferno";
import { HttpService, I18NextService, UserService } from "../../services";
import { toast } from "../../toast";
Expand Down Expand Up @@ -33,38 +34,35 @@ export class ImageUploadForm extends Component<
render() {
return (
<form className="image-upload-form d-inline">
<label htmlFor={this.id} className="pointer text-muted small fw-bold">
{this.props.imageSrc ? (
<span className="d-inline-block position-relative">
{/* TODO: Create "Current Iamge" translation for alt text */}
<img
alt=""
src={this.props.imageSrc}
height={this.props.rounded ? 60 : ""}
width={this.props.rounded ? 60 : ""}
className={`img-fluid ${
this.props.rounded ? "rounded-circle" : ""
}`}
/>
<button
className="position-absolute d-block p-0 end-0 border-0 top-0 bg-transparent text-white"
type="button"
onClick={linkEvent(this, this.handleRemoveImage)}
aria-label={I18NextService.i18n.t("remove")}
>
<Icon icon="x" classes="mini-overlay" />
</button>
</span>
) : (
<span className="btn btn-secondary">{this.props.uploadTitle}</span>
)}
</label>
{this.props.imageSrc && (
<span className="d-inline-block position-relative mb-2">
{/* TODO: Create "Current Iamge" translation for alt text */}
<img
alt=""
src={this.props.imageSrc}
height={this.props.rounded ? 60 : ""}
width={this.props.rounded ? 60 : ""}
className={classNames({
"rounded-circle object-fit-cover": this.props.rounded,
"img-fluid": !this.props.rounded,
})}
/>
<button
className="position-absolute d-block p-0 end-0 border-0 top-0 bg-transparent text-white"
type="button"
onClick={linkEvent(this, this.handleRemoveImage)}
aria-label={I18NextService.i18n.t("remove")}
>
<Icon icon="x" classes="mini-overlay" />
</button>
</span>
)}
<input
id={this.id}
type="file"
accept="image/*,video/*"
className="small form-control"
name={this.id}
className="d-none"
disabled={!UserService.Instance.myUserInfo}
onChange={linkEvent(this, this.handleImageUpload)}
/>
Expand Down
3 changes: 3 additions & 0 deletions src/shared/components/common/markdown-textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ export class MarkdownTextArea extends Component<
<form className="btn btn-sm text-muted fw-bold">
<label
htmlFor={`file-upload-${this.id}`}
// TODO: Fix this linting violation
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
className={`mb-0 ${
UserService.Instance.myUserInfo && "pointer"
}`}
Expand Down
6 changes: 3 additions & 3 deletions src/shared/components/common/pictrs-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ export class PictrsImage extends Component<PictrsImageProps, any> {
className={classNames("overflow-hidden pictrs-image", {
"img-fluid": !this.props.icon && !this.props.iconOverlay,
banner: this.props.banner,
"thumbnail rounded":
"thumbnail rounded object-fit-cover":
this.props.thumbnail && !this.props.icon && !this.props.banner,
"img-expanded slight-radius":
!this.props.thumbnail && !this.props.icon,
"img-blur": this.props.thumbnail && this.props.nsfw,
"img-cover img-icon me-1": this.props.icon,
"ms-2 mb-0 rounded-circle img-cover avatar-overlay":
"object-fit-cover img-icon me-1": this.props.icon,
"ms-2 mb-0 rounded-circle object-fit-cover avatar-overlay":
this.props.iconOverlay,
"avatar-pushup": this.props.pushup,
})}
Expand Down
52 changes: 28 additions & 24 deletions src/shared/components/home/emojis-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
</div>
)}
<div className="table-responsive">
<table id="emojis_table" className="table table-sm table-hover">
<table
id="emojis_table"
className="table table-sm table-hover align-middle"
>
<thead className="pointer">
<tr>
<th>{I18NextService.i18n.t("column_emoji")}</th>
Expand Down Expand Up @@ -129,30 +132,31 @@ export class EmojiForm extends Component<EmojiFormProps, EmojiFormState> {
/>
)}
{cv.image_url.length === 0 && (
<form>
<label
className="btn btn-sm btn-secondary pointer"
htmlFor={`file-uploader-${index}`}
data-tippy-content={I18NextService.i18n.t(
"upload_image"
)}
>
{capitalizeFirstLetter(
I18NextService.i18n.t("upload")
<label
// TODO: Fix this linting violation
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
tabIndex={0}
className="btn btn-sm btn-secondary pointer"
htmlFor={`file-uploader-${index}`}
data-tippy-content={I18NextService.i18n.t(
"upload_image"
)}
>
{capitalizeFirstLetter(
I18NextService.i18n.t("upload")
)}
<input
name={`file-uploader-${index}`}
id={`file-uploader-${index}`}
type="file"
accept="image/*"
className="d-none"
onChange={linkEvent(
{ form: this, index: index },
this.handleImageUpload
)}
<input
name={`file-uploader-${index}`}
id={`file-uploader-${index}`}
type="file"
accept="image/*"
className="d-none"
onChange={linkEvent(
{ form: this, index: index },
this.handleImageUpload
)}
/>
</label>
</form>
/>
</label>
)}
</td>
<td className="text-right">
Expand Down
38 changes: 21 additions & 17 deletions src/shared/components/home/site-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,28 +158,32 @@ export class SiteForm extends Component<SiteFormProps, SiteFormState> {
/>
</div>
</div>
<div className="input-group mb-3">
<label className="me-2 col-form-label">
<div className="row mb-3">
<label className="col-sm-2 col-form-label">
{I18NextService.i18n.t("icon")}
</label>
<ImageUploadForm
uploadTitle={I18NextService.i18n.t("upload_icon")}
imageSrc={this.state.siteForm.icon}
onUpload={this.handleIconUpload}
onRemove={this.handleIconRemove}
rounded
/>
<div className="col-sm-10">
<ImageUploadForm
uploadTitle={I18NextService.i18n.t("upload_icon")}
imageSrc={this.state.siteForm.icon}
onUpload={this.handleIconUpload}
onRemove={this.handleIconRemove}
rounded
/>
</div>
</div>
<div className="input-group mb-3">
<label className="me-2 col-form-label">
<div className="row mb-3">
<label className="col-sm-2 col-form-label">
{I18NextService.i18n.t("banner")}
</label>
<ImageUploadForm
uploadTitle={I18NextService.i18n.t("upload_banner")}
imageSrc={this.state.siteForm.banner}
onUpload={this.handleBannerUpload}
onRemove={this.handleBannerRemove}
/>
<div className="col-sm-10">
<ImageUploadForm
uploadTitle={I18NextService.i18n.t("upload_banner")}
imageSrc={this.state.siteForm.banner}
onUpload={this.handleBannerUpload}
onRemove={this.handleBannerRemove}
/>
</div>
</div>
<div className="mb-3 row">
<label className="col-12 col-form-label" htmlFor="site-desc">
Expand Down
111 changes: 54 additions & 57 deletions src/shared/components/post/post-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -349,32 +349,12 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
<input
type="url"
id="post-url"
className="form-control"
className="form-control mb-3"
value={url}
onInput={linkEvent(this, handlePostUrlChange)}
onPaste={linkEvent(this, handleImageUploadPaste)}
/>
{this.renderSuggestedTitleCopy()}
<form>
<label
htmlFor="file-upload"
className={`${
UserService.Instance.myUserInfo && "pointer"
} d-inline-block float-right text-muted fw-bold`}
data-tippy-content={I18NextService.i18n.t("upload_image")}
>
<Icon icon="image" classes="icon-inline" />
</label>
<input
id="file-upload"
type="file"
accept="image/*,video/*"
name="file"
className="d-none"
disabled={!UserService.Instance.myUserInfo}
onChange={linkEvent(this, handleImageUpload)}
/>
</form>
{url && validURL(url) && (
<div>
<a
Expand Down Expand Up @@ -404,56 +384,73 @@ export class PostForm extends Component<PostFormProps, PostFormState> {
</a>
</div>
)}
</div>
</div>

<div className="mb-3 row">
<label htmlFor="file-upload" className={"col-sm-2 col-form-label"}>
{capitalizeFirstLetter(I18NextService.i18n.t("image"))}
<Icon icon="image" classes="icon-inline ms-1" />
</label>
<div className="col-sm-10">
<input
id="file-upload"
type="file"
accept="image/*,video/*"
name="file"
className="small col-sm-10 form-control"
disabled={!UserService.Instance.myUserInfo}
onChange={linkEvent(this, handleImageUpload)}
/>
{this.state.imageLoading && <Spinner />}
{url && isImage(url) && (
<img src={url} className="img-fluid" alt="" />
<img src={url} className="img-fluid mt-2" alt="" />
)}
{this.state.imageDeleteUrl && (
<button
className="btn btn-danger btn-sm mt-2"
onClick={linkEvent(this, handleImageDelete)}
aria-label={I18NextService.i18n.t("delete")}
data-tippy-content={I18NextService.i18n.t("delete")}
>
<Icon icon="x" classes="icon-inline me-1" />
{capitalizeFirstLetter(I18NextService.i18n.t("delete"))}
</button>
)}
{this.props.crossPosts && this.props.crossPosts.length > 0 && (
<>
<div className="my-1 text-muted small fw-bold">
{I18NextService.i18n.t("cross_posts")}
</div>
<PostListings
showCommunity
posts={this.props.crossPosts}
enableDownvotes={this.props.enableDownvotes}
enableNsfw={this.props.enableNsfw}
allLanguages={this.props.allLanguages}
siteLanguages={this.props.siteLanguages}
viewOnly
// All of these are unused, since its view only
onPostEdit={() => {}}
onPostVote={() => {}}
onPostReport={() => {}}
onBlockPerson={() => {}}
onLockPost={() => {}}
onDeletePost={() => {}}
onRemovePost={() => {}}
onSavePost={() => {}}
onFeaturePost={() => {}}
onPurgePerson={() => {}}
onPurgePost={() => {}}
onBanPersonFromCommunity={() => {}}
onBanPerson={() => {}}
onAddModToCommunity={() => {}}
onAddAdmin={() => {}}
onTransferCommunity={() => {}}
/>
</>
)}
</div>
{this.props.crossPosts && this.props.crossPosts.length > 0 && (
<>
<div className="my-1 text-muted small fw-bold">
{I18NextService.i18n.t("cross_posts")}
</div>
<PostListings
showCommunity
posts={this.props.crossPosts}
enableDownvotes={this.props.enableDownvotes}
enableNsfw={this.props.enableNsfw}
allLanguages={this.props.allLanguages}
siteLanguages={this.props.siteLanguages}
viewOnly
// All of these are unused, since its view only
onPostEdit={() => {}}
onPostVote={() => {}}
onPostReport={() => {}}
onBlockPerson={() => {}}
onLockPost={() => {}}
onDeletePost={() => {}}
onRemovePost={() => {}}
onSavePost={() => {}}
onFeaturePost={() => {}}
onPurgePerson={() => {}}
onPurgePost={() => {}}
onBanPersonFromCommunity={() => {}}
onBanPerson={() => {}}
onAddModToCommunity={() => {}}
onAddAdmin={() => {}}
onTransferCommunity={() => {}}
/>
</>
)}
</div>

<div className="mb-3 row">
<label className="col-sm-2 col-form-label" htmlFor="post-title">
{I18NextService.i18n.t("title")}
Expand Down