-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consistency responsive header update header remove chatgpt comments finish up header and fix up other components lint and delete basecard (will be merged in future pr) Add BaseCard and Header Base Card/text components and veiws make header/sidebar fixed, create documentationpage for quickstart/resources
- Loading branch information
1 parent
d1bf2de
commit b5c1984
Showing
28 changed files
with
1,417 additions
and
116 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
File renamed without changes
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
|
||
interface BaseCardProps { | ||
GameImage: string; | ||
GameName: string; | ||
GameDescr: string; | ||
GameYear: number; | ||
} | ||
|
||
const YearCard: React.FC<BaseCardProps> = ({ GameImage, GameName, GameDescr, GameYear }) => { | ||
const redirect = (): void => { | ||
console.log(GameYear.toString()); // Redirect to year page | ||
}; | ||
|
||
return ( | ||
<div className="max-w-sm rounded overflow-hidden shadow-md transition duration-300 ease-in-out transform hover:shadow-lg hover:cursor-pointer" onClick={redirect}> | ||
<div className="aspect-w-4 aspect-h-3"> | ||
<img className="object-cover" src={require(`../${GameImage}`)} alt={GameName} /> | ||
</div> | ||
<div className="px-6 py-4"> | ||
<div className="font-bold text-xl mb-2">{GameName}</div> | ||
<p className="text-gray-700 text-base">{GameDescr}</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default YearCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from "react"; | ||
import ReactMarkdown from "react-markdown"; | ||
import { Link } from "react-router-dom"; | ||
|
||
const isInternalLink = (to: string): boolean => { | ||
const url = new URL(to, window.location.origin); | ||
console.log(url, window.location.hostname); | ||
return url.hostname === window.location.hostname; | ||
}; | ||
|
||
interface DocumentationPageProps { | ||
text: string; | ||
} | ||
|
||
const DocumentationPage: React.FC<DocumentationPageProps> = ({ text }) => { | ||
return ( | ||
<div className="h-full w-full overflow-auto bg-white p-6"> | ||
<ReactMarkdown | ||
components={{ | ||
a: ({ href, ...props }) => { | ||
const target = href ?? ""; | ||
if (isInternalLink(target)) { | ||
return ( | ||
<Link | ||
className="text-cyan-600 hover:underline" | ||
to={target} | ||
{...props} | ||
/> | ||
); | ||
} else { | ||
return ( | ||
<a | ||
className="text-cyan-600 hover:underline" | ||
href={target} | ||
{...props} | ||
/> | ||
); | ||
} | ||
}, | ||
}} | ||
> | ||
{text} | ||
</ReactMarkdown> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DocumentationPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import React, { Fragment, useContext } from "react"; | ||
import { Menu, Transition } from "@headlessui/react"; | ||
import { Link, NavLink } from "react-router-dom"; | ||
import { AuthStateEnum, useCurrentUser } from "../contexts/CurrentUserContext"; | ||
import Icon from "./elements/Icon"; | ||
import { EpisodeContext } from "../contexts/EpisodeContext"; | ||
import { SIDEBAR_ITEM_DATA } from "./sidebar"; | ||
|
||
const Header: React.FC = () => { | ||
const { authState, logout, user } = useCurrentUser(); | ||
const { episodeId } = useContext(EpisodeContext); | ||
|
||
return ( | ||
<nav className="fixed top-0 h-16 w-full bg-gray-700"> | ||
<div className="w-full px-2 sm:px-6 lg:px-8"> | ||
<div className="relative flex h-16 items-center justify-between"> | ||
{/* mobile menu */} | ||
<Menu> | ||
<div className="absolute inset-y-0 left-3 flex items-center sm:hidden"> | ||
<Menu.Button className="rounded-md px-1 py-1.5 focus:outline-none focus:ring-2 focus:ring-inset focus:ring-white"> | ||
<span className="sr-only">Open main menu</span> | ||
<Icon | ||
name="bars_3" | ||
className="text-gray-300 hover:text-white" | ||
size="lg" | ||
/> | ||
</Menu.Button> | ||
</div> | ||
<Transition | ||
as={Fragment} | ||
leave="transition ease-in duration-100" | ||
leaveFrom="opacity-100" | ||
leaveTo="opacity-0" | ||
> | ||
<Menu.Items className="absolute left-1 top-12 z-10 mt-2 w-64 gap-2 rounded-md bg-white p-2 font-light shadow-lg sm:hidden"> | ||
{SIDEBAR_ITEM_DATA.map(({ iconName, text, linkTo }, index) => ( | ||
<Menu.Item key={index}> | ||
<NavLink | ||
className={({ isActive }) => | ||
"flex items-center gap-3 rounded-lg py-2 pl-1.5 pr-8 text-base " + | ||
(isActive | ||
? "cursor-default text-cyan-600" | ||
: "text-gray-800 ui-active:bg-gray-500 ui-active:text-gray-100") | ||
} | ||
to={`/${episodeId}/${linkTo}`} | ||
> | ||
<Icon name={iconName} size="md" /> | ||
{text} | ||
</NavLink> | ||
</Menu.Item> | ||
))} | ||
|
||
{authState === AuthStateEnum.NOT_AUTHENTICATED && ( | ||
<> | ||
<hr className="m-2" /> | ||
<Menu.Item as="div" className="w-full pb-2 pt-1"> | ||
<Link | ||
to="/login" | ||
className="rounded-full px-2.5 text-cyan-600 ring-0 hover:bg-gray-100/10" | ||
> | ||
Log in | ||
</Link> | ||
</Menu.Item> | ||
</> | ||
)} | ||
</Menu.Items> | ||
</Transition> | ||
</Menu> | ||
{/* battlecode logo */} | ||
<div className="flex flex-1 items-center justify-center sm:items-stretch sm:justify-start"> | ||
<div className="flex flex-shrink-0 items-center"> | ||
<img | ||
className="hidden h-8 sm:block" | ||
src="/battlecode-logo-horiz-white.png" | ||
alt="Battlecode Logo" | ||
/> | ||
<img | ||
className="h-10 sm:hidden" | ||
src="/battlecode-logo-vert-white.png" | ||
alt="Battlecode Logo" | ||
/> | ||
</div> | ||
<div className="hidden sm:ml-6 sm:block"></div> | ||
</div> | ||
{/* profile menu (if the user is logged in) */} | ||
{authState === AuthStateEnum.AUTHENTICATED && ( | ||
<Menu> | ||
<div className="absolute inset-y-0 right-0 flex items-center pr-2 sm:pr-0"> | ||
<Menu.Button className="rounded-full focus:outline-none focus:ring-2 focus:ring-white focus:ring-offset-2 focus:ring-offset-gray-800"> | ||
<span className="sr-only">Open user menu</span> | ||
<img | ||
className="h-8 w-8 rounded-full bg-white" | ||
src={user?.profile?.avatar_url} | ||
alt="Profile Picture" | ||
/> | ||
</Menu.Button> | ||
</div> | ||
<Transition | ||
as={Fragment} | ||
leave="transition ease-in duration-100" | ||
leaveFrom="opacity-100" | ||
leaveTo="opacity-0" | ||
> | ||
<Menu.Items className="absolute right-1 top-12 z-10 mt-2 w-40 rounded-md bg-white py-1 text-gray-800 shadow-lg"> | ||
<Menu.Item> | ||
<Link | ||
className="flex w-full items-center rounded-lg px-4 py-2 sm:text-sm " | ||
to="/account" | ||
> | ||
Your profile | ||
</Link> | ||
</Menu.Item> | ||
<Menu.Item> | ||
<button | ||
onClick={logout} | ||
className="flex w-full items-center rounded-lg px-4 py-2 sm:text-sm" | ||
> | ||
Sign out | ||
</button> | ||
</Menu.Item> | ||
</Menu.Items> | ||
</Transition> | ||
</Menu> | ||
)} | ||
{/* sign up / login button */} | ||
{authState === AuthStateEnum.NOT_AUTHENTICATED && ( | ||
<div className="absolute inset-y-0 right-1 flex flex-row items-center justify-center gap-3"> | ||
<Link | ||
to="/login" | ||
className="hidden rounded-full px-3 py-1.5 text-gray-200 ring-0 hover:bg-gray-100/10 sm:block" | ||
> | ||
Log in | ||
</Link> | ||
<Link | ||
to="/register" | ||
className="rounded-full px-3 py-1.5 text-center text-white ring-2 ring-inset ring-gray-200 hover:bg-gray-100/10" | ||
> | ||
Register | ||
</Link> | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
</nav> | ||
); | ||
}; | ||
|
||
export default Header; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.