Skip to content

Commit

Permalink
revise homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfagun74 committed Oct 27, 2024
1 parent 851ac6c commit 8ba774a
Show file tree
Hide file tree
Showing 6 changed files with 137 additions and 32 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"autoprefixer": "^10.4.20",
"postcss": "^8.4.47",
"postcss-import": "^16.1.0",
"prop-types": "^15.8.1",
"tailwindcss": "^3.4.14"
},
"browserslist": {
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 24 additions & 18 deletions src/components/Button.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Link from "@docusaurus/Link";
import clsx from "clsx";
import PropTypes from "prop-types";

const baseStyles = {
solid:
Expand All @@ -11,35 +12,40 @@ const baseStyles = {
const variantStyles = {
solid: {
primary:
"bg-primary-default text-white hover:bg-primary-darker hover:text-text-inverse active:bg-primary-darkest active:text-text-inverse focus-visible:outline-primary-darkest",
white:
"bg-white text-slate-900 hover:bg-indigo-50 active:bg-indigo-200 active:text-slate-600 focus-visible:outline-white",
},
outline: {
slate:
"ring-slate-200 text-slate-700 hover:text-slate-900 hover:ring-slate-300 active:bg-slate-100 active:text-slate-600 focus-visible:outline-indigo-600 focus-visible:ring-slate-300",
white:
"ring-slate-700 text-white hover:ring-slate-500 active:ring-slate-700 active:text-slate-400 focus-visible:outline-white",
"bg-primary-default text-white hover:text-white hover:bg-primary-darker active:bg-primary-darkest focus-visible:outline-primary-darkest",
},
};

// Function to determine the appropriate variant class
function getVariantClass(variant, color) {
if (variant === "outline") {
return variantStyles.outline?.[color];
} else if (variant === "solid") {
return variantStyles.solid?.[color];
}
return undefined;
}

export function Button({ className, ...props }) {
props.variant ??= "solid";
props.color ??= "primary";

className = clsx(
baseStyles[props.variant],
props.variant === "outline"
? variantStyles.outline[props.color]
: props.variant === "solid"
? variantStyles.solid[props.color]
: undefined,
className
);
const variantClass = getVariantClass(props.variant, props.color);

className = clsx(baseStyles[props.variant], variantClass, className);
console.log(className);

return typeof props.href === "undefined" ? (
<button className={className} {...props} />
) : (
<Link className={className} {...props} />
);
}

// Prop validation
Button.propTypes = {
href: PropTypes.string,
className: PropTypes.string,
variant: PropTypes.oneOf(["solid", "outline"]),
color: PropTypes.oneOf(["primary"]),
};
63 changes: 63 additions & 0 deletions src/components/DropdownButton.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import Link from "@docusaurus/Link";
import PropTypes from "prop-types";
import React, { useEffect, useRef, useState } from "react";
import { Button } from "./Button";

const Dropdown = ({ className, options, ...props }) => {
const [isOpen, setIsOpen] = useState(false);
const dropdownRef = useRef(null);

const toggleMenu = () => setIsOpen(!isOpen);

// Close dropdown if clicked outside
useEffect(() => {
const handleClickOutside = (event) => {
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
setIsOpen(false);
}
};

document.addEventListener("mousedown", handleClickOutside);
return () => document.removeEventListener("mousedown", handleClickOutside);
}, []);

return (
<span ref={dropdownRef} className="relative inline-block text-left">
<Button className={className + " w-full"} {...props} onClick={toggleMenu} />

{isOpen && (
<div
className="absolute right-0 z-10 mt-2 w-full origin-top-right rounded-md bg-background-dark shadow-lg ring-1 ring-text-light"
role="menu"
aria-orientation="vertical"
>
<div className="py-1" role="none">
{options.map((option) => (
<Link
key={option.label}
href={option.link}
target="_blank"
className="font-bold hover:no-underline block px-4 py-2 text-sm hover:bg-background-default text-text-default"
aria-label={option.label}
>
{option.label}
</Link>
))}
</div>
</div>
)}
</span>
);
};

Dropdown.propTypes = {
className: PropTypes.string,
options: PropTypes.arrayOf(
PropTypes.shape({
label: PropTypes.string.isRequired,
link: PropTypes.string.isRequired,
})
).isRequired,
};

export default Dropdown;
46 changes: 33 additions & 13 deletions src/components/Hero.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { Button } from "./Button";
import { Container } from "./Container";
import Dropdown from "./DropdownButton";

export function Hero() {
const dropdownOptions = [
{
label: "Microsoft Store",
link: "https://www.microsoft.com/store/apps/9PCKDV76GL75",
},
{
label: "GitHub",
link: "https://github.com/Phalcode/gamevault-app/releases",
},
];

return (
<Container className="pb-16 pt-20 text-center">
<img src="/img/logo.png" className="h-48 nozoom" alt="Logo" />
Expand All @@ -18,25 +30,33 @@ export function Hero() {
<path d="M203.371.916c-26.013-2.078-76.686 1.963-124.73 9.946L67.3 12.749C35.421 18.062 18.2 21.766 6.004 25.934 1.244 27.561.828 27.778.874 28.61c.07 1.214.828 1.121 9.595-1.176 9.072-2.377 17.15-3.92 39.246-7.496C123.565 7.986 157.869 4.492 195.942 5.046c7.461.108 19.25 1.696 19.17 2.582-.107 1.183-7.874 4.31-25.75 10.366-21.992 7.45-35.43 12.534-36.701 13.884-2.173 2.308-.202 4.407 4.442 4.734 2.654.187 3.263.157 15.593-.78 35.401-2.686 57.944-3.488 88.365-3.143 46.327.526 75.721 2.23 130.788 7.584 19.787 1.924 20.814 1.98 24.557 1.332l.066-.011c1.201-.203 1.53-1.825.399-2.335-2.911-1.31-4.893-1.604-22.048-3.261-57.509-5.556-87.871-7.36-132.059-7.842-23.239-.254-33.617-.116-50.627.674-11.629.54-42.371 2.494-46.696 2.967-2.359.259 8.133-3.625 26.504-9.81 23.239-7.825 27.934-10.149 28.304-14.005.417-4.348-3.529-6-16.878-7.066Z" />
</svg>
<span className="relative">your own</span>
</span>{" "}
</span>
<br />
gaming platform.
</h1>
<p className="mx-auto mt-6 max-w-2xl text-lg tracking-tight text-text-light">
Hoarding video games is fun, but a chaotic list of files on a network
share is not. <br /> Let GameVault organize everything for you and enjoy
a Steam-like experience within the comfort of your own server.
a selfhosted Steam-like experience for games on your own home server.
</p>
<div className="mt-10 flex justify-center gap-x-6">
<Button className="w-52" href="/docs/intro">
Learn more
</Button>
<Button
className="w-52"
href="https://www.microsoft.com/store/apps/9PCKDV76GL75"
target="_blank"
>
Download Client
</Button>
<div className="mt-10 grid grid-cols-1 sm:grid-cols-2 gap-4 max-w-xl mx-auto">
<Button href="/docs/intro">Learn more</Button>
<Dropdown options={dropdownOptions}>
Download Client{" "}
<svg
className="-mr-1 h-5 w-5"
viewBox="0 0 20 20"
fill="currentColor"
aria-hidden="true"
data-slot="icon"
>
<path
fillRule="evenodd"
d="M5.22 8.22a.75.75 0 0 1 1.06 0L10 11.94l3.72-3.72a.75.75 0 1 1 1.06 1.06l-4.25 4.25a.75.75 0 0 1-1.06 0L5.22 9.28a.75.75 0 0 1 0-1.06Z"
clipRule="evenodd"
/>
</svg>
</Dropdown>
</div>
</Container>
);
Expand Down
14 changes: 13 additions & 1 deletion src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

/* For readability concerns, you should choose a lighter palette in dark mode. */
[data-theme="dark"] {
--ifm-color-primary: #9f99d6;
--ifm-color-primary: #5249b6;
--ifm-color-primary-dark: #867fcb;
--ifm-color-primary-darker: #7a72c6;
--ifm-color-primary-darkest: #554ab6;
Expand Down Expand Up @@ -55,3 +55,15 @@ img[alt="GameVault+ Banner"] {
font-size: 3.75rem;
line-height: 1;
}

button,
input[type="submit"],
input[type="reset"] {
background: none;
color: inherit;
border: none;
padding: 0;
font: inherit;
cursor: pointer;
outline: inherit;
}

0 comments on commit 8ba774a

Please sign in to comment.