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

Additions to complete standards #508

Open
wants to merge 2 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
24 changes: 21 additions & 3 deletions web/src/components/CreatePostForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,26 @@ const CreatePostForm = ({ initialLink = "" }) => {
<button
className="btn btn-circle btn-primary fixed bottom-4 right-4 shadow-lg"
onClick={() => setIsModalOpen(true)}
aria-label="Create a new post"
>
+
</button>

{/* Modal */}
{isModalOpen && (
<div className="modal modal-open">
<div
className="modal modal-open"
role="dialog"
aria-labelledby="modal-title"
aria-describedby="modal-description"
>
<div className="modal-box">
<h2 className="font-bold text-lg mb-4">Create a New Post</h2>
<h2 id="modal-title" className="font-bold text-lg mb-4">
Create a New Post
</h2>
<p id="modal-description" className="sr-only">
Fill in the form below to create a new post with a Spotify link and optional comment.
</p>
<form onSubmit={handleSubmit}>
{!initialLink && (
<div className="form-group mb-4">
Expand All @@ -76,6 +87,7 @@ const CreatePostForm = ({ initialLink = "" }) => {
onChange={(e) => setLink(e.target.value)}
className="input input-bordered w-full"
required
aria-label="Spotify link"
/>
</div>
)}
Expand All @@ -89,16 +101,22 @@ const CreatePostForm = ({ initialLink = "" }) => {
onChange={(e) => setComment(e.target.value)}
className="textarea textarea-bordered w-full"
rows={3}
aria-label="Comment about the post"
/>
</div>
<div className="modal-action">
<button type="submit" className="btn btn-primary">
<button
type="submit"
className="btn btn-primary"
aria-label="Submit the form to create a post"
>
Create Post
</button>
<button
type="button"
className="btn"
onClick={() => setIsModalOpen(false)}
aria-label="Cancel and close the modal"
>
Cancel
</button>
Expand Down
1 change: 1 addition & 0 deletions web/src/components/FormInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const FormInput = (props:any) => {
value={props.value}
onChange={props.onChange}
required
aria-label=""
/>
</label>
);
Expand Down
84 changes: 52 additions & 32 deletions web/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,81 @@ const Header = () => {
const { username } = useUser();
const [query, setQuery] = useState("");


const navigate = useNavigate();

const handleSearch = (e: React.FormEvent) => {
e.preventDefault();
navigate(`/search/${query}`);
};


return (
<div className="navbar bg-base-100 shadow-xl rounded-box" >
<div
className="navbar bg-base-100 shadow-xl rounded-box"
role="navigation"
aria-label="Main navigation"
>
{/* Logo */}
<div className="flex-1">
<Link className="btn btn-ghost text-xl" to="/" aria-label="Spot On">
<Link
className="btn btn-ghost text-xl"
to="/"
aria-label="Spot On - Navigate to homepage"
>
Spot On
</Link>
</div>
</div>

{ <form onSubmit={handleSearch} className="flex-none gap-2">
{/* Search Bar */}
<form onSubmit={handleSearch} className="flex-none gap-2" role="search" aria-label="Search form">
<div className="form-control">
<label htmlFor="search" className="sr-only">
Search
</label>
<input
type="text"
id="search"
placeholder="Search"
className="input input-bordered w-24 md:w-auto"
value={query}
onChange={(e) => setQuery(e.target.value)}
aria-label="Search input"
/>
</div>
</form>}


</form>

{/* Theme Toggle */}
<label className="swap swap-rotate" aria-label="Toggle theme">
<input type="checkbox" className="theme-controller" value="dark" />

<label className="swap swap-rotate">
{/* this hidden checkbox controls the state */}
<input type="checkbox" className="theme-controller" value="dark" />
{/* Sun Icon */}
<svg
className="swap-off h-10 w-10 fill-current"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
role="img"
aria-hidden="true"
>
<title>Switch to light theme</title>
<path d="M5.64,17l-.71.71a1,1,0,0,0,0,1.41,1,1,0,0,0,1.41,0l.71-.71A1,1,0,0,0,5.64,17ZM5,12a1,1,0,0,0-1-1H3a1,1,0,0,0,0,2H4A1,1,0,0,0,5,12Zm7-7a1,1,0,0,0,1-1V3a1,1,0,0,0-2,0V4A1,1,0,0,0,12,5ZM5.64,7.05a1,1,0,0,0,.7.29,1,1,0,0,0,.71-.29,1,1,0,0,0,0-1.41l-.71-.71A1,1,0,0,0,4.93,6.34Zm12,.29a1,1,0,0,0,.7-.29l.71-.71a1,1,0,1,0-1.41-1.41L17,5.64a1,1,0,0,0,0,1.41A1,1,0,0,0,17.66,7.34ZM21,11H20a1,1,0,0,0,0,2h1a1,1,0,0,0,0-2Zm-9,8a1,1,0,0,0-1,1v1a1,1,0,0,0,2,0V20A1,1,0,0,0,12,19ZM18.36,17A1,1,0,0,0,17,18.36l.71.71a1,1,0,0,0,1.41,0,1,1,0,0,0,0-1.41ZM12,6.5A5.5,5.5,0,1,0,17.5,12,5.51,5.51,0,0,0,12,6.5Zm0,9A3.5,3.5,0,1,1,15.5,12,3.5,3.5,0,0,1,12,15.5Z" />
</svg>

{/* sun icon */}
<svg
className="swap-off h-10 w-10 fill-current"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24">
<path
d="M5.64,17l-.71.71a1,1,0,0,0,0,1.41,1,1,0,0,0,1.41,0l.71-.71A1,1,0,0,0,5.64,17ZM5,12a1,1,0,0,0-1-1H3a1,1,0,0,0,0,2H4A1,1,0,0,0,5,12Zm7-7a1,1,0,0,0,1-1V3a1,1,0,0,0-2,0V4A1,1,0,0,0,12,5ZM5.64,7.05a1,1,0,0,0,.7.29,1,1,0,0,0,.71-.29,1,1,0,0,0,0-1.41l-.71-.71A1,1,0,0,0,4.93,6.34Zm12,.29a1,1,0,0,0,.7-.29l.71-.71a1,1,0,1,0-1.41-1.41L17,5.64a1,1,0,0,0,0,1.41A1,1,0,0,0,17.66,7.34ZM21,11H20a1,1,0,0,0,0,2h1a1,1,0,0,0,0-2Zm-9,8a1,1,0,0,0-1,1v1a1,1,0,0,0,2,0V20A1,1,0,0,0,12,19ZM18.36,17A1,1,0,0,0,17,18.36l.71.71a1,1,0,0,0,1.41,0,1,1,0,0,0,0-1.41ZM12,6.5A5.5,5.5,0,1,0,17.5,12,5.51,5.51,0,0,0,12,6.5Zm0,9A3.5,3.5,0,1,1,15.5,12,3.5,3.5,0,0,1,12,15.5Z" />
</svg>
{/* Moon Icon */}
<svg
className="swap-on h-10 w-10 fill-current"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
role="img"
aria-hidden="true"
>
<title>Switch to dark theme</title>
<path d="M21.64,13a1,1,0,0,0-1.05-.14,8.05,8.05,0,0,1-3.37.73A8.15,8.15,0,0,1,9.08,5.49a8.59,8.59,0,0,1,.25-2A1,1,0,0,0,8,2.36,10.14,10.14,0,1,0,22,14.05,1,1,0,0,0,21.64,13Zm-9.5,6.69A8.14,8.14,0,0,1,7.08,5.22v.27A10.15,10.15,0,0,0,17.22,15.63a9.79,9.79,0,0,0,2.1-.22A8.11,8.11,0,0,1,12.14,19.73Z" />
</svg>
</label>

{/* moon icon */}
<svg
className="swap-on h-10 w-10 fill-current"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24">
<path
d="M21.64,13a1,1,0,0,0-1.05-.14,8.05,8.05,0,0,1-3.37.73A8.15,8.15,0,0,1,9.08,5.49a8.59,8.59,0,0,1,.25-2A1,1,0,0,0,8,2.36,10.14,10.14,0,1,0,22,14.05,1,1,0,0,0,21.64,13Zm-9.5,6.69A8.14,8.14,0,0,1,7.08,5.22v.27A10.15,10.15,0,0,0,17.22,15.63a9.79,9.79,0,0,0,2.1-.22A8.11,8.11,0,0,1,12.14,19.73Z" />
</svg>
</label>
<div><NavbarAccount username={username} /></div>

{/* User Account */}
<div>
<NavbarAccount username={username} />
</div>
</div>
);
};
Expand Down
49 changes: 35 additions & 14 deletions web/src/components/NavbarAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const NavbarAccount = ({ username }: NavbarAccountProps) => {
setError(error.message);
}
setUsername("");
localStorage.clear(); // Clear all localStorage data (or selectively remove keys)
localStorage.clear(); // Clear all localStorage data (or selectively remove keys)

navigate("/");
};
Expand All @@ -32,24 +32,37 @@ const NavbarAccount = ({ username }: NavbarAccountProps) => {
<div
tabIndex={0}
role="button"
aria-haspopup="menu"
aria-expanded="false"
className="btn btn-ghost btn-circle avatar"
aria-label="User menu"
>
<div className="w-10 rounded-full">
<img alt={username} src="https://i.pravatar.cc/300" />
<img
alt={`Avatar of ${username}`}
src="https://i.pravatar.cc/300"
aria-hidden="true"
/>
</div>
</div>
<ul
tabIndex={0}
role="menu"
className="mt-3 z-[1] p-2 shadow menu menu-sm dropdown-content bg-base-100 rounded-box w-52"
aria-label="User options menu"
>
<li>
<Link to="/profile" aria-label="profile">Profile</Link>
<li role="none">
<Link to="/profile" role="menuitem" aria-label="Go to Profile">
Profile
</Link>
</li>
<li>
<Link to="/settings" aria-label="settings">Settings</Link>
<li role="none">
<Link to="/settings" role="menuitem" aria-label="Go to Settings">
Settings
</Link>
</li>
<li>
<Link to="/" onClick={logout} aria-label="Logout">
<li role="none">
<Link to="/" onClick={logout} role="menuitem" aria-label="Logout">
Logout
</Link>
</li>
Expand All @@ -58,16 +71,24 @@ const NavbarAccount = ({ username }: NavbarAccountProps) => {
);
} else {
return (
<ul className="menu menu-horizontal px-1">
<li>
<Link to="/login" aria-label="Login">Login</Link>
<ul
className="menu menu-horizontal px-1"
role="menu"
aria-label="Navigation menu"
>
<li role="none">
<Link to="/login" role="menuitem" aria-label="Go to Login">
Login
</Link>
</li>
<li>
<Link to="/register" aria-label="Register">Register</Link>
<li role="none">
<Link to="/register" role="menuitem" aria-label="Go to Register">
Register
</Link>
</li>
</ul>
);
}
};

export default NavbarAccount;
export default NavbarAccount;
Loading