Skip to content

Commit

Permalink
SEO and accessibility improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
RmnRss committed Oct 7, 2020
1 parent 2ff085b commit 5f8383d
Show file tree
Hide file tree
Showing 30 changed files with 154 additions and 36 deletions.
4 changes: 2 additions & 2 deletions components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ const Button = React.forwardRef(
ref={ref}
type={props.type || "button"}
isIcon={isIcon}
aria-label={label}
{...props}
>
<HoverBar />
{icon && <IconHolder size={24}>{icon}</IconHolder>}
{label}
{isIcon ? <IconHolder size={24}>{icon}</IconHolder> : <>{label}</>}
</ButtonContainer>
);
}
Expand Down
6 changes: 6 additions & 0 deletions components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ export default function Header() {
*/
function toggleSearch() {
setOpenSearch(!openSearch);
if (!openSearch) {
document.getElementById("query").focus();
}
}

return (
Expand All @@ -212,13 +215,15 @@ export default function Header() {
<ButtonsRow>
<HeaderButton
inverted
label={"Open search"}
color="dark"
icon={openSearch ? <CloseIcon /> : <SearchIcon />}
onClick={() => toggleSearch()}
/>

<DrawerMenuButton
inverted
label={"Open menu"}
color="dark"
icon={<MenuIcon />}
onClick={() => toggleDrawer()}
Expand All @@ -234,6 +239,7 @@ export default function Header() {
trigger={
<HeaderButton
inverted
label={"Open notifications"}
color="dark"
icon={<Notification />}
/>
Expand Down
26 changes: 24 additions & 2 deletions components/WrapInLink.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
import Link from "next/link";
import PropTypes from "prop-types";
import React from "react";

/***
* Wrapper component for dynamic href and as
*/
export default function WrapInLink({ children, href, as }) {
export default function WrapInLink({ children, href, as, ...props }) {
return (
<Link passHref href={href} as={as}>
<a target="_self">{children}</a>
<a {...props} target="_self">
{children}
</a>
</Link>
);
}

WrapInLink.propTypes = {
/**
* Components to wrap
*/
children: PropTypes.node.isRequired,
/**
* Destination of the link
*/
href: PropTypes.string.isRequired,
/**
* As path of the link
*/
as: PropTypes.string,
};

WrapInLink.defaultProps = {
as: null,
};
2 changes: 1 addition & 1 deletion components/cards/HelpCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function HelpCard(props) {
return (
<>
{external ? (
<a href={props.href} target="_blank">
<a href={props.href} target="_blank" rel="noopener">
<PureCard {...props} />
</a>
) : (
Expand Down
8 changes: 6 additions & 2 deletions components/cards/KitCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ export default function KitCard(props) {
<Details>
We're currently working on a new version of Kit Dashboards. For now you
can use the{" "}
<a href="http://astroplant-alpha.surge.sh/home" target="_blank">
<a
href="http://astroplant-alpha.surge.sh/home"
target="_blank"
rel="noopener"
>
current tools
</a>{" "}
to access and edit your kits. To learn more about the new features
please{" "}
<a href="http://astroplant.slack.com/" target="_blank">
<a href="http://astroplant.slack.com/" target="_blank" rel="noopener">
join our Slack
</a>
.
Expand Down
2 changes: 2 additions & 0 deletions components/cards/SimpleMediaCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export default function SimpleMediaCard({ media, showTools }) {
<>
<Button
inverted
label={"Edit Media"}
color={"secondary"}
icon={<EditIcon />}
onClick={() =>
Expand All @@ -147,6 +148,7 @@ export default function SimpleMediaCard({ media, showTools }) {
/>
<Button
inverted
label={"Delete Media"}
color={"error"}
icon={<DeleteIcon />}
onClick={() => toggle()}
Expand Down
19 changes: 16 additions & 3 deletions components/forms/AccountForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,41 @@ export default function AccountForm(props) {
<TextInput
disabled
label="Username"
id="username"
name="username"
type="text"
/>

<TextInput label="Email" name="email" type="email" />
<TextInput label="Email" id="email" name="email" type="email" />
</Row>

<Row>
<TextInput label="First Name" name="firstName" type="text" />
<TextInput label="Last Name" name="lastName" type="text" />
<TextInput
label="First Name"
id="firstName"
name="firstName"
type="text"
/>
<TextInput
label="Last Name"
id="lastName"
name="lastName"
type="text"
/>
</Row>

<Row>
<TextInput
addon={"@"}
label="Slack username"
id="slackUsername"
name="slackUsername"
type="text"
/>

<LongTextInput
label="Description"
id="description"
name="description"
type="text"
maxLength={140}
Expand Down
3 changes: 3 additions & 0 deletions components/forms/ChangePasswordForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,23 @@ export default function ChangePasswordForm() {
<Form>
<TextInput
label="Current Password"
id="oldPassword"
name="oldPassword"
type="password"
placeholder="Current"
/>

<TextInput
label="New password"
id="newPassword"
name="newPassword"
type="password"
placeholder="New secure password"
/>

<TextInput
label="Validate password"
id="validatePassword"
name="validatePassword"
type="password"
placeholder="Validate new password"
Expand Down
10 changes: 7 additions & 3 deletions components/forms/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import styled from "styled-components";
import * as Yup from "yup";
import { authenticate, useAuth } from "../../providers/Auth";
import { useSnackBars } from "../../providers/SnackBarProvider";
import { forgotPassword, login } from "../../services/community";
import { login } from "../../services/community";
import { getErrorMessage, hasError } from "../../utils/fetchTools";
import Button from "../Button";
import Checkbox from "../inputs/CheckBox";
Expand Down Expand Up @@ -55,7 +55,7 @@ export default function LoginForm() {

// Navigate to the home page
if (isLogged) {
setTimeout(function() {
setTimeout(function () {
actions.resetForm();
}, 2000);
}
Expand All @@ -72,18 +72,22 @@ export default function LoginForm() {
<Form>
<TextInput
label="Username"
id="username"
name="username"
type="text"
placeholder="SpaceFarmer"
/>
<TextInput
label="Password"
id="password"
name="password"
type="password"
placeholder="Password"
/>
<Row>
<Checkbox name="rememberMe">Remember Me</Checkbox>
<Checkbox id="rememberMe" name="rememberMe">
Remember Me
</Checkbox>
{/*
<a
onClick={async () => {
Expand Down
4 changes: 4 additions & 0 deletions components/forms/MediaCreationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ export default function MediaCreationForm({ librarySections, mediaToEdit }) {
<>
<TextInput
label="URL"
id={`content[${index}].url`}
name={`content[${index}].url`}
type="text"
placeholder="https://example.com"
Expand All @@ -255,6 +256,7 @@ export default function MediaCreationForm({ librarySections, mediaToEdit }) {
/>
<TextInput
label="Caption"
id={`content[${index}].caption`}
name={`content[${index}].caption`}
type="text"
placeholder="A nice url."
Expand Down Expand Up @@ -292,6 +294,7 @@ export default function MediaCreationForm({ librarySections, mediaToEdit }) {
<>
<TextInput
label="Title"
id={`content[${index}].title`}
name={`content[${index}].title`}
type="text"
placeholder="My file title."
Expand All @@ -300,6 +303,7 @@ export default function MediaCreationForm({ librarySections, mediaToEdit }) {

<LongTextInput
label="Description"
id={`content[${index}].description`}
name={`content[${index}].description`}
type="text"
placeholder="A description of the file."
Expand Down
10 changes: 6 additions & 4 deletions components/forms/SignUpForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ const Disclaimer = styled.p`
`;

const SignupSchema = Yup.object().shape({
email: Yup.string()
.email("Invalid email")
.required("Required"),
email: Yup.string().email("Invalid email").required("Required"),
username: Yup.string()
.min(2, "Username must be at least 3 characters!")
.max(50, "Username is too long.")
Expand Down Expand Up @@ -98,30 +96,34 @@ export default function SignUpForm() {
</Disclaimer>
<TextInput
label="email"
id="email"
name="email"
type="email"
placeholder="[email protected]"
/>
<TextInput
label="Username"
id="username"
name="username"
type="text"
placeholder="SpaceFarmer"
/>
<TextInput
label="Password"
id="password"
name="password"
type="password"
placeholder="Password"
/>
<TextInput
label="Validate password"
id="validatePassword"
name="validatePassword"
type="password"
placeholder="Validate Password"
/>

<Checkbox name="acceptTerms">
<Checkbox id="acceptTerms" name="acceptTerms">
I agree to the <a>terms and conditions</a>
</Checkbox>

Expand Down
1 change: 1 addition & 0 deletions components/forms/UploadForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default function UploadForm(props) {
)}

<FileInput
id={"files"}
name={"files"}
accept="image/*"
multiple={props.multiple}
Expand Down
2 changes: 1 addition & 1 deletion components/inputs/CheckBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function Checkbox({ children, ...props }) {
<>
<Row>
<Input type="checkbox" {...field} {...props} />
<label>{children}</label>
<label htmlFor={props.name || props.id}>{children}</label>
</Row>

{meta.touched && meta.error ? (
Expand Down
1 change: 1 addition & 0 deletions components/inputs/FileInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export default function FileInput({
</ItemContent>
<RemoveButton
inverted
label={"Remove File"}
color="greyDark"
icon={<RemoveIcon />}
onClick={() => removeFile(file.name)}
Expand Down
9 changes: 9 additions & 0 deletions components/inputs/SearchBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ const SearchButton = styled(Button)`
margin: 0;
`;

const HiddenLabel = styled.label`
visibility: hidden;
width: 0;
`;

export default function SearchBar(props) {
const [query, setQuery] = useState("");

Expand Down Expand Up @@ -68,11 +73,15 @@ export default function SearchBar(props) {

return (
<Form {...props} onSubmit={handleSubmit} id="searchbar">
<HiddenLabel style={{ width: 0 }} htmlFor={"query"}>
Search
</HiddenLabel>
<Icon color={"grey"} size={24}>
<SearchIcon />
</Icon>
<Input
type="text"
id={"query"}
name={"query"}
placeholder={"Search"}
onChange={handleChange}
Expand Down
5 changes: 4 additions & 1 deletion components/layouts/MainLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export default function MainLayout({
children,
}) {
return (
<PageLayout metaTitle={metaTitle} metaDescription={metaDescription}>
<PageLayout
metaTitle={metaTitle || pageTitle}
metaDescription={metaDescription}
>
<Path />
<h2>{pageTitle}</h2>

Expand Down
Loading

0 comments on commit 5f8383d

Please sign in to comment.