Skip to content

Commit

Permalink
feat: add about page
Browse files Browse the repository at this point in the history
  • Loading branch information
RNAdvani committed Oct 23, 2024
1 parent d361370 commit 1da818f
Show file tree
Hide file tree
Showing 5 changed files with 233 additions and 32 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export default [
{ allowConstantExport: true },
],
"react/react-in-jsx-scope": "off",
"react/no-unescaped-entities": "off",
"react/jsx-uses-react": "off",
"prettier/prettier": ["error"],

Expand Down
7 changes: 7 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createBrowserRouter, RouterProvider } from "react-router-dom";
import Home from "./pages/Home";
import NotFound from "./pages/NotFound";
import "./styles/App.css";
import About from "./pages/About";
import Layout from "./components/Layout/Layout";

// Create a browser router
Expand All @@ -18,6 +19,12 @@ const router = createBrowserRouter([
element: <Home />,
errorElement: <NotFound />,
},
{
id: "about",
path: "/about",
element: <About />,
errorElement: <NotFound />,
},
{
id: "not-found",
path: "*",
Expand Down
17 changes: 16 additions & 1 deletion src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ const Header = () => {
>
Home
</Link>
<Link
to="/about"
onClick={toggleMenu}
className="text-[16px] font-semibold"
data-testid="mobile-home-link"
>
About
</Link>
<a
href="https://github.com/utk09-NCL/color-palette-generator/"
onClick={toggleMenu}
Expand Down Expand Up @@ -111,14 +119,21 @@ const Header = () => {
Color Conjure
</h1>

<div className="absolute left-1/2 transform -translate-x-1/2">
<div className="absolute left-1/2 transform flex gap-4 -translate-x-1/2">
<Link
to="/"
className="text-[16px] md:text-[20px] font-semibold"
data-testid="desktop-home-link"
>
Home
</Link>
<Link
to="/about"
className="text-[16px] md:text-[20px] font-semibold"
data-testid="desktop-home-link"
>
About
</Link>
</div>

<div className="flex items-center space-x-4">
Expand Down
99 changes: 68 additions & 31 deletions src/components/Header/Header.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ describe("Header", () => {
</MemoryRouter>,
);

// Check desktop header is present
// Check desktop header is present and hidden on mobile
const desktopHeader = screen.getByTestId("desktop-header");
expect(desktopHeader).toBeInTheDocument();
expect(desktopHeader).toHaveClass("hidden", "lg:block");

// Check home link
const homeLink = screen.getByTestId("desktop-home-link");
expect(homeLink).toBeInTheDocument();
expect(homeLink).toHaveAttribute("href", "/");
// Check brand name
expect(screen.getAllByText("Color Conjure")).toHaveLength(2);

// Check navigation links
const homeLinks = screen.getAllByRole("link", { name: /home/i });
expect(homeLinks[0]).toHaveAttribute("href", "/");

const aboutLinks = screen.getAllByRole("link", { name: /about/i });
expect(aboutLinks[0]).toHaveAttribute("href", "/about");

// Check GitHub link
const githubLink = screen.getByTestId("desktop-github-link");
Expand All @@ -42,12 +48,11 @@ describe("Header", () => {
"href",
"https://github.com/utk09-NCL/color-palette-generator/",
);
expect(githubLink).toHaveAttribute("target", "_blank");
expect(githubLink).toHaveAttribute("rel", "noreferrer");
});

it("toggles mobile menu when hamburger icon is clicked", () => {
// Set window width to mobile view
global.innerWidth = 500;

render(
<MemoryRouter>
<Header />
Expand All @@ -70,21 +75,24 @@ describe("Header", () => {
expect(mobileMenu).toHaveClass("-translate-x-full");
});

it("has correct link attributes", () => {
it("closes mobile menu when navigation links are clicked", () => {
render(
<MemoryRouter>
<Header />
</MemoryRouter>,
);

// Check desktop GitHub link attributes
const desktopGithubLink = screen.getByTestId("desktop-github-link");
expect(desktopGithubLink).toHaveAttribute("target", "_blank");
expect(desktopGithubLink).toHaveAttribute("rel", "noreferrer");
expect(desktopGithubLink).toHaveAttribute(
"href",
"https://github.com/utk09-NCL/color-palette-generator/",
);
// Open menu
const hamburgerButton = screen.getByTestId("hamburger-button");
fireEvent.click(hamburgerButton);

// Click home link in mobile menu
const homeLink = screen.getAllByRole("link", { name: /home/i });
fireEvent.click(homeLink[0]);

// Check if menu is closed
const mobileMenu = screen.getByTestId("mobile-menu");
expect(mobileMenu).toHaveClass("-translate-x-full");
});

it("adds and removes scroll event listener", () => {
Expand Down Expand Up @@ -114,37 +122,66 @@ describe("Header", () => {
</MemoryRouter>,
);

// Simulate scroll
// Simulate scroll beyond maxScroll (10px)
Object.defineProperty(window, "scrollY", { value: 15 });
fireEvent.scroll(window);

const desktopHeader = screen.getByTestId("desktop-header");

// Check if header style is updated according to scrollProgress = 1
expect(desktopHeader).toHaveStyle({
width: "100%",
transform: "scale(1)",
borderRadius: "0rem",
width: "100%", // 100 - (1 - 1) * 20 = 100%
transform: "scale(1)", // 0.9 + 1 * 0.1 = 1
borderRadius: "0rem", // (1 - 1) * 0.75 = 0
});
});

it("closes mobile menu when navigation link is clicked", () => {
global.innerWidth = 500;

it("displays correct content in mobile menu", () => {
render(
<MemoryRouter>
<Header />
</MemoryRouter>,
);

// Open menu
// Open mobile menu
const hamburgerButton = screen.getByTestId("hamburger-button");
fireEvent.click(hamburgerButton);

// Click home link
const mobileHomeLink = screen.getByTestId("mobile-home-link");
fireEvent.click(mobileHomeLink);
// Check for menu title
expect(screen.getByText("Menu")).toBeInTheDocument();

// Check if menu is closed
const mobileMenu = screen.getByTestId("mobile-menu");
expect(mobileMenu).toHaveClass("-translate-x-full");
// Check for navigation links
const homeLink = screen.getAllByRole("link", { name: /home/i });
expect(homeLink[0]).toBeInTheDocument();

const aboutLink = screen.getAllByRole("link", { name: /about/i });
expect(aboutLink[0]).toBeInTheDocument();

// Check for GitHub link
const githubLink = screen.getByTestId("mobile-github-link");
expect(githubLink).toBeInTheDocument();
expect(githubLink).toHaveAttribute(
"href",
"https://github.com/utk09-NCL/color-palette-generator/",
);
});

it("adjusts padding based on scroll position", () => {
render(
<MemoryRouter>
<Header />
</MemoryRouter>,
);

// Initially should have pt-4
const headerWrapper = screen.getByTestId("desktop-header").parentElement;
expect(headerWrapper).toHaveClass("pt-4");

// Simulate scroll
Object.defineProperty(window, "scrollY", { value: 15 });
fireEvent.scroll(window);

// Should now have pt-0
expect(headerWrapper).toHaveClass("pt-0");
});
});
141 changes: 141 additions & 0 deletions src/pages/About.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import {
FaGithub,
FaPalette,
FaCheck,
FaFileExport,
FaUniversalAccess,
} from "react-icons/fa";
import {
SiReact,
SiVite,
SiTailwindcss,
SiEslint,
SiPrettier,
SiVitest,
} from "react-icons/si";

export default function Component() {
const features = [
{ icon: <FaPalette />, text: "Color Shade Generation" },
{ icon: <FaCheck />, text: "Contrast Checker" },
{ icon: <FaFileExport />, text: "Export Options" },
{ icon: <FaUniversalAccess />, text: "Accessibility Compliance" },
{ icon: <></>, text: "Interactive Color Manipulation" },
];

const tools = [
{ icon: <SiReact />, name: "React" },
{ icon: <SiVite />, name: "Vite" },
{ icon: <SiTailwindcss />, name: "Tailwind CSS" },
{ icon: <SiEslint />, name: "ESLint" },
{ icon: <SiPrettier />, name: "Prettier" },
{ icon: <SiVitest />, name: "Vitest" },
];

return (
<div className="min-h-screen bg-gradient-to-br bg-white pt-10 text-headerBrand scroll-smooth">
<div className="container mx-auto px-4 py-16 space-y-16">
<header className="text-center">
<h1 className="text-6xl font-bold mb-6">About Color Conjure 🎨</h1>
<p className="text-2xl max-w-3xl mx-auto">
Empowering designers and developers to create accessible and
consistent color schemes with ease.
</p>
</header>

<div className="border w-full h-[1px]" />

<section className="bg-white rounded-custom-xl rounded-xl p-10">
<h2 className="text-4xl font-semibold mb-6">
What is Color Conjure?
</h2>
<p className="text-xl leading-relaxed">
Color Conjure is an innovative, open-source color palette generator
designed to streamline the process of creating harmonious and
accessible color schemes for your projects. Whether you're a
seasoned designer or a budding developer, our tool empowers you to
generate shades, verify color contrasts, and export your palettes in
various formats, all with unparalleled ease and precision.
</p>
</section>

<div className="border w-full h-[1px]" />

<section className="bg-white rounded-custom-xl rounded-xl p-10">
<h2 className="text-4xl font-semibold mb-10">Key Features</h2>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
{features.map((feature, index) => (
<div
key={index}
className="flex items-center space-x-4 bg-headerBackground rounded-md text-black p-6 rounded-custom-lg"
>
<div className="text-4xl">{feature.icon}</div>
<span className="text-xl font-medium">{feature.text}</span>
</div>
))}
</div>
</section>

<div className="border w-full h-[1px]" />

<section className="bg-white rounded-custom-xl rounded-xl p-10">
<h2 className="text-4xl font-semibold mb-10">Tools & Libraries</h2>
<div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-6">
{tools.map((tool) => (
<div
key={tool.name}
className="flex rounded-md flex-col items-center justify-center bg-headerBackground text-black p-6 aspect-square"
>
<div className="text-5xl mb-4">{tool.icon}</div>
<span className="text-lg font-medium text-center">
{tool.name}
</span>
</div>
))}
</div>
</section>

<div className="border w-full h-[1px]" />

<section className="bg-white rounded-custom-xl rounded-xl p-10">
<h2 className="text-4xl font-semibold mb-6">Get Involved</h2>
<p className="text-xl mb-8">
We welcome contributions from developers and designers alike! There
are many ways to get involved with Color Conjure and help shape its
future.
</p>
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
<a
href="https://github.com/utk09-NCL/color-palette-generator"
target="_blank"
rel="noreferrer"
className="flex items-center justify-center rounded-md px-6 py-4 bg-headerBrand text-headerBackground rounded-custom-lg text-xl font-medium"
>
<FaGithub className="mr-3 text-2xl" /> View on GitHub
</a>
<a
href="https://github.com/utk09-NCL/color-palette-generator/blob/main/CONTRIBUTING.md"
target="_blank"
rel="noreferrer"
className="flex items-center justify-center rounded-md px-6 py-4 bg-headerBrand text-headerBackground rounded-custom-lg text-xl font-medium"
>
Contributing Guidelines
</a>
<a
href="https://github.com/utk09-NCL/color-palette-generator/blob/main/design/DESIGN.md"
target="_blank"
rel="noreferrer"
className="flex items-center justify-center rounded-md px-6 py-4 bg-headerBrand text-headerBackground rounded-custom-lg text-xl font-medium"
>
Contribute to Design
</a>
</div>
</section>

<footer className="text-center text-xl">
<p>&copy; 2024 Color Conjure</p>
</footer>
</div>
</div>
);
}

0 comments on commit 1da818f

Please sign in to comment.