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

Add semantic ID's and classes to improve theming/userscript experience #1327

Merged
merged 16 commits into from
Jun 16, 2023
Merged
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
2 changes: 1 addition & 1 deletion src/shared/components/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class App extends Component<any, any> {
return (
<>
<Provider i18next={i18n}>
<div id="app">
<div id="app" className="lemmy-site">
{siteView && (
<Theme defaultTheme={siteView.local_site.default_theme} />
)}
Expand Down
4 changes: 2 additions & 2 deletions src/shared/components/app/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class Footer extends Component<FooterProps, any> {

render() {
return (
<nav className="container-lg navbar navbar-expand-md navbar-light navbar-bg p-3">
<footer className="container-lg navbar navbar-expand-md navbar-light navbar-bg p-3">
<div className="navbar-collapse">
<ul className="navbar-nav ml-auto">
{this.props.site?.version !== VERSION && (
Expand Down Expand Up @@ -63,7 +63,7 @@ export class Footer extends Component<FooterProps, any> {
</li>
</ul>
</div>
</nav>
</footer>
);
}
}
30 changes: 17 additions & 13 deletions src/shared/components/app/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
const siteView = this.props.siteRes?.site_view;
const person = UserService.Instance.myUserInfo?.local_user_view.person;
return (
<nav className="navbar navbar-expand-md navbar-light shadow-sm p-0 px-3 container-lg">
<nav
className="navbar navbar-expand-md navbar-light shadow-sm p-0 px-3 container-lg"
id="navbar"
>
<NavLink
id="navTitle"
to="/"
title={siteView?.site.description ?? siteView?.site.name}
className="d-flex align-items-center navbar-brand mr-md-3"
Expand All @@ -100,10 +104,10 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
</NavLink>
{person && (
<ul className="navbar-nav d-flex flex-row ml-auto d-md-none">
<li className="nav-item">
<li id="navMessages" className="nav-item nav-item-icon">
<NavLink
to="/inbox"
className="p-1 nav-link border-0"
className="p-1 nav-link border-0 nav-messages"
title={i18n.t("unread_messages", {
count: Number(this.state.unreadApplicationCountRes.state),
formattedCount: numToSI(this.unreadInboxCount),
Expand All @@ -119,7 +123,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
</NavLink>
</li>
{this.moderatesSomething && (
<li className="nav-item">
<li className="nav-item nav-item-icon">
<NavLink
to="/reports"
className="p-1 nav-link border-0"
Expand All @@ -139,7 +143,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
</li>
)}
{amAdmin() && (
<li className="nav-item">
<li className="nav-item nav-item-icon">
<NavLink
to="/registration_applications"
className="p-1 nav-link border-0"
Expand Down Expand Up @@ -178,7 +182,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
id="navbarDropdown"
ref={this.mobileMenuRef}
>
<ul className="mr-auto navbar-nav">
<ul id="navbarLinks" className="mr-auto navbar-nav">
<li className="nav-item">
<NavLink
to="/communities"
Expand Down Expand Up @@ -228,8 +232,8 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
</a>
</li>
</ul>
<ul className="navbar-nav">
<li className="nav-item">
<ul id="navbarIcons" className="navbar-nav">
<li id="navSearch" className="nav-item">
<NavLink
to="/search"
className="nav-link"
Expand All @@ -240,7 +244,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
</NavLink>
</li>
{amAdmin() && (
<li className="nav-item">
<li id="navAdmin" className="nav-item">
<NavLink
to="/admin"
className="nav-link"
Expand All @@ -253,7 +257,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
)}
{person ? (
<>
<li className="nav-item">
<li id="navMessages" className="nav-item">
<NavLink
className="nav-link"
to="/inbox"
Expand All @@ -272,7 +276,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
</NavLink>
</li>
{this.moderatesSomething && (
<li className="nav-item">
<li id="navModeration" className="nav-item">
<NavLink
className="nav-link"
to="/reports"
Expand All @@ -292,7 +296,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
</li>
)}
{amAdmin() && (
<li className="nav-item">
<li id="navApplications" className="nav-item">
<NavLink
to="/registration_applications"
className="nav-link"
Expand All @@ -312,7 +316,7 @@ export class Navbar extends Component<NavbarProps, NavbarState> {
</li>
)}
{person && (
<div className="dropdown">
<div id="dropdownUser" className="dropdown">
<button
className="btn dropdown-toggle"
role="button"
Expand Down
3 changes: 2 additions & 1 deletion src/shared/components/comment/comment-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface CommentFormProps {
onReplyCancel?(): void;
allLanguages: Language[];
siteLanguages: number[];
containerClass?: string;
onUpsertComment(form: EditComment | CreateComment): void;
}

Expand All @@ -40,7 +41,7 @@ export class CommentForm extends Component<CommentFormProps, any> {
: undefined;

return (
<div className="mb-3">
<div className={["mb-3", this.props.containerClass].join(" ")}>
{UserService.Instance.myUserInfo ? (
<MarkdownTextArea
initialContent={initialContent}
Expand Down
8 changes: 5 additions & 3 deletions src/shared/components/comment/comment-node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {

return (
<li className="comment" role="comment">
<div
<article
Zetaphor marked this conversation as resolved.
Show resolved Hide resolved
id={`comment-${cv.comment.id}`}
className={classNames(`details comment-node py-2`, {
"border-top border-light": !this.props.noBorder,
Expand Down Expand Up @@ -400,6 +400,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
focus
allLanguages={this.props.allLanguages}
siteLanguages={this.props.siteLanguages}
containerClass="comment-comment-container"
onUpsertComment={this.props.onEditComment}
/>
)}
Expand Down Expand Up @@ -512,7 +513,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
</button>
{!this.state.showAdvanced ? (
<button
className="btn btn-link btn-animate text-muted"
className="btn btn-link btn-animate text-muted btn-more"
onClick={linkEvent(this, this.handleShowAdvanced)}
data-tippy-content={i18n.t("more")}
aria-label={i18n.t("more")}
Expand Down Expand Up @@ -944,7 +945,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
</div>
)}
</div>
</div>
</article>
{showMoreChildren && (
<div
className={classNames("details ml-1 comment-node py-2", {
Expand Down Expand Up @@ -1143,6 +1144,7 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
focus
allLanguages={this.props.allLanguages}
siteLanguages={this.props.siteLanguages}
containerClass="comment-comment-container"
onUpsertComment={this.props.onCreateComment}
/>
)}
Expand Down
5 changes: 3 additions & 2 deletions src/shared/components/common/markdown-textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ export class MarkdownTextArea extends Component<
MarkdownTextAreaProps,
MarkdownTextAreaState
> {
private id = `comment-textarea-${randomStr()}`;
private formId = `comment-form-${randomStr()}`;
private id = `markdown-textarea-${randomStr()}`;
private formId = `markdown-form-${randomStr()}`;

private tribute: any;

state: MarkdownTextAreaState = {
Expand Down
62 changes: 32 additions & 30 deletions src/shared/components/community/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,37 +131,39 @@ export class Sidebar extends Component<SidebarProps, SidebarState> {
const myUSerInfo = UserService.Instance.myUserInfo;
const { name, actor_id } = this.props.community_view.community;
return (
<div>
<div className="card border-secondary mb-3">
<div className="card-body">
{this.communityTitle()}
{this.props.editable && this.adminButtons()}
{myUSerInfo && this.subscribe()}
{this.canPost && this.createPost()}
{myUSerInfo && this.blockCommunity()}
{!myUSerInfo && (
<div className="alert alert-info" role="alert">
<T
i18nKey="community_not_logged_in_alert"
interpolation={{
community: name,
instance: hostname(actor_id),
}}
>
#<code className="user-select-all">#</code>#
</T>
</div>
)}
</div>
</div>
<div className="card border-secondary mb-3">
<div className="card-body">
{this.description()}
{this.badges()}
{this.mods()}
</div>
<aside className="mb-3">
<div id="sidebarContainer">
<section id="sidebarMain" className="card border-secondary mb-3">
<div className="card-body">
{this.communityTitle()}
{this.props.editable && this.adminButtons()}
{myUSerInfo && this.subscribe()}
{this.canPost && this.createPost()}
{myUSerInfo && this.blockCommunity()}
{!myUSerInfo && (
<div className="alert alert-info" role="alert">
<T
i18nKey="community_not_logged_in_alert"
interpolation={{
community: name,
instance: hostname(actor_id),
}}
>
#<code className="user-select-all">#</code>#
</T>
</div>
)}
</div>
</section>
<section id="sidebarInfo" className="card border-secondary mb-3">
<div className="card-body">
{this.description()}
{this.badges()}
{this.mods()}
</div>
</section>
</div>
</div>
</aside>
);
}

Expand Down
53 changes: 27 additions & 26 deletions src/shared/components/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -419,35 +419,36 @@ export class Home extends Component<any, HomeState> {
} = this.state;

return (
<div>
<div>
<div className="card border-secondary mb-3">
<div className="card-body">
{this.trendingCommunities()}
{canCreateCommunity(this.state.siteRes) && (
<LinkButton
path="/create_community"
translationKey="create_a_community"
/>
)}
<div id="sidebarContainer">
<section id="sidebarMain" className="card border-secondary mb-3">
<div className="card-body">
{this.trendingCommunities()}
{canCreateCommunity(this.state.siteRes) && (
<LinkButton
path="/communities"
translationKey="explore_communities"
path="/create_community"
translationKey="create_a_community"
/>
</div>
)}
<LinkButton
path="/communities"
translationKey="explore_communities"
/>
</div>
<SiteSidebar
site={site}
admins={admins}
counts={counts}
showLocal={showLocal(this.isoData)}
/>
{this.hasFollows && (
<div className="card border-secondary mb-3">
<div className="card-body">{this.subscribedCommunities}</div>
</div>
)}
</div>
</section>
<SiteSidebar
site={site}
admins={admins}
counts={counts}
showLocal={showLocal(this.isoData)}
/>
{this.hasFollows && (
<section
id="sidebarSubscribed"
className="card border-secondary mb-3"
>
<div className="card-body">{this.subscribedCommunities}</div>
</section>
)}
</div>
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/shared/components/home/site-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class SiteSidebar extends Component<SiteSidebarProps, SiteSidebarState> {

render() {
return (
<div className="card border-secondary mb-3">
<section id="sidebarInfo" className="card border-secondary mb-3">
<div className="card-body">
<div>
<div className="mb-2">{this.siteName()}</div>
Expand All @@ -41,7 +41,7 @@ export class SiteSidebar extends Component<SiteSidebarProps, SiteSidebarState> {
)}
</div>
</div>
</div>
</section>
);
}

Expand Down
5 changes: 4 additions & 1 deletion src/shared/components/post/create-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ export class CreatePost extends Component<
</h5>
) : (
<div className="row">
<div className="col-12 col-lg-6 offset-lg-3 mb-4">
<div
id="createPostForm"
className="col-12 col-lg-6 offset-lg-3 mb-4"
>
<h5>{i18n.t("create_post")}</h5>
<PostForm
onCreate={this.handlePostCreate}
Expand Down
Loading